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();
}
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"));
}
}
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");
}
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"));
}
}
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"));
}
}
Aggregations