Search in sources :

Example 11 with MuleRegistry

use of org.mule.runtime.core.internal.registry.MuleRegistry in project mule by mulesoft.

the class MuleMessageDataTypePropagationTestCase method maintainsDataTypeOnGetPayloadTransformation.

@Test
public void maintainsDataTypeOnGetPayloadTransformation() throws Exception {
    InputStream payload = mock(InputStream.class);
    Message message = Message.builder().value(payload).mediaType(APPLICATION_XML_CUSTOM).build();
    MuleRegistry muleRegistry = mock(MuleRegistry.class);
    when(muleContext.getRegistry()).thenReturn(muleRegistry);
    Transformer transformer = mock(Transformer.class);
    when(transformer.transform(anyObject(), anyObject())).thenReturn(TEST_PAYLOAD);
    when(muleRegistry.lookupTransformer(any(), any())).thenReturn(transformer);
    assertThat(message.getPayload().getDataType().getMediaType().getPrimaryType(), equalTo(APPLICATION_XML.getPrimaryType()));
    assertThat(message.getPayload().getDataType().getMediaType().getSubType(), equalTo(APPLICATION_XML.getSubType()));
    assertThat(message.getPayload().getDataType().getMediaType().getCharset().get(), equalTo(CUSTOM_ENCODING));
}
Also used : Transformer(org.mule.runtime.core.api.transformer.Transformer) Message(org.mule.runtime.api.message.Message) InputStream(java.io.InputStream) MuleRegistry(org.mule.runtime.core.internal.registry.MuleRegistry) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

MuleRegistry (org.mule.runtime.core.internal.registry.MuleRegistry)11 MuleContextWithRegistries (org.mule.runtime.core.internal.context.MuleContextWithRegistries)8 Test (org.junit.Test)3 NotificationDispatcher (org.mule.runtime.api.notification.NotificationDispatcher)3 StreamingManager (org.mule.runtime.core.api.streaming.StreamingManager)3 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)3 ComponentInitialStateManager (org.mule.runtime.api.deployment.management.ComponentInitialStateManager)2 ErrorTypeRepository (org.mule.runtime.api.exception.ErrorTypeRepository)2 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)2 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)2 Transformer (org.mule.runtime.core.api.transformer.Transformer)2 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Component (org.mule.runtime.api.component.Component)1 ComponentIdentifier (org.mule.runtime.api.component.ComponentIdentifier)1 ConfigurationProperties (org.mule.runtime.api.component.ConfigurationProperties)1 ConfigurationComponentLocator (org.mule.runtime.api.component.location.ConfigurationComponentLocator)1 Location (org.mule.runtime.api.component.location.Location)1 DefaultExpressionLanguageFactoryService (org.mule.runtime.api.el.DefaultExpressionLanguageFactoryService)1