summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/binding-jms/src/test
diff options
context:
space:
mode:
authorbeckerdo <beckerdo@13f79535-47bb-0310-9956-ffa450edef68>2009-01-30 15:52:55 +0000
committerbeckerdo <beckerdo@13f79535-47bb-0310-9956-ffa450edef68>2009-01-30 15:52:55 +0000
commitce33970ade8a9bf77e0e9eb2b376c3898b78637c (patch)
tree114b7b224c17bdd8fc20eef956a13da8b9965689 /branches/sca-java-1.x/modules/binding-jms/src/test
parent7dca5833965c8dd71528a1925718a9e6cefedb82 (diff)
TUSCANY-2776 The JMSBindingProcessor does not perform validation of binding properties
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@739312 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/binding-jms/src/test')
-rw-r--r--branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java b/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
index 7fe482c4f2..ff41751d7d 100644
--- a/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
+++ b/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorTestCase.java
@@ -121,6 +121,33 @@ public class JMSBindingProcessorTestCase extends TestCase {
+ " </component>"
+ "</composite>";
+ private static final String COMPOSITE_INVALID_URI =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"invalidjms:testQueue\" />"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
+ // Invalid: contains both a response attribute and a response element.
+ private static final String COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" responseConnection=\"responseConnectionAttrName\">"
+ + " <response>"
+ + " <destination name=\"responseConnectionElementName\"/>"
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
private XMLInputFactory inputFactory;
private StAXArtifactProcessor<Object> staxProcessor;
private Monitor monitor;
@@ -208,4 +235,36 @@ public class JMSBindingProcessorTestCase extends TestCase {
assertEquals("prop1 = 2", binding.getJMSSelector());
}
+
+ /** Test various parsing validation requirements. */
+ public void testParsingValidationErrors1() throws Exception {
+ // Composite with malformed URI.
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_INVALID_URI));
+
+ try {
+ Composite composite = (Composite)staxProcessor.read(reader);
+ } catch(Exception e) {
+ // JMSBindingExceptions are expected with invalid composite.
+ if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
+ throw e;
+ // Do assertion to make sure test registers results.
+ assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
+ }
+ }
+
+ /** Test various model validation requirements. */
+ public void testValidationErrors1() throws Exception {
+ // Composite with response connection attr and element.
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT));
+
+ try {
+ Composite composite = (Composite)staxProcessor.read(reader);
+ } catch(Exception e) {
+ // JMSBindingExceptions are expected with invalid composite.
+ if ( !e.getClass().isAssignableFrom( JMSBindingException.class ) )
+ throw e;
+ // Do assertion to make sure test registers results.
+ assertTrue( e.getClass().isAssignableFrom( JMSBindingException.class ) );
+ }
+ }
}