Search in sources :

Example 21 with OnExceptionDefinition

use of org.apache.camel.model.OnExceptionDefinition in project camel by apache.

the class DefaultExceptionPolicyStrategyTest method setupPoliciesNoTopLevelException.

private void setupPoliciesNoTopLevelException() {
    // without the top level exception that can be used as fallback
    strategy = new DefaultExceptionPolicyStrategy();
    policies = new HashMap<ExceptionPolicyKey, OnExceptionDefinition>();
    type1 = new OnExceptionDefinition(CamelExchangeException.class);
    type3 = new OnExceptionDefinition(IOException.class);
    policies.put(new ExceptionPolicyKey(null, CamelExchangeException.class, null), type1);
    policies.put(new ExceptionPolicyKey(null, IOException.class, null), type3);
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition) IOException(java.io.IOException)

Example 22 with OnExceptionDefinition

use of org.apache.camel.model.OnExceptionDefinition in project camel by apache.

the class DefaultExceptionPolicyStrategyTest method setupPolicies.

private void setupPolicies() {
    strategy = new DefaultExceptionPolicyStrategy();
    policies = new HashMap<ExceptionPolicyKey, OnExceptionDefinition>();
    type1 = new OnExceptionDefinition(CamelExchangeException.class);
    type2 = new OnExceptionDefinition(Exception.class);
    type3 = new OnExceptionDefinition(IOException.class);
    policies.put(new ExceptionPolicyKey(null, CamelExchangeException.class, null), type1);
    policies.put(new ExceptionPolicyKey(null, Exception.class, null), type2);
    policies.put(new ExceptionPolicyKey(null, IOException.class, null), type3);
}
Also used : CamelExchangeException(org.apache.camel.CamelExchangeException) OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition) IOException(java.io.IOException) RuntimeCamelException(org.apache.camel.RuntimeCamelException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ValidationException(org.apache.camel.ValidationException) ExchangeTimedOutException(org.apache.camel.ExchangeTimedOutException) SocketException(java.net.SocketException) ConnectException(java.net.ConnectException) CamelExchangeException(org.apache.camel.CamelExchangeException) AlreadyStoppedException(org.apache.camel.AlreadyStoppedException)

Example 23 with OnExceptionDefinition

use of org.apache.camel.model.OnExceptionDefinition in project camel by apache.

the class DefaultExceptionPolicyStrategyTest method testCausedByNotConnected.

public void testCausedByNotConnected() {
    setupPoliciesCausedBy();
    IOException ioe = new IOException("Damm");
    ioe.initCause(new ConnectException("Not connected"));
    OnExceptionDefinition result = strategy.getExceptionPolicy(policies, null, ioe);
    assertEquals(type3, result);
}
Also used : OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition) IOException(java.io.IOException) ConnectException(java.net.ConnectException)

Example 24 with OnExceptionDefinition

use of org.apache.camel.model.OnExceptionDefinition in project camel by apache.

the class DefaultExceptionPolicyStrategyTest method testCausedBy.

public void testCausedBy() {
    setupPoliciesCausedBy();
    IOException ioe = new IOException("Damm");
    ioe.initCause(new FileNotFoundException("Somefile not found"));
    OnExceptionDefinition result = strategy.getExceptionPolicy(policies, null, ioe);
    assertEquals(type1, result);
}
Also used : FileNotFoundException(java.io.FileNotFoundException) OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition) IOException(java.io.IOException)

Aggregations

OnExceptionDefinition (org.apache.camel.model.OnExceptionDefinition)24 IOException (java.io.IOException)9 FileNotFoundException (java.io.FileNotFoundException)6 ConnectException (java.net.ConnectException)5 AlreadyStoppedException (org.apache.camel.AlreadyStoppedException)4 CamelExchangeException (org.apache.camel.CamelExchangeException)4 MalformedURLException (java.net.MalformedURLException)3 SocketException (java.net.SocketException)3 ExchangeTimedOutException (org.apache.camel.ExchangeTimedOutException)3 RuntimeCamelException (org.apache.camel.RuntimeCamelException)3 ValidationException (org.apache.camel.ValidationException)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 AsyncCallback (org.apache.camel.AsyncCallback)1 AsyncProcessor (org.apache.camel.AsyncProcessor)1 Processor (org.apache.camel.Processor)1 DefaultRouteNode (org.apache.camel.impl.DefaultRouteNode)1