@Test public void testShouldReturnNullForServlet25() { ServletContext servletContext = mock(ServletContext.class); when(servletContext.getMajorVersion()).thenReturn(2); HttpServletRequest request = mock(HttpServletRequest.class); when(request.getDispatcherType()).thenThrow(new IllegalStateException("Call not allowed")); DispatcherTypeProvider provider = new Servlet3DispatcherTypeProvider(); DispatcherType dispatcherType = provider.getDispatcherType(request, servletContext); assertNull(dispatcherType); }
@Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (context.getMajorVersion() >= 3) { return DispatcherType.valueOf(request.getDispatcherType().name()); } return null; }
Servlet3DispatcherTypeProvider implements DispatcherTypeProvider { @Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (context.getMajorVersion() >= 3) { return DispatcherType.valueOf(request.getDispatcherType().name()); } return null; } }
Servlet3DispatcherTypeProvider implements DispatcherTypeProvider { @Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (context.getMajorVersion() >= 3) { return DispatcherType.valueOf(request.getDispatcherType().name()); } return null; }  }
Servlet3DispatcherTypeProvider implements DispatcherTypeProvider { @Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (context.getMajorVersion() >= 3) { return DispatcherType.valueOf(request.getDispatcherType().name()); } return null; }  @Override int priority(); @Override DispatcherType getDispatcherType(ServletRequest request, ServletContext context); }
Servlet3DispatcherTypeProvider implements DispatcherTypeProvider { @Override public DispatcherType getDispatcherType(ServletRequest request, ServletContext context) { if (context.getMajorVersion() >= 3) { return DispatcherType.valueOf(request.getDispatcherType().name()); } return null; }  @Override int priority(); @Override DispatcherType getDispatcherType(ServletRequest request, ServletContext context);  }