Search in sources :

Example 6 with DemoServiceImpl

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

the class ServerStatusCheckerTest method testServerStatusChecker.

@Test
public void testServerStatusChecker() throws Exception {
    int port = NetUtils.getAvailablePort(7000);
    URL url = URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName());
    DemoService service = new DemoServiceImpl();
    DubboProtocol.getDubboProtocol().export(proxy.getInvoker(service, DemoService.class, url));
    StatusChecker server = ExtensionLoader.getExtensionLoader(StatusChecker.class).getExtension("server");
    Assertions.assertEquals(ServerStatusChecker.class, server.getClass());
    Status status = server.check();
    Assertions.assertEquals(Status.Level.OK, status.getLevel());
    ProtocolUtils.closeAll();
}
Also used : Status(org.apache.dubbo.common.status.Status) DemoService(org.apache.dubbo.rpc.protocol.dubbo.support.DemoService) StatusChecker(org.apache.dubbo.common.status.StatusChecker) URL(org.apache.dubbo.common.URL) DemoServiceImpl(org.apache.dubbo.rpc.protocol.dubbo.support.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 7 with DemoServiceImpl

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

the class DubboProtocolTest method testPayloadOverException.

@Test
public void testPayloadOverException() throws Exception {
    DemoService service = new DemoServiceImpl();
    int port = NetUtils.getAvailablePort();
    protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName()).addParameter("payload", 10 * 1024)));
    service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName()).addParameter("timeout", 6000L).addParameter("payload", 160)));
    try {
        service.download(300);
        Assertions.fail();
    } catch (Exception expected) {
        Assertions.assertTrue(expected.getMessage().contains("Data length too large"));
    }
}
Also used : DemoService(org.apache.dubbo.rpc.protocol.dubbo.support.DemoService) RpcException(org.apache.dubbo.rpc.RpcException) DemoServiceImpl(org.apache.dubbo.rpc.protocol.dubbo.support.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 8 with DemoServiceImpl

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

the class DubboProtocolTest method testRemoteApplicationName.

@Test
public void testRemoteApplicationName() throws Exception {
    DemoService service = new DemoServiceImpl();
    int port = NetUtils.getAvailablePort();
    URL url = URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "?codec=exchange").addParameter("timeout", 3000L).addParameter("application", "consumer");
    protocol.export(proxy.getInvoker(service, DemoService.class, url));
    service = proxy.getProxy(protocol.refer(DemoService.class, url));
    assertEquals(service.getRemoteApplicationName(), "consumer");
}
Also used : DemoService(org.apache.dubbo.rpc.protocol.dubbo.support.DemoService) URL(org.apache.dubbo.common.URL) DemoServiceImpl(org.apache.dubbo.rpc.protocol.dubbo.support.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 9 with DemoServiceImpl

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

the class DubboProtocolTest method testNonSerializedParameter.

@Test
public void testNonSerializedParameter() throws Exception {
    DemoService service = new DemoServiceImpl();
    int port = NetUtils.getAvailablePort();
    protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "?codec=exchange")));
    service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "?codec=exchange").addParameter("timeout", 3000L)));
    try {
        service.nonSerializedParameter(new NonSerialized());
        Assertions.fail();
    } catch (RpcException e) {
        Assertions.assertTrue(e.getMessage().contains("org.apache.dubbo.rpc.protocol.dubbo.support.NonSerialized must implement java.io.Serializable"));
    }
}
Also used : NonSerialized(org.apache.dubbo.rpc.protocol.dubbo.support.NonSerialized) RpcException(org.apache.dubbo.rpc.RpcException) DemoService(org.apache.dubbo.rpc.protocol.dubbo.support.DemoService) DemoServiceImpl(org.apache.dubbo.rpc.protocol.dubbo.support.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 10 with DemoServiceImpl

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

the class DubboProtocolTest method testReturnNonSerialized.

@Test
public void testReturnNonSerialized() throws Exception {
    DemoService service = new DemoServiceImpl();
    int port = NetUtils.getAvailablePort();
    protocol.export(proxy.getInvoker(service, DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "?codec=exchange")));
    service = proxy.getProxy(protocol.refer(DemoService.class, URL.valueOf("dubbo://127.0.0.1:" + port + "/" + DemoService.class.getName() + "?codec=exchange").addParameter("timeout", 3000L)));
    try {
        service.returnNonSerialized();
        Assertions.fail();
    } catch (RpcException e) {
        e.printStackTrace();
        Assertions.assertTrue(e.getMessage().contains("org.apache.dubbo.rpc.protocol.dubbo.support.NonSerialized must implement java.io.Serializable"));
    }
}
Also used : RpcException(org.apache.dubbo.rpc.RpcException) DemoService(org.apache.dubbo.rpc.protocol.dubbo.support.DemoService) DemoServiceImpl(org.apache.dubbo.rpc.protocol.dubbo.support.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Aggregations

DemoService (org.apache.dubbo.rpc.protocol.dubbo.support.DemoService)12 DemoServiceImpl (org.apache.dubbo.rpc.protocol.dubbo.support.DemoServiceImpl)12 Test (org.junit.jupiter.api.Test)12 URL (org.apache.dubbo.common.URL)3 RpcException (org.apache.dubbo.rpc.RpcException)3 EchoService (org.apache.dubbo.rpc.service.EchoService)3 HashMap (java.util.HashMap)2 Type (org.apache.dubbo.rpc.protocol.dubbo.support.Type)2 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Status (org.apache.dubbo.common.status.Status)1 StatusChecker (org.apache.dubbo.common.status.StatusChecker)1 NonSerialized (org.apache.dubbo.rpc.protocol.dubbo.support.NonSerialized)1 Disabled (org.junit.jupiter.api.Disabled)1