Search in sources :

Example 16 with OnExceptionDefinition

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

the class ErrorHandlerSupportTest method testTwoPolicyChildFirst.

public void testTwoPolicyChildFirst() {
    ErrorHandlerSupport support = new ShuntErrorHandlerSupport();
    support.addExceptionPolicy(null, new OnExceptionDefinition(ChildException.class));
    support.addExceptionPolicy(null, new OnExceptionDefinition(ParentException.class));
    assertEquals(ChildException.class, getExceptionPolicyFor(support, new ChildException(), 0));
    assertEquals(ParentException.class, getExceptionPolicyFor(support, new ParentException(), 0));
}
Also used : OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition)

Example 17 with OnExceptionDefinition

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

the class ErrorHandlerSupportTest method testOnePolicyChildLast.

public void testOnePolicyChildLast() {
    List<Class<? extends Throwable>> exceptions = new ArrayList<Class<? extends Throwable>>();
    exceptions.add(ParentException.class);
    exceptions.add(ChildException.class);
    ErrorHandlerSupport support = new ShuntErrorHandlerSupport();
    support.addExceptionPolicy(null, new OnExceptionDefinition(exceptions));
    assertEquals(ChildException.class, getExceptionPolicyFor(support, new ChildException(), 1));
    assertEquals(ParentException.class, getExceptionPolicyFor(support, new ParentException(), 0));
}
Also used : ArrayList(java.util.ArrayList) OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition)

Example 18 with OnExceptionDefinition

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

the class ErrorHandlerSupportTest method testTwoPolicyChildLast.

public void testTwoPolicyChildLast() {
    ErrorHandlerSupport support = new ShuntErrorHandlerSupport();
    support.addExceptionPolicy(null, new OnExceptionDefinition(ParentException.class));
    support.addExceptionPolicy(null, new OnExceptionDefinition(ChildException.class));
    assertEquals(ChildException.class, getExceptionPolicyFor(support, new ChildException(), 0));
    assertEquals(ParentException.class, getExceptionPolicyFor(support, new ParentException(), 0));
}
Also used : OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition)

Example 19 with OnExceptionDefinition

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

the class DefaultExceptionPolicyStrategyTest method setupPoliciesCausedBy.

private void setupPoliciesCausedBy() {
    strategy = new DefaultExceptionPolicyStrategy();
    policies = new HashMap<ExceptionPolicyKey, OnExceptionDefinition>();
    type1 = new OnExceptionDefinition(FileNotFoundException.class);
    type2 = new OnExceptionDefinition(ConnectException.class);
    type3 = new OnExceptionDefinition(IOException.class);
    policies.put(new ExceptionPolicyKey(null, FileNotFoundException.class, null), type1);
    policies.put(new ExceptionPolicyKey(null, IOException.class, null), type2);
    policies.put(new ExceptionPolicyKey(null, ConnectException.class, null), type3);
}
Also used : OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ConnectException(java.net.ConnectException)

Example 20 with OnExceptionDefinition

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

the class DefaultExceptionPolicyStrategyTest method testDirectMatch2.

public void testDirectMatch2() {
    setupPolicies();
    OnExceptionDefinition result = strategy.getExceptionPolicy(policies, null, new Exception(""));
    assertEquals(type2, result);
}
Also used : OnExceptionDefinition(org.apache.camel.model.OnExceptionDefinition) 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)

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