Search in sources :

Example 1 with HttpClient

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());
}
Also used : HashMap(java.util.HashMap) HttpClient(org.talend.sdk.component.api.service.http.HttpClient) HttpClientFactoryImpl(org.talend.sdk.component.runtime.manager.service.HttpClientFactoryImpl) ReflectionService(org.talend.sdk.component.runtime.manager.reflect.ReflectionService) ParameterModelService(org.talend.sdk.component.runtime.manager.reflect.ParameterModelService) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) Test(org.junit.jupiter.api.Test)

Aggregations

InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Test (org.junit.jupiter.api.Test)1 HttpClient (org.talend.sdk.component.api.service.http.HttpClient)1 ParameterModelService (org.talend.sdk.component.runtime.manager.reflect.ParameterModelService)1 ReflectionService (org.talend.sdk.component.runtime.manager.reflect.ReflectionService)1 HttpClientFactoryImpl (org.talend.sdk.component.runtime.manager.service.HttpClientFactoryImpl)1