use of org.apache.cxf.endpoint.ConduitSelector in project cxf by apache.
the class ProxyTest method testRMClientGetConduit.
@Test
public void testRMClientGetConduit() throws Exception {
Proxy proxy = new Proxy(rme);
Bus bus = control.createMock(Bus.class);
Endpoint endpoint = control.createMock(Endpoint.class);
Conduit conduit = control.createMock(Conduit.class);
ConduitSelector cs = control.createMock(ConduitSelector.class);
EasyMock.expect(cs.selectConduit(EasyMock.isA(Message.class))).andReturn(conduit).anyTimes();
control.replay();
Proxy.RMClient client = proxy.new RMClient(bus, endpoint, cs);
assertSame(conduit, client.getConduit());
client.close();
}
use of org.apache.cxf.endpoint.ConduitSelector in project cxf by apache.
the class FailoverAddressOverrideTest method verifyStrategy.
protected void verifyStrategy(Object proxy, Class<?> clz, int count) {
ConduitSelector conduitSelector = ClientProxy.getClient(proxy).getConduitSelector();
if (conduitSelector instanceof FailoverTargetSelector) {
AbstractStaticFailoverStrategy strategy = (AbstractStaticFailoverStrategy) ((FailoverTargetSelector) conduitSelector).getStrategy();
assertTrue("unexpected strategy", clz.isInstance(strategy));
List<String> alternates = strategy.getAlternateAddresses(null);
assertNotNull("expected alternate addresses", alternates);
assertEquals("unexpected alternate addresses", count, alternates.size());
} else {
fail("unexpected conduit selector: " + conduitSelector);
}
}
use of org.apache.cxf.endpoint.ConduitSelector in project cxf by apache.
the class LoadDistributorTest method testDistributedSequentialStrategyWithFailover.
@Test
public void testDistributedSequentialStrategyWithFailover() throws Exception {
startTarget(REPLICA_A);
startTarget(REPLICA_B);
startTarget(REPLICA_C);
setupGreeter();
stopTarget(REPLICA_B);
ConduitSelector conduitSelector = ClientProxy.getClient(greeter).getConduitSelector();
if (conduitSelector instanceof LoadDistributorTargetSelector) {
((LoadDistributorTargetSelector) conduitSelector).setStrategy(new LoadDistributorStaticStrategy());
} else {
fail("unexpected conduit selector: " + conduitSelector);
}
Map<String, Integer> responseCounts = new HashMap<>();
for (int i = 0; i < 12; ++i) {
String response = greeter.greetMe("fred");
assertNotNull("expected non-null response", response);
incrementResponseCount(responseCounts, response);
}
assertTrue((long) responseCounts.get(REPLICA_A) > 0);
assertTrue((long) responseCounts.get(REPLICA_C) > 0);
assertEquals(12, responseCounts.get(REPLICA_A) + responseCounts.get(REPLICA_C));
stopTarget(REPLICA_A);
stopTarget(REPLICA_C);
}
use of org.apache.cxf.endpoint.ConduitSelector in project cxf by apache.
the class FailoverTest method verifyStrategy.
protected void verifyStrategy(Object proxy, Class<?> clz) {
ConduitSelector conduitSelector = ClientProxy.getClient(proxy).getConduitSelector();
if (conduitSelector instanceof FailoverTargetSelector) {
Object strategy = ((FailoverTargetSelector) conduitSelector).getStrategy();
assertTrue("unexpected strategy", clz.isInstance(strategy));
} else {
fail("unexpected conduit selector: " + conduitSelector);
}
}
use of org.apache.cxf.endpoint.ConduitSelector in project cxf by apache.
the class LoadDistributorAddressOverrideTest method testDistributedSequentialStrategyWithoutFailover.
@Test
public void testDistributedSequentialStrategyWithoutFailover() throws Exception {
startTarget(REPLICA_A);
startTarget(REPLICA_C);
setupGreeterA();
verifyStrategy(greeter, SequentialStrategy.class, 3);
ConduitSelector conduitSelector = ClientProxy.getClient(greeter).getConduitSelector();
if (conduitSelector instanceof LoadDistributorTargetSelector) {
((LoadDistributorTargetSelector) conduitSelector).setFailover(false);
} else {
fail("unexpected conduit selector: " + conduitSelector);
}
Map<String, Integer> responseCounts = new HashMap<>();
for (int i = 0; i < 12; ++i) {
try {
String response = greeter.greetMe("fred");
assertNotNull("expected non-null response", response);
incrementResponseCount(responseCounts, response);
} catch (WebServiceException ex) {
incrementResponseCount(responseCounts, "");
}
}
assertEquals(4, (long) responseCounts.get(REPLICA_A));
assertEquals(null, responseCounts.get(REPLICA_B));
assertEquals(4, (long) responseCounts.get(REPLICA_C));
assertEquals(4, (long) responseCounts.get(""));
verifyCurrentEndpoint(REPLICA_C);
stopTarget(REPLICA_A);
stopTarget(REPLICA_C);
}
Aggregations