Search in sources :

Example 71 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class ValidatorInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    requestTB = MessageUtil.getPostRequest("http://thomas-bayer.com");
    requestXService = MessageUtil.getPostRequest("http://ws.xwebservices.com");
    exc = new Exchange(null);
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Before(org.junit.Before)

Example 72 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class RewriteInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    HttpRouter router = new HttpRouter();
    di = new DispatchingInterceptor();
    di.init(router);
    sp = new ServiceProxy(new ServiceProxyKey(80, null), "www.predic8.de", 80);
    sp.init(router);
    exc = new Exchange(null);
    exc.setRequest(MessageUtil.getGetRequest("/buy/banana/3"));
    rewriter = new RewriteInterceptor();
    List<Mapping> mappings = new ArrayList<Mapping>();
    mappings.add(new Mapping("/buy/(.*)/(.*)", "/buy?item=$1&amount=$2", null));
    rewriter.setMappings(mappings);
    rewriter.init(router);
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) ArrayList(java.util.ArrayList) Mapping(com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping) HttpRouter(com.predic8.membrane.core.HttpRouter) DispatchingInterceptor(com.predic8.membrane.core.interceptor.DispatchingInterceptor) Before(org.junit.Before)

Example 73 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class SoapOperationExtractorTest method notSoap.

@Test
public void notSoap() throws Exception {
    Exchange exc = getExchange("soapOperationExtractor/notSoap.xml");
    extractor.handleRequest(exc);
    Assert.assertNull(exc.getProperty(SoapOperationExtractor.SOAP_OPERATION));
    Assert.assertNull(exc.getProperty(SoapOperationExtractor.SOAP_OPERATION_NS));
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Test(org.junit.Test)

Example 74 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class SoapOperationExtractorTest method nonEmptyHeader.

@Test
public void nonEmptyHeader() throws Exception {
    Exchange exc = getExchange("soapOperationExtractor/getBuecherWithHeader.xml");
    extractor.handleRequest(exc);
    Assert.assertEquals("getBuecher", exc.getProperty(SoapOperationExtractor.SOAP_OPERATION));
    Assert.assertEquals("http://predic8.de", exc.getProperty(SoapOperationExtractor.SOAP_OPERATION_NS));
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Test(org.junit.Test)

Example 75 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class SoapOperationExtractorTest method getExchange.

private Exchange getExchange(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;
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Header(com.predic8.membrane.core.http.Header) Request(com.predic8.membrane.core.http.Request)

Aggregations

Exchange (com.predic8.membrane.core.exchange.Exchange)107 Test (org.junit.Test)39 IOException (java.io.IOException)32 Request (com.predic8.membrane.core.http.Request)25 Outcome (com.predic8.membrane.core.interceptor.Outcome)24 Response (com.predic8.membrane.core.http.Response)16 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)16 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)16 HttpRouter (com.predic8.membrane.core.HttpRouter)14 Before (org.junit.Before)13 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)12 AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)11 Header (com.predic8.membrane.core.http.Header)10 HttpClient (com.predic8.membrane.core.transport.http.HttpClient)10 CacheBuilder (com.google.common.cache.CacheBuilder)9 Rule (com.predic8.membrane.core.rules.Rule)6 URISyntaxException (java.net.URISyntaxException)6 UnknownHostException (java.net.UnknownHostException)6 ArrayList (java.util.ArrayList)6 Session (com.predic8.membrane.core.interceptor.authentication.session.SessionManager.Session)5