muleContext.getRegistry().registerConnector(testConnector2);
String globalEndpointName = "concreteEndpoint";
// Create and register a endpoint builder (global endpoint) with connector1
EndpointBuilder endpointBuilder = new EndpointURIEndpointBuilder("test://address", muleContext);
endpointBuilder.setConnector(testConnector1);
muleContext.getRegistry().registerObject(globalEndpointName, endpointBuilder);
EndpointFactory endpointFactory = new DefaultEndpointFactory();
endpointFactory.setMuleContext(muleContext);
// Test that DefaultEndpointFactory.getEndpointBuilder() returns a new
// EndpointBuilder instance equal to
// the one we registered earlier
EndpointBuilder endpointBuilder1 = endpointFactory.getEndpointBuilder(globalEndpointName);
assertNotSame(endpointBuilder1, endpointBuilder);
assertTrue(endpointBuilder1.equals(endpointBuilder));
// Test that DefaultEndpointFactory.getEndpointBuilder() returns a new
// EndpointBuilder instance equal to
// the one we registered earlier
EndpointBuilder endpointBuilder2 = endpointFactory.getEndpointBuilder(globalEndpointName);
assertNotSame(endpointBuilder2, endpointBuilder);
assertTrue(endpointBuilder2.equals(endpointBuilder));
// Check that all EndpointBuilder's returned are unique but equal
assertNotSame(endpointBuilder1, endpointBuilder2);
assertTrue(endpointBuilder1.equals(endpointBuilder2));
assertEquals(endpointBuilder1.hashCode(), endpointBuilder2.hashCode());
// Test creating an endpoint from endpointBuilder1
endpointBuilder1.setExchangePattern(MessageExchangePattern.REQUEST_RESPONSE);
endpointBuilder1.setResponseTimeout(99);
ImmutableEndpoint ep = endpointFactory.getInboundEndpoint(endpointBuilder1);
assertEquals(ep.getEndpointURI().getUri().toString(), "test://address");
assertEquals(MessageExchangePattern.REQUEST_RESPONSE, ep.getExchangePattern());
assertEquals(99, ep.getResponseTimeout());
assertNotNull(ep.getConnector());
assertEquals(testConnector1, ep.getConnector());
// Test creating an endpoint from endpointBuilder2
endpointBuilder2.setExchangePattern(MessageExchangePattern.ONE_WAY);
endpointBuilder2.setResponseTimeout(0);
endpointBuilder2.setConnector(testConnector2);
ImmutableEndpoint ep2 = endpointFactory.getInboundEndpoint(endpointBuilder2);
assertEquals(ep2.getEndpointURI().getUri().toString(), "test://address");
assertEquals(MessageExchangePattern.ONE_WAY, ep2.getExchangePattern());
assertEquals(0, ep2.getResponseTimeout());
assertNotNull(ep.getConnector());