public CallMediatorSerializationTest() { factory = new CallMediatorFactory(); serializer = new CallMediatorSerializer(); }
public OMElement serializeSpecificMediator(Mediator m) { if (!(m instanceof CallMediator)) { handleException("Unsupported mediator passed in for serialization : " + m.getType()); } CallMediator mediator = (CallMediator) m; OMElement call = fac.createOMElement("call", synNS); saveTracingState(call, mediator); Endpoint activeEndpoint = mediator.getEndpoint(); if (activeEndpoint != null) { call.addChild(EndpointSerializer.getElementFromEndpoint(activeEndpoint)); } if (mediator.isBlocking()) { call.addAttribute(fac.createOMAttribute("blocking", nullNS, "true")); if (!mediator.getInitClientOptions()) { call.addAttribute(fac.createOMAttribute("initAxis2ClientOptions", nullNS, "false")); } if (mediator.getClientRepository() != null) { call.addAttribute(fac.createOMAttribute("repository", nullNS, mediator.getClientRepository())); } if (mediator.getAxis2xml() != null) { call.addAttribute(fac.createOMAttribute("axis2xml", nullNS, mediator.getAxis2xml())); } } return call; }
public void testBlockingAttributeSerialization() { String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\" blocking=\"true\">" + "<endpoint>" + "<address uri='http://localhost:9000/services/MyService1'>" + "<enableAddressing/>" + "<timeout>" + "<duration>60</duration>" + "<responseAction>discard</responseAction>" + "</timeout>" + "</address>" + "</endpoint>" + "</call>"; OMElement config1 = createOMElement(callConfig); CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties()); OMElement config2 = serializer.serializeMediator(null, call1); CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties()); assertTrue("blocking attribute is not serialized properly - probably an issue in factory", call1.isBlocking()); assertTrue("blocking attribute is not serialized properly", call2.isBlocking()); }
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties()); OMElement config2 = serializer.serializeMediator(null, call1); CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties()); OMElement config2 = serializer.serializeMediator(null, call1); CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties()); OMElement config2 = serializer.serializeMediator(null, call1); CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties());
public void testAddressEndpointSerialization() { String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<address uri='http://localhost:9000/services/MyService1'>" + "<enableAddressing/>" + "<timeout>" + "<duration>60</duration>" + "<responseAction>discard</responseAction>" + "</timeout>" + "</address>" + "</endpoint>" + "</call>"; OMElement config1 = createOMElement(callConfig); CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties()); OMElement config2 = serializer.serializeMediator(null, call1); CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties()); assertTrue("Top level endpoint should be a address endpoint.", call1.getEndpoint() instanceof AddressEndpoint); AddressEndpoint ep1 = (AddressEndpoint) call1.getEndpoint(); assertTrue("Top level endpoint should be a address endpoint.", call2.getEndpoint() instanceof AddressEndpoint); AddressEndpoint ep2 = (AddressEndpoint) call2.getEndpoint(); assertEquals("Address URI is not serialized properly", ep1.getDefinition().getAddress(), ep2.getDefinition().getAddress()); assertEquals( "Addressing information is not serialized properly", ep1.getDefinition().isAddressingOn(), ep2.getDefinition().isAddressingOn()); }
public void testWSDLEndpointSerialization() { String callConfig = "<call xmlns=\"http://ws.apache.org/ns/synapse\">" + "<endpoint>" + "<wsdl uri='file:src/test/resources/esbservice.wsdl' service='esbservice' port='esbserviceSOAP11port_http'>" + "<enableAddressing/>" + "</wsdl>" + "</endpoint>" + "</call>"; OMElement config1 = createOMElement(callConfig); CallMediator call1 = (CallMediator) factory.createMediator(config1, new Properties()); OMElement config2 = serializer.serializeMediator(null, call1); CallMediator call2 = (CallMediator) factory.createMediator(config2, new Properties()); assertTrue("Top level endpoint should be a WSDL endpoint.", call1.getEndpoint() instanceof WSDLEndpoint); WSDLEndpoint ep1 = (WSDLEndpoint) call1.getEndpoint(); assertTrue("Top level endpoint should be a WSDL endpoint.", call2.getEndpoint() instanceof WSDLEndpoint); WSDLEndpoint ep2 = (WSDLEndpoint) call2.getEndpoint(); assertEquals("Service name is not serialized properly.", ep1.getServiceName(), ep2.getServiceName()); assertEquals("Port name is not serialized properly", ep1.getPortName(), ep2.getPortName()); assertEquals("WSDL URI is not serialized properly", ep1.getWsdlURI(), ep2.getWsdlURI()); assertEquals( "Addressing information is not serialized properly", ep1.getDefinition().isAddressingOn(), ep2.getDefinition().isAddressingOn()); }