DubboMonitorFactory extends AbstractMonitorFactory { @Override protected Monitor createMonitor(URL url) { URLBuilder urlBuilder = URLBuilder.from(url); urlBuilder.setProtocol(url.getParameter(PROTOCOL_KEY, DUBBO_PROTOCOL)); if (StringUtils.isEmpty(url.getPath())) { urlBuilder.setPath(MonitorService.class.getName()); } String filter = url.getParameter(REFERENCE_FILTER_KEY); if (StringUtils.isEmpty(filter)) { filter = ""; } else { filter = filter + ","; } urlBuilder.addParameters(CHECK_KEY, String.valueOf(false), REFERENCE_FILTER_KEY, filter + "-monitor"); Invoker<MonitorService> monitorInvoker = protocol.refer(MonitorService.class, urlBuilder.build()); MonitorService monitorService = proxyFactory.getProxy(monitorInvoker); return new DubboMonitor(monitorInvoker, monitorService); }  void setProtocol(Protocol protocol); void setProxyFactory(ProxyFactory proxyFactory);  }
@Test public void testCreateMonitor() { URL urlWithoutPath = URL.valueOf("http: Monitor monitor = dubboMonitorFactory.createMonitor(urlWithoutPath); assertThat(monitor, not(nullValue())); URL urlWithFilterKey = URL.valueOf("http: monitor = dubboMonitorFactory.createMonitor(urlWithFilterKey); assertThat(monitor, not(nullValue())); ArgumentCaptor<Invoker> invokerArgumentCaptor = ArgumentCaptor.forClass(Invoker.class); verify(proxyFactory, atLeastOnce()).getProxy(invokerArgumentCaptor.capture()); Invoker invoker = invokerArgumentCaptor.getValue(); assertThat(invoker.getUrl().getParameter(REFERENCE_FILTER_KEY), containsString("testFilter")); }