diff options
Diffstat (limited to '')
-rw-r--r-- | sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java b/sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java index 72574b2fb6..6a229d1ea2 100644 --- a/sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java +++ b/sandbox/wjaniszewski/binding-erlang/src/test/java/org/apache/tuscany/sca/binding/erlang/testing/ErlangBindingProcessorTestCase.java @@ -28,6 +28,7 @@ import javax.xml.stream.XMLStreamReader; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.binding.erlang.ErlangBinding; +import org.apache.tuscany.sca.binding.erlang.impl.ErlangBindingImpl; import org.apache.tuscany.sca.contribution.processor.DefaultStAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; @@ -50,10 +51,30 @@ public class ErlangBindingProcessorTestCase { + " <component name=\"HelloWorldComponent\">" + " <implementation.java class=\"services.HelloWorld\"/>" + " <service name=\"HelloWorldService\">" + + " <tuscany:binding.erlang node=\"SomeNode\" timeout=\"1000\" cookie=\"cookie\"/>" + + " </service>" + + " </component>" + + "</composite>"; + + private static final String COMPOSITE_DEFAULT_TIMEOUT = + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://binding-erlang\" name=\"binding-erlang\">" + + " <component name=\"HelloWorldComponent\">" + + " <implementation.java class=\"services.HelloWorld\"/>" + + " <service name=\"HelloWorldService\">" + " <tuscany:binding.erlang node=\"SomeNode\"/>" + " </service>" + " </component>" + "</composite>"; + + private static final String COMPOSITE_ZERO_TIMEOUT = + "<?xml version=\"1.0\" encoding=\"ASCII\"?>" + "<composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:tuscany=\"http://tuscany.apache.org/xmlns/sca/1.0\" targetNamespace=\"http://binding-erlang\" name=\"binding-erlang\">" + + " <component name=\"HelloWorldComponent\">" + + " <implementation.java class=\"services.HelloWorld\"/>" + + " <service name=\"HelloWorldService\">" + + " <tuscany:binding.erlang node=\"SomeNode\" timeout=\"0\"/>" + + " </service>" + + " </component>" + + "</composite>"; private static XMLInputFactory inputFactory; private static StAXArtifactProcessor<Object> staxProcessor; @@ -87,6 +108,37 @@ public class ErlangBindingProcessorTestCase { ErlangBinding binding = (ErlangBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0); assertEquals("SomeNode", binding.getNode()); + assertEquals(1000, binding.getTimeout()); + assertEquals("cookie", binding.getCookie()); + } + + /** + * Tests using default "resultTimeout" value + * + * @throws Exception + */ + @Test + public void testLoadDefaultTimeout() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_DEFAULT_TIMEOUT)); + Composite composite = (Composite)staxProcessor.read(reader); + ErlangBinding binding = + (ErlangBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertEquals(ErlangBindingImpl.DEFAULT_TIMEOUT, binding.getTimeout()); + assertEquals(null, binding.getCookie()); } + /** + * Tests "resultTimeout" attribute set to 0 + * + * @throws Exception + */ + @Test + public void testLoadZeroTimeout() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(COMPOSITE_ZERO_TIMEOUT)); + Composite composite = (Composite)staxProcessor.read(reader); + ErlangBinding binding = + (ErlangBinding)composite.getComponents().get(0).getServices().get(0).getBindings().get(0); + assertEquals(ErlangBindingImpl.DEFAULT_TIMEOUT, binding.getTimeout()); + } + } |