org.osesb.transporthandlers.test.deployabletestpackage1
Class TransportHandlerAsynchronousUnitTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.osesb.utilities.junit.OSESBTestCase
              extended by org.osesb.transporthandlers.test.deployabletestpackage1.TransportHandlerAsynchronousUnitTest
All Implemented Interfaces:
junit.framework.Test

public class TransportHandlerAsynchronousUnitTest
extends OSESBTestCase

This class contains unit tests for asynchronous interactions with the transport handlers that are deployed with the MessagePipeline(s) in deployabletestpackage1/transporthandler-config.

The purpose of this test package is to test asynchronous interaction.

For SOAP transport, this means testing the ws-addressing capabilities of the SOAPXMLMessageTransportHandler. The JAXRPCDynamicClient(s) used for the test are configured with JAXRPCWSAddressingConfiguration(s) that specify <wsa:ReplyTo> and <wsa:FaultTo> entries. The JAXRPCDynamicClient(s) invoke SOAPXMLMessageTransportHandler#receiveAsynchronousMessage(). The configured org.osesb.connectors.jaxrpc.addressing.JAXRPCServerAddressingHandler processes the ws-addressing entries in the SOAPHeader of the incoming message, which causes replies and faults to be sent to the specified EndpointReferences.

For the test, the <wsa:ReplyTo> and <wsa:FaultTo> EndpointReferences specify a JMS-backed web service, which puts the incoming message content to the configured queue or topic. The JMS-backed web service is in the org.osesb.test.soapjmsreceiverservice package of the test-webservices module. The service sets the correlation ID of the JMS message put to the JMS destination to the <wsa:RelatesTo> SOAPHeader entry of the incoming SOAPMessage.

For JMS transport the test situation is conceptually the same, except that a JMS client is used to send messages to a JMSXMLMessageTransportHandler and instead of using ws-addressing facilities the <replyToQueue> or <replyToTopic> elements of the JMSClientConfiguration are used to specify the JMS Destination for the replies.

The transport handlers under test are configured to send asynchronous replies that utlimately are put to the same JMS Topic, which is one of the framework's base test destinations, 'topic1'. So, JMS messages sent to the JMS transport handler, JMSXMLMessageTransportHandlerMDB, will have their JMS ReplyTo Destination set to 'topic1'. Messages sent to the SOAP transport handler, SOAPXMLMessageTransportHandlerBean, will have a ws-addressing configuration with <ReplyTo> and <FaultTo> EndpointReferences that point to the 'SOAPJMSReceiverService', which is deployed from the org.osesb.test.soapjmsreceiverservice package of the test-webservices module. For the test, the 'SOAPJMSReceiverService' is configured to put incoming messages onto 'topic1'.

After sending a test message, the tests start a JMS Receiver on 'topic 1' with JMSCorrelationID filter property set to the message ID of the test message that was sent. The test verifies that the message is the expected reply or an expected BrokerErrorMessage with an 'exceptionClassification' field set to PipelineStageException.testException.

The test uses cdcatalog.xml as the test message and sets the localPart of the messageType to 'cdOrder_4', which means that, in osESB, the messages are routed to the MessagePipeline configured by deployabletestpackage1/transporthandler-config/message-pipeline-4-test-config.xml.

The tests use a pool of ClientGateway(s) configured by keyed-pooled-clientgateway-test-config.xml, where each poolKey configures a client-side MessagePipeline that sends test messages to a different transport handler as follows:

The tests are run for each poolKey in clientGatewayPoolKeys. Each poolKey corresponds to a different transport handler. Comment and uncomment poolKey entries to run the tests against a set of transport handlers.

Transport handlers use a pool of org.osesb.msgrouting.MessageRouter(s) to route messages to a org.osesb.messagepipeline.MessagePipeline for processing. The MessageRouter selects the MessagePipeline based on the message's messageType. The MessageRouter uses the <messagetype-to-messagepipeline-map> configuration element of a MessageRouterConfiguration to map message types to MessagePipelines.

There are two ways that the message type for an incoming message is determined:

  1. A transport handler can be configured with a static messageType. In this case all messages arriving at that transport handler will be assigned the same message type.
  2. If a transport handler is not configured with a static message type, then the configured MessageRouter uses a XMLMessageTypeHelper to extract a message type from the XML message.

DefaultXMLMessageTypeHelper is the default XMLMessageTypeHelper class and is constructed with a XMLMessageTypeXPathExpressionListConfiguration. DefaultXMLMessageTypeHelper applies the configured XPath expressions to a XML message until a messageType is determined. DefaultXMLMessageTypeHelper#getMessagetype() returns the messageType as a QName, where the namespaceURI is the XML document namespace (if any) and the localPart is the value for the element or attribute that is given by a XPath expression.

To configure a MessageRouter with a different XMLMessageTypeHelper, create a class that extends AbstractXMLMessageTypeHelper and use the <xmlMessagetypeHelperConfiguration> content model element of the MessageRouterConfiguration.


Field Summary
 
Fields inherited from class org.osesb.utilities.junit.OSESBTestCase
configFile, log, reader, testDataDirectory, testProperties, thisClassName
 
Constructor Summary
TransportHandlerAsynchronousUnitTest(java.lang.String name)
          Construct a new instance.
 
Method Summary
static void main(java.lang.String[] args)
          The main method runs all the tests in the text ui
 void setUp()
          This method is called before a test is executed.
static junit.framework.Test suite()
          The suite method runs all the tests
 void tearDown()
          This method is called after a test is executed.
 void testAsynchronousInteractionUsingMessagePipeline_4()
          Unit test of asynchronous interaction with transport handlers deployed with the MessagePipeline configured by deployabletestpackage1/transporthandler-config/message-pipeline-4-test-config.xml, which configures a MessagePipeline as follows:

The test MessagePipeline is configured with a single PipelineStage, EchoMessageWithRandomPipelineStageExceptionPipelineStage, with a runStage() method that generates a random number.

 
Methods inherited from class org.osesb.utilities.junit.OSESBTestCase
getBooleanTestProperty, getIntTestProperty, getLongTestProperty, getTestResourcesAsStreams, getTestResourcesAsText, getTestResourcesFiles, loadTestProperties, readTestFilesAsStreams
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TransportHandlerAsynchronousUnitTest

public TransportHandlerAsynchronousUnitTest(java.lang.String name)
Construct a new instance.

OSESBTestCase (ancestor) constructor does the following:

  1. Instantiates a logging implementation.
  2. Instantiates an instance of ClassLoaderFileReader for reading test files from the ClassPath (not the file system).
  3. Loads Test.properties into ResourceBundle testProperties.
  4. Sets the testDataDirectory property using the testDataDirectory entry from Test.properties.

Method Detail

suite

public static junit.framework.Test suite()
The suite method runs all the tests


setUp

public void setUp()
           throws java.lang.Exception
This method is called before a test is executed.

Overrides:
setUp in class OSESBTestCase
Throws:
java.lang.Exception

tearDown

public void tearDown()
              throws java.lang.Exception
This method is called after a test is executed.

Overrides:
tearDown in class OSESBTestCase
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
The main method runs all the tests in the text ui


testAsynchronousInteractionUsingMessagePipeline_4

public void testAsynchronousInteractionUsingMessagePipeline_4()
                                                       throws java.lang.Exception
Unit test of asynchronous interaction with transport handlers deployed with the MessagePipeline configured by deployabletestpackage1/transporthandler-config/message-pipeline-4-test-config.xml, which configures a MessagePipeline as follows:

The test MessagePipeline is configured with a single PipelineStage, EchoMessageWithRandomPipelineStageExceptionPipelineStage, with a runStage() method that generates a random number. If the number is even, runStage() parses the input message using a pooled SAX parser and sets the result message for it's MessagePipeline to the content of the input message. If the number is odd, runStage() throws a PipelineStageException with the 'exceptionClassification' property set to 'testException'.

Note: For this test, the SOAPXMLMessageTransportHandler must be configured to return BrokerErrorMessages to the client when an error occurs. The 'onExceptionSendBrokerErrorMessage' environment property should be set to true.

The purpose of this test package is to test asynchronous interaction.

For SOAP transport, this means testing the ws-addressing capabilities of the SOAPXMLMessageTransportHandler. The JAXRPCDynamicClient(s) used for the test are configured with JAXRPCWSAddressingConfiguration(s) that specify <wsa:ReplyTo> and <wsa:FaultTo> entries. The JAXRPCDynamicClient(s) invoke SOAPXMLMessageTransportHandler#receiveAsynchronousMessage(). The configured org.osesb.connectors.jaxrpc.addressing.JAXRPCServerAddressingHandler processes the ws-addressing entries in the SOAPHeader of the incoming message, which causes replies and faults to be sent to the specified EndpointReferences.

For the test, the <wsa:ReplyTo> and <wsa:FaultTo> EndpointReferences specify a JMS-backed web service, which puts the incoming message content to the configured queue or topic. The JMS-backed web service is in the org.osesb.test.soapjmsreceiverservice package of the test-webservices module. The service sets the correlation ID of the JMS message put to the JMS destination to the <wsa:RelatesTo> SOAPHeader entry of the incoming SOAPMessage.

For JMS transport the test situation is conceptually the same, except that a JMS client is used to send messages to a JMSXMLMessageTransportHandler and instead of using ws-addressing facilities the <replyToQueue> or <replyToTopic> elements of the JMSClientConfiguration are used to specify the JMS Destination for the replies.

The transport handlers under test are configured to send asynchronous replies that utlimately are put to the same JMS Topic, which is one of the framework's base test destinations, 'topic1'. So, JMS messages sent to the JMS transport handler, JMSXMLMessageTransportHandlerMDB, will have their JMS ReplyTo Destination set to 'topic1'. Messages sent to the SOAP transport handler, SOAPXMLMessageTransportHandlerBean, will have a ws-addressing configuration with <ReplyTo> and <FaultTo> EndpointReferences that point to the 'SOAPJMSReceiverService', which is deployed from the org.osesb.test.soapjmsreceiverservice package of the test-webservices module. For the test, the 'SOAPJMSReceiverService' is configured to put incoming messages onto 'topic1'.

Throws:
java.lang.Exception