Skip to main content
Last updated July 16, 2012 22:03, by Olivier LeDiouris
Feedicon  

This page is in progress

How to check out the code and run a sample

You need:

  • An svn client (make sure svn is in your path)
  • JDeveloper, at least version 11.1.1.5.0


From a command line, type:

 Prompt> svn checkout https://svn.java.net/svn/soa-testing-snippets~soatestingutilities soa-testing-snippets

In JDeveloper, open the application named SOATestingSnippets.jws, in the directory created above, soa-testing-snippets.
This application contains several projects, one for the core utilities of this testing experience, and several samples, including some composites to deploy, and some projects to deploy, test, and undeploy them, and produce a report.
Go to the project named ConsolidatedTestEnv, and edit its properties. It depends on some libraries - that should be resolved - and some external jar files, all located in the ConsolidatedTestEnv/lib directory.
Make sure this project compiles, and deploy it. A jar-file should be generated in the deploy directory, and named ConsolidatedTestEnv.jar. This jar-file will be referred to from the samples we'll talk about later.
This project contains all the test patterns we will be using later.

A Declarative Approach

In the project named ConsolidatedTestEnv, see the Ant script named basic-service-test.xml
Edit the file named master.properties, and look for the properties named machine.name and proxy.name. Modify them to match the machine you want to deploy the services to.
Do the same for admin.port.number and soa.port.number.

 ...
 machine.name=localhost
 #
 # proxy.name, used to access services, and to run them
 #
 proxy.name=localhost
 #
 # Admin port number
 #
 admin.port.number=7001
 #
 # Put the proxy port in soa.port.number when appropriate
 #
 soa.port.number=7001
 ...


For convenience, we provide a script named basic-test.cmd, that runs of Windows. Its role is to set some environment variables that will be needed from the Ant scripts running the tests. Those variables are :

  • JAVA_HOME
  • JDEV_HOME
  • MW_HOME
  • MDS_INTEGRATION_HOME
  • SOA_INSTALL

The path is also set, to make sure Ant will be in it. Translating this script for Linux or other system should not be a problem.
Once the system variables are set, the script launches Ant, and runs the build-file named basic-service-test.xml.

 @echo off
 @setlocal
 set PATH=C:\JDev.11.1.1.5.0\jdk160_24\bin;C:\JDev.11.1.1.5.0\modules\org.apache.ant_1.7.1\bin
 set JAVA_HOME=D:\Program Files\Java\jdk1.7.0
 set SOA_HOME=C:\JDev.11.1.1.5.0\jdeveloper
 set JDEV_HOME=C:\JDev.11.1.1.5.0
 set MW_HOME=D:\WLS.10.3.5.0
 :: For an DB based MDS, MDS_INTEGRATION_HOME has the same value as SOA_HOME
 set MDS_INTEGRATION_HOME=C:\JDev.11.1.1.5.0\jdeveloper
 ::
 set SOA_INSTALL=Oracle_SOA1
 ::
 ant -f basic-service-test.xml %*
 @endlocal

A default target will give you some clues about what to do:

 Prompt> basic-test
 Buildfile: basic-service-test.xml
 
 help:
     [echo]
     [echo]       Try this:
     [echo]         ant -f basic-service-test.xml usage.help
     [echo]         ant -f basic-service-test.xml -projecthelp -verbose
     [echo]
 
 BUILD SUCCESSFUL
 Total time: 3 seconds

To see what the script can do, type:

 Prompt> basic-test -projecthelp -verbose
 Main targets:
 
  all         Does all the stuff.
  unit.test   Unit tests on the deployed services.
  usage.help  Details of the components used for the various tests
 Other targets:
 
  deploy.composite
  help
  in.case.asynchronous.1.fails
  in.case.asynchronous.2.fails
  in.case.asynchronous.2.to.fails
  in.case.discoverer.fails
  in.case.synchronous.fails
  init
  package.composite
  parallel.tasks
  report
  test.discoverer
  undeploy.composite
  unit.test.async.1.way
  unit.test.asynchronous.2.ways
  unit.test.asynchronous.2.ways.with.timeout
  unit.test.synchronous
 Default target: help

To run the full basic sample, type

 Prompt> basic-test all
 Buildfile: basic-service-test.xml
 
 init:
     [echo] Several variables are required for the deployment steps.
     [echo] Java Runtime Environment version: 1.7.0
     [echo] Java Home: D:\Program Files\Java\jdk1.7.0\jre
     [echo] ...required variables are set, moving on.
 [resolve.classpath] Classpath is 100% resolved.
 
 deploy.composite:
 
 package.composite:
     [echo]
     [echo]       ==========================
     [echo]        Step One
     [echo]        Deploying Composite SOACompositeForInstallationTests
     [echo]       ==========================
     [echo]
     [echo] oracle.home = C:\JDev.11.1.1.5.0\jdeveloper
 
 deploy:
    [input] skipping input as property serverURL has already been set.
    [input] skipping input as property sarLocation has already been set.
 [deployComposite] setting user/password..., user=weblogic
 [deployComposite] Processing sar=../SOACompositeForInstallationTests/deploy/sca_SOACompositeForInstallationTests_rev1.0.jar
 [deployComposite] Adding sar file - C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\..\SOACompositeForInstallationTests\deploy\sca_SOACompositeForInstallationTests_rev1.0.jar
 [deployComposite] INFO: Creating HTTP connection to host:130.35.95.19, port:7001
 [deployComposite] INFO: Received HTTP response from the server, response code=200
 [deployComposite] WARNING: BAM Adapter Connection Factory (JNDI name eis/bam/rmi) is missing property HostName
 [deployComposite] WARNING: BAM Adapter Connection Factory (JNDI name eis/bam/rmi) is missing property PortNumber
 [deployComposite] WARNING: BAM Adapter Connection Factory (JNDI name eis/bam/rmi) is missing property UserName
 [deployComposite] WARNING: BAM Adapter Connection Factory (JNDI name eis/bam/rmi) is missing property Password
 [deployComposite] ---->Deploying composite success.
 
 unit.test.async.1.way:
     [echo]
     [echo]     ====================================
     [echo]     Testing Asynchronous One Way Service
     [echo]     proxy.name=130.35.95.19
     [echo]     soa.port.number=7001
     [echo]     ====================================
     [echo]     outputfile: asynchronous
     [echo]
    [junit] Running unittests.patterns.services.AsynchronousOneWayUnitTest
    [junit] Jul 13, 2012 8:33:22 AM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] Jul 13, 2012 8:33:23 AM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] INFO: WSM-09004 Component auditing cannot be initialized.
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] INFO: WSM-09004 Component auditing cannot be initialized.
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 9.456 sec
 
 in.case.asynchronous.1.fails:
 
 unit.test.synchronous:
     [echo]
     [echo]     ====================================
     [echo]     Testing Synchronous Service
     [echo]     ====================================
     [echo]     outputfile: synchronous
     [echo]
    [junit] Running unittests.patterns.services.SynchronousServiceUnitTest
    [junit] Jul 13, 2012 8:33:31 AM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] Jul 13, 2012 8:33:31 AM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] INFO: WSM-09004 Component auditing cannot be initialized.
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] INFO: WSM-09004 Component auditing cannot be initialized.
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 4.207 sec
 
 in.case.synchronous.fails:
 
 unit.test.asynchronous.2.ways:
     [echo]
     [echo]     =====================================
     [echo]     Testing ASynchronous Two Ways Service
     [echo]     =====================================
     [echo]     outputfile: asynchronous.2
     [echo]
    [junit] Running unittests.patterns.services.AsynchronousTwoWayUnitTest
    [junit] Jul 13, 2012 8:33:38 AM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] Jul 13, 2012 8:33:38 AM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] INFO: WSM-09004 Component auditing cannot be initialized.
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] INFO: WSM-09004 Component auditing cannot be initialized.
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 9.349 sec
 
 in.case.asynchronous.2.fails:
 
 unit.test.asynchronous.2.ways.with.timeout:
     [echo]
     [echo]     =====================================
     [echo]     Testing ASynchronous Two Ways Service
     [echo]     With timeout
     [echo]     =====================================
     [echo]     outputfile: asynchronous.2.to
     [echo]
    [junit] Running unittests.patterns.services.AsynchronousTwoWayUnitTest
    [junit] Jul 13, 2012 8:33:50 AM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] Jul 13, 2012 8:33:50 AM oracle.security.jps.internal.config.xml.XmlConfigurationFactory initDefaultConfiguration
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] INFO: WSM-09004 Component auditing cannot be initialized.
    [junit] SEVERE: java.io.FileNotFoundException: C:\_mywork\dev-corner\java.net\soa-testing-snippets\ConsolidatedTestEnv\.\config\jps-config.xml (The system cannot find the path specified)
    [junit] INFO: WSM-09004 Component auditing cannot be initialized.
    [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 8.96 sec
 
 in.case.asynchronous.2.to.fails:
 
 report:
 
 unit.test:
 
 undeploy.composite:
     [echo]
     [echo]       ==========================
     [echo]        Step One bis
     [echo]        Undeploying Composite SOACompositeForInstallationTests
     [echo]       ==========================
     [echo]
     [echo] oracle.home = C:\JDev.11.1.1.5.0\jdeveloper\bin/..
 
 undeploy:
    [input] skipping input as property serverURL has already been set.
    [input] skipping input as property compositeName has already been set.
    [input] skipping input as property revision has already been set.
 [undeployComposite] setting user/password..., user=weblogic
 [undeployComposite] compositeDN =default/SOACompositeForInstallationTests!1.0
 [undeployComposite] INFO: Creating HTTP connection to host:130.35.95.19, port:7001
 [undeployComposite] INFO: Received HTTP response from the server, response code=200
 [undeployComposite] ---->Undeploy composite success.
 all:
     [echo] Done!
 BUILD SUCCESSFUL
 Total time: 1 minute 25 seconds

A Composite is deployed, several tests are run, a report is produced (in HTML in this case, a pdf one is also available), and the composite is un-deployed.

A closer look

Open the build file named basic-service-test.xml.
Notice the property named SYNCHRONOUS

 <property name="SYNCHRONOUS"    value="unittests.patterns.services.SynchronousServiceUnitTest"/>

It will be used by the target named unit.test.synchronous

  <target name="unit.test.synchronous">
    <echo>
    ====================================
    Testing Synchronous Service
    ====================================
    outputfile: synchronous
    </echo>
    <junit printsummary="yes" fork="yes" showoutput="yes" failureproperty="synchronous.fail">      
      <classpath refid="classpath"/>
      <formatter type="xml"/>
      <sysproperty key="verbose" value="${verbose}"/>
      <sysproperty key="properties.file.name" value="generic-service-test-synchronous.properties"/>
      <test name="${SYNCHRONOUS}" haltonfailure="no" outfile="synchronous"/>
    </junit>    
    <antcall target="in.case.synchronous.fails"/>
  </target>

See in the target above the sysproperty named properties.file.name, it contains the declaration of the test to run with the class mentionned in the ${SYNCHRONOUS} variable.
Here is an example of such a file:

 wsdl.url=http://${proxy.name}:${soa.port.number}/soa-infra/services/default/SOACompositeForInstallationTests/synchronousbpelprocess_client_ep?WSDL
 service.name=synchronousbpelprocess_client_ep
 service.port=SynchronousBPELProcess_pt
 service.operation=process
 service.ns.uri=http://xmlns.oracle.com/soatesthelper/SOACompositeForInstallationTests/SynchronousBPELProcess
 service.input.payload.file=generic-sync.input.xml
 service.output.payload.file=generic-sync.output.xml
 move.on.if.payload.is.invalid=true

The properties names should be clear enough... See how the wsdl.url refers to the variables mentioned in master.properties, and the service payloads, input and output.
The test will post the input payload to the service described by the properties of the file, get the response, and compare it to the output payload.

A Programmatic Approach

This example shows how to refer to the test classes directly. This choice is totally up to the user, what is done here could very well be done declaratively, just like above.
In the project named SOAInstallationTester, see the Ant script named soa-validator.xml
This script intends to test the basic features of a new SOA installation.

Notice the target named deploy.seven, it is using a configuration plan to deploy a composite that depends on another one. The configuration plan is patched before being processed.

 
 ...
     <antcall target="search.replace">
      <param name="from"    value="../ASync.with.EDN/ASync.with.EDN_cfgplan.xml"/>
      <param name="to"      value="../ASync.with.EDN/ASync.with.EDN_cfgplan.patched.xml"/>
      <param name="search"  value="130.35.95.19:7001"/>
      <param name="replace" value="${proxy.name}:${soa.port.number}"/>
    </antcall>
    <ant antfile="${soa.home}/bin/ant-sca-deploy.xml" target="deploy">
      <property name="sarLocation" value="${sar.file.seven}"/>
      <property name="configplan"  value="../ASync.with.EDN/ASync.with.EDN_cfgplan.patched.xml"/>
      <property name="overwrite"   value="true"/>
    </ant>
 ...
 
 
 
Close
loading
Please Confirm
Close