Search in sources :

Example 1 with InternationalizationServiceFactory

use of org.talend.sdk.component.runtime.internationalization.InternationalizationServiceFactory in project component-runtime by Talend.

the class JavaProxyEnricherFactoryTest method serialization.

@Test
void serialization() throws IOException, ClassNotFoundException {
    final ClassLoader loader = Thread.currentThread().getContextClassLoader();
    final JavaProxyEnricherFactory factory = new JavaProxyEnricherFactory();
    final Translator proxyBased = Translator.class.cast(factory.asSerializable(loader, getClass().getSimpleName(), Translator.class.getName(), new InternationalizationServiceFactory().create(Translator.class, loader)));
    assertEquals("ok", proxyBased.message());
    DynamicContainerFinder.SERVICES.put(Translator.class, proxyBased);
    DynamicContainerFinder.LOADERS.put(getClass().getSimpleName(), Thread.currentThread().getContextClassLoader());
    try {
        final Translator fromApi = Serializer.roundTrip(proxyBased);
        assertEquals(fromApi, proxyBased);
        assertSame(Proxy.getInvocationHandler(fromApi), Proxy.getInvocationHandler(proxyBased));
    } finally {
        DynamicContainerFinder.LOADERS.clear();
        DynamicContainerFinder.SERVICES.remove(Translator.class);
    }
}
Also used : InternationalizationServiceFactory(org.talend.sdk.component.runtime.internationalization.InternationalizationServiceFactory) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 InternationalizationServiceFactory (org.talend.sdk.component.runtime.internationalization.InternationalizationServiceFactory)1