Package org.fishwife.jrugged

Examples of org.fishwife.jrugged.ServiceWrapper


        if (!shouldWrapMethodCall(methodName)) {
            return invocation.proceed();
        }
        else {
            ServiceWrapper wrapper = methodMap.get(methodName);

            return wrapper.invoke(new Callable<Object>() {
                    public Object call() throws Exception {
                        try {
                            return invocation.proceed();
                        } catch (Throwable e) {
                            if (e instanceof Exception)
View Full Code Here


        if (!shouldWrapMethodCall(methodName)) {
            return invocation.proceed();
        }
        else {
            ServiceWrapper wrapper = serviceWrapper;

            return wrapper.invoke(new Callable<Object>() {
                    public Object call() throws Exception {
                        try {
                            return invocation.proceed();
                        } catch (Throwable e) {
                            if (e instanceof Exception)
View Full Code Here

    public HttpResponse execute(HttpHost host, HttpRequest req, HttpContext ctx)
            throws IOException, ClientProtocolException {
        host = getCanonicalHost(host);
        HttpClient client = clients.get(host);
        if (client == null) {
            ServiceWrapper wrapper = factory.getWrapperWithName(host.toHostString());
            client = new ServiceWrappedHttpClient(backend, wrapper);
            clients.put(host, client);
        }
        return client.execute(host, req, ctx);
    }
View Full Code Here

        assertTrue(impl instanceof HttpClient);
    }
   
    @Test
    public void usesRequestHostToCreateWrapper() throws Exception {
        final ServiceWrapper wrapper = new NullWrapper();
        expect(mockBackend.execute(isA(HttpHost.class), isA(HttpRequest.class), isA(HttpContext.class)))
                .andReturn(resp);
        expect(mockFactory.getWrapperWithName(HOST_STRING)).andReturn(wrapper);
        replayMocks();
        impl.execute(host, req, ctx);
View Full Code Here

    }

    @Test
    public void wiresWrapperUpToRequest() throws Exception {
        final Flag f = new Flag();
        ServiceWrapper wrapper = new NullWrapper(f);
        expect(mockBackend.execute(isA(HttpHost.class), isA(HttpRequest.class), isA(HttpContext.class)))
            .andReturn(resp);
        expect(mockFactory.getWrapperWithName(isA(String.class))).andReturn(wrapper);
        replayMocks();
        impl.execute(host, req, ctx);
View Full Code Here

        assertTrue(f.set);
    }
   
    @Test
    public void reusesWrapperForRequestsFromSameHost() throws Exception {
        ServiceWrapper wrapper = new NullWrapper();
        HttpUriRequest req1 = new HttpGet("http://foo.example.com/bar");
        HttpUriRequest req2 = new HttpGet("http://foo.example.com/baz");
        HttpResponse resp1 = resp;
        HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        expect(mockFactory.getWrapperWithName(isA(String.class))).andReturn(wrapper);
View Full Code Here

        verifyMocks();
    }
   
    @Test
    public void reusesWrapperForRequestsFromEquivalentHostsDefaultHttpPort() throws Exception {
        ServiceWrapper wrapper = new NullWrapper();
        HttpUriRequest req1 = new HttpGet("http://foo.example.com/bar");
        HttpUriRequest req2 = new HttpGet("http://foo.example.com:80/baz");
        HttpResponse resp1 = resp;
        HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        expect(mockFactory.getWrapperWithName(isA(String.class))).andReturn(wrapper);
View Full Code Here

        verifyMocks();
    }
   
    @Test
    public void reusesWrapperForRequestsFromEquivalentHostsDefaultHttpsPort() throws Exception {
        ServiceWrapper wrapper = new NullWrapper();
        HttpUriRequest req1 = new HttpGet("https://foo.example.com/bar");
        HttpUriRequest req2 = new HttpGet("https://foo.example.com:443/baz");
        HttpResponse resp1 = resp;
        HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        expect(mockFactory.getWrapperWithName(isA(String.class))).andReturn(wrapper);
View Full Code Here

        verifyMocks();
    }

    @Test
    public void reusesWrapperForRequestsFromEquivalentHostsCaseInsensitiveHostName() throws Exception {
        ServiceWrapper wrapper = new NullWrapper();
        HttpUriRequest req1 = new HttpGet("http://foo.example.com/bar");
        HttpUriRequest req2 = new HttpGet("http://FOO.Example.cOM/baz");
        HttpResponse resp1 = resp;
        HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        expect(mockFactory.getWrapperWithName(isA(String.class))).andReturn(wrapper);
View Full Code Here

    }
   
    @Test
    public void usesDifferentWrappersForDifferentHosts() throws Exception {
        Flag f1 = new Flag();
        ServiceWrapper wrapper1 = new NullWrapper(f1);
        Flag f2 = new Flag();
        ServiceWrapper wrapper2 = new NullWrapper(f2);
        HttpUriRequest req1 = new HttpGet("http://foo.example.com/");
        HttpUriRequest req2 = new HttpGet("http://bar.example.com/");
        HttpResponse resp1 = resp;
        HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
        expect(mockFactory.getWrapperWithName("foo.example.com:80")).andReturn(wrapper1);
View Full Code Here

TOP

Related Classes of org.fishwife.jrugged.ServiceWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.