@Test
  public void cachesResolvedStaticEndpoints() throws Exception {
    OutboundEndpoint prototypeEndpoint = mock(OutboundEndpoint.class);
    when(prototypeEndpoint.getMuleContext()).thenReturn(muleContext);

    EndpointBuilder staticEndpointBuilder = mock(EndpointBuilder.class);
    when(staticEndpointBuilder.buildOutboundEndpoint()).thenReturn(prototypeEndpoint);

    EndpointBuilder endpointBuilder = mock(EndpointBuilder.class);
    when(endpointBuilder.buildOutboundEndpoint()).thenReturn(prototypeEndpoint);
    when(endpointBuilder.clone()).thenReturn(staticEndpointBuilder);

    DynamicOutboundEndpoint dynamicOutboundEndpoint =
        new DynamicOutboundEndpoint(
            endpointBuilder,
            new DynamicURIBuilder(new URIBuilder("test://localhost:#[header:port]", muleContext)));

    testOutboundEvent = createTestOutboundEvent();
    dynamicOutboundEndpoint.process(testOutboundEvent);
    dynamicOutboundEndpoint.process(testOutboundEvent);

    verify(endpointBuilder, times(1)).buildOutboundEndpoint();
  }