Package javax.ws.rs.core

Examples of javax.ws.rs.core.CacheControl


        throwIllegalArgumentExceptionIfNull(header, LocalizationMessages.CACHE_CONTROL_IS_NULL());;

        try {
            HttpHeaderReader reader = HttpHeaderReader.newInstance(header);
            CacheControl cacheControl = new CacheControl();
            cacheControl.setNoTransform(false); // defaults to true
            while (reader.hasNext()) {
                readDirective(cacheControl, reader);
                if (reader.hasNextSeparator(',', true)) {
                    reader.nextSeparator(',');
                }
View Full Code Here


   
   
       
    @Test
    public void testFromSimpleString() {
        CacheControl c = CacheControl.valueOf(
            "public;must-revalidate");
        assertTrue(c.isPublic() && !c.isPrivate() && !c.isNoStore()
                   && c.isMustRevalidate() && !c.isProxyRevalidate());
        assertTrue(!c.isNoCache()
                   && !c.isNoTransform() && c.getNoCacheFields().size() == 0
                   && c.getPrivateFields().size() == 0);
    }
View Full Code Here

                   && c.getPrivateFields().size() == 0);
    }
   
    @Test
    public void testFromComplexString() {
        CacheControl c = CacheControl.valueOf(
            "private=\"foo\";no-cache=\"bar\";no-store;no-transform;"
            + "must-revalidate;proxy-revalidate;max-age=2;s-maxage=3");
        assertTrue(!c.isPublic() && c.isPrivate() && c.isNoStore()
                   && c.isMustRevalidate() && c.isProxyRevalidate() && c.isNoCache());
        assertTrue(c.isNoTransform() && c.getNoCacheFields().size() == 1
                   && c.getPrivateFields().size() == 1);
        assertEquals("foo", c.getPrivateFields().get(0));
        assertEquals("bar", c.getNoCacheFields().get(0));
       
    }
View Full Code Here

                noCache = true;
                addFields(noCacheFields, token);
            }
        }
       
        CacheControl cc = new CacheControl();
        cc.setMaxAge(maxAge);
        cc.setSMaxAge(sMaxAge);
        cc.setPublic(isPublic);
        cc.setPrivate(isPrivate);
        cc.getPrivateFields().addAll(privateFields);
        cc.setMustRevalidate(mustRevalidate);
        cc.setProxyRevalidate(proxyRevalidate);
        cc.setNoCache(noCache);
        cc.getNoCacheFields().addAll(noCacheFields);
        cc.setNoStore(noStore);
        cc.setNoTransform(noTransform);
       
        return cc;
    }
View Full Code Here

                + "max-age=21600, "
                + "s-maxage=3000, "
                + "extension=value, "
                + "extension3, "
                + "extension2=\"value with space\"";
        CacheControl cc = new CacheControl();
        cc.setMaxAge(21600);
        cc.setMustRevalidate(true);
        cc.setNoCache(true);
        cc.setNoStore(true);
        cc.setNoTransform(true);
        cc.setPrivate(true);
        cc.setProxyRevalidate(true);
        cc.setSMaxAge(3000);
        cc.getCacheExtension().put("extension", "value");
        cc.getCacheExtension().put("extension2", "value with space");
        cc.getCacheExtension().put("extension3", null);
        cc.getNoCacheFields().add("noCachefield1");
        cc.getNoCacheFields().add("noCachefield2");
        cc.getPrivateFields().add("privateField1");

        String[] cache_out = cacheControlHeaderDelegate.toString(cc).split(",");
        String[] cache_expected = expectedCacheControlHeader.split(",");
        Arrays.sort(cache_expected);
        Arrays.sort(cache_out);
View Full Code Here

   
   
       
    @Test
    public void testFromSimpleString() {
        CacheControl c = CacheControl.valueOf(
            "public;must-revalidate");
        assertTrue(!c.isPrivate() && !c.isNoStore()
                   && c.isMustRevalidate() && !c.isProxyRevalidate());
        assertTrue(!c.isNoCache()
                   && !c.isNoTransform() && c.getNoCacheFields().size() == 0
                   && c.getPrivateFields().size() == 0);
    }
View Full Code Here

                   && c.getPrivateFields().size() == 0);
    }
   
    @Test
    public void testFromComplexString() {
        CacheControl c = CacheControl.valueOf(
            "private=\"foo\";no-cache=\"bar\";no-store;no-transform;"
            + "must-revalidate;proxy-revalidate;max-age=2;s-maxage=3");
        assertTrue(c.isPrivate() && c.isNoStore()
                   && c.isMustRevalidate() && c.isProxyRevalidate() && c.isNoCache());
        assertTrue(c.isNoTransform() && c.getNoCacheFields().size() == 1
                   && c.getPrivateFields().size() == 1);
        assertEquals("foo", c.getPrivateFields().get(0));
        assertEquals("bar", c.getNoCacheFields().get(0));
       
    }
View Full Code Here

        assertEquals(s, parsed);      
    }
   
    @Test
    public void testNoCacheEnabled() {
        CacheControl cc = new CacheControl();
        cc.setNoCache(true);
        assertEquals("no-cache;no-transform", cc.toString());
    }
View Full Code Here

        assertEquals("no-cache;no-transform", cc.toString());
    }
   
    @Test
    public void testNoCacheDisabled() {
        CacheControl cc = new CacheControl();
        cc.setNoCache(false);
        assertEquals("no-transform", cc.toString());
    }
View Full Code Here

        assertEquals("no-transform", cc.toString());
    }
   
    @Test
    public void testCacheExtensionToString() {
        CacheControl cc = new CacheControl();
        cc.getCacheExtension().put("ext1", null);
        cc.getCacheExtension().put("ext2", "value2");
        cc.getCacheExtension().put("ext3", "value 3");
        String value = cc.toString();
        assertTrue(value.indexOf("ext1") != -1 && value.indexOf("ext1=") == -1);
        assertTrue(value.indexOf("ext2=value2") != -1);
        assertTrue(value.indexOf("ext3=\"value 3\"") != -1);
    }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.CacheControl

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.