WebUtil { public static String getServletMappingRoot(String mapping) { if (mapping.endsWith("/*")) { mapping = mapping.substring(0, mapping.length() - 1); } else if (!mapping.endsWith("/")) { return mapping + "/"; } return mapping; }  static String getServletMappingRoot(String mapping);  }
@Test public void testGetServletMappingRoot() throws Exception { assertEquals("/xyz/", WebUtil.getServletMappingRoot("/xyz/*")); assertEquals("/xyz/abc/", WebUtil.getServletMappingRoot("/xyz/abc")); assertEquals("/xyz/abc/", WebUtil.getServletMappingRoot("/xyz/abc/")); assertEquals("/", WebUtil.getServletMappingRoot("/")); assertEquals("/", WebUtil.getServletMappingRoot("")); }