Search in sources :

Example 16 with DemoServiceImpl

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

the class InvokerTelnetHandlerTest method testInvokeOverriddenMethodBySelect.

@Test
public void testInvokeOverriddenMethodBySelect() throws RemotingException {
    // create a real instance to keep the attribute values;
    mockChannel = spy(getChannelInstance());
    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 = "{\"name\":\"Dubbo\",\"age\":8}";
    String result = invoke.telnet(mockChannel, "getPerson(" + param + ")");
    assertTrue(result.contains("Please use the select command to select the method you want to invoke. eg: select 1"));
    result = select.telnet(mockChannel, "1");
    // result dependent on method order.
    assertTrue(result.contains("result: 8") || result.contains("result: \"Dubbo\""));
    result = select.telnet(mockChannel, "2");
    assertTrue(result.contains("result: 8") || result.contains("result: \"Dubbo\""));
}
Also used : 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