Index Changes

JBI Mock Framework

Announcements

- Version 0.8 Available for Download!

The JBI Mock Framework is a set of classes allowing developers to test JBI components at a unit level, mocking out the Normalized Message Router (NMR). Using the mock classes, developers can achieve high test coverage for their JBI Components.

License

The JBI Mock Framework is open source software released under the Common Development and Distribution License (CDDL) 1.0.

Features

  • Provides Mock interfaces and Basic implementations for the majority of JBI interfaces
  • Mock classes to write unit tests for Binding Components and Service Engines
  • Examples showing how to use the Spring Framework and JUnit to create a unit test
  • (planned) Creating advanced implementation classes

Requirements

  • JDK 1.4 or higher

Development Status

  • Current version is 0.8
  • Looking for users and developers

Source Code

The source code for the JBI Mock Framework is located under Open JBI Components CVS. The source is located under the contrib-gestalt directory. Click here for instructions on how to build the JBI Mock Framework. Maven 2 is required to build the JBI Mock Framework.

Alternatively you can download the source.

Issue Tracker

Go to the Open JBI Components Issue Tracker to submit issues. Please choose JBI Mock Framework as the subcomponent.

Mailing Lists

For questions and feedback please use the Open JBI Components mailing lists.

Discussion Forums

To start discussions use the Open JBI Components discussion forums.

Contacts

Downloads

Downloads exists under the Open JBI Components download section at open-jbi-components/JBI Mock Framework/version/ here.

Current Version: 0.8

Artifact

Source

Table of Contents

  1. User Documentation
  2. Developer Documentation

User Documentation

The following section describes how users can use the JBI Mock Framework to create JUnit tests for their JBI Components. Some knowledge of Apache Maven is helpful.
  1. Include JBI Mock Framework dependency in your project
    • Maven 1.x project
      • The JBI Mock Framework is built using maven2, and we don't have access to publish the artifacts to the java.net maven 1 repository. Consequently you will have to download the JBI Mock Framework artifacts and place them in your internal maven 1 repository. Follow the steps below to do this:
        • Download the JBI Mock Framework
        • Create a directory in your maven 1 repository corresponding to the group id {com.gestalt.jbi.mock}
        • Create a jars directory under the folder /com.gestalt.jbi.mock
        • Copy the jbi-mock jar to the jars directory (might also need to set permissions).
      • At this point you should have the following in your maven 1 repository: /com.gestalt.jbi.mock/jars/jbi-mock-X.X.jar
      • Add the dependency tag to your project.xml<pre> &lt;dependency&gt; &lt;groupId&gt;com.gestalt.jbi.mock&lt;/groupId&gt; &lt;artifactId&gt;jbi-mock&lt;/artifactId&gt; &lt;version&gt;0.8&lt;/version&gt; &lt;/dependency&gt; </pre>
      • Add transitive dependencies to the project. Here is a list of the required dependencies.
    • Maven 2 project
      • The jbi-mock artifacts have been uploaded to the java.net maven 2 repository under the directory /com/gestalt/jbi/mock/jbi-mock.
      • Follow these instructions to access the java.net maven 2 repository in your project.
      • Add the dependency tag to your pom.xml<pre> &lt;dependency&gt; &lt;groupId&gt;com.gestalt.jbi.mock&lt;/groupId&gt; &lt;artifactId&gt;jbi-mock&lt;/artifactId&gt; &lt;version&gt;0.8&lt;/version&gt; &lt;/dependency&gt; </pre>
  2. Write the Unit test
    • Now you are ready to write a unit test for your Binding Component or Service Engine. Spring is the recommended container.
    • The JBI Mock Framework includes 4 unit tests that can be referenced to see how to create a component unit test. These 4 tests are written against the included unit class ServiceEngineExample.java.
      1. ServiceEngineExampleManualTest.java - example on how to manually instantiate the Mock classes and manually inject them into the ServiceEngine. This requires no container.
      2. ServiceEngineExampleNanoTest.java - example on how to use Nano Container to instantiate the Mock classes. References the resource nanocontainer.xml located under the /jbi-mock/src/test/resources directory.
      3. ServiceEngineExamplePicoTest.java - example on how to use Pico Container to instantiate the Mock classes
      4. ServiceEngineExampleSpringTest.java - example on how to use the Spring Framework to instantiate the Mock classes and automatically inject them into the ServiceEngine. References the resource spring-basic.xml under the /jbi-mock/src/test/resources directory.
    • Also the Encoding Service Engine uses the JBI Mock Framework to write a unit test. See EncodingComponentTest.java
    • Finally there are some other examples of how to use existing JBI classes in a unit test verses using Mock classes. These sample spring files are located under the /jbi-mock/src/test/resources directory.
      1. spring-openesb.xml - shows how to use existing OpenESB classes in a unit test
      2. spring-servicemix.xml - shows how to use existing ServiceMix classes in a unit test

Developer Documentation

If you would like to contribute to the JBI Mock Framework, please request a developer role to the Open JBI Components project on java.net.

Developer Guidelines

  • Test should be included with changes
  • The design of the JBI Mock Framework was based off Dependency Injection
  • Setter Injection, rather than Constructor Injection, is the form used
  • Mock interfaces of the JBI interfaces are created to provide specific mock methods that all implementations should implement
  • There should be no instaniation of a class in any of the mock classes. For example, developers should not say, DeliveryChannel dc = new MockDeliveryChannelBasic(). Instead the developer should provide an instance variable for dc and provider a set and get method. This allows users of the JBI Mock Framework to inject any DeliveryChannel implementation they want and not be tied to MockDeliveryChannelBasic.
  • Currently trying to keep it compatible with JDK 1.4 to increase the user base
  • Follow the Java coding standards
  • Classes and methods (public or private) should be javadoc'd thoroughly

Javadoc

JBI Mock Framework Javadocs

This is a temporary location until an efficient solution can be found to keep the javadocs on the java.net site.

Coming soon as questions arrive. Please direct any questions to the Open JBI Components mailing lists.

Site Map

Start of a SiteMap for indirect links to pages.

Build Instructions
Dependencies

Contacts


Access Count: 40
StatCounter Access Count :

JSPWiki v2.4.100
[RSS]
« Home Index Changes Prefs
This page (revision-104) was last changed on 01-Oct-07 11:48 AM, -0700 by MarkWhite