Author: davsclaus Date: Tue Apr 13 06:30:04 2010 New Revision: 933490 URL: http://svn.apache.org/viewvc?rev=933490&view=rev Log: CAMEL-2637: Invalid configured errorHandlerRef will now throw exception on startup.
Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java (with props) camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java (with props) camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml (contents, props changed) - copied, changed from r933249, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml (with props) Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java?rev=933490&r1=933489&r2=933490&view=diff ============================================================================== --- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java Tue Apr 13 06:30:04 2010 @@ -102,6 +102,9 @@ public class ErrorHandlerBuilderRef exte } else { // use specific configured error handler answer = routeContext.lookup(ref, ErrorHandlerBuilder.class); + if (answer == null) { + throw new IllegalArgumentException("ErrorHandlerBuilder with id " + ref + " not found in registry."); + } } return answer; @@ -114,6 +117,9 @@ public class ErrorHandlerBuilderRef exte String otherRef = other.getRef(); if (isErrorHandlerBuilderConfigured(otherRef)) { answer = camelContext.getRegistry().lookup(otherRef, ErrorHandlerBuilder.class); + if (answer == null) { + throw new IllegalArgumentException("ErrorHandlerBuilder with id " + otherRef + " not found in registry."); + } } } Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java?rev=933490&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java (added) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java Tue Apr 13 06:30:04 2010 @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spring.config; + +import org.apache.camel.FailedToCreateRouteException; +import org.apache.camel.RuntimeCamelException; +import org.apache.camel.spring.SpringTestSupport; +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @version $Revision$ + */ +public class ErrorHandlerCamelContextRefNotFoundTest extends SpringTestSupport { + + @Override + protected void setUp() throws Exception { + try { + super.setUp(); + } catch (RuntimeCamelException e) { + FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause()); + IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause()); + assertEquals("ErrorHandlerBuilder with id foo not found in registry.", iae.getMessage()); + } + } + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml"); + } + + public void testDummy() { + // noop + } +} Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java?rev=933490&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java (added) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java Tue Apr 13 06:30:04 2010 @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.spring.config; + +import org.apache.camel.FailedToCreateRouteException; +import org.apache.camel.RuntimeCamelException; +import org.apache.camel.spring.SpringTestSupport; +import org.springframework.context.support.AbstractXmlApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @version $Revision$ + */ +public class ErrorHandlerRouteContextRefNotFoundTest extends SpringTestSupport { + + @Override + protected void setUp() throws Exception { + try { + super.setUp(); + } catch (RuntimeCamelException e) { + FailedToCreateRouteException cause = assertIsInstanceOf(FailedToCreateRouteException.class, e.getCause()); + IllegalArgumentException iae = assertIsInstanceOf(IllegalArgumentException.class, cause.getCause()); + assertEquals("ErrorHandlerBuilder with id bar not found in registry.", iae.getMessage()); + } + } + + @Override + protected AbstractXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml"); + } + + public void testDummy() { + // noop + } +} \ No newline at end of file Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml (from r933249, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml) URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml&r1=933249&r2=933490&rev=933490&view=diff ============================================================================== --- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/errorHandler.xml (original) +++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml Tue Apr 13 06:30:04 2010 @@ -22,9 +22,7 @@ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd "> - - <camelContext id="camel" errorHandlerRef="deadLetterErrorHandler" xmlns="http://camel.apache.org/schema/spring"> - <jmxAgent id="agent" disabled="true"/> + <camelContext id="camel" errorHandlerRef="foo" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="seda:a"/> <to uri="seda:b"/> @@ -35,15 +33,4 @@ </route> </camelContext> - <bean id="deadLetterErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder"> - <property name="deadLetterUri" value="bean:exceptionProcessor"/> - <property name="redeliveryPolicy" ref="rsRedeliveryPolicyConfig"/> - </bean> - - <bean id="rsRedeliveryPolicyConfig" class="org.apache.camel.processor.RedeliveryPolicy"> - <property name="maximumRedeliveries" value="1"/> - <property name="redeliveryDelay" value="30000"/> - <property name="useExponentialBackOff" value="true"/> - </bean> - </beans> Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerCamelContextRefNotFoundTest.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml?rev=933490&view=auto ============================================================================== --- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml (added) +++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml Tue Apr 13 06:30:04 2010 @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd + "> + + <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="seda:a"/> + <to uri="seda:b"/> + </route> + <route errorHandlerRef="bar"> + <from uri="direct:c"/> + <to uri="direct:d"/> + </route> + </camelContext> + +</beans> Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/ErrorHandlerRouteContextRefNotFoundTest.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml