org.osesb.msgrouting.test.deployabletestpackage2
Class ProcessLoanApplicationMessagePipelineUnitTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.osesb.utilities.junit.OSESBTestCase
              extended by org.osesb.msgrouting.test.deployabletestpackage2.ProcessLoanApplicationMessagePipelineUnitTest
All Implemented Interfaces:
junit.framework.Test

public class ProcessLoanApplicationMessagePipelineUnitTest
extends OSESBTestCase

This class contains unit tests for the MessagePipelines in the org.osesb.msgrouting.test.deployabletestpackage2 package. The MessagePipeline is configured by processloanapplication-message-pipeline-config.xml.


Field Summary
 
Fields inherited from class org.osesb.utilities.junit.OSESBTestCase
configFile, log, reader, testDataDirectory, testProperties, thisClassName
 
Constructor Summary
ProcessLoanApplicationMessagePipelineUnitTest(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 testProcessLoanApplicationMessagePipeline()
          Unit test for the MessagePipelines in the org.osesb.msgrouting.test.deployabletestpackage2 package.
 
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

ProcessLoanApplicationMessagePipelineUnitTest

public ProcessLoanApplicationMessagePipelineUnitTest(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


testProcessLoanApplicationMessagePipeline

public void testProcessLoanApplicationMessagePipeline()
                                               throws java.lang.Exception
Unit test for the MessagePipelines in the org.osesb.msgrouting.test.deployabletestpackage2 package. The MessagePipeline is configured by processloanapplication-message-pipeline-config.xml.

The test MessagePipeline named 'processLoanApplication-MessagePipeline' is configured to process the message, loanApplicationRequest.xml, as follows: 1. A XMLValidationPipelineStage validates the loanApplicationXMLMessage against a schema in the configured instance of the XMLRepository. The name of the PipelineStage is ProcessLoanApplicationXMLValidationPipelineStage. For unit testing the MessagePipeline, the XML repository is configured in deployabletestpackage2/xml-repository. Repository entries are mapped to the messageType of the incoming message, which in this case is given by the QName {http://osesb.test.com/loanApp}loanApplicationRequest. 2. A DatabaseQueryWithXMLParametersPipelineStage retrieves the credit rating for a customer from the JDBCTEST database using the value of the customerID element of the loanApplicationXMLMessage. DatabaseQueryWithXMLParametersPipelineStage puts the java.sql.ResultSet, which contains one row and one column (CREDITRATING), on the MessagePipelineContext in a variable named "stageName.sqlStatementName.resultSet" where: stageName == RetrieveCustomerCreditRatingDatabaseQueryWithXMLParametersPipelineStage sqlStatementName == getCreditRating Note that the customer credit rating can be 0 or null. The name of the PipelineStage is RetrieveCustomerCreditRatingDatabaseQueryWithXMLParametersPipelineStage. 3. A custom PipelineStage that retrieves the customer credit rating from the MessagePipelineContext and puts the value of the customer credit rating on the MessagePipelineContext. The DOM Element is added to the loanApplicationRequest by the next PipelineStage, which is a XMLUpdaterPipelineStage. The name of the PipelineStage is PutCreditRatingOnMessageContextPipelineStage. The next PipelineStage, which is a XMLUpdaterPipelineStage, expects an Object[] named "stageName.xmlUpdateItems" where 'stageName' is the name of the XMLUpdaterPipelineStage. The Object[] will contain one item, a DOM Element, which the XMLUpdaterPipelineStage will add to the loanApplicationRequest. This PipelineStage retrieves the customer credit rating from the ResultSet, creates an Element named 'creditRating', and creates the Object[] for the XMLUpdaterPipelineStage. 4. A XMLUpdaterPipelineStage updates the loanApplicationRequest with the customer credit rating and sets the updated XML as the current message for the MessagePipeline. The name of the PipelineStage is AddCreditRatingElementPipelineStage. 5. A custom FlowControlPipelineStage that configures a single MessagePipeline branch that is run if the customer credit rating is not > 0. The name of the PipelineStage is CreditRatingFlowControlPipelineStage. 6. A DroolsRuleXMLApplierFlowControlPipelineStage which configures a rule that runs one of three MessagePipelines: the 'processHighRiskLoanMessagePipeline', the 'processLowRiskLoanMessagePipeline', or the 'processHighValueCustomerLoanMessagePipeline'. The configured Drools rule selects the MessagePipeline that processes the loanApplicationRequest based on the 'creditRating' Element of the loanApplicationRequest message. The name of the PipelineStage is SelectLoanProcessorMessagePipelineDroolsRuleFlowControlPipelineStage.

Throws:
java.lang.Exception