Tuesday, August 25, 2009

Starting SOA Suite Testcases from java

In a previous blog I already explained how to unit test a Soa Suite 11g composite application. In that blog entry I create a Test Suite with a testcase but I had to start this testcase and watch the results of the test in the Enterprise Manager Website. In this blog I will start the TestSuite with the Testcases from the Soa Suite java API. This can be handy when you have a continious build system like Hudson or Apache Continuum. Now you can build your test in JDeveloper and run the test in the Continious Build System.
In this test I made a simple Test Suite with two testcases and deployed this to the Soa Suite Server.
Create a test project with the following libraries
And create a java class like this example class.

package nl.whitehorses.bpel.unit;

import java.util.Hashtable;
import java.util.List;

import javax.naming.Context;




public class StartUnitProcess {
public StartUnitProcess() {

Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL, "t3://localhost:8001/soa-infra");
jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS, "weblogic1");
jndiProps.put("dedicated.connection", "true");

Locator locator = null;
try {
// connect to the soa server
locator = LocatorFactory.createLocator(jndiProps);

TestSuiteFilter testFilter = new TestSuiteFilter();
String compositeDN = "default/Helloworld!1.0";
List testSuites = locator.getTestSuites(compositeDN,testFilter);

for (TestSuite testSuite : testSuites) {
System.out.println("Found TestSuite name: "+testSuite.getName()+" description: "+testSuite.getDescription());

List testcases = testSuite.getTestCases();
System.out.println("Total TestCases: " +testcases.size());

for (TestCase testCase : testcases) {
System.out.println("Contains TestCase: " +testCase.getName());

TestRunOptions testRunOptions = new TestRunOptions();

TestRunResults result = locator.executeTestCases(compositeDN,testRunOptions,testcases);
System.out.println("total errors: "+ result.getNumErrors() +
" status: "+ result.getStatus());

List testSuiteResults = result.getTestSuiteResults() ;
for (TestSuiteResult testSuiteResult : testSuiteResults) {
System.out.println("TestSuite name: "+testSuiteResult.getSuiteName()+
" success: "+testSuiteResult.getNumSuccesses() +
" errors: "+ testSuiteResult.getNumErrors() );
List testCaseResults = testSuiteResult.getTestResults() ;
for (TestCaseResult testCaseResult : testCaseResults) {
System.out.println("TestCase name: "+testCaseResult.getTestName()+
" status: "+testCaseResult.getStatus() );
} catch (Exception e) {

public static void main(String[] args) {
StartUnitProcess startUnitProcess = new StartUnitProcess();

Here is an example of the result of invoking the TestSuite in java

Thursday, August 13, 2009

CRUD operations with a Bind Entity variable in BPEL

With Soa Suite 11G ( FMW 11G R1) you can now use the Bind Entity activity in a BPEL process, which can do your CRUD operations for you. This Bind Entity is connected to a web service reference, this WS has to have SDO types just like an ADF BC SDO service interface. Now you can use an normal Assign activity to retrieve or update data from the Entity variable instead of an invoking a lot of Partner Links.

First we need to make a SDO web service. For more details then this short description, see my previous blog or this blog of Andrejus .

I made an simple ADF BC Model project with an Employee viewobject based on the employees table in the HR sample schema.

Create a Service Interface on this Employees Viewobject and select all the basic operations.

JDeveloper 11G generates SDO types on this employees viewobject and generates a Web Service on this Application Module. We will use this WS in the BPEL process.

Create a new Service Interface deployment profile

Deploy this to a Weblogic Server

The Web Service is ready and we can create a new SOA Project. I use a XSD with a simple request and response. The input will be the EmployeeId and the BPEL process returns the lastname

We don't need use the ADF-BC service adapter, just add the Web Service Adapter to the Composite. Use the WSDL of the Employee WS in the WS Reference adapter

Wire the WS adapter reference to the BPEL process
Open the BPEL process and add a new variable

Select the partnerlink in the entity variable.

Select the Employee WS
Now we need to define the element in this variable. Select the Employees SDO element

Add the Bind Entity activity to the BPEL process, This will map the Primary Key on the just created variable.

Select the just created employee variable
Select the Primary Key Element of the Employee XSD. In my case is this EmployeeId

And use the BPEL request (input) variable as value to this PK column. This will lookup the right employee

We are ready with the configuration of the Bind Entity. We can now use Assign Activities to retrieve or update the Employee record. In my case I will get the lastname of the employee and return this as response

that's all , just deploy this to the Soa Server and test this in the EM website. Use for example 199

This returns Grant as lastname

Here you can download the test workspace

Sunday, August 2, 2009

JDeveloper 11G improvements for the Mediator component

With JDeveloper 11G FMW R1 Oracle made life a little bit easier when you are working with the Mediator component. In 10.1.3 the ESB Router can do a lot but you didn't have IDE support to configure this.
The first big change is the Assign option in the routing rules. In 10.1.3 you can change the header properties of a adapter by setting these values in the XSLT transformation of a routing.

In 11G you can't set a adapter property in a routing rule transformation. You need to do this in the assign option. This is a great feature, the transformation doesn't contain any hidden logica.

This assign wizard summarize all the possible header properties you can set. In 10.1.3 you have to search the internet what properties you can use.

The ESB XSLT header functions are now being replaced by the Mediator Get Functions. The Set functions are replaced by the Assign option.

In 11G you can create a Domain Value Map in JDeveloper. In 10.1.3 we had to do this in the ESB console, this is great for the DVM lookup XSLT function. You can use the looking glass button to select the right values.

The XSLT GetProperty function also summaries all the adapter properties.

In 10.1.3 we have a ESB request parameter to see the original request in the reply transformation. In 10.1.3 we have to do this all manually with JDeveloper 11G you have now an Include Request option in the reply Transformation.

In the XSLT editor you can use the request values in your reply transformation.