Search in sources :

Example 6 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project cxf by apache.

the class AbstractFailoverTest method testSequentialStrategyWith406.

@Test
public void testSequentialStrategyWith406() throws Exception {
    FailoverFeature feature = getFeature(false, Server.ADDRESS3);
    feature.getTargetSelector().setSupportNotAvailableErrorsOnly(false);
    strategyTestWebClientHttpError(Server.ADDRESS2, feature, Server.ADDRESS3, false);
}
Also used : FailoverFeature(org.apache.cxf.clustering.FailoverFeature) Test(org.junit.Test)

Example 7 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project cxf by apache.

the class AbstractFailoverTest method testSequentialStrategyWith404.

@Test
public void testSequentialStrategyWith404() throws Exception {
    FailoverFeature feature = getFeature(false, Server.ADDRESS3);
    feature.getTargetSelector().setSupportNotAvailableErrorsOnly(true);
    strategyTestWebClient(Server.ADDRESS2 + "/new", feature, Server.ADDRESS3, null, false, false);
}
Also used : FailoverFeature(org.apache.cxf.clustering.FailoverFeature) Test(org.junit.Test)

Example 8 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project cxf by apache.

the class CircuitBreakerFailoverTest method testSequentialStrategyWithElapsingCircuitBreakerTimeout.

@Test
public void testSequentialStrategyWithElapsingCircuitBreakerTimeout() throws Throwable {
    FailoverFeature feature = customizeFeature(new CircuitBreakerFailoverFeature(1, 3000), false, "http://localhost:" + NON_PORT + "/non-existent", "http://localhost:" + NON_PORT + "/non-existent2");
    final BookStore bookStore = getBookStore("http://localhost:" + NON_PORT + "/non-existent", feature);
    // should reset all circuit breakers and the URLs could be tried again.
    for (int i = 0; i < 2; ++i) {
        try {
            bookStore.getBook(1);
            fail("Exception expected");
        } catch (ProcessingException ex) {
            if (!(ex.getCause() instanceof IOException)) {
                throw ex.getCause();
            }
        }
        // Let's wait a bit more than circuit breaker timeout
        Thread.sleep(4000);
    }
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.BookStore) FailoverFeature(org.apache.cxf.clustering.FailoverFeature) CircuitBreakerFailoverFeature(org.apache.cxf.clustering.circuitbreaker.CircuitBreakerFailoverFeature) CircuitBreakerFailoverFeature(org.apache.cxf.clustering.circuitbreaker.CircuitBreakerFailoverFeature) IOException(java.io.IOException) ProcessingException(javax.ws.rs.ProcessingException) Test(org.junit.Test)

Example 9 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project cxf by apache.

the class CircuitBreakerFailoverTest method testSequentialStrategyWithRetry.

@Test
public void testSequentialStrategyWithRetry() throws Exception {
    FailoverFeature feature = getFeature(false, "http://localhost:" + NON_PORT + "/non-existent", Server.ADDRESS2);
    strategyTest("http://localhost:" + NON_PORT + "/non-existent", feature, Server.ADDRESS2, null, false, false, false);
}
Also used : FailoverFeature(org.apache.cxf.clustering.FailoverFeature) CircuitBreakerFailoverFeature(org.apache.cxf.clustering.circuitbreaker.CircuitBreakerFailoverFeature) Test(org.junit.Test)

Example 10 with FailoverFeature

use of org.apache.cxf.clustering.FailoverFeature in project cxf by apache.

the class FailoverWebClientTest method testRetryFailover.

@Test
public void testRetryFailover() throws Exception {
    String address = "http://localhost:" + PORT1 + "/bookstore/unavailable";
    final FailoverFeature feature = new FailoverFeature();
    RetryStrategy strategy = new RetryStrategy();
    strategy.setMaxNumberOfRetries(5);
    feature.setStrategy(strategy);
    final JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    bean.setAddress(address);
    bean.setFeatures(Arrays.asList(feature));
    bean.setServiceClass(FailoverBookStore.class);
    WebClient webClient = bean.createWebClient();
    final Book b = webClient.get(Book.class);
    assertEquals(124L, b.getId());
    assertEquals("root", b.getName());
    assertEquals(address, webClient.getBaseURI().toString());
}
Also used : JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) Book(org.apache.cxf.systest.jaxrs.Book) CircuitBreakerFailoverFeature(org.apache.cxf.clustering.circuitbreaker.CircuitBreakerFailoverFeature) FailoverFeature(org.apache.cxf.clustering.FailoverFeature) RetryStrategy(org.apache.cxf.clustering.RetryStrategy) WebClient(org.apache.cxf.jaxrs.client.WebClient) Test(org.junit.Test)

Aggregations

FailoverFeature (org.apache.cxf.clustering.FailoverFeature)29 Test (org.junit.Test)25 ArrayList (java.util.ArrayList)7 CircuitBreakerFailoverFeature (org.apache.cxf.clustering.circuitbreaker.CircuitBreakerFailoverFeature)7 RandomStrategy (org.apache.cxf.clustering.RandomStrategy)4 SequentialStrategy (org.apache.cxf.clustering.SequentialStrategy)4 WebClient (org.apache.cxf.jaxrs.client.WebClient)4 ProcessingException (javax.ws.rs.ProcessingException)3 Book (org.apache.cxf.systest.jaxrs.Book)3 BookStore (org.apache.cxf.systest.jaxrs.BookStore)3 URL (java.net.URL)2 RetryStrategy (org.apache.cxf.clustering.RetryStrategy)2 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)2 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)2 IOException (java.io.IOException)1 List (java.util.List)1 Response (javax.ws.rs.core.Response)1 QName (javax.xml.namespace.QName)1 Service (javax.xml.ws.Service)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1