From ffb50b737377c1a13b08c7498f4b82c3d8eb33ee Mon Sep 17 00:00:00 2001 From: chathurangaj Date: Sun, 8 Dec 2024 22:48:36 +0530 Subject: [PATCH] add serializer tests --- .../endpoints/HTTPEndpointSerializerTest.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/modules/core/src/test/java/org/apache/synapse/config/xml/endpoints/HTTPEndpointSerializerTest.java b/modules/core/src/test/java/org/apache/synapse/config/xml/endpoints/HTTPEndpointSerializerTest.java index 5747924368..08fbc0c266 100644 --- a/modules/core/src/test/java/org/apache/synapse/config/xml/endpoints/HTTPEndpointSerializerTest.java +++ b/modules/core/src/test/java/org/apache/synapse/config/xml/endpoints/HTTPEndpointSerializerTest.java @@ -33,4 +33,78 @@ public void test() throws Exception { OMElement serializedResponse = HTTPEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue("Endpoint not serialized!", compare(serializedResponse, inputElement)); } + + public void testCreateEndpointDefinitionWithErrorHandling() throws Exception { + + String inputXml = "" + + "" + + "" + + "1000" + + "discard" + + "" + + "" + + "403" + + "1" + + "" + + "" + + ""; + OMElement inputElement = AXIOMUtil.stringToOM(inputXml); + HTTPEndpoint endpoint = (HTTPEndpoint) HTTPEndpointFactory.getEndpointFromElement(inputElement, true, null); + OMElement serializedResponse = HTTPEndpointSerializer.getElementFromEndpoint(endpoint); + assertTrue("Endpoint definition with error handling not serialized!", compare(serializedResponse, inputElement)); + } + + public void testCreateEndpointDefinitionWithCompleteErrorHandling() throws Exception { + + String inputXml = "" + + "" + + "" + + "200" + + "discard" + + "" + + "" + + "403" + + "10" + + "10" + + "2" + + "" + + "" + + "304"+ + "10" + + "5" + + "" + + "" + + ""; + OMElement inputElement = AXIOMUtil.stringToOM(inputXml); + HTTPEndpoint endpoint = (HTTPEndpoint) HTTPEndpointFactory.getEndpointFromElement(inputElement, true, null); + OMElement serializedResponse = HTTPEndpointSerializer.getElementFromEndpoint(endpoint); + assertTrue("Endpoint definition with complete error handling not serialized!", compare(serializedResponse, inputElement)); + } + + public void testCreateEndpointDefinitionWithDynamicErrorHandling() throws Exception { + + String inputXml = "" + + "" + + "" + + "{get-property('timeoutDuration')}" + + "{get-property('timeoutAction')}" + + "" + + "" + + "{get-property('suspendErrorCodes')}" + + "{get-property('suspendInitialDuration')}" + + "{get-property('suspendMaximumDuration')}" + + "{get-property('suspendProgressionFactor')}" + + "" + + "" + + "{get-property('retryErrorCodes')}"+ + "{get-property('retryCount')}" + + "{get-property('retryDelay')}" + + "" + + "" + + ""; + OMElement inputElement = AXIOMUtil.stringToOM(inputXml); + HTTPEndpoint endpoint = (HTTPEndpoint) HTTPEndpointFactory.getEndpointFromElement(inputElement, true, null); + OMElement serializedResponse = HTTPEndpointSerializer.getElementFromEndpoint(endpoint); + assertTrue("Endpoint definition with dynamic error handling not serialized!", compare(serializedResponse, inputElement)); + } } \ No newline at end of file