diff options
Diffstat (limited to 'branches/sca-java-1.x/modules/binding-jms/src')
3 files changed, 57 insertions, 4 deletions
diff --git a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java index 6c9ba36162..073e01d8e3 100644 --- a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java +++ b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBinding.java @@ -494,7 +494,19 @@ public class JMSBinding implements BindingRRB, PolicySetAttachPoint { } /** - * Provides key set of operation names in this binding. + * Adds an operationName to this binding. + * @param opName + */ + public void addOperationName(String opName) { + Map<String, Object> props = operationProperties.get(opName); + if (props == null) { + props = new HashMap<String, Object>(); + operationProperties.put(opName, props); + } + } + + /** + * Provides set of operation names in this binding. * @return a Set<String> of operation names */ public Set<String> getOperationNames() { diff --git a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java index 81fb1969d1..74dfd0c755 100644 --- a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java +++ b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java @@ -616,7 +616,9 @@ public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> { warning("MissingJMSOperationPropertyName", jmsBinding); return; } - String nativeOpName = reader.getAttributeValue(null, "nativeOperation"); + // Since nativeOpName, headers, and property elements are optional, must add opName. + jmsBinding.addOperationName(opName); + String nativeOpName = reader.getAttributeValue(null, "nativeOperation"); // optional if (nativeOpName != null && nativeOpName.length() > 0) { jmsBinding.setNativeOperationName(opName, nativeOpName); } @@ -624,9 +626,9 @@ public class JMSBindingProcessor implements StAXArtifactProcessor<JMSBinding> { while (true) { switch (reader.next()) { case START_ELEMENT: - if (reader.getName().getLocalPart().equals("headers")) { + if (reader.getName().getLocalPart().equals("headers")) { // optional parseOperationHeaders(reader, jmsBinding, opName); - } else if (reader.getName().getLocalPart().equals("property")) { + } else if (reader.getName().getLocalPart().equals("property")) { // optional jmsBinding.getOperationPropertiesProperties(opName).putAll(parseBindingProperties(reader)); } // break; 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 74524daf19..facdffffe9 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 @@ -110,6 +110,22 @@ public class JMSBindingProcessorTestCase extends TestCase { + " </component>"
+ "</composite>";
+ private 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\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms:testQueue\" >"
+ + " <operationProperties name=\"op1\">"
+ + " </operationProperties >"
+ + " <operationProperties name=\"op2\" nativeOperation=\"nativeOp2\" >"
+ + " </operationProperties >"
+ + " </binding.jms>"
+ + " </service>"
+ + " </component>"
+ + "</composite>";
+
private 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\">"
@@ -615,5 +631,28 @@ public class JMSBindingProcessorTestCase extends TestCase { assertEquals(77, ((Integer)value).intValue());
}
+ /**
+ * Tests the APIs:
+ * public Set<String> getOperationNames();
+ * Provides no optional properties or sub elements
+ * @throws Exception
+ */
+ public void testOpProperties3() throws Exception {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(OP_NAMES_NO_PROPERTIES1));
+
+ Composite composite = (Composite)staxProcessor.read(reader);
+ JMSBinding binding = (JMSBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+
+ Set<String> opNames = binding.getOperationNames();
+ assertEquals( 2, opNames.size() );
+ // Recall that order is not guaranteed iterating over a set.
+ for (Iterator<String> it=opNames.iterator(); it.hasNext(); ) {
+ String opName = it.next();
+ assertTrue( opName.equals( "op1") || opName.equals( "op2"));
+ }
+ }
+
}
|