org.osesb.messagepipeline.test
Class DOMParserPipelineStageTest

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

public class DOMParserPipelineStageTest
extends OSESBTestCase

JUnit Test for org.osesb.messagepipeline.builtinstages.DOMParserPipelineStage.

Tests a DOMParserPipelineStage, which extends PipelineStage with a runStage() method that parses XML to DOM and sets the current MessagePipeline message to the result and/or places the result on the MessagePipelineContext.

DOMParserPipelineStage can be configured to check that XML is valid against one or more schemas using a XMLValidationPipelineStageConfiguration. The XMLValidationPipelineStageConfiguration is loaded by stageProcessingStarting(). If a XMLValidationPipelineStageConfiguration is not configured, then runStage() will parse the XML to DOM, but will not perform schema validation.

If configured for schema validation, then the schemas are located according to the following ordered lookup:

  1. The schema files are explicitly set by another PiplelineStage or a descendent of this DOMParserPipelineStage using the setSchemaFiles() method.
  2. The location of the schemas are statically configured. If the DOMParserPipelineStage is configured with a XMLValidationPipelineStageConfiguration that includes a XMLArtifactListConfiguration with one or more schema files, then the runStage() method will use the configured schema files to validate the XML. The XMLArtifactListConfiguration can configure schemas as File URLs or as locations in the configured instance of the XMLRepository.
  3. The location of the schemas are dynamically determined as locations in the configured instance of the XMLRepository according to the following ordered lookup:
    1. The 'messageType' property of the EAIMessage that is passed to runStage() is used to form a QName which maps to a schema location in the configured instance of the XMLRepository.
    2. The schemaLocation and noNamespaceSchemaLocation attributes of the XML root element are used to form a QName that is mapped to a schema location in the configured instance of the XMLRepository.


Field Summary
 
Fields inherited from class org.osesb.utilities.junit.OSESBTestCase
configFile, log, reader, testDataDirectory, testProperties, thisClassName
 
Constructor Summary
DOMParserPipelineStageTest(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 testConfiguredSchemas()
          Tests a DOMParserPipelineStage configured whewre the schema files are configured using a XMLArtifactListConfiguration.
 void testDynamicSchemaResolution()
          For this test, DOMParserPipelineStage is configured to resolve schema locations to the configured instance of the XMLRepository using a) the messageType, b) the schemaLocationAttribute, or c) the noNamespaceSchemaLocation attribute.
 void testSetSchemaFiles()
          Tests explicitly setting the schemas using setSchemaFiles().
 
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

DOMParserPipelineStageTest

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


testDynamicSchemaResolution

public void testDynamicSchemaResolution()
                                 throws java.lang.Exception
For this test, DOMParserPipelineStage is configured to resolve schema locations to the configured instance of the XMLRepository using a) the messageType, b) the schemaLocationAttribute, or c) the noNamespaceSchemaLocation attribute.

Throws:
java.lang.Exception

testConfiguredSchemas

public void testConfiguredSchemas()
                           throws java.lang.Exception
Tests a DOMParserPipelineStage configured whewre the schema files are configured using a XMLArtifactListConfiguration.

Throws:
java.lang.Exception

testSetSchemaFiles

public void testSetSchemaFiles()
                        throws java.lang.Exception
Tests explicitly setting the schemas using setSchemaFiles().

Throws:
java.lang.Exception