Sunday, August 10, 2014

Test your WebLogic 12.1.3 enviroment with Robot

Robot Framework is a generic test automation framework which has an easy-to-use tabular test data syntax and it utilizes the keyword-driven testing approach. This means we can write our tests in readable and understandable text.

If we combine this with the REST Management interface of WebLogic 12.1.3 we are able to test every detail of a WebLogic domain configuration and when we combine this with selenium or other Robot plugins we can also test our Web Applications or REST/Web Services.

So after all your provisioning and application deployments actions we can test our new environment in just a few minutes and Administrators or Testers can make or extend these tests without any developer knowledge.

Here is an example of some WebLogic domain tests

The only thing a developer should do, is to use make these test sentences, so called keywords

Here is the matching keyword example

Off course you don't need to use keywords but then you will get something like this. :-)

For this we need to enable the REST Management interface Weblogic 12.1.3 ( WebLogic Console -> Domain -> General -> Advanced -> Enable RESTful Management Services ) and install the robotframework-requests add-on.

Click here for more information about the WebLogic REST management service and you can use Postman ( a Chrome plugin)  to test your REST calls.

Next we can add our tests & keywords in a subfolder.

And run pybot rest_testsuites

With this as output

The detail report 

With the Selenium plugin (robotframework-selenium2library ) we can also test a web application deployed on a WebLogic server. In this example I will use the WebLogic Console application to test the selenium plugin.

run pybot console_testsuites

Our test

The matching resource file with the keywords.

For more information about Robot in combination with WebLogic you can also read the great blogs of my colleague Mark Nelson

Here you can download the github workspace


Thursday, August 7, 2014

Create with WLST a SOA Suite, Service Bus 12.1.3 Domain

When you want to create a 12.1.3 SOA Suite, Service Bus Domain, you have to use the WebLogic utility.  The 12.1.3 config utility is a big improvement when you compare this to WebLogic 11g. With this I can create some complex cluster configuration without any after configuration.
But if you want to automate the domain creation and use it in your own (provisioning) tool/script then you can use the following scripts to create a normal SOA Suite, Service Bus domain together with BPM, BAM & the Enterprise scheduler options.

Off course!!! use this script only for development, do some intensive testing on this domain and don't use this script in production or acceptance ( use the supported utility).

The second part of this blog we will create a cluster configuration with a WLST offline script.

Before we can start we need to have a FMW database repository.  You can use the RCU utility ( MDW_HOME/oracle_common/bin/rcu) to create one.

Enable the following options

Here you can also see the improvements in the 12c FMW domain creation like

  • ServerGroups, an easy way of assigning libraries,  applications and datasources to managed servers and clusters. It will auto-detect if a managed server is part of a cluster :-)
  • Service Table Datasource together with the getDatabaseDefaults() function, no need to change all the datasources. It will re-use the RCU configuration data.

Use this to start the creation of our domain.

Here we need to do some extra configuration like

  • Change a few datasources so they will use the Oracle XA driver

With this as output.

When you want to create a cluster configuration you can use the following script.

Thursday, July 31, 2014

Test your Application with the WebLogic Maven plugin

In this blogpost I will show you how easy it is to add some unit tests to your application when you use Maven together with the 12.1.3 Oracle software ( like WebLogic , JDeveloper or Eclipse OEPE).

To demonstrate this, I will create a RESTful Person Service in JDeveloper 12.1.3 which will use the Maven project layout.

We will do the following:

Create a Project and Application based on a Maven Archetype.
Create a JAX-RS 2.0 Person Resource

In the Maven Test phase, we will test this Person Rest Service.
  • Use JerseyTest to test the Person Resource
  • Use JerseyTest and Mockito to test and mock the Person Rest Service.

In the Maven Integration Test phase, we will test the Person Resource on a WebLogic domain and run some external soupUI tests.

  • Create a WebLogic Domain
  • Start the AdminServer
  • Deploy the JAX-RS 2.0 shared library and our Person Rest Service
  • Run some soapUI test cases.
  • Remove the WebLogic domain.

Before we can start, we need to use oracle-maven-sync-12.1.3.jar plugin to populate our local or maven repository with all the Oracle binaries.

For more information how to do this you can take a look at one of the following links.

We start by creating a new application in JDeveloper 12.1.3

Go to the Maven tree and select Generate from Archetype.

 Provide the maven Group and Artifact id and lookup the basic-webservice Archetype.

When you search for webLogic you will find the basic web service archetypes. Make sure you select the 12.1.3 one.

This will create a Web Service Project but we also need to create an application. So the next step is the Application creation dialog.

Because we want to use JAX-RS and not JAX-WS, so we need to delete the SayHello web service.

Next step is adding the REST Web Service feature to this project. 

Create a RESTful Service class

Choose JAX-RS 2.0 Style

Choose RESTful Service From New

 Provide all the REST service details and enable application/json as Media Types.

And viola we got our Person RESTful Service.

JDeveloper will automatically add the JAX-RS 2.0 shared library to your project.

This finishes our basic service.

This is how the final Person service will look like.

We can now add some unit tests to the Maven Test phase. We will make 2 JUnit test cases where we will use JerseyTest, so we can test the Person Resource and one with Mockito so we can also mock the data of the Person Resource.

For these tests a lightweight grizzly2 HTTP container will be started by Maven.

The pom's dependency libraries which we will need.

Using only JerseyTest is probably not so meaningful because you probably also need an emulate your EJB's but here you have the JerseyTest snippet

And the JerseyTest with Mockito snippet.

We can now run mvn clean test

This is nice, but the next question is "Can we also run this Application on a WebLogic Container and do some external tests"

For this we can use the weblogic-maven-plugin in the integration-test Maven phase.
The WebLogic plugin can create a new WebLogic Domain, Start the AdminServer, Deploy the JAX-RS 2 shared library, our Application and off course stop the AdminServer and remove the domain.

In SoapUI 5.0 I made a Testcase for this Person REST Service and add the soapUI project xml to our JDeveloper project.

The Maven soapUI plugin , In my case I added the smartbear private repository to my own Nexus repository.

Now we can start maven with mvn clean deploy

Create a new WebLogic domain ( inside the maven target folder ),  deploy our application together with the shared library.

Start the soapUI testcases.

With this as result.

That's all.

You can find this demo project on github