use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.
the class SelectTelnetHandlerTest method testInvokeWithIllegalMessage.
@Test
public void testInvokeWithIllegalMessage() throws RemotingException {
mockChannel = mock(Channel.class);
given(mockChannel.getAttribute("telnet.service")).willReturn(DemoService.class.getName());
given(mockChannel.getAttribute(InvokeTelnetHandler.INVOKE_METHOD_LIST_KEY)).willReturn(methods);
given(mockChannel.getLocalAddress()).willReturn(NetUtils.toAddress("127.0.0.1:5555"));
given(mockChannel.getRemoteAddress()).willReturn(NetUtils.toAddress("127.0.0.1:20886"));
registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
String result = select.telnet(mockChannel, "index");
assertTrue(result.contains("Illegal index ,please input select 1"));
result = select.telnet(mockChannel, "0");
assertTrue(result.contains("Illegal index ,please input select 1"));
result = select.telnet(mockChannel, "1000");
assertTrue(result.contains("Illegal index ,please input select 1"));
}
use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.
the class SelectTelnetHandlerTest method testInvokeWithoutMethodList.
@Test
public void testInvokeWithoutMethodList() throws RemotingException {
mockChannel = mock(Channel.class);
given(mockChannel.getAttribute("telnet.service")).willReturn(DemoService.class.getName());
given(mockChannel.getLocalAddress()).willReturn(NetUtils.toAddress("127.0.0.1:5555"));
given(mockChannel.getRemoteAddress()).willReturn(NetUtils.toAddress("127.0.0.1:20886"));
registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
String result = select.telnet(mockChannel, "1");
assertTrue(result.contains("Please use the invoke command first."));
}
use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.
the class InvokerTelnetHandlerTest method testInvokeMethodWithMapParameter.
@Test
public void testInvokeMethodWithMapParameter() throws RemotingException {
mockChannel = mock(Channel.class);
given(mockChannel.getAttribute("telnet.service")).willReturn(DemoService.class.getName());
given(mockChannel.getLocalAddress()).willReturn(NetUtils.toAddress("127.0.0.1:5555"));
given(mockChannel.getRemoteAddress()).willReturn(NetUtils.toAddress("127.0.0.1:20886"));
registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
String param = "{1:\"Dubbo\",2:\"test\"}";
String result = invoke.telnet(mockChannel, "getMap(" + param + ")");
assertTrue(result.contains("result: {1:\"Dubbo\",2:\"test\"}"));
}
use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.
the class InvokerTelnetHandlerTest method testInvokeByPassingNullValue.
@SuppressWarnings("unchecked")
@Test
public void testInvokeByPassingNullValue() {
mockChannel = mock(Channel.class);
given(mockChannel.getAttribute("telnet.service")).willReturn(DemoService.class.getName());
given(mockChannel.getLocalAddress()).willReturn(NetUtils.toAddress("127.0.0.1:5555"));
given(mockChannel.getRemoteAddress()).willReturn(NetUtils.toAddress("127.0.0.1:20886"));
registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
try {
invoke.telnet(mockChannel, "sayHello(null)");
} catch (Exception ex) {
assertTrue(ex instanceof NullPointerException);
}
}
use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.
the class InvokerTelnetHandlerTest method testInvokeByPassingEnumValue.
@Test
public void testInvokeByPassingEnumValue() throws RemotingException {
mockChannel = mock(Channel.class);
given(mockChannel.getAttribute("telnet.service")).willReturn(null);
given(mockChannel.getLocalAddress()).willReturn(NetUtils.toAddress("127.0.0.1:5555"));
given(mockChannel.getRemoteAddress()).willReturn(NetUtils.toAddress("127.0.0.1:20886"));
registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
String result = invoke.telnet(mockChannel, "getType(\"High\")");
assertTrue(result.contains("result: \"High\""));
}
Aggregations