diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointDefinitionFactory.java b/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointDefinitionFactory.java
index 59ed6ff85d..c4f36618ed 100644
--- a/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointDefinitionFactory.java
+++ b/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/EndpointDefinitionFactory.java
@@ -167,7 +167,7 @@ public EndpointDefinition createDefinition(OMElement elem) {
if (timeoutDurationValue.getKeyValue() != null) {
Long.parseLong(timeoutDurationValue.getKeyValue());
}
- definition.setTimeoutDuration(valueFactory.createTextValue(duration));
+ definition.setTimeoutDuration(timeoutDurationValue);
} catch (NumberFormatException e) {
handleException("Endpoint timeout duration expected as a " +
"number but was not a number");
@@ -242,7 +242,7 @@ public EndpointDefinition createDefinition(OMElement elem) {
if (retryDelayValue.getKeyValue() != null) {
Integer.parseInt(retryDelayValue.getKeyValue());
}
- definition.setRetryDurationOnTimeout(valueFactory.createTextValue(retryDelay));
+ definition.setRetryDurationOnTimeout(retryDelayValue);
} catch (NumberFormatException e) {
handleException("The retry delay for timeouts should be specified " +
"as a valid number : " + retryDelay.getText(), e);
@@ -289,7 +289,7 @@ public EndpointDefinition createDefinition(OMElement elem) {
}
}
}
- definition.setSuspendErrorCodes(valueFactory.createTextValue(suspendCodes));
+ definition.setSuspendErrorCodes(suspendErrorCodesValue);
}
OMElement initialDuration = suspendOnFailure.getFirstChildWithName(new QName(
diff --git a/modules/core/src/test/java/org/apache/synapse/endpoints/HttpEndpointTest.java b/modules/core/src/test/java/org/apache/synapse/endpoints/HttpEndpointTest.java
index c2a9cf06f9..8bbf2ce205 100644
--- a/modules/core/src/test/java/org/apache/synapse/endpoints/HttpEndpointTest.java
+++ b/modules/core/src/test/java/org/apache/synapse/endpoints/HttpEndpointTest.java
@@ -162,13 +162,21 @@ public void testSetDynamicTimeoutAction() throws XMLStreamException, AxisFault {
HTTPEndpointFactory httpEndpointFactory = new HTTPEndpointFactory();
OMElement omElement = AXIOMUtil.stringToOM(
- "12{$ctx:timeoutAction}");
+ "" +
+ "" +
+ "" +
+ "12" +
+ "{$ctx:timeoutAction}" +
+ "" +
+ "");
EndpointDefinition ep = httpEndpointFactory.createEndpointDefinition(omElement);
HTTPEndpoint httpEndpoint = new HTTPEndpoint();
httpEndpoint.setDefinition(ep);
MessageContext messageContext = createMessageContext();
messageContext.setProperty("timeoutAction", "discard");
- Assert.assertEquals(httpEndpoint.getDefinition().getResolvedTimeoutAction(messageContext), SynapseConstants.DISCARD);
+ Assert.assertEquals(
+ httpEndpoint.getDefinition().getResolvedTimeoutAction(messageContext), SynapseConstants.DISCARD);
}
@Test
@@ -176,7 +184,19 @@ public void testSetSuspendOnFailureInitialDuration() throws XMLStreamException,
HTTPEndpointFactory httpEndpointFactory = new HTTPEndpointFactory();
OMElement omElement = AXIOMUtil.stringToOM(
- "10100010");
+ "" +
+ "" +
+ "10" +
+ "" +
+ "" +
+ "1000" +
+ "1" +
+ "" +
+ "" +
+ "0" +
+ "" +
+ "");
EndpointDefinition ep1 = httpEndpointFactory.createEndpointDefinition(omElement);
Assert.assertEquals(ep1.getRetriesOnTimeoutBeforeSuspend(), "0");
Assert.assertEquals(ep1.getInitialSuspendDuration(), "1000");
@@ -187,20 +207,28 @@ public void testDefaultErrorHandlingValues() throws XMLStreamException, AxisFaul
HTTPEndpointFactory httpEndpointFactory = new HTTPEndpointFactory();
OMElement omElement = AXIOMUtil.stringToOM(
- "\n" +
- " ");
+ "");
EndpointDefinition ep = httpEndpointFactory.createEndpointDefinition(omElement);
HTTPEndpoint httpEndpoint = new HTTPEndpoint();
httpEndpoint.setDefinition(ep);
MessageContext messageContext = createMessageContext();
- Assert.assertEquals("Default timeout action should be 100", 100, httpEndpoint.getDefinition().getResolvedTimeoutAction(messageContext));
- Assert.assertEquals("Default initial suspend duration should be -1", -1, httpEndpoint.getDefinition().getResolvedInitialSuspendDuration(messageContext));
- Assert.assertEquals("Default maximum suspend duration should be 0", Long.MAX_VALUE, httpEndpoint.getDefinition().getResolvedSuspendMaximumDuration(messageContext));
- Assert.assertEquals("Default suspend progression factor should be 1", 1f, httpEndpoint.getDefinition().getResolvedSuspendProgressionFactor(messageContext), 0.0f);
- Assert.assertEquals("Default suspend error codes should be empty", new ArrayList<>(), httpEndpoint.getDefinition().getResolvedSuspendErrorCodes(messageContext));
- Assert.assertEquals("Default timeout error codes should be empty", new ArrayList<>(), httpEndpoint.getDefinition().getResolvedTimeoutErrorCodes(messageContext));
- Assert.assertEquals("Default retries on timeout before suspend should be 0", 0, httpEndpoint.getDefinition().getResolvedRetriesOnTimeoutBeforeSuspend(messageContext));
- Assert.assertEquals("Default retry duration on timeout should be 0", 0, httpEndpoint.getDefinition().getResolvedRetryDurationOnTimeout(messageContext));
+ Assert.assertEquals("Default timeout action should be 100", 100,
+ httpEndpoint.getDefinition().getResolvedTimeoutAction(messageContext));
+ Assert.assertEquals("Default initial suspend duration should be -1", -1,
+ httpEndpoint.getDefinition().getResolvedInitialSuspendDuration(messageContext));
+ Assert.assertEquals("Default maximum suspend duration should be 0", Long.MAX_VALUE,
+ httpEndpoint.getDefinition().getResolvedSuspendMaximumDuration(messageContext));
+ Assert.assertEquals("Default suspend progression factor should be 1", 1f,
+ httpEndpoint.getDefinition().getResolvedSuspendProgressionFactor(messageContext), 0.0f);
+ Assert.assertEquals("Default suspend error codes should be empty", new ArrayList<>(),
+ httpEndpoint.getDefinition().getResolvedSuspendErrorCodes(messageContext));
+ Assert.assertEquals("Default timeout error codes should be empty", new ArrayList<>(),
+ httpEndpoint.getDefinition().getResolvedTimeoutErrorCodes(messageContext));
+ Assert.assertEquals("Default retries on timeout before suspend should be 0", 0,
+ httpEndpoint.getDefinition().getResolvedRetriesOnTimeoutBeforeSuspend(messageContext));
+ Assert.assertEquals("Default retry duration on timeout should be 0", 0,
+ httpEndpoint.getDefinition().getResolvedRetryDurationOnTimeout(messageContext));
}
@Test
@@ -208,7 +236,8 @@ public void testSetSuspendErrorCodes() throws XMLStreamException, AxisFault {
HTTPEndpointFactory httpEndpointFactory = new HTTPEndpointFactory();
OMElement omElement = AXIOMUtil.stringToOM(
- "\n" +
+ "\n" +
" \n" +
" {$ctx:suspendErrorCodes}\n" +
" -1\n" +
@@ -227,7 +256,8 @@ public void testSetSuspendErrorCodes() throws XMLStreamException, AxisFault {
List actualSuspendErrorCodes = new ArrayList<>();
actualSuspendErrorCodes.add(101503);
actualSuspendErrorCodes.add(101504);
- List expectedSuspendErrorCodes = httpEndpoint.getDefinition().getResolvedSuspendErrorCodes(messageContext);
+ List expectedSuspendErrorCodes =
+ httpEndpoint.getDefinition().getResolvedSuspendErrorCodes(messageContext);
Assert.assertTrue(expectedSuspendErrorCodes.equals(actualSuspendErrorCodes));
}
@@ -236,7 +266,8 @@ public void testSetTimeoutErrorCodes() throws XMLStreamException, AxisFault {
HTTPEndpointFactory httpEndpointFactory = new HTTPEndpointFactory();
OMElement omElement = AXIOMUtil.stringToOM(
- "\n" +
+ "\n" +
" \n" +
" {$ctx:timeoutErrorCodes}\n" +
" 10\n" +
@@ -251,7 +282,8 @@ public void testSetTimeoutErrorCodes() throws XMLStreamException, AxisFault {
List actualTimeoutErrorCodes = new ArrayList<>();
actualTimeoutErrorCodes.add(101503);
actualTimeoutErrorCodes.add(101504);
- List expectedTimeoutErrorCodes = httpEndpoint.getDefinition().getResolvedTimeoutErrorCodes(messageContext);
+ List expectedTimeoutErrorCodes =
+ httpEndpoint.getDefinition().getResolvedTimeoutErrorCodes(messageContext);
Assert.assertTrue(expectedTimeoutErrorCodes.equals(actualTimeoutErrorCodes));
}