Package com.google.gwt.http.client

Examples of com.google.gwt.http.client.Response


    }

    public void testPurge() throws Exception{
        final VolatileQueueableCacheStorage storage = new VolatileQueueableCacheStorage();
        final CacheKey key = new SimpleCacheKey("first");
        Response resp = new ResponseMock();
         
        storage.putResult(key, resp);
        // hashCode should be good enough
        assertEquals(resp.hashCode(), storage.getResultOrReturnNull(key).hashCode());
        storage.purge();
        assertNull(storage.getResultOrReturnNull(key));
    }
View Full Code Here


            }
        };
    }

    private void onResponseReceived(Response response) {
        Response wrappedResponse = new ResponseWrapper(response);

        try {
            R result = restResponseDeserializer.deserialize(getAction(), wrappedResponse);

            onExecuteSuccess(result, wrappedResponse);
View Full Code Here

    @Override
    public boolean filter(final Method method, final RequestBuilder builder) {
        final CacheKey cacheKey = cacheKey(builder);

        if (cacheKey != null) {
            final Response cachedResponse = cacheStorage.getResultOrReturnNull(cacheKey);
            if (cachedResponse != null) {
                //case 1: we got a result in cache => return it...
                if (LogConfiguration.loggingIsEnabled()) {
                    Logger.getLogger(Dispatcher.class.getName())
                            .info("already got a cached response for: " + builder.getHTTPMethod() + " "
View Full Code Here

        EasyMock.verify(rc2);
    }
   
    public void testRestyHeader(){
        CacheKey key = new SimpleCacheKey("first");
        Response resp = EasyMock.createMock(Response.class);
        EasyMock.replay(resp);
       
        storage.putResult(key, resp);
       
        assertNotNull(storage.getResultOrReturnNull(key).getHeader(QueueableCacheStorage.RESTY_CACHE_HEADER));
View Full Code Here

    protected void tearDown() {
        GWTMockUtilities.restore();
    }
   
    public void testNoCallbacksSuccess() throws Exception{
        Response response = EasyMock.createMock(Response.class);
        Method method = EasyMock.createMock(Method.class);
        EasyMock.expect(response.getStatusCode()).andReturn(201);
        EasyMock.expect(method.getData()).andReturn(new HashMap<String,String>());
        EasyMock.replay(response, method);
       
        filter.filter(method, response, null);
       
        EasyMock.verify(response, method);
        // hashCode should be good enough
        assertEquals(response.hashCode(), this.storage.getResultOrReturnNull(key).hashCode());
    }
View Full Code Here

        // hashCode should be good enough
        assertEquals(response.hashCode(), this.storage.getResultOrReturnNull(key).hashCode());
    }

    public void testNoCallbacksError() throws Exception{
        Response response = EasyMock.createMock(Response.class);
        Method method = EasyMock.createMock(Method.class);
        EasyMock.expect(response.getStatusCode()).andReturn(401);
        EasyMock.replay(response, method);
       
        filter.filter(method, response, null);
       
        EasyMock.verify(response, method);
View Full Code Here

        EasyMock.verify(response, method);
        assertNull(this.storage.getResultOrReturnNull(key));
    }

    public void testManyCallbacksSuccess() throws Exception{
        Response response = EasyMock.createMock(Response.class);
        Method method = EasyMock.createMock(Method.class);
        EasyMock.expect(method.getData()).andReturn(new HashMap<String,String>());
        RequestCallback[] myCallbacks = new RequestCallback[4];
        for( int i = 0; i < myCallbacks.length; i++){
            myCallbacks[i] = EasyMock.createMock(RequestCallback.class);
            myCallbacks[i].onResponseReceived(null, null);
            EasyMock.replay(myCallbacks[i]);
        }
       
        EasyMock.expect(response.getStatusCode()).andReturn(200);
       
        EasyMock.replay(response, method);
       
        for( int i = 0; i < myCallbacks.length; i++){
            this.storage.addCallback(key, myCallbacks[i]);
        }
       
        RequestCallback callback = filter.filter(method, response, myCallbacks[0]);

        assertNotSame(callback, myCallbacks[0]);
       
        callback.onResponseReceived(null, null);
       
        EasyMock.verify(response, method);
        for(RequestCallback rc: myCallbacks){
            EasyMock.verify(rc);
        }
        // hashCode should be good enough
        assertEquals(response.hashCode(), this.storage.getResultOrReturnNull(key).hashCode());
    }
View Full Code Here

        EasyMock.replay(method);
       
        FilterawareRequestCallback callback = new DefaultFilterawareRequestCallback(method);

        // set the response code
        Response resp = EasyMock.createMock(Response.class);
        EasyMock.expect(resp.getStatusCode()).andReturn(200).anyTimes();
        EasyMock.replay(resp);
       
        // expect to call each filter with RequestCallback rc
        CallbackFilter[] filters = new CallbackFilter[4];
        for(int i = 0; i < filters.length; i++){
View Full Code Here

    }
   
    public void testDefaultScope(){
        CacheKey key = new SimpleCacheKey("first");
        CacheKey secondKey = new SimpleCacheKey("second");
        Response resp = EasyMock.createMock(Response.class);
        EasyMock.replay(resp);
         
        storage.putResult(key, resp);
        storage.putResult(secondKey, resp);
       
View Full Code Here

        EasyMock.verify(resp);
    }

    public void testScope(){
        CacheKey key = new SimpleCacheKey("first");
        Response resp = EasyMock.createMock(Response.class);
        EasyMock.replay(resp);
         
        storage.putResult(key, resp);
       
        String scope = "admin";
        CacheKey scopedKey = new SimpleCacheKey("first scoped");
        CacheKey secondScopedKey = new SimpleCacheKey("second scoped");
        Response scopedResp = EasyMock.createMock(Response.class);
        EasyMock.replay(scopedResp);

        storage.putResult(scopedKey, scopedResp, scope);
        storage.putResult(secondScopedKey, scopedResp, scope);
       
View Full Code Here

TOP

Related Classes of com.google.gwt.http.client.Response

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.