Examples of CacheControl


Examples of javax.ws.rs.core.CacheControl

   public void testCacheControl()
   {
      CacheControlDelegate delegate = new CacheControlDelegate();

      {
         CacheControl cc = new CacheControl();
         cc.setNoCache(true);
         cc.setNoTransform(true);
         cc.setPrivate(true);
         cc.setMustRevalidate(true);
         cc.setProxyRevalidate(true);
         System.out.println(delegate.toString(cc));
         CacheControl cc2 = delegate.fromString(delegate.toString(cc));
         assertEqual(cc, cc2);

      }

      {
         CacheControl cc = new CacheControl();
         cc.setNoCache(true);
         cc.getNoCacheFields().add("bill");
         cc.getNoCacheFields().add("marc");
         cc.setPrivate(true);
         cc.getPrivateFields().add("yo");
         cc.getCacheExtension().put("foo", "bar");
         cc.setMaxAge(25);
         cc.setSMaxAge(25);
         System.out.println(delegate.toString(cc));
         CacheControl cc2 = delegate.fromString(delegate.toString(cc));
         assertEqual(cc, cc2);

      }
   }
View Full Code Here

Examples of javax.ws.rs.core.CacheControl

      try
      {
         int status = client.executeMethod(method);
         Assert.assertEquals(status, HttpServletResponse.SC_OK);
         System.out.println("Cache-Control: " + method.getResponseHeader("cache-control").getValue());
         CacheControl cc = CacheControl.valueOf(method.getResponseHeader("cache-control").getValue());
         Assert.assertFalse(cc.isPrivate());
         Assert.assertEquals(3600, cc.getMaxAge());
      }
      catch (IOException e)
      {
         throw new RuntimeException(e);
      }
View Full Code Here

Examples of javax.ws.rs.core.CacheControl

      @Produces("text/plain")
      public Response getEtagged(@Context Request request)
      {
         count++;
         Response.ResponseBuilder builder = request.evaluatePreconditions(new EntityTag("42"));
         CacheControl cc = new CacheControl();
         cc.setMaxAge(2);
         if (builder != null)
         {
            return builder.cacheControl(cc).build();
         }
         return Response.ok("hello" + count).cacheControl(cc).tag("42").build();
View Full Code Here

Examples of javax.ws.rs.core.CacheControl

         Response.ResponseBuilder builder = request.evaluatePreconditions(new EntityTag("42"));
         if (builder != null)
         {
            return Response.serverError().build();
         }
         CacheControl cc = new CacheControl();
         cc.setMaxAge(2);
         return Response.ok("hello" + count).cacheControl(cc).tag("32").build();
      }
View Full Code Here

Examples of javax.ws.rs.core.CacheControl

         }
         else
         {
            // validation if client sent
            Response.ResponseBuilder builder = validation.evaluatePreconditions(new EntityTag(entry.getEtag()));
            CacheControl cc = new CacheControl();
            cc.setMaxAge(entry.getExpirationInSeconds());
            if (builder != null)
            {
               return (ServerResponse) builder.cacheControl(cc).build();
            }
View Full Code Here

Examples of javax.ws.rs.core.CacheControl

      if (occ == null)
      {
         context.proceed();
         return;
      }
      CacheControl cc = null;

      if (occ instanceof CacheControl) cc = (CacheControl) occ;
      else
      {
         cc = CacheControl.valueOf(occ.toString());
      }

      if (cc.isNoCache())
      {
         context.proceed();
         return;
      }
View Full Code Here

Examples of javax.ws.rs.core.CacheControl

        // when
        final RestfulResponse<VersionRepresentation> restfulResponse = RestfulResponse.ofT(resp);

        // then
        final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
        assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
        assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
    }
View Full Code Here

Examples of javax.ws.rs.core.CacheControl

        // when
        final RestfulResponse<UserRepresentation> restfulResponse = RestfulResponse.ofT(resp);

        // then
        final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
        assertThat(cacheControl, hasMaxAge(60 * 60));
        assertThat(cacheControl.getMaxAge(), is(60 * 60));
    }
View Full Code Here

Examples of javax.ws.rs.core.CacheControl

        final RestfulResponse<DomainObjectRepresentation> restfulResponse = Util.domainObjectJaxrsResponse(client, "PrimitiveValuedEntities");

        // then
        assertThat(restfulResponse.getStatus(), is(HttpStatusCode.OK));
       
        final CacheControl expected = new CacheControl();
        expected.setNoCache(true);
        assertThat(restfulResponse.getHeader(Header.CACHE_CONTROL), isCacheControl().withNoCache().build());
    }
View Full Code Here

Examples of javax.ws.rs.core.CacheControl

        // when
        final RestfulResponse<ListRepresentation> restfulResponse = RestfulResponse.ofT(resp);

        // then
        final CacheControl cacheControl = restfulResponse.getHeader(Header.CACHE_CONTROL);
        assertThat(cacheControl, hasMaxAge(24 * 60 * 60));
        assertThat(cacheControl.getMaxAge(), is(24 * 60 * 60));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.