Author: hiranya
Date: Mon Jul 22 21:49:10 2013
New Revision: 1505827

URL: http://svn.apache.org/r1505827
Log:
Applying the patch for SYNAPSE-951 with a test case. Bug fix in endpoint 
serializer - adding a stray responseAction element.

Modified:
    
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointDefinitionSerializer.java
    
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializationTest.java

Modified: 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointDefinitionSerializer.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointDefinitionSerializer.java?rev=1505827&r1=1505826&r2=1505827&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointDefinitionSerializer.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointDefinitionSerializer.java
 Mon Jul 22 21:49:10 2013
@@ -118,14 +118,17 @@ public class EndpointDefinitionSerialize
             
duration.setText(Long.toString(endpointDefinition.getTimeoutDuration()));
             timeout.addChild(duration);
 
-            OMElement action = fac.createOMElement("responseAction", 
SynapseConstants.SYNAPSE_OMNAMESPACE);
-            if (endpointDefinition.getTimeoutAction() == 
SynapseConstants.DISCARD) {
-                action.setText("discard");
-            } else if (endpointDefinition.getTimeoutAction()
-                    == SynapseConstants.DISCARD_AND_FAULT) {
-                action.setText("fault");
+            if (endpointDefinition.getTimeoutAction() != 
SynapseConstants.NONE) {
+                OMElement action = fac.createOMElement("responseAction",
+                        SynapseConstants.SYNAPSE_OMNAMESPACE);
+                if (endpointDefinition.getTimeoutAction() == 
SynapseConstants.DISCARD) {
+                    action.setText("discard");
+                } else if (endpointDefinition.getTimeoutAction()
+                        == SynapseConstants.DISCARD_AND_FAULT) {
+                    action.setText("fault");
+                }
+                timeout.addChild(action);
             }
-            timeout.addChild(action);
         }
 
         if (endpointDefinition.getInitialSuspendDuration() != -1 ||

Modified: 
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializationTest.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializationTest.java?rev=1505827&r1=1505826&r2=1505827&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializationTest.java
 (original)
+++ 
synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/config/xml/endpoints/AddressEndpointSerializationTest.java
 Mon Jul 22 21:49:10 2013
@@ -99,4 +99,25 @@ public class AddressEndpointSerializatio
         // the generated name should not show up in the serialization
         assertTrue(compare(serializedOut,inputElement));
     }
+
+    public void testAddressEndpointScenarioFive() throws Exception {
+        String inputXML =
+                "<endpoint name=\"EchoServiceEp\" 
xmlns=\"http://ws.apache.org/ns/synapse\";>" +
+                        "<address 
uri=\"http://10.200.3.190:8281/services/echo\";><timeout>" +
+                        
"<duration>2000</duration></timeout><suspendOnFailure>" +
+                        
"<initialDuration>60000</initialDuration><progressionFactor>2.0" +
+                        
"</progressionFactor></suspendOnFailure><markForSuspension>" +
+                        
"<errorCodes>101000,101500</errorCodes><retriesBeforeSuspension>3" +
+                        
"</retriesBeforeSuspension></markForSuspension><retryConfig>" +
+                        
"<disabledErrorCodes>101507,101509</disabledErrorCodes></retryConfig>" +
+                        "</address></endpoint>" ;
+
+        OMElement inputElement = createOMElement(inputXML);
+        AddressEndpoint endpoint = (AddressEndpoint) 
AddressEndpointFactory.getEndpointFromElement(
+                inputElement, true, null);
+        assertNotNull(endpoint.getName()); // make sure we generate names for 
anonymous endpoints
+        OMElement serializedOut = 
AddressEndpointSerializer.getElementFromEndpoint(endpoint);
+        // the generated name should not show up in the serialization
+        assertTrue(compare(serializedOut,inputElement));
+    }
 }


Reply via email to