UrlUtils { public static boolean isServiceKeyMatch(URL pattern, URL value) { return pattern.getParameter(Constants.INTERFACE_KEY).equals( value.getParameter(Constants.INTERFACE_KEY)) && isItemMatch(pattern.getParameter(Constants.GROUP_KEY), value.getParameter(Constants.GROUP_KEY)) && isItemMatch(pattern.getParameter(Constants.VERSION_KEY), value.getParameter(Constants.VERSION_KEY)); }  static URL parseURL(String address, Map<String, String> defaults); static List<URL> parseURLs(String address, Map<String, String> defaults); static Map<String, Map<String, String>> convertRegister(Map<String, Map<String, String>> register); static Map<String, String> convertSubscribe(Map<String, String> subscribe); static Map<String, Map<String, String>> revertRegister(Map<String, Map<String, String>> register); static Map<String, String> revertSubscribe(Map<String, String> subscribe); static Map<String, Map<String, String>> revertNotify(Map<String, Map<String, String>> notify); static List<String> revertForbid(List<String> forbid, Set<URL> subscribed); static URL getEmptyUrl(String service, String category); static boolean isMatchCategory(String category, String categories); static boolean isMatch(URL consumerUrl, URL providerUrl); static boolean isMatchGlobPattern(String pattern, String value, URL param); static boolean isMatchGlobPattern(String pattern, String value); static boolean isServiceKeyMatch(URL pattern, URL value);  }
@Test public void testIsServiceKeyMatch() throws Exception { URL url = URL.valueOf("test: URL pattern = url.addParameter(Constants.GROUP_KEY, "test") .addParameter(Constants.INTERFACE_KEY, "test") .addParameter(Constants.VERSION_KEY, "test"); URL value = pattern; assertTrue(UrlUtils.isServiceKeyMatch(pattern, value)); pattern = pattern.addParameter(Constants.GROUP_KEY, "*"); assertTrue(UrlUtils.isServiceKeyMatch(pattern, value)); pattern = pattern.addParameter(Constants.VERSION_KEY, "*"); assertTrue(UrlUtils.isServiceKeyMatch(pattern, value)); }