Search in sources :

Example 6 with DemoServiceImpl

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

the class InvokerTelnetHandlerTest method testOverriddenMethodWithSpecifyParamType.

@SuppressWarnings("unchecked")
@Test
public void testOverriddenMethodWithSpecifyParamType() 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, "getPerson({\"name\":\"zhangsan\",\"age\":12,\"class\":\"org.apache.dubbo.qos.legacy.service.Person\"})");
    assertTrue(result.contains("result: 12"));
}
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 7 with DemoServiceImpl

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

the class ListTelnetHandlerTest method testListService.

@Test
public void testListService() throws RemotingException {
    mockChannel = mock(Channel.class);
    given(mockChannel.getAttribute("telnet.service")).willReturn(DemoService.class.getName());
    registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
    String result = list.telnet(mockChannel, "DemoService");
    for (Method method : DemoService.class.getMethods()) {
        assertTrue(result.contains(method.getName()));
    }
}
Also used : Channel(org.apache.dubbo.remoting.Channel) DemoService(org.apache.dubbo.qos.legacy.service.DemoService) Method(java.lang.reflect.Method) DemoServiceImpl(org.apache.dubbo.qos.legacy.service.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 8 with DemoServiceImpl

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

the class ListTelnetHandlerTest method testListDetail.

@Test
public void testListDetail() 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, "-l");
    assertEquals("PROVIDER:\r\norg.apache.dubbo.qos.legacy.service.DemoService ->  published: N\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 9 with DemoServiceImpl

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

the class ListTelnetHandlerTest method testListDetailService.

@Test
public void testListDetailService() throws RemotingException {
    mockChannel = mock(Channel.class);
    given(mockChannel.getAttribute("telnet.service")).willReturn(DemoService.class.getName());
    registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
    String result = list.telnet(mockChannel, "-l DemoService");
    for (Method method : DemoService.class.getMethods()) {
        assertTrue(result.contains(ReflectUtils.getName(method)));
    }
}
Also used : Channel(org.apache.dubbo.remoting.Channel) DemoService(org.apache.dubbo.qos.legacy.service.DemoService) Method(java.lang.reflect.Method) DemoServiceImpl(org.apache.dubbo.qos.legacy.service.DemoServiceImpl) Test(org.junit.jupiter.api.Test)

Example 10 with DemoServiceImpl

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

the class ListTelnetHandlerTest method testListDefault.

@Test
public void testListDefault() throws RemotingException {
    mockChannel = mock(Channel.class);
    given(mockChannel.getAttribute("telnet.service")).willReturn(DemoService.class.getName());
    registerProvider(DemoService.class.getName(), new DemoServiceImpl(), DemoService.class);
    String result = list.telnet(mockChannel, "");
    assertTrue(result.startsWith("Use default service org.apache.dubbo.qos.legacy.service.DemoService.\r\n" + "org.apache.dubbo.qos.legacy.service.DemoService (as provider):\r\n"));
    for (Method method : DemoService.class.getMethods()) {
        assertTrue(result.contains(method.getName()));
    }
}
Also used : Channel(org.apache.dubbo.remoting.Channel) DemoService(org.apache.dubbo.qos.legacy.service.DemoService) Method(java.lang.reflect.Method) 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