Search in sources :

Example 1 with FailoverStrategy

use of org.apache.cxf.clustering.FailoverStrategy in project tesb-rt-se by Talend.

the class LocatorClientEnablerTest method enableClient.

@Test
public void enableClient() {
    ServiceLocator sl = createMock(ServiceLocator.class);
    Capture<LocatorTargetSelector> capturedSelector = new Capture<LocatorTargetSelector>();
    Client client = createMock(Client.class);
    expect(client.getConduitSelector()).andStubReturn(conduitSelector);
    client.setConduitSelector(capture(capturedSelector));
    replay(client);
    LocatorClientEnabler clientRegistrar = new LocatorClientEnabler();
    clientRegistrar.setServiceLocator(sl);
    clientRegistrar.setLocatorSelectionStrategyMap(locatorSelectionStrategyMap);
    // clientRegistrar.setLocatorSelectionStrategy("defaultSelectionStrategy");
    clientRegistrar.setDefaultLocatorSelectionStrategy("evenDistributionSelectionStrategy");
    clientRegistrar.enable(client);
    LocatorTargetSelector selector = capturedSelector.getValue();
    assertEquals(endpoint, selector.getEndpoint());
    FailoverStrategy strategy = selector.getStrategy();
    assertThat(strategy, instanceOf(LocatorSelectionStrategy.class));
    verify(client);
}
Also used : ServiceLocator(org.talend.esb.servicelocator.client.ServiceLocator) FailoverStrategy(org.apache.cxf.clustering.FailoverStrategy) Client(org.apache.cxf.endpoint.Client) Capture(org.easymock.Capture) Test(org.junit.Test)

Aggregations

FailoverStrategy (org.apache.cxf.clustering.FailoverStrategy)1 Client (org.apache.cxf.endpoint.Client)1 Capture (org.easymock.Capture)1 Test (org.junit.Test)1 ServiceLocator (org.talend.esb.servicelocator.client.ServiceLocator)1