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);
}
Aggregations