@Test void testFindExtensionServletMatch2() throws Exception { DefaultWebApplicationRequestMapper webAppRequestMapper = new DefaultWebApplicationRequestMapper(); DefaultWebApplication webApp = new DefaultWebApplication(); webApp.setWebApplicationRequestMapper(webAppRequestMapper); webApp.addServlet("echo2", new TestEcho1Servlet()); webApp.addServletMapping("echo2", "*.echo2"); webApp.initialize(); webApp.start(); TestWebApplicationRequest request = new TestWebApplicationRequest(); request.setServletPath("/echo.echo"); request.setWebApplication(new DefaultWebApplication()); TestWebApplicationResponse response = new TestWebApplicationResponse(); webApp.service(request, response); assertTrue(response.getStatus() != 200); }
@Override public Set<String> addServletMapping(String servletName, String... urlPatterns) { if (isEmpty(urlPatterns)) { throw new IllegalArgumentException("Mappings for " + servletName + " cannot be empty"); } Set<String> mappedToOtherServlet = stream(urlPatterns) .filter(servletMappings::containsKey) .filter(urlPattern -> !servletMappings.get(urlPattern).equals(servletName)) .collect(toSet()); if (!mappedToOtherServlet.isEmpty()) { return mappedToOtherServlet; } for (String urlPattern : urlPatterns) { servletMappings.put(urlPattern, servletName); } return emptySet(); }
DefaultWebApplicationRequestMapper implements WebApplicationRequestMapper { @Override public Set<String> addServletMapping(String servletName, String... urlPatterns) { if (isEmpty(urlPatterns)) { throw new IllegalArgumentException("Mappings for " + servletName + " cannot be empty"); } Set<String> mappedToOtherServlet = stream(urlPatterns) .filter(servletMappings::containsKey) .filter(urlPattern -> !servletMappings.get(urlPattern).equals(servletName)) .collect(toSet()); if (!mappedToOtherServlet.isEmpty()) { return mappedToOtherServlet; } for (String urlPattern : urlPatterns) { servletMappings.put(urlPattern, servletName); } return emptySet(); } }
DefaultWebApplicationRequestMapper implements WebApplicationRequestMapper { @Override public Set<String> addServletMapping(String servletName, String... urlPatterns) { if (isEmpty(urlPatterns)) { throw new IllegalArgumentException("Mappings for " + servletName + " cannot be empty"); } Set<String> mappedToOtherServlet = stream(urlPatterns) .filter(servletMappings::containsKey) .filter(urlPattern -> !servletMappings.get(urlPattern).equals(servletName)) .collect(toSet()); if (!mappedToOtherServlet.isEmpty()) { return mappedToOtherServlet; } for (String urlPattern : urlPatterns) { servletMappings.put(urlPattern, servletName); } return emptySet(); }  }
DefaultWebApplicationRequestMapper implements WebApplicationRequestMapper { @Override public Set<String> addServletMapping(String servletName, String... urlPatterns) { if (isEmpty(urlPatterns)) { throw new IllegalArgumentException("Mappings for " + servletName + " cannot be empty"); } Set<String> mappedToOtherServlet = stream(urlPatterns) .filter(servletMappings::containsKey) .filter(urlPattern -> !servletMappings.get(urlPattern).equals(servletName)) .collect(toSet()); if (!mappedToOtherServlet.isEmpty()) { return mappedToOtherServlet; } for (String urlPattern : urlPatterns) { servletMappings.put(urlPattern, servletName); } return emptySet(); }  @Override Set<String> addFilterMapping(Set<DispatcherType> dispatcherTypes, String filterName, String... urlPatterns); @Override Set<String> addFilterMappingBeforeExisting(Set<DispatcherType> dispatcherTypes, String filterName, String... urlPatterns); @Override Set<String> addServletMapping(String servletName, String... urlPatterns); @Override Collection<String> findFilterMappings(DispatcherType dispatcherType, String path); @Override DefaultWebApplicationRequestMapping findServletMapping(String path); @Override Collection<String> getServletMappings(String servletName); @Override String getServletName(String mapping); }
DefaultWebApplicationRequestMapper implements WebApplicationRequestMapper { @Override public Set<String> addServletMapping(String servletName, String... urlPatterns) { if (isEmpty(urlPatterns)) { throw new IllegalArgumentException("Mappings for " + servletName + " cannot be empty"); } Set<String> mappedToOtherServlet = stream(urlPatterns) .filter(servletMappings::containsKey) .filter(urlPattern -> !servletMappings.get(urlPattern).equals(servletName)) .collect(toSet()); if (!mappedToOtherServlet.isEmpty()) { return mappedToOtherServlet; } for (String urlPattern : urlPatterns) { servletMappings.put(urlPattern, servletName); } return emptySet(); }  @Override Set<String> addFilterMapping(Set<DispatcherType> dispatcherTypes, String filterName, String... urlPatterns); @Override Set<String> addFilterMappingBeforeExisting(Set<DispatcherType> dispatcherTypes, String filterName, String... urlPatterns); @Override Set<String> addServletMapping(String servletName, String... urlPatterns); @Override Collection<String> findFilterMappings(DispatcherType dispatcherType, String path); @Override DefaultWebApplicationRequestMapping findServletMapping(String path); @Override Collection<String> getServletMappings(String servletName); @Override String getServletName(String mapping);  }