Package org.ocpsoft.rewrite.servlet

Examples of org.ocpsoft.rewrite.servlet.DispatcherType


    * Determines the {@link DispatcherType} of the current request using the {@link DispatcherTypeProvider} SPI.
    */
   private DispatcherType getDispatcherType(final HttpServletRewrite event)
   {
      for (DispatcherTypeProvider provider : getDispatcherTypeProviders(event)) {
         DispatcherType dispatcherType = provider.getDispatcherType(event.getRequest(), event.getServletContext());
         if (dispatcherType != null) {
            return dispatcherType;
         }
      }
      throw new IllegalStateException("Unable to determine dispatcher type of current request");
View Full Code Here


      HttpServletRequest request = mock(HttpServletRequest.class);
      when(request.getDispatcherType()).thenReturn(javax.servlet.DispatcherType.FORWARD);

      // WHEN the provider is asked for the DispatcherType
      DispatcherTypeProvider provider = new Servlet3DispatcherTypeProvider();
      DispatcherType dispatcherType = provider.getDispatcherType(request, servletContext);

      // THEN it should return FORWARD
      assertEquals(DispatcherType.FORWARD, dispatcherType);

   }
View Full Code Here

      HttpServletRequest request = mock(HttpServletRequest.class);
      when(request.getDispatcherType()).thenThrow(new IllegalStateException("Call not allowed"));

      // WHEN the provider is asked for the DispatcherType
      DispatcherTypeProvider provider = new Servlet3DispatcherTypeProvider();
      DispatcherType dispatcherType = provider.getDispatcherType(request, servletContext);

      // THEN it should return null
      assertNull(dispatcherType);

   }
View Full Code Here

    * Determines the {@link DispatcherType} of the current request using the {@link DispatcherTypeProvider} SPI.
    */
   private DispatcherType getDispatcherType(HttpServletRequest request, ServletContext context)
   {
      for (DispatcherTypeProvider provider : dispatcherProviders) {
         DispatcherType dispatcherType = provider.getDispatcherType(request, context);
         if (dispatcherType != null) {
            return dispatcherType;
         }
      }
      throw new IllegalStateException("Unable to determine dispatcher type of current request");
View Full Code Here

    * Determines the {@link DispatcherType} of the current request using the {@link DispatcherTypeProvider} SPI.
    */
   private DispatcherType getDispatcherType(final HttpServletRewrite event)
   {
      for (DispatcherTypeProvider provider : getDispatcherTypeProviders()) {
         DispatcherType dispatcherType = provider.getDispatcherType(event.getRequest(), event.getServletContext());
         if (dispatcherType != null) {
            return dispatcherType;
         }
      }
      throw new IllegalStateException("Unable to determine dispatcher type of current request");
View Full Code Here

      // GIVEN a request without any attributes set
      HttpServletRequest request = mock(HttpServletRequest.class);

      // WHEN the provider is asked for the DispatcherType
      DispatcherTypeProvider provider = new Servlet25DispatcherTypeProvider();
      DispatcherType dispatcherType = provider.getDispatcherType(request, mock(ServletContext.class));

      // THEN it should return REQUEST
      assertEquals(DispatcherType.REQUEST, dispatcherType);

   }
View Full Code Here

      HttpServletRequest request = mock(HttpServletRequest.class);
      when(request.getAttribute("javax.servlet.include.request_uri")).thenReturn("/some/url");

      // WHEN the provider is asked for the DispatcherType
      DispatcherTypeProvider provider = new Servlet25DispatcherTypeProvider();
      DispatcherType dispatcherType = provider.getDispatcherType(request, mock(ServletContext.class));

      // THEN it should return INCLUDE
      assertEquals(DispatcherType.INCLUDE, dispatcherType);

   }
View Full Code Here

      HttpServletRequest request = mock(HttpServletRequest.class);
      when(request.getAttribute("javax.servlet.forward.request_uri")).thenReturn("/some/url");

      // WHEN the provider is asked for the DispatcherType
      DispatcherTypeProvider provider = new Servlet25DispatcherTypeProvider();
      DispatcherType dispatcherType = provider.getDispatcherType(request, mock(ServletContext.class));

      // THEN it should return INCLUDE
      assertEquals(DispatcherType.FORWARD, dispatcherType);

   }
View Full Code Here

TOP

Related Classes of org.ocpsoft.rewrite.servlet.DispatcherType

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.