Package javax.ws.rs.core

Examples of javax.ws.rs.core.CacheControl


public class CacheControlHeaderProviderTest extends Assert {
   
    @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

                Message m = new MessageImpl();
                m.put(CacheControlHeaderProvider.CACHE_CONTROL_SEPARATOR_PROPERTY, ";");
                return m;
            }
        };
        CacheControl c = cp.fromString(
            "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

    this.rowspec = new RowSpec(URLDecoder.decode(rowspec,
      HConstants.UTF8_ENCODING));
    if (versions != null) {
      this.rowspec.setMaxVersions(Integer.valueOf(versions));
    }
    this.cacheControl = new CacheControl();
    this.cacheControl.setMaxAge(servlet.getMaxAge(tableName));
    this.cacheControl.setNoTransform(false);   
  }
View Full Code Here

            //parse out the '.jar'
            name = info.getFileName().substring(0,info.getFileName().length() - 4);
        } else {
            //fail
            logger.warning("FILE NOT A MODULE!");
            return Response.status(Status.INTERNAL_SERVER_ERROR).cacheControl(new CacheControl()).build();
        }
       
        File tmpFile = null;
        try {
            tmpFile = File.createTempFile(name+"_tmp", ".jar");
            tmpFile.deleteOnExit();
            RunUtil.writeToFile(new FileInputStream(file), tmpFile);
        } catch(Exception e) {
            logger.warning("ERROR WRITING TO FILE!");
            return Response.status(Status.INTERNAL_SERVER_ERROR).cacheControl(new CacheControl()).build();
        }
       
       
        Collection<File> moduleFiles = new LinkedList<File>();
        moduleFiles.add(tmpFile);
        Collection<Module> result = manager.addToInstall(moduleFiles);
        if(result.isEmpty()) {
            logger.warning("NOTHING IN MODULE!");
            return Response.status(Status.INTERNAL_SERVER_ERROR).cacheControl(new CacheControl()).build();
        }
       
        //We won't use this data on the client side, so pass in dummy data for
        //file size and URL.       
        FileMeta metaData = new FileMeta(tmpFile.getName(), 0, "");
        List<FileMeta> metas = Lists.newArrayList(metaData);
        GenericEntity<List<FileMeta>> entity = new GenericEntity<List<FileMeta>>(metas){};
        return Response.ok(entity).cacheControl(new CacheControl()).build();
    }
View Full Code Here

    @GET
    public Response tryInstallAll() {
        ModuleManager manager = ModuleManager.getModuleManager();
        manager.installAll();
       
        return Response.ok().cacheControl(new CacheControl()).build();
    }
View Full Code Here

    public CacheControl fromString(String header) {
        if (header == null)
            throw new IllegalArgumentException("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

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.