Author: davsclaus
Date: Tue Dec 16 10:39:45 2008
New Revision: 727113
URL: http://svn.apache.org/viewvc?rev=727113&view=rev
Log:
CAMEL-1188: added unit test (already fixed). Polished javadoc. The new # uri
option lookup should not throw exception if not found, this is handled by the
component later (to support lenient properties)
Added:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java
(contents, props changed)
- copied, changed from r726956,
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRouteTest.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java?rev=727113&r1=727112&r2=727113&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
Tue Dec 16 10:39:45 2008
@@ -35,6 +35,10 @@
* <li>Either <tt>IN</tt> or <tt>OUT</tt> body according to the message
exchange pattern. If the pattern is
* Out capable then the <tt>OUT</tt> body is returned, otherwise <tt>IN</tt>.
* </ul>
+ * <p/>
+ * <b>Important note on usage:</b> See this
+ * <a
href="http://activemq.apache.org/camel/why-does-camel-use-too-many-threads-with-producertemplate.html">FAQ
entry</a>
+ * before using.
*
* @version $Revision$
*/
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java?rev=727113&r1=727112&r2=727113&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
Tue Dec 16 10:39:45 2008
@@ -82,6 +82,9 @@
return onNewPredicate(PredicateBuilder.isInstanceOf(expression, type));
}
+ /**
+ * @deprecated use {...@link #regex(String)}
+ */
public Predicate matchesRegex(String regex) {
return onNewPredicate(PredicateBuilder.regex(expression, regex));
}
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java?rev=727113&r1=727112&r2=727113&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
Tue Dec 16 10:39:45 2008
@@ -184,10 +184,13 @@
/**
* Sets the bean properties on the given bean
+ *
+ * @param bean the bean
+ * @param parameters properties to set
*/
protected void setProperties(Object bean, Map parameters) throws Exception
{
// set reference properties first as they use # syntax that fools the
regular properties setter
- setReferenceProperties(bean, parameters);
+ setReferenceProperties(bean, parameters);
IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), bean,
parameters);
}
@@ -213,8 +216,6 @@
}
// must remove as its a valid option and we could
configure it
it.remove();
- } else {
- throw new IllegalArgumentException("Property: " + name
+ " not found on bean: " + bean + " of type: " + bean.getClass().getName());
}
}
}
Copied:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java
(from r726956,
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRouteTest.java)
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java?p2=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRouteTest.java&r1=726956&r2=727113&rev=727113&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRouteTest.java
(original)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java
Tue Dec 16 10:39:45 2008
@@ -17,23 +17,24 @@
package org.apache.camel.processor.onexception;
import org.apache.camel.ContextTestSupport;
-import org.apache.camel.RuntimeCamelException;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.JndiRegistry;
/**
- * Unit test inspired by user forum.
+ * Unit test for CAMEL-1188
*/
-public class OnExceptionRouteTest extends ContextTestSupport {
+public class OnExceptionFromChoiceTest extends ContextTestSupport {
- private MyOwnHandlerBean myOwnHandlerBean;
private MyServiceBean myServiceBean;
- public void testNoError() throws Exception {
+ public void testNoErrorWhen() throws Exception {
getMockEndpoint("mock:error").expectedMessageCount(0);
+ getMockEndpoint("mock:func").expectedMessageCount(0);
+ getMockEndpoint("mock:tech").expectedMessageCount(0);
+ getMockEndpoint("mock:otherwise").expectedMessageCount(0);
- MockEndpoint mock = getMockEndpoint("mock:result");
+ MockEndpoint mock = getMockEndpoint("mock:when");
mock.expectedMessageCount(1);
template.sendBody("direct:start",
"<order><type>myType</type><user>James</user></order>");
@@ -43,50 +44,34 @@
public void testFunctionalError() throws Exception {
getMockEndpoint("mock:error").expectedMessageCount(0);
+ getMockEndpoint("mock:tech").expectedMessageCount(0);
+ getMockEndpoint("mock:when").expectedMessageCount(0);
+ getMockEndpoint("mock:otherwise").expectedMessageCount(0);
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(0);
+ MockEndpoint mock = getMockEndpoint("mock:func");
+ mock.expectedMessageCount(1);
template.sendBody("direct:start",
"<order><type>myType</type><user>Func</user></order>");
assertMockEndpointsSatisfied();
- assertEquals("<order><type>myType</type><user>Func</user></order>",
myOwnHandlerBean.getPayload());
}
public void testTechnicalError() throws Exception {
- getMockEndpoint("mock:error").expectedMessageCount(1);
-
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(0);
-
- template.sendBody("direct:start",
"<order><type>myType</type><user>Tech</user></order>");
-
- assertMockEndpointsSatisfied();
- // should not handle it
- assertNull(myOwnHandlerBean.getPayload());
- }
-
- public void testErrorWhileHandlingException() throws Exception {
getMockEndpoint("mock:error").expectedMessageCount(0);
+ getMockEndpoint("mock:func").expectedMessageCount(0);
+ getMockEndpoint("mock:when").expectedMessageCount(0);
+ getMockEndpoint("mock:otherwise").expectedMessageCount(0);
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(0);
+ MockEndpoint mock = getMockEndpoint("mock:tech");
+ mock.expectedMessageCount(1);
- try {
- template.sendBody("direct:start",
"<order><type>myType</type><user>FuncError</user></order>");
- fail("Should throw a RuntimeCamelException");
- } catch (RuntimeCamelException e) {
- assertEquals("Damm something did not work",
e.getCause().getMessage());
- }
+ template.sendBody("direct:start",
"<order><type>myType</type><user>Tech</user></order>");
assertMockEndpointsSatisfied();
- // should not handle it
- assertNull(myOwnHandlerBean.getPayload());
}
@Override
protected void setUp() throws Exception {
- myOwnHandlerBean = new MyOwnHandlerBean();
myServiceBean = new MyServiceBean();
super.setUp();
}
@@ -94,7 +79,6 @@
@Override
protected JndiRegistry createRegistry() throws Exception {
JndiRegistry jndi = super.createRegistry();
- jndi.bind("myOwnHandler", myOwnHandlerBean);
jndi.bind("myServiceBean", myServiceBean);
return jndi;
}
@@ -104,29 +88,19 @@
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- // default should errors go to mock:error
errorHandler(deadLetterChannel("mock:error"));
-
- // START SNIPPET: e1
- // if a MyTechnicalException is thrown we will not try to
redeliver and we mark it as handled
- // so the caller does not get a failure
- // since we have no to then the exchange will continue to be
routed to the normal error handler
- // destination that is mock:error as defined above
-
onException(MyTechnicalException.class).maximumRedeliveries(0).handled(true);
-
- // if a MyFunctionalException is thrown we do not want Camel
to redelivery but handle it our self using
- // our bean myOwnHandler, then the exchange is not routed to
the default error (mock:error)
-
onException(MyFunctionalException.class).maximumRedeliveries(0).handled(true).to("bean:myOwnHandler");
-
- // here we route message to our service bean
- from("direct:start").choice()
- .when().xpath("//type = 'myType'")
- .to("bean:myServiceBean")
- // END SNIPPET: e1
- .to("mock:result");
+
+
onException(MyTechnicalException.class).maximumRedeliveries(0).handled(true).to("mock:tech");
+
onException(MyFunctionalException.class).maximumRedeliveries(0).handled(true).to("mock:func");
+
+ from("direct:start")
+ .choice()
+
.when(bean("myServiceBean").isEqualTo("James")).to("mock:when")
+ .otherwise()
+ .to("mock:otherwise");
}
};
}
-}
+}
\ No newline at end of file
Propchange:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionFromChoiceTest.java
------------------------------------------------------------------------------
svn:mergeinfo =