Search in sources :

Example 1 with DelegateExporterMap

use of org.apache.dubbo.rpc.protocol.DelegateExporterMap in project dubbo by alibaba.

the class InjvmProtocolTest method testLocalProtocol.

@Test
public void testLocalProtocol() throws Exception {
    DemoService service = new DemoServiceImpl();
    Invoker<?> invoker = proxy.getInvoker(service, DemoService.class, URL.valueOf("injvm://127.0.0.1/TestService").addParameter(INTERFACE_KEY, DemoService.class.getName()));
    assertTrue(invoker.isAvailable());
    Exporter<?> exporter = protocol.export(invoker);
    exporters.add(exporter);
    service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("injvm://127.0.0.1/TestService").addParameter(INTERFACE_KEY, DemoService.class.getName())));
    assertEquals(service.getSize(new String[] { "", "", "" }), 3);
    service.invoke("injvm://127.0.0.1/TestService", "invoke");
    InjvmInvoker injvmInvoker = new InjvmInvoker(DemoService.class, URL.valueOf("injvm://127.0.0.1/TestService"), null, new DelegateExporterMap() {

        @Override
        public boolean isEmpty() {
            return true;
        }

        @Override
        public Exporter<?> getExport(String key) {
            return null;
        }

        @Override
        public void addExportMap(String key, Exporter<?> exporter) {
        }

        @Override
        public boolean removeExportMap(String key, Exporter<?> exporter) {
            return true;
        }

        @Override
        public Collection<Exporter<?>> getExporters() {
            return null;
        }
    });
    assertFalse(injvmInvoker.isAvailable());
}
Also used : Collection(java.util.Collection) DelegateExporterMap(org.apache.dubbo.rpc.protocol.DelegateExporterMap) Exporter(org.apache.dubbo.rpc.Exporter) Test(org.junit.jupiter.api.Test)

Aggregations

Collection (java.util.Collection)1 Exporter (org.apache.dubbo.rpc.Exporter)1 DelegateExporterMap (org.apache.dubbo.rpc.protocol.DelegateExporterMap)1 Test (org.junit.jupiter.api.Test)1