@Override protected OMElement serializeEndpoint(Endpoint endpoint) { if (!(endpoint instanceof AddressEndpoint)) { handleException("Invalid endpoint type."); } fac = OMAbstractFactory.getOMFactory(); OMElement endpointElement = fac.createOMElement("endpoint", SynapseConstants.SYNAPSE_OMNAMESPACE); AddressEndpoint addressEndpoint = (AddressEndpoint) endpoint; EndpointDefinition epAddress = addressEndpoint.getDefinition(); OMElement addressElement = serializeEndpointDefinition(epAddress); endpointElement.addChild(addressElement); // serialize the properties serializeProperties(addressEndpoint, endpointElement); //serialize attributes serializeCommonAttributes(endpoint, endpointElement); return endpointElement; }
@Override public OMElement serializeEndpointDefinition(EndpointDefinition endpointDefinition) { OMElement element = fac.createOMElement("address", SynapseConstants.SYNAPSE_OMNAMESPACE); if (endpointDefinition.getAddress() != null) { element.addAttribute( fac.createOMAttribute("uri", null, endpointDefinition.getAddress())); } else { handleException("Invalid Endpoint. Address is required"); } EndpointDefinitionSerializer serializer = new EndpointDefinitionSerializer(); serializer.serializeEndpointDefinition(endpointDefinition, element); serializeSpecificEndpointProperties(endpointDefinition, element); return element; } }
public void testAddressEndpointScenarioFour() throws Exception { String inputXML = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</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)); }
return new AddressEndpointSerializer(); } else if (endpoint instanceof DefaultEndpoint) { return new DefaultEndpointSerializer();
public void testAddressEndpointScenarioOne() throws Exception { String inputXML = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" />" + "</endpoint>" ; OMElement inputElement = createOMElement(inputXML); AddressEndpoint endpoint = (AddressEndpoint) AddressEndpointFactory.getEndpointFromElement( inputElement,true,null); OMElement serializedOut = AddressEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue(compare(serializedOut,inputElement)); }
return new AddressEndpointSerializer(); } else if (endpoint instanceof DefaultEndpoint) { return new DefaultEndpointSerializer();
@Override protected OMElement serializeEndpoint(Endpoint endpoint) { if (!(endpoint instanceof AddressEndpoint)) { handleException("Invalid endpoint type."); } fac = OMAbstractFactory.getOMFactory(); OMElement endpointElement = fac.createOMElement("endpoint", SynapseConstants.SYNAPSE_OMNAMESPACE); AddressEndpoint addressEndpoint = (AddressEndpoint) endpoint; EndpointDefinition epAddress = addressEndpoint.getDefinition(); OMElement addressElement = serializeEndpointDefinition(epAddress); endpointElement.addChild(addressElement); // serialize the properties serializeProperties(addressEndpoint, endpointElement); //serialize attributes serializeCommonAttributes(endpoint, endpointElement); return endpointElement; }
@Override public OMElement serializeEndpointDefinition(EndpointDefinition endpointDefinition) { OMElement element = fac.createOMElement("address", SynapseConstants.SYNAPSE_OMNAMESPACE); if (endpointDefinition.getAddress() != null) { element.addAttribute( fac.createOMAttribute("uri", null, endpointDefinition.getAddress())); } else { handleException("Invalid Endpoint. Address is required"); } EndpointDefinitionSerializer serializer = new EndpointDefinitionSerializer(); serializer.serializeEndpointDefinition(endpointDefinition, element); serializeSpecificEndpointProperties(endpointDefinition, element); return element; } }
public void testAddressEndpointScenarioTwo() throws Exception { String inputXML = "<endpoint name=\"testEndpoint\" onError=\"foo\" xmlns=" + "\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "</address>"+ "</endpoint>" ; OMElement inputElement = createOMElement(inputXML); AddressEndpoint endpoint = (AddressEndpoint) AddressEndpointFactory.getEndpointFromElement( inputElement,false,null); OMElement serializedOut = AddressEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue(compare(serializedOut,inputElement)); }
public void testAddressEndpointScenarioThree() throws Exception { String inputXML = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "<markForSuspension>" + "<errorCodes>101507,101508</errorCodes>" + "<retriesBeforeSuspension>3</retriesBeforeSuspension>" + "<retryDelay>1000</retryDelay>" + "</markForSuspension>" + "<suspendOnFailure>" + "<errorCodes>101505,101506</errorCodes>" + "<initialDuration>5000</initialDuration>" + "<progressionFactor>2.0</progressionFactor>" + "<maximumDuration>60000</maximumDuration>" + "</suspendOnFailure>" + "<retryConfig>" + "<disabledErrorCodes>101501,101502</disabledErrorCodes>" + "</retryConfig>" + "</address>" + "</endpoint>" ; OMElement inputElement = createOMElement(inputXML); AddressEndpoint endpoint = (AddressEndpoint) AddressEndpointFactory.getEndpointFromElement( inputElement,true,null); OMElement serializedOut = AddressEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue(compare(serializedOut,inputElement)); }
public void testAddressEndpointScenarioDe() throws Exception { String inputXML = "<endpoint xmlns=\"http://ws.apache.org/ns/synapse\">" + "<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" >" + "<markForSuspension>" + "<errorCodes>101507,101508</errorCodes>" + "<retriesBeforeSuspension>3</retriesBeforeSuspension>" + "<retryDelay>1000</retryDelay>" + "</markForSuspension>" + "<suspendOnFailure>" + "<errorCodes>101505,101506</errorCodes>" + "<initialDuration>5000</initialDuration>" + "<progressionFactor>2.0</progressionFactor>" + "<maximumDuration>60000</maximumDuration>" + "</suspendOnFailure>" + "<retryConfig>" + "<enabledErrorCodes>101501,101502</enabledErrorCodes>" + "</retryConfig>" + "</address>" + "</endpoint>" ; OMElement inputElement = createOMElement(inputXML); AddressEndpoint endpoint = (AddressEndpoint) AddressEndpointFactory.getEndpointFromElement( inputElement,true,null); OMElement serializedOut = AddressEndpointSerializer.getElementFromEndpoint(endpoint); assertTrue(compare(serializedOut,inputElement)); }