diff options
author | beckerdo <beckerdo@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-12 16:27:20 +0000 |
---|---|---|
committer | beckerdo <beckerdo@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-12 16:27:20 +0000 |
commit | 06e86a2c10c32cd86a7a6961f0d73b57ebd98fdc (patch) | |
tree | 49c2314a634760c66037fa5f56144ddb6c3b4216 /branches/sca-java-1.x/modules/binding-jms/src/test | |
parent | 11d9d3ab051dbd1cb7afe8fded7505aaa19200da (diff) |
TUSCANY-2825 JMSBindingProcessor missing 'write' method implementation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@743796 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/binding-jms/src/test')
2 files changed, 380 insertions, 19 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 facdffffe9..29ab264c7c 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 @@ -44,8 +44,9 @@ import org.apache.tuscany.sca.monitor.impl.DefaultMonitorFactoryImpl; * Tests for JMS binding xml
*/
public class JMSBindingProcessorTestCase extends TestCase {
-
- private static final String COMPOSITE =
+ // Note: If you are adding new JMS binding read test cases,
+ // consider adding a similar test case to JMSBindingProcessorWriteTestCase.
+ public static final String COMPOSITE =
"<?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\">"
@@ -56,21 +57,21 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String HEADERS1 =
+ public static final String HEADERS1 =
"<?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\" >"
- + " <headers JMSType=\"myType\" JMSCorrelationID=\"myCorrelId\" JMSDeliveryMode=\"PERSISTENT\" JMSTimeToLive=\"54321\" JMSPriority=\"5\" >"
+ + " <headers JMSType=\"myType\" JMSCorrelationID=\"myCorrelId\" JMSDeliveryMode=\"PERSISTENT\" JMSTimeToLive=\"54321\" JMSPriority=\"5\">"
+ " </headers>"
+ " </binding.jms>"
+ " </service>"
+ " </component>"
+ "</composite>";
- private static final String PROPERTIES1 =
+ public static final String PROPERTIES1 =
"<?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\">"
@@ -86,7 +87,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String OP_PROPERTIES1 =
+ public static final String OP_PROPERTIES1 =
"<?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\">"
@@ -110,7 +111,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String OP_NAMES_NO_PROPERTIES1 =
+ public static final String OP_NAMES_NO_PROPERTIES1 =
"<?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\">"
@@ -126,7 +127,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String SELECTOR =
+ public static final String SELECTOR =
"<?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\">"
@@ -139,7 +140,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String COMPOSITE_INVALID_URI =
+ public 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\">"
@@ -151,7 +152,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + "</composite>";
// Invalid: contains both a response attribute and a response element.
- private static final String COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT =
+ public 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\">"
@@ -166,7 +167,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String DEST_PROPS =
+ public static final String DEST_PROPS =
"<?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\">"
@@ -186,7 +187,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String CF_PROPS =
+ public static final String CF_PROPS =
"<?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\">"
@@ -206,7 +207,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String AS_PROPS =
+ public static final String AS_PROPS =
"<?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\">"
@@ -226,7 +227,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String RESP_DEST_PROPS =
+ public static final String RESP_DEST_PROPS =
"<?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\">"
@@ -248,7 +249,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String RESP_CF_PROPS =
+ public static final String RESP_CF_PROPS =
"<?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\">"
@@ -270,7 +271,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String RESP_AS_PROPS =
+ public static final String RESP_AS_PROPS =
"<?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\">"
@@ -292,7 +293,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String OP_PROPS_PROPS =
+ public static final String OP_PROPS_PROPS =
"<?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\">"
@@ -312,7 +313,7 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
- private static final String RES_ADPT_PROPS =
+ public static final String RES_ADPT_PROPS =
"<?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\">"
@@ -654,5 +655,4 @@ public class JMSBindingProcessorTestCase extends TestCase { }
}
-
}
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorWriteTestCase.java b/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorWriteTestCase.java new file mode 100644 index 0000000000..b7d3088c42 --- /dev/null +++ b/branches/sca-java-1.x/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessorWriteTestCase.java @@ -0,0 +1,361 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.binding.jms.impl; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.StringReader; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamWriter; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; +import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; +import org.apache.tuscany.sca.core.UtilityExtensionPoint; +import org.apache.tuscany.sca.monitor.Monitor; +import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.monitor.impl.DefaultMonitorFactoryImpl; + +/** + * Tests for JMS binding XML writes. + * In general, for each JMS binding XML read test case, there + * is a write test case. + */ +public class JMSBindingProcessorWriteTestCase extends TestCase { + +// public static final String COMPOSITE = +// public static final String HEADERS1 = +// public static final String PROPERTIES1 = +// public static final String OP_PROPERTIES1 = +// public static final String OP_NAMES_NO_PROPERTIES1 = +// public static final String SELECTOR = +// public static final String COMPOSITE_INVALID_URI = +// // Invalid: contains both a response attribute and a response element. +// public static final String COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT = +// public static final String DEST_PROPS = +// public static final String CF_PROPS = +// public static final String AS_PROPS = +// public static final String RESP_DEST_PROPS = +// public static final String RESP_CF_PROPS = +// public static final String RESP_AS_PROPS = +// public static final String OP_PROPS_PROPS = +// public static final String RES_ADPT_PROPS = + + private XMLInputFactory inputFactory; + private XMLOutputFactory outputFactory; + private StAXArtifactProcessor<Object> staxProcessor; + private Monitor monitor; + + @Override + protected void setUp() throws Exception { + DefaultExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry(); + inputFactory = XMLInputFactory.newInstance(); + outputFactory = XMLOutputFactory.newInstance(); + // Create a monitor + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + MonitorFactory monitorFactory = new DefaultMonitorFactoryImpl(); + if (monitorFactory != null) { + monitor = monitorFactory.createMonitor(); + utilities.addUtility(monitorFactory); + } + StAXArtifactProcessorExtensionPoint staxProcessors = new DefaultStAXArtifactProcessorExtensionPoint(extensionPoints); + staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null, monitor); + } + + /** + * Test parsing valid composite definition. Valid composite populated with correct values expected. + * @throws Exception + */ + public void testLoadValidComposite() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.COMPOSITE)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals( binding, binding2); + } + + public void testHeaders1() throws Exception { + XMLStreamReader reader = + inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.HEADERS1)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals( binding, binding2 ); + } + + public void testProperties1() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.PROPERTIES1)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals( binding, binding2 ); + } + + public void testOpProperties1() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.OP_PROPERTIES1)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } + + public void testSubscriptionHeaders() throws Exception { + XMLStreamReader reader = + inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.SELECTOR)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } + + public void testDestinationProperties() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.DEST_PROPS)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } + + public void testConnectionFactoryProperties() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.CF_PROPS)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } + + public void testActivationSpecProperties() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.AS_PROPS)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } + + public void testResponseDestinationProperties() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.RESP_DEST_PROPS)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } + + public void testResponseConnectionFactoryProperties() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.RESP_CF_PROPS)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } + + public void testResponseActivationSpecProperties() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.RESP_AS_PROPS)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } + + public void testOperationPropertiesProperties() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.OP_PROPS_PROPS)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } + + public void testResouceAdapterProperties() throws Exception { + XMLStreamReader reader = + inputFactory.createXMLStreamReader(new StringReader(JMSBindingProcessorTestCase.RES_ADPT_PROPS)); + Composite composite = (Composite)staxProcessor.read(reader); + JMSBinding binding = (JMSBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding); + + // Write out JMSBinding model to stream. + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + staxProcessor.write(composite, outputFactory.createXMLStreamWriter(bos)); + + // Read written JMSBinding to a different JMSBinding model. + XMLStreamReader reader2 = inputFactory.createXMLStreamReader(new StringReader(bos.toString())); + Composite composite2 = (Composite)staxProcessor.read(reader2); + JMSBinding binding2 = (JMSBinding)composite2.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertNotNull(binding2); + + // Compare initial binding to written binding. + assertEquals(binding, binding2); + } +} |