Search in sources :

Example 1 with DemoServiceImpl

use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.

the class ListTelnetHandlerTest method testList.

@Test
public void testList() throws RemotingException {
    mockChannel = mock(Channel.class);
    given(mockChannel.getAttribute("telnet.service")).willReturn(null);
    registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
    String result = list.telnet(mockChannel, "");
    assertEquals("PROVIDER:\r\norg.apache.dubbo.qos.legacy.service.DemoService\r\n", result);
}
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 2 with DemoServiceImpl

use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.

the class SelectTelnetHandlerTest method testInvokeWithNull.

@Test
public void testInvokeWithNull() 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, null);
    assertTrue(result.contains("Please input the index of the method you want to invoke"));
}
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 3 with DemoServiceImpl

use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.

the class InvokerTelnetHandlerTest method testInvokeDefaultService.

@SuppressWarnings("unchecked")
@Test
public void testInvokeDefaultService() 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 = invoke.telnet(mockChannel, "echo(\"ok\")");
    assertTrue(result.contains("result: \"ok\""));
}
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 4 with DemoServiceImpl

use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.

the class InvokerTelnetHandlerTest method testInvokeWithSpecifyService.

@SuppressWarnings("unchecked")
@Test
public void testInvokeWithSpecifyService() 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, "DemoService.echo(\"ok\")");
    assertTrue(result.contains("result: \"ok\""));
}
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 5 with DemoServiceImpl

use of org.apache.dubbo.qos.legacy.service.DemoServiceImpl in project dubbo by alibaba.

the class InvokerTelnetHandlerTest method testInvokeMultiJsonParamMethod.

@Test
public void testInvokeMultiJsonParamMethod() 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 param = "{\"name\":\"Dubbo\",\"age\":8},{\"name\":\"Apache\",\"age\":20}";
    String result = invoke.telnet(mockChannel, "getPerson(" + param + ")");
    assertTrue(result.contains("result: 28"));
}
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