MuleContext firstAppContext = null;
MuleContext secondAppContext = null;
try
{
domainContext = new DomainContextBuilder().setDomainConfig("domain/http/http-shared-connector.xml").build();
firstAppContext = new ApplicationContextBuilder().setApplicationResources(new String[] {"domain/http/http-hello-mule-app.xml"}).setDomainContext(domainContext).build();
ApplicationContextBuilder secondApp = new ApplicationContextBuilder();
secondAppContext = secondApp.setApplicationResources(new String[] {"domain/http/http-hello-world-app.xml"}).setDomainContext(domainContext).build();
firstAppContext.stop();
MuleMessage response = secondAppContext.getClient().send("http://localhost:" + dynamicPort.getNumber() + "/service/helloWorld", "test", null);
assertThat(response, notNullValue());
assertThat(response.getPayloadAsString(), is("hello world"));
assertThat((domainContext.getRegistry().<Connector>get("sharedHttpConnector")).isStarted(), Is.is(true));