RouteUtils { public static Map<String, String> previewRoute(String serviceName, String consumerAddress, String queryUrl, Map<String, String> serviceUrls, Route route, Map<String, List<String>> clusters, List<Route> routed) { if(null == route) { throw new IllegalArgumentException("Route is null."); } List<Route> routes = new ArrayList<Route>(); routes.add(route); return route(serviceName, consumerAddress, queryUrl, serviceUrls, routes, clusters, routed); }  static boolean matchRoute(String consumerAddress, String consumerQueryUrl, Route route, Map<String, List<String>> clusters); static Map<String, String> previewRoute(String serviceName, String consumerAddress, String queryUrl, Map<String, String> serviceUrls,
            Route route, Map<String, List<String>> clusters, List<Route> routed); static List<Route> findUsedRoute(String serviceName, String consumerAddress, String consumerQueryUrl,
            List<Route> routes, Map<String, List<String>> clusters); static List<Provider> route(String serviceName, String consumerAddress, String consumerQueryUrl, List<Provider> providers,
    		List<Override> overrides, List<Route> routes, Map<String, List<String>> clusters, List<Route> routed); static Map<String, String> route(String serviceName, String consumerAddress, String consumerQueryUrl, Map<String, String> serviceUrls,
            List<Route> routes, Map<String, List<String>> clusters, List<Route> routed);  }
@Test public void test_previewRoute() throws Exception { Route route = new Route(); route.setId(1L); route.setService("hello.HelloService"); route.setMatchRule("consumer.host=1.1.2.2,2.2.2.3"); route.setFilterRule("provider.host=3.3.4.4&provider.application=morgan"); { Map<String, String> preview = RouteUtils.previewRoute("hello.HelloService", "1.1.2.2:20880", "application=morgan", serviceUrls, route, clusters, null); Map<String, String> expected = new HashMap<String, String>(); expected.put("dubbo: assertEquals(expected, preview); preview = RouteUtils.previewRoute("hello.HelloService", "1.1.2.2", "application=morgan&methods=getPort,say", serviceUrls, route, clusters, null); expected = new HashMap<String, String>(); expected.put("dubbo: assertEquals(expected, preview); preview = RouteUtils.previewRoute("hello.HelloService", "1.1.2.2", "application=morgan&methods=getPort,say,ghostMethod", serviceUrls, route, clusters, null); expected = new HashMap<String, String>(); expected.put("dubbo: assertEquals(expected, preview); preview = RouteUtils.previewRoute("hello.HelloService", "1.2.3.4", "application=morgan", serviceUrls, route, clusters, null); assertEquals(serviceUrls_starMethods, preview); preview = RouteUtils.previewRoute("hello.HelloService", "1.2.3.4", "application=morgan&methods=getPort,say", serviceUrls, route, clusters, null); assertEquals(serviceUrls, preview); preview = RouteUtils.previewRoute("hello.HelloService", "1.2.3.4", "application=morgan&methods=getPort,say,ghostMethod", serviceUrls, route, clusters, null); assertEquals(serviceUrls_ghostMethods, preview); } { route.setMatchRule("consumer.cluster = cluster1"); Map<String, String> preview = RouteUtils.previewRoute("hello.HelloService", "7.7.7.7:20880", "application=morgan", serviceUrls, route, clusters, null); Map<String, String> expected = new HashMap<String, String>(); expected.put("dubbo: assertEquals(expected, preview); preview = RouteUtils.previewRoute("hello.HelloService", "7.7.7.7", "application=morgan&methods=getPort,say", serviceUrls, route, clusters, null); expected = new HashMap<String, String>(); expected.put("dubbo: assertEquals(expected, preview); preview = RouteUtils.previewRoute("hello.HelloService", "7.7.7.7", "application=morgan&methods=getPort,say,ghostMethod", serviceUrls, route, clusters, null); expected = new HashMap<String, String>(); expected.put("dubbo: assertEquals(expected, preview); preview = RouteUtils.previewRoute("hello.HelloService", "1.2.3.4", "application=morgan", serviceUrls, route, clusters, null); assertEquals(serviceUrls_starMethods, preview); preview = RouteUtils.previewRoute("hello.HelloService", "1.2.3.4", "application=morgan&methods=getPort,say", serviceUrls, route, clusters, null); assertEquals(serviceUrls, preview); preview = RouteUtils.previewRoute("hello.HelloService", "1.2.3.4", "application=morgan&methods=getPort,say,ghostMethod", serviceUrls, route, clusters, null); assertEquals(serviceUrls_ghostMethods, preview); } }