Search in sources :

Example 1 with FailoverFailedException

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

the class CircuitBreakerFailoverTest method testSequentialStrategyUnavailableAlternatives.

@Test(expected = FailoverFailedException.class)
public void testSequentialStrategyUnavailableAlternatives() throws Exception {
    FailoverFeature feature = getFeature(false, "http://localhost:" + NON_PORT + "/non-existent", "http://localhost:" + NON_PORT + "/non-existent2");
    final BookStore bookStore = getBookStore("http://localhost:" + NON_PORT + "/non-existent", feature);
    // Second iteration should not call any URL as all targets are not available.
    for (int i = 0; i < 2; ++i) {
        try {
            bookStore.getBook(1);
            fail("Exception expected");
        } catch (ProcessingException ex) {
            if (ex.getCause() instanceof FailoverFailedException) {
                throw (FailoverFailedException) ex.getCause();
            }
        }
    }
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.BookStore) FailoverFeature(org.apache.cxf.clustering.FailoverFeature) CircuitBreakerFailoverFeature(org.apache.cxf.clustering.circuitbreaker.CircuitBreakerFailoverFeature) FailoverFailedException(org.apache.cxf.clustering.FailoverFailedException) ProcessingException(javax.ws.rs.ProcessingException) Test(org.junit.Test)

Aggregations

ProcessingException (javax.ws.rs.ProcessingException)1 FailoverFailedException (org.apache.cxf.clustering.FailoverFailedException)1 FailoverFeature (org.apache.cxf.clustering.FailoverFeature)1 CircuitBreakerFailoverFeature (org.apache.cxf.clustering.circuitbreaker.CircuitBreakerFailoverFeature)1 BookStore (org.apache.cxf.systest.jaxrs.BookStore)1 Test (org.junit.Test)1