Search in sources :

Example 1 with InputStreamToByteArray

use of org.mule.runtime.core.internal.transformer.simple.InputStreamToByteArray in project mule by mulesoft.

the class TransformerCachingTestCase method testCacheUpdate.

@Test
public void testCacheUpdate() throws Exception {
    DataType sourceType = DataType.fromType(FilterInputStream.class);
    MuleRegistry registry = ((MuleContextWithRegistries) muleContext).getRegistry();
    Transformer trans = registry.lookupTransformer(sourceType, BYTE_ARRAY);
    assertNotNull(trans);
    assertTrue(trans instanceof InputStreamToByteArray);
    Transformer trans2 = new FilterInputStreamToByteArray();
    registry.registerTransformer(trans2);
    trans = registry.lookupTransformer(sourceType, BYTE_ARRAY);
    assertNotNull(trans);
    assertTrue(trans instanceof FilterInputStreamToByteArray);
    trans = registry.lookupTransformer(INPUT_STREAM, BYTE_ARRAY);
    assertNotNull(trans);
    assertTrue(trans instanceof InputStreamToByteArray);
    registry.unregisterTransformer(trans2.getName());
    trans = registry.lookupTransformer(sourceType, BYTE_ARRAY);
    assertNotNull(trans);
    assertTrue(trans instanceof InputStreamToByteArray);
}
Also used : Transformer(org.mule.runtime.core.api.transformer.Transformer) DiscoverableTransformer(org.mule.runtime.core.api.transformer.DiscoverableTransformer) AbstractTransformer(org.mule.runtime.core.api.transformer.AbstractTransformer) InputStreamToByteArray(org.mule.runtime.core.internal.transformer.simple.InputStreamToByteArray) MuleContextWithRegistries(org.mule.runtime.core.internal.context.MuleContextWithRegistries) DataType(org.mule.runtime.api.metadata.DataType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 DataType (org.mule.runtime.api.metadata.DataType)1 AbstractTransformer (org.mule.runtime.core.api.transformer.AbstractTransformer)1 DiscoverableTransformer (org.mule.runtime.core.api.transformer.DiscoverableTransformer)1 Transformer (org.mule.runtime.core.api.transformer.Transformer)1 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)1 InputStreamToByteArray (org.mule.runtime.core.internal.transformer.simple.InputStreamToByteArray)1