Package org.fusesource.restygwt.client.cache

Examples of org.fusesource.restygwt.client.cache.CacheKey


        return "org.fusesource.restygwt.VolatileQueueableCacheStorageTestGwt";
    }
   
    public void testTimeout() throws Exception{
        final VolatileQueueableCacheStorage storage = new VolatileQueueableCacheStorage(100);
        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());
View Full Code Here


        delayTestFinish(250);
    }

    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());
View Full Code Here

     *
     * @return continue filtering or not
     */
    @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...
View Full Code Here

    @Override
    public RequestCallback filter(final Method method, final Response response,
            RequestCallback callback) {
        final int code = response.getStatusCode();

        final CacheKey ck = cacheKey(method.builder);
        final List<RequestCallback> removedCallbacks = cache.removeCallbacks(ck);

        if (removedCallbacks != null){
            callback = new RequestCallback() {
                @Override
View Full Code Here

    protected CacheKey cacheKey(final RequestBuilder builder) {
        return new ComplexCacheKey(builder);
    }

    protected void cacheResult(final Method method, final Response response) {
        CacheKey cacheKey = cacheKey(method.builder);
        if (GWT.isClient() && LogConfiguration.loggingIsEnabled()) {
            Logger.getLogger(CachingCallbackFilter.class.getName()).finer("cache to " + cacheKey
                    + ": " + response);
        }
        cache.putResult(cacheKey, response, getCacheDomains(method));
View Full Code Here

        return code == Response.SC_CONFLICT || super.isCachingStatusCode(code);
    }
   
    @Override
    protected void cacheResult(Method method, Response response) {
        final CacheKey cacheKey;
        if (response.getStatusCode() == Response.SC_CREATED && response.getHeader("Location") != null){
            final String uri;
            if(response.getHeader("Location").startsWith("http")){
                uri = response.getHeader("Location");
            }
View Full Code Here

        super.setUp();
        GWTMockUtilities.disarm();

        this.storage = new DefaultQueueableCacheStorage();
        this.key = new SimpleCacheKey("key");
        final CacheKey k = key;
        this.filter = new CachingCallbackFilter(this.storage){

            @Override
            protected CacheKey cacheKey(RequestBuilder builder) {
                return k;
View Full Code Here

    protected void tearDown() {
        GWTMockUtilities.restore();
    }
   
    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

        EasyMock.verify(resp);
        EasyMock.verify(scopedResp);
    }
   
    public void testQueue() {
        CacheKey key = new SimpleCacheKey("first");
        CacheKey secondKey = new SimpleCacheKey("second");
       
        assertFalse(storage.hasCallback(key));
       
        RequestCallback rc1 = EasyMock.createMock(RequestCallback.class);
        RequestCallback rc2 = EasyMock.createMock(RequestCallback.class);
View Full Code Here

TOP

Related Classes of org.fusesource.restygwt.client.cache.CacheKey

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.