use of org.talend.sdk.component.api.service.http.HttpClient in project component-runtime by Talend.
the class ReflectionServiceTest method copiable.
@Test
void copiable() throws NoSuchMethodException {
final HashMap<Class<?>, Object> precomputed = new HashMap<>();
precomputed.put(UserHttpClient.class, new HttpClientFactoryImpl("test", new ReflectionService(new ParameterModelService()), JsonbBuilder.create(), emptyMap()).create(UserHttpClient.class, "http://foo"));
final Method httpMtd = TableOwner.class.getMethod("http", UserHttpClient.class);
final HttpClient client1 = HttpClient.class.cast(reflectionService.parameterFactory(httpMtd, precomputed).apply(emptyMap())[0]);
final HttpClient client2 = HttpClient.class.cast(reflectionService.parameterFactory(httpMtd, precomputed).apply(emptyMap())[0]);
assertNotSame(client1, client2);
final InvocationHandler handler1 = Proxy.getInvocationHandler(client1);
final InvocationHandler handler2 = Proxy.getInvocationHandler(client2);
assertNotSame(handler1, handler2);
assertEquals(handler1.toString(), handler2.toString());
}
Aggregations