From 5bb876b10f1ba6a71451a4ae709d529a28aed245 Mon Sep 17 00:00:00 2001 From: beckerdo Date: Tue, 10 Feb 2009 20:36:13 +0000 Subject: TUSCANY-2835 JMS Binding does not save operation names unless there are properties. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@743094 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/binding/jms/impl/JMSBinding.java | 14 +++++++- .../sca/binding/jms/impl/JMSBindingProcessor.java | 8 +++-- .../jms/impl/JMSBindingProcessorTestCase.java | 39 ++++++++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) (limited to 'branches/sca-java-1.x/modules/binding-jms/src') 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 props = operationProperties.get(opName); + if (props == null) { + props = new HashMap(); + operationProperties.put(opName, props); + } + } + + /** + * Provides set of operation names in this binding. * @return a Set of operation names */ public Set 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 { 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 { 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 { + " " + ""; + private static final String OP_NAMES_NO_PROPERTIES1 = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + private static final String SELECTOR = "" + "" @@ -615,5 +631,28 @@ public class JMSBindingProcessorTestCase extends TestCase { assertEquals(77, ((Integer)value).intValue()); } + /** + * Tests the APIs: + * public Set 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 opNames = binding.getOperationNames(); + assertEquals( 2, opNames.size() ); + // Recall that order is not guaranteed iterating over a set. + for (Iterator it=opNames.iterator(); it.hasNext(); ) { + String opName = it.next(); + assertTrue( opName.equals( "op1") || opName.equals( "op2")); + } + } + } -- cgit v1.2.3