From ce33970ade8a9bf77e0e9eb2b376c3898b78637c Mon Sep 17 00:00:00 2001 From: beckerdo Date: Fri, 30 Jan 2009 15:52:55 +0000 Subject: 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 --- .../jms/impl/JMSBindingProcessorTestCase.java | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'branches/sca-java-1.x/modules/binding-jms/src/test') 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 { + " " + ""; + private static final String COMPOSITE_INVALID_URI = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + // Invalid: contains both a response attribute and a response element. + private static final String COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + private XMLInputFactory inputFactory; private StAXArtifactProcessor 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 ) ); + } + } } -- cgit v1.2.3