use of com.alibaba.dubbo.remoting.exchange.support.SimpleFuture in project incubator-shenyu by apache.
the class AlibabaDubboProxyServiceTest method testGenericInvoker.
@Test
public void testGenericInvoker() throws Exception {
GenericService genericService = mock(GenericService.class);
String sample = String.format("%x", System.nanoTime());
when(referenceConfig.get()).thenReturn(genericService);
when(genericService.$invoke(METHOD_NAME, LEFT, RIGHT)).then(invocationOnMock -> {
RpcContext.getContext().setFuture(new FutureAdapter<>(new SimpleFuture(new RpcResult(sample))));
return sample;
});
try (MockedStatic<AlibabaDubboConfigCache> ignored = mockStatic(AlibabaDubboConfigCache.class)) {
AlibabaDubboConfigCache alibabaDubboConfigCache = mock(AlibabaDubboConfigCache.class);
when(AlibabaDubboConfigCache.getInstance()).thenReturn(alibabaDubboConfigCache);
when(alibabaDubboConfigCache.initRef(metaData)).thenReturn(referenceConfig);
AlibabaDubboProxyService alibabaDubboProxyService = new AlibabaDubboProxyService(new BodyParamResolveServiceImpl());
ResponseFuture responseFuture = alibabaDubboProxyService.genericInvoker("", metaData);
assertNotNull(responseFuture);
assertEquals(sample, RpcContext.getContext().getFuture().get());
}
}
use of com.alibaba.dubbo.remoting.exchange.support.SimpleFuture in project incubator-shenyu by apache.
the class AlibabaDubboPluginTest method setUp.
@BeforeEach
public void setUp() {
metaData = new MetaData();
metaData.setId("1332017966661636096");
metaData.setAppName("dubbo");
metaData.setPath("/dubbo/findAll");
metaData.setServiceName("org.apache.shenyu.test.dubbo.api.service.DubboTestService");
metaData.setMethodName("findAll");
metaData.setRpcType(RpcTypeEnum.DUBBO.getName());
when(mockAlibabaDubboProxyService.genericInvoker(null, metaData)).thenReturn(new SimpleFuture(new RpcResult(metaData.getId())));
alibabaDubboPluginUnderTest = new AlibabaDubboPlugin(mockAlibabaDubboProxyService);
}
Aggregations