Search in sources :

Example 1 with StreamCloserService

use of org.mule.runtime.core.api.util.StreamCloserService in project mule by mulesoft.

the class DefaultMuleContextTestCase method getStreamCloserService.

@Test
public void getStreamCloserService() throws Exception {
    createMuleContext();
    StreamCloserService serviceFromRegistry = ((MuleContextWithRegistries) context).getRegistry().lookupObject(OBJECT_MULE_STREAM_CLOSER_SERVICE);
    MuleRegistryHelper registry = spy((MuleRegistryHelper) ((MuleContextWithRegistries) context).getRegistry());
    ((DefaultMuleContext) context).setMuleRegistry(registry);
    StreamCloserService streamCloserService = context.getStreamCloserService();
    assertThat(streamCloserService, not(nullValue()));
    assertThat(streamCloserService, is(sameInstance(serviceFromRegistry)));
    // test that subsequent invocations consistently returns the same object
    assertThat(context.getStreamCloserService(), is(sameInstance(streamCloserService)));
    // verify we're not fetching from registry many times
    verify(registry, times(1)).lookupObject(OBJECT_MULE_STREAM_CLOSER_SERVICE);
}
Also used : MuleRegistryHelper(org.mule.runtime.core.internal.registry.MuleRegistryHelper) StreamCloserService(org.mule.runtime.core.api.util.StreamCloserService) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 StreamCloserService (org.mule.runtime.core.api.util.StreamCloserService)1 MuleRegistryHelper (org.mule.runtime.core.internal.registry.MuleRegistryHelper)1