diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-03-21 08:50:01 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-03-21 08:50:01 +0000 |
commit | c2e791e0fc951d1b4fda773a67709a6eaa3ca0bf (patch) | |
tree | 66c20462994c28dce6214ab1f66bdf5bfe3a244f /sca-java-2.x/trunk/testing/itest/jms/format-wf-writing/src/test/java | |
parent | 12ad93c6d65dad04f9ee8d122390ac4e50a0af76 (diff) |
Add a test for writing jms wireFormats when the response one defaults to the request one
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1303311 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/testing/itest/jms/format-wf-writing/src/test/java')
-rw-r--r-- | sca-java-2.x/trunk/testing/itest/jms/format-wf-writing/src/test/java/org/apache/tuscany/sca/binding/jms/format/WireFormatWritingTestCase.java | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/jms/format-wf-writing/src/test/java/org/apache/tuscany/sca/binding/jms/format/WireFormatWritingTestCase.java b/sca-java-2.x/trunk/testing/itest/jms/format-wf-writing/src/test/java/org/apache/tuscany/sca/binding/jms/format/WireFormatWritingTestCase.java index d6d1c200bf..adecce0f4b 100644 --- a/sca-java-2.x/trunk/testing/itest/jms/format-wf-writing/src/test/java/org/apache/tuscany/sca/binding/jms/format/WireFormatWritingTestCase.java +++ b/sca-java-2.x/trunk/testing/itest/jms/format-wf-writing/src/test/java/org/apache/tuscany/sca/binding/jms/format/WireFormatWritingTestCase.java @@ -19,6 +19,7 @@ package org.apache.tuscany.sca.binding.jms.format;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
@@ -157,7 +158,23 @@ public class WireFormatWritingTestCase { + " </component>"
+ "</composite>";
-
+ public static final String REQ1_WIRE_FORMAT =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200912\" targetNamespace=\"http://binding-jms\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.1\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms >"
+ + " <tuscany:wireFormat.jmsObject/> "
+ + " <response>"
+ + " <destination create=\"never\" jndiName=\"jms/Oasis_JMS_Response\" type=\"queue\"/> "
+ + " <connectionFactory create=\"never\" jndiName=\"jms/Oasis_JMS_CF\"/> "
+ + " </response>"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
private ValidatingXMLInputFactory inputFactory;
private ExtensibleStAXArtifactProcessor staxProcessor;
private ProcessorContext context;
@@ -179,6 +196,12 @@ public class WireFormatWritingTestCase { }
@Test
+ public void testRequest1WireFormat() throws Exception {
+ String xml = doit(REQ1_WIRE_FORMAT);
+ assertEquals(1, countWireFromats(xml, "<tuscany:wireFormat.jmsObject"));
+
+ }
+ @Test
public void testNoWireFormat() throws Exception {
doit(NO_WIRE_FORMAT);
}
@@ -209,7 +232,7 @@ public class WireFormatWritingTestCase { }
}
- public void doit(String xml) throws Exception {
+ public String doit(String xml) throws Exception {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
ValidatingXMLInputFactory.setMonitor(reader, context.getMonitor());
Composite composite = (Composite)staxProcessor.read(reader, context);
@@ -230,29 +253,10 @@ public class WireFormatWritingTestCase { context.getMonitor().analyzeProblems();
assertNotNull(composite);
reader.close();
+ return writtenXML;
}
-
-
-
- private void verifyExtendedElementComposite(Composite composite) throws XMLStreamException {
-
-// assertEquals("RecursiveExtendedElement", composite.getName().getLocalPart());
-// assertEquals(1, composite.getExtensions().size());
-// Extension ext1 = (Extension) composite.getExtensions().get(0);
-// assertEquals("unknownElement", ext1.getQName().getLocalPart());
-// assertEquals("http://docs.oasis-open.org/ns/opencsa/sca/200912", ext1.getQName().getNamespaceURI());
-//
-// XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader((String)ext1.getValue()));
-// reader.next();
-// assertEquals("unknownElement", reader.getLocalName());
-// reader.next();
-// assertEquals("subUnknownElement1", reader.getLocalName());
-// assertEquals(1, reader.getAttributeCount());
-// assertEquals("attribute", reader.getAttributeLocalName(0));
-// assertEquals("anyAttribute", reader.getAttributeValue(0));
-//
-// reader.close();
-//
- }
+ public int countWireFromats(String xml, String wf){
+ return xml.split("\\Q" + wf + "\\E", -1).length - 1;
+ }
}
\ No newline at end of file |