Author: bvahdat
Date: Mon Jan 21 16:05:43 2013
New Revision: 1436438
URL: http://svn.apache.org/viewvc?rev=1436438&view=rev
Log:
CAMEL-5983: Avoid the negative-tests to behave as false-positive.
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/language/BeanTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanWithExceptionTest.java
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/language/BeanTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/BeanTest.java?rev=1436438&r1=1436437&r2=1436438&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/language/BeanTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/language/BeanTest.java
Mon Jan 21 16:05:43 2013
@@ -73,6 +73,7 @@ public class BeanTest extends LanguageTe
Object result = exp.evaluate(exchange, Object.class);
assertNull(result);
+ assertNotNull(exchange.getException());
MethodNotFoundException e =
assertIsInstanceOf(MethodNotFoundException.class, exchange.getException());
assertSame(user, e.getBean());
assertEquals("unknown", e.getMethodName());
@@ -84,6 +85,7 @@ public class BeanTest extends LanguageTe
Object result = exp.evaluate(exchange, Object.class);
assertNull(result);
+ assertNotNull(exchange.getException());
MethodNotFoundException e =
assertIsInstanceOf(MethodNotFoundException.class, exchange.getException());
assertSame(context.getRegistry().lookup("foo"), e.getBean());
assertEquals("cake", e.getMethodName());
Modified:
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanWithExceptionTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanWithExceptionTest.java?rev=1436438&r1=1436437&r2=1436438&view=diff
==============================================================================
---
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanWithExceptionTest.java
(original)
+++
camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanWithExceptionTest.java
Mon Jan 21 16:05:43 2013
@@ -34,12 +34,12 @@ import org.slf4j.LoggerFactory;
* @version
*/
public class BeanWithExceptionTest extends ContextTestSupport {
- protected Processor validator = new MyValidator();
protected MockEndpoint validEndpoint;
protected MockEndpoint invalidEndpoint;
public void testValidMessage() throws Exception {
validEndpoint.expectedMessageCount(1);
+ invalidEndpoint.expectedMessageCount(0);
template.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
@@ -53,19 +53,20 @@ public class BeanWithExceptionTest exten
}
public void testInvalidMessage() throws Exception {
+ validEndpoint.expectedMessageCount(0);
invalidEndpoint.expectedMessageCount(1);
- try {
- template.send("direct:start", new Processor() {
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setBody("<invalid/>");
- exchange.getIn().setHeader("foo", "notMatchedHeaderValue");
- exchange.setProperty("cheese", "old");
- }
- });
- } catch (Exception e) {
- // expected
- }
+ Exchange exchange = template.send("direct:start", new Processor() {
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setBody("<invalid/>");
+ exchange.getIn().setHeader("foo", "notMatchedHeaderValue");
+ exchange.setProperty("cheese", "old");
+ }
+ });
+
+ assertNotNull(exchange.getException());
+ ValidationException exception =
assertIsInstanceOf(ValidationException.class, exchange.getException());
+ assertEquals("Invalid header foo: notMatchedHeaderValue",
exception.getMessage());
assertMockEndpointsSatisfied();
}