Package org.jboss.seam.web

Examples of org.jboss.seam.web.ConditionalAbstractResource


      EnhancedMockHttpServletRequest request = new EnhancedMockHttpServletRequest(session);
      EnhancedMockHttpServletResponse response = new EnhancedMockHttpServletResponse();

      request.addHeader(ConditionalAbstractResource.HEADER_IF_NONE_MATCH, "\"1234\", \"5678\"");

      ConditionalAbstractResource resource = new ConditionalAbstractResource()
      {
         public void getResource(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         {
            if (!sendConditional(request, response, "\"5678\"", null))
            {
               response.sendError(HttpServletResponse.SC_OK);
            }
         }

         public String getResourcePath()
         {
            return null;
         }
      };

      resource.getResource(request, response);

      assertEquals(response.getStatus(), HttpServletResponse.SC_NOT_MODIFIED);
      assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_ETAG), "\"5678\"");

   }
View Full Code Here


      EnhancedMockHttpServletRequest request = new EnhancedMockHttpServletRequest(session);
      EnhancedMockHttpServletResponse response = new EnhancedMockHttpServletResponse();

      request.addHeader(ConditionalAbstractResource.HEADER_IF_NONE_MATCH, "\"123\", \"456\"");

      ConditionalAbstractResource resource = new ConditionalAbstractResource()
      {
         public void getResource(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         {
            if (!sendConditional(request, response, "\"5678\"", null))
            {
               response.sendError(HttpServletResponse.SC_OK);
            }
         }

         public String getResourcePath()
         {
            return null;
         }
      };

      resource.getResource(request, response);

      assertEquals(response.getStatus(), HttpServletResponse.SC_OK);
      assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_ETAG), "\"5678\"");
   }
View Full Code Here

      EnhancedMockHttpServletResponse response = new EnhancedMockHttpServletResponse();

      final Long currentTime = new Date().getTime();
      request.addHeader(ConditionalAbstractResource.HEADER_IF_MODIFIED_SINCE, currentTime);

      ConditionalAbstractResource resource = new ConditionalAbstractResource()
      {
         public void getResource(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         {
            if (!sendConditional(request, response, null, currentTime))
            {
               response.sendError(HttpServletResponse.SC_OK);
            }
         }

         public String getResourcePath()
         {
            return null;
         }
      };

      resource.getResource(request, response);

      assertEquals(response.getStatus(), HttpServletResponse.SC_NOT_MODIFIED);
      assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_LAST_MODIFIED), currentTime);

   }
View Full Code Here

      EnhancedMockHttpServletResponse response = new EnhancedMockHttpServletResponse();

      final Long currentTime = new Date().getTime();
      request.addHeader(ConditionalAbstractResource.HEADER_IF_MODIFIED_SINCE, currentTime);

      ConditionalAbstractResource resource = new ConditionalAbstractResource()
      {
         public void getResource(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         {
            if (!sendConditional(request, response, null, currentTime + 5000))
            {
               response.sendError(HttpServletResponse.SC_OK);
            }
         }

         public String getResourcePath()
         {
            return null;
         }
      };

      resource.getResource(request, response);

      assertEquals(response.getStatus(), HttpServletResponse.SC_OK);
      assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_LAST_MODIFIED), currentTime + 5000);

   }
View Full Code Here

      final Long currentTime = new Date().getTime();
      request.addHeader(ConditionalAbstractResource.HEADER_IF_MODIFIED_SINCE, currentTime);
      request.addHeader(ConditionalAbstractResource.HEADER_IF_NONE_MATCH, "\"1234\", \"5678\"");

      ConditionalAbstractResource resource = new ConditionalAbstractResource()
      {
         public void getResource(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         {
            if (!sendConditional(request, response, "\"5678\"", currentTime))
            {
               response.sendError(HttpServletResponse.SC_OK);
            }
         }

         public String getResourcePath()
         {
            return null;
         }
      };

      resource.getResource(request, response);

      assertEquals(response.getStatus(), HttpServletResponse.SC_NOT_MODIFIED);
      assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_LAST_MODIFIED), currentTime);
      assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_ETAG), "\"5678\"");
View Full Code Here

      final Long currentTime = new Date().getTime();
      request.addHeader(ConditionalAbstractResource.HEADER_IF_MODIFIED_SINCE, currentTime);
      request.addHeader(ConditionalAbstractResource.HEADER_IF_NONE_MATCH, "\"1234\", \"5678\"");

      ConditionalAbstractResource resource = new ConditionalAbstractResource()
      {
         public void getResource(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
         {
            if (!sendConditional(request, response, "\"5678\"", currentTime + 5000))
            {
               response.sendError(HttpServletResponse.SC_OK);
            }
         }

         public String getResourcePath()
         {
            return null;
         }
      };

      resource.getResource(request, response);

      assertEquals(response.getStatus(), HttpServletResponse.SC_OK);
      assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_LAST_MODIFIED), currentTime + 5000);
      assertEquals(response.getHeader(ConditionalAbstractResource.HEADER_ETAG), "\"5678\"");
View Full Code Here

TOP

Related Classes of org.jboss.seam.web.ConditionalAbstractResource

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.