Running SCA Tests from Maven

In this post, let’s look at how we can run SCA test suites from Maven.

To get started, we are going to need a test.  Let’s set up our process to add two numbers.  Go ahead and open the XML Schema for the inputs and outputs and change it to take two int’s as input and return a single int as output, as shown below:

image

Now update the assign activity’s copy rule in the BPEL process to add the two numbers together.  The “from” part of the copy rule should look like this:

$inputVariable.payload/client:a + $inputVariable.payload/client:b

Now, let’s define a test.

Right click on the testsuites folder, and choose Create Test Suite.  Give it a name like test_suite1.  Then the Create Composite Test wizard will open.  Click on Next twice to get to the Input Message page.  Click on Generate Sample and set the values for a and b to 1 and 2, like this:

<process xmlns="http://xmlns.oracle.com/soaApp1/soaProject1/BPELProcess1">
  <a>1</a>
  <b>2</b>
</process>

Click on Next and then Generate Sample again and set the output to look like this:

<processResponse xmlns="http://xmlns.oracle.com/soaApp1/soaProject1/BPELProcess1">
  <result>3</result>
</processResponse>

Click on Finish.  Now we have a test.

Next, we need to create a jndi.properties file.  This file is required by sca-test – regardless of whether you run it from ANT or Maven, etc.

Create a new file in your project and set up the content like this:

java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://my.server:7003/soa-infra
java.naming.security.principal=weblogic
java.naming.security.credentials=welcome1
dedicated.connection=true
dedicated.rmicontext=true

We also need to update the POM to tell Maven where the jndi.properties is located.

Open the POM, uncomment the jndi.properties.input property and make sure it points to the right file.  If you called your file jndi.properties and put it in the root of your project, then the example provided in the POM is the right value for you.

<!-- these parameters are used by the test goal -->
<!-- if you are using the sca-test (test) goal, you need to uncomment the following
     line and point it to your jndi.properties file. -->
<jndi.properties.input>${basedir}/jndi.properties</jndi.properties.input>
<scatest.result>${scac.output.dir}/testResult</scatest.result>
<!--  input is the name of the composite to run test suties against -->
<input>soaProject1</input>

Now you can run the tests by executing the Maven verify goal – either in JDeveloper or from the command line.

The output will look something like this:


C:\src2\soaApp1>mvn verify
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.redstack:soaProject1:sar:1.0-SNAPSHOT
[WARNING] The expression ${version} is deprecated. Please use ${project.version} instead.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] soaProject1
[INFO] soaApp1
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building soaProject1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ soaProject1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\src2\soaApp1\soaProject1\src\main\resources
[INFO] Copying 1 resource
[INFO]
[INFO] --- oracle-soa-plugin:12.1.3-0-0:compile (default-compile) @ soaProject1 ---
[INFO] ------------------------------------------------------------------------
[INFO] ORACLE SOA MAVEN PLUGIN - COMPILE
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] ABOUT TO RUN oracle.soa.scac.ValidateComposite...
[INFO] The environment variable/property 'oracle.home' is not set.
[INFO] If you want to compile a composite with a component that depends
on MDS - like a Human Task or Business Rule - AND you want to use a file
based MDS repository, you will need to specify 'oracle.home' OR update
your .adf/META-INF/adf-config.xml to point to your file-based MDS.
If you specify oracle.home it must point to the SOA Quickstart or
JDeveloper install directory with '/soa' appended to it, unless you
update the adf-config.xml to remove the reference to oracle.home.
[INFO] compile: Executing: [cmd:[c:\java\jdk1.8.0_05\bin\java, -Djava.protocol.handler.pkgs=oracle.mds.net.protocol|oracle.fabric.comm
on.classloaderurl.handler|oracle.fabric.common.uddiurl.handler, oracle.soa.scac.ValidateComposite, C:\src2\soaApp1\soaProject1/SOA//co
mposite.xml, -level=1]]
[INFO] Process being executed, waiting for completion.
[INFO] [exec] Jul 11, 2014 9:57:39 AM oracle.fabric.common.wsdl.SchemaManager isIncrementalBuildSupported
[INFO] [exec] INFO: XMLSchema incremental build enabled.
[INFO] [exec] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO] [exec] >> modified xmlbean locale class in use
[INFO] [exec] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[INFO] compile: [cmd:[c:\java\jdk1.8.0_05\bin\java, -Djava.protocol.handler.pkgs=oracle.mds.net.protocol|oracle.fabric.common.classloa
derurl.handler|oracle.fabric.common.uddiurl.handler, oracle.soa.scac.ValidateComposite, C:\src2\soaApp1\soaProject1/SOA//composite.xml
, -level=1]] exit code=0
[INFO] SOA COMPILE DONE
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ soaProject1 ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\src2\soaApp1\soaProject1\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ soaProject1 ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ soaProject1 ---
[INFO] No tests to run.
[INFO]
[INFO] --- oracle-soa-plugin:12.1.3-0-0:sar (default-sar) @ soaProject1 ---
[INFO] Building sar: C:\src2\soaApp1\soaProject1\target\sca_soaProject1_rev1.0-SNAPSHOT.jar
[INFO]
[INFO] --- oracle-soa-plugin:12.1.3-0-0:deploy (default-deploy) @ soaProject1 ---
[INFO] ------------------------------------------------------------------------
[INFO] ORACLE SOA MAVEN PLUGIN - DEPLOY COMPOSITE
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] setting user/password..., user=weblogic
Processing sar=C:\src2\soaApp1\soaProject1/target/sca_soaProject1_rev1.0-SNAPSHOT.jar
Adding sar file - C:\src2\soaApp1\soaProject1\target\sca_soaProject1_rev1.0-SNAPSHOT.jar
INFO: Creating HTTP connection to host:slc05evl.us.oracle.com, port:7003
INFO: Received HTTP response from the server, response code=200
---->Deploying composite success.
[INFO]
[INFO] --- oracle-soa-plugin:12.1.3-0-0:test (default-test) @ soaProject1 ---
[INFO] native formatting
[INFO] native
[INFO] [<test:testRunResults compositeDN="default/soaProject1" errorCount="0" failureCount="0" testCount="1" passCount="1" inProgressC
ount="0" runId="25f6b51184bcfb61:-3d069c46:1471d21b49b:-7ffc" runName="oracle-soa-plugin-scatest" startDate="2014-07-10T16:58:02.423-0
7:00" endDate="2014-07-10T16:58:05.314-07:00" xmlns:test="<a href="http://xmlns.oracle.com/sca/2006/test&quot;">http://xmlns.oracle.com/sca/2006/test"</a>><test:testSuite suiteName="test_suite
1"><test:testResult compositeDN="default/soaProject1!1.0-SNAPSHOT*soa_2d677f20-07e9-47bc-9448-7922926a37d5" flowId="10001" scaPartitio
nId="1" endDate="2014-07-10T16:58:05.314-07:00" startDate="2014-07-10T16:58:03.457-07:00" suiteName="test_suite1" testName="test1.xml"
testRunName="oracle-soa-plugin-scatest" testRunId="25f6b51184bcfb61:-3d069c46:1471d21b49b:-7ffc" outcome="passed" callHandlerClassNam
e=""><test:wireActionResults wireSource="bpelprocess1_client_ep"><test:assertionOutcome outcome="passed"><assertion comparisonMethod="
xml-similar" xmlns="<a href="http://xmlns.oracle.com/sca/2006/test&quot;">http://xmlns.oracle.com/sca/2006/test"</a>>
<description/>
<expected>
<location key="output" callbackOperation="processResponse"/>
<message>
<part partName="payload">
<content>

<processResponse xmlns="<a href="http://xmlns.oracle.com/soaApp1/soaProject1/BPELProcess1&quot;">http://xmlns.oracle.com/soaApp1/soaProject1/BPELProcess1"</a>>
<result>3</result>
</processResponse></content>
</part>
</message>
</expected>
</assertion><test:actual><test:message><test:part partName="payload"><test:content><bpel:processResponse xmlns:bpel="<a href="http://xmln">http://xmln</a>
s.oracle.com/soaApp1/soaProject1/BPELProcess1"><bpel:result>3</bpel:result></bpel:processResponse></test:content></test:part></test:me
ssage></test:actual></test:assertionOutcome></test:wireActionResults></test:testResult></test:testSuite><test:property propertyName="d
b.type" propertyValue="oracle"/><test:property propertyName="bpel.host.name" propertyValue="slc05evl.us.oracle.com"/><test:property pr
opertyName="soa.oracle.home" propertyValue="/scratch/marnelso/newsoa/final/server/soa"/></test:testRunResults>]
[INFO] C:\Users\Mark\AppData\Local\Temp\out\oracle-soa-plugin-scatest.xml
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building soaApp1 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] soaProject1 ....................................... SUCCESS [01:31 min]
[INFO] soaApp1 ........................................... SUCCESS [  0.002 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:38 min
[INFO] Finished at: 2014-07-11T09:58:55+10:00
[INFO] Final Memory: 15M/91M
[INFO] ------------------------------------------------------------------------

Now, if you were running this build in a CI server, like Hudson, then you could have it collect the results and chart them for you.

In the next post, let’s add some more interesting things to our SOA Application.

About Mark Nelson

Mark Nelson is a Developer Evangelist at Oracle, focusing on microservices and messaging. Before this role, Mark was an Architect in the Enterprise Cloud-Native Java Team, the Verrazzano Enterprise Container Platform project, worked on Wercker, WebLogic and was a senior member of the A-Team since 2010, and worked in Sales Consulting at Oracle since 2006 and various roles at IBM since 1994.
This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.

2 Responses to Running SCA Tests from Maven

  1. Looks nice! keep up the good work 🙂

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s