@Test public void testShouldReturnIncludeDispatcherTypeWithCorrectAttributeSet() { HttpServletRequest request = mock(HttpServletRequest.class); when(request.getAttribute("javax.servlet.include.request_uri")).thenReturn("/some/url"); DispatcherTypeProvider provider = new Servlet25DispatcherTypeProvider(); DispatcherType dispatcherType = provider.getDispatcherType(request, mock(ServletContext.class)); assertEquals(DispatcherType.INCLUDE, dispatcherType); }
@Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (request.getAttribute("javax.servlet.forward.request_uri") != null) { return DispatcherType.FORWARD; } if (request.getAttribute("javax.servlet.include.request_uri") != null) { return DispatcherType.INCLUDE; } Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception"); if (throwable != null) { return DispatcherType.ERROR; } return DispatcherType.REQUEST; }
Servlet25DispatcherTypeProvider implements DispatcherTypeProvider { @Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (request.getAttribute("javax.servlet.forward.request_uri") != null) { return DispatcherType.FORWARD; } if (request.getAttribute("javax.servlet.include.request_uri") != null) { return DispatcherType.INCLUDE; } Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception"); if (throwable != null) { return DispatcherType.ERROR; } return DispatcherType.REQUEST; } }
Servlet25DispatcherTypeProvider implements DispatcherTypeProvider { @Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (request.getAttribute("javax.servlet.forward.request_uri") != null) { return DispatcherType.FORWARD; } if (request.getAttribute("javax.servlet.include.request_uri") != null) { return DispatcherType.INCLUDE; } Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception"); if (throwable != null) { return DispatcherType.ERROR; } return DispatcherType.REQUEST; }  }
Servlet25DispatcherTypeProvider implements DispatcherTypeProvider { @Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (request.getAttribute("javax.servlet.forward.request_uri") != null) { return DispatcherType.FORWARD; } if (request.getAttribute("javax.servlet.include.request_uri") != null) { return DispatcherType.INCLUDE; } Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception"); if (throwable != null) { return DispatcherType.ERROR; } return DispatcherType.REQUEST; }  @Override int priority(); @Override DispatcherType getDispatcherType(ServletRequest request, ServletContext context); }
Servlet25DispatcherTypeProvider implements DispatcherTypeProvider { @Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (request.getAttribute("javax.servlet.forward.request_uri") != null) { return DispatcherType.FORWARD; } if (request.getAttribute("javax.servlet.include.request_uri") != null) { return DispatcherType.INCLUDE; } Throwable throwable = (Throwable) request.getAttribute("javax.servlet.error.exception"); if (throwable != null) { return DispatcherType.ERROR; } return DispatcherType.REQUEST; }  @Override int priority(); @Override DispatcherType getDispatcherType(ServletRequest request, ServletContext context);  }