Search in sources :

Example 11 with DemoServiceImpl

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"));
}
Also used : Channel(org.apache.dubbo.remoting.Channel) DemoService(org.apache.dubbo.qos.legacy.service.DemoService) DemoServiceImpl(org.apache.dubbo.qos.legacy.service.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 12 with DemoServiceImpl

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."));
}
Also used : Channel(org.apache.dubbo.remoting.Channel) DemoService(org.apache.dubbo.qos.legacy.service.DemoService) DemoServiceImpl(org.apache.dubbo.qos.legacy.service.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 13 with DemoServiceImpl

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\"}"));
}
Also used : Channel(org.apache.dubbo.remoting.Channel) DemoService(org.apache.dubbo.qos.legacy.service.DemoService) DemoServiceImpl(org.apache.dubbo.qos.legacy.service.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 14 with DemoServiceImpl

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);
    }
}
Also used : Channel(org.apache.dubbo.remoting.Channel) DemoService(org.apache.dubbo.qos.legacy.service.DemoService) RemotingException(org.apache.dubbo.remoting.RemotingException) DemoServiceImpl(org.apache.dubbo.qos.legacy.service.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 15 with DemoServiceImpl

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\""));
}
Also used : Channel(org.apache.dubbo.remoting.Channel) DemoService(org.apache.dubbo.qos.legacy.service.DemoService) DemoServiceImpl(org.apache.dubbo.qos.legacy.service.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Aggregations

DemoService (org.apache.dubbo.qos.legacy.service.DemoService)16 DemoServiceImpl (org.apache.dubbo.qos.legacy.service.DemoServiceImpl)16 Test (org.junit.jupiter.api.Test)16 Channel (org.apache.dubbo.remoting.Channel)15 Method (java.lang.reflect.Method)3 RemotingException (org.apache.dubbo.remoting.RemotingException)1