use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class MessageAnalyserTest method getRequest.
private Exchange getRequest(String path) throws IOException {
Exchange exc = new Exchange(null);
Request req = new Request();
req.create("POST", "http://test", "HTTP/", new Header(), getClass().getClassLoader().getResourceAsStream(path));
exc.setRequest(req);
return exc;
}
use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class MessageAnalyserTest method extractFromResponse.
@Test
public void extractFromResponse() throws Exception {
Exchange exc = getResponse("messageAnalyser/getBuecherResponseSOAP11.xml");
analyser.handleResponse(exc);
Assert.assertEquals("Envelope", exc.getProperty(MessageAnalyser.RESPONSE_ROOT_ELEMENT_NAME));
Assert.assertEquals(Constants.SOAP11_NS, exc.getProperty(MessageAnalyser.RESPONSE_ROOT_ELEMENT_NS));
Assert.assertEquals(Constants.SOAP11_VERION, exc.getProperty(MessageAnalyser.RESPONSE_SOAP_VERSION));
Assert.assertEquals("getBuecher", exc.getProperty(MessageAnalyser.RESPONSE_SOAP_OPERATION));
Assert.assertEquals("http://predic8.de", exc.getProperty(MessageAnalyser.RESPONSE_SOAP_OPERATION_NS));
}
use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class RegExReplaceInterceptorTest method testReplaceBinary.
@Test
public void testReplaceBinary() throws Exception {
String example = "Hello";
RegExReplaceInterceptor regexp = new RegExReplaceInterceptor();
regexp.setRegex(Pattern.quote(example));
regexp.setReplace("Membrane");
Exchange exc = new Request.Builder().body(example).header("Content-Type", "text/plain").buildExchange();
regexp.handleRequest(exc);
assertTrue(exc.getRequest().getBodyAsStringDecoded().equals("Membrane"));
exc = new Request.Builder().body(example).header("Content-Type", "application/octet-stream").buildExchange();
regexp.handleRequest(exc);
assertTrue(exc.getRequest().getBodyAsStringDecoded().equals(example));
}
use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class WSDLInterceptorTest method setUp.
@Before
public void setUp() throws Exception {
exc = new Exchange(new FakeHttpHandler(3011));
exc.setRequest(MessageUtil.getGetRequest("/axis2/services/BLZService?wsdl"));
InputStream resourceAsStream = this.getClass().getResourceAsStream("/blz-service.wsdl");
Response okResponse = Response.ok().contentType("text/xml; charset=utf-8").body(resourceAsStream, true).build();
exc.setResponse(okResponse);
exc.setOriginalHostHeader("thomas-bayer.com:80");
interceptor = new WSDLInterceptor();
}
use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.
the class WADLInterceptorTest method testDefaultSettings.
@Test
public void testDefaultSettings() throws Exception {
Exchange exc = getExchange();
assertEquals(interceptor.handleResponse(exc), Outcome.CONTINUE);
assertAttribute(exc, "//wadl:resources/@base", "http://thomas-bayer.com:3011/search/V1/");
assertAttribute(exc, "//wadl:resource/@path", "newsSearch");
assertAttribute(exc, "//wadl:grammars/wadl:include[1]/@href", "http://thomas-bayer.com:3011/search.xsd");
assertAttribute(exc, "//wadl:grammars/wadl:include[2]/@href", "http://thomas-bayer.com:3011/error/Error.xsd");
}
Aggregations