camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r773199 - in /camel/trunk: camel-core/src/test/java/org/apache/camel/ camel-core/src/test/java/org/apache/camel/builder/ camel-core/src/test/java/org/apache/camel/language/ components/camel-test/src/main/java/org/apache/camel/test/
Date Sat, 09 May 2009 10:58:36 GMT
Author: ningjiang
Date: Sat May  9 10:58:36 2009
New Revision: 773199

URL: http://svn.apache.org/viewvc?rev=773199&view=rev
Log:
CAMEL-1593 make the utils method in TestSupport to be public static

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ContextErrorHandlerTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
    camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/TestSupport.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java?rev=773199&r1=773198&r2=773199&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java Sat May
 9 10:58:36 2009
@@ -29,6 +29,8 @@
 import org.apache.camel.spi.Language;
 import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.jndi.JndiTest;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * A useful base class which creates a {@link CamelContext} with some routes
@@ -37,6 +39,7 @@
  * @version $Revision$
  */
 public abstract class ContextTestSupport extends TestSupport {
+    
     protected CamelContext context;
     protected ProducerTemplate template;
     protected ConsumerTemplate consumer;

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java?rev=773199&r1=773198&r2=773199&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupport.java Sat May  9 10:58:36
2009
@@ -37,31 +37,32 @@
  *
  * @version $Revision$
  */
-public abstract class TestSupport extends TestCase {
-
+public abstract class TestSupport extends TestCase {    
+    
+    private static final Log LOG = LogFactory.getLog(TestSupport.class); 
+    
     protected transient Log log = LogFactory.getLog(getClass());
-
     // Builder methods for expressions used when testing
     // -------------------------------------------------------------------------
 
     /**
      * Returns a value builder for the given header
      */
-    public ValueBuilder header(String name) {
+    public static ValueBuilder header(String name) {
         return Builder.header(name);
     }
 
     /**
      * Returns a value builder for the given property
      */
-    public ValueBuilder property(String name) {
+    public static ValueBuilder property(String name) {
         return Builder.property(name);
     }    
     
     /**
      * Returns a predicate and value builder for the inbound body on an exchange
      */
-    public ValueBuilder body() {
+    public static ValueBuilder body() {
         return Builder.body();
     }
 
@@ -69,7 +70,7 @@
      * Returns a predicate and value builder for the inbound message body as a
      * specific type
      */
-    public <T> ValueBuilder bodyAs(Class<T> type) {
+    public static <T> ValueBuilder bodyAs(Class<T> type) {
         return Builder.bodyAs(type);
     }
 
@@ -77,7 +78,7 @@
      * Returns a predicate and value builder for the outbound body on an
      * exchange
      */
-    public ValueBuilder outBody() {
+    public static ValueBuilder outBody() {
         return Builder.outBody();
     }
 
@@ -85,7 +86,7 @@
      * Returns a predicate and value builder for the outbound message body as a
      * specific type
      */
-    public <T> ValueBuilder outBodyAs(Class<T> type) {
+    public static <T> ValueBuilder outBodyAs(Class<T> type) {
         return Builder.outBodyAs(type);
     }
 
@@ -93,7 +94,7 @@
      * Returns a predicate and value builder for the fault body on an
      * exchange
      */
-    public ValueBuilder faultBody() {
+    public static ValueBuilder faultBody() {
         return Builder.faultBody();
     }
 
@@ -101,35 +102,35 @@
      * Returns a predicate and value builder for the fault message body as a
      * specific type
      */
-    public <T> ValueBuilder faultBodyAs(Class<T> type) {
+    public static <T> ValueBuilder faultBodyAs(Class<T> type) {
         return Builder.faultBodyAs(type);
     }
 
     /**
      * Returns a value builder for the given system property
      */
-    public ValueBuilder systemProperty(String name) {
+    public static ValueBuilder systemProperty(String name) {
         return Builder.systemProperty(name);
     }
 
     /**
      * Returns a value builder for the given system property
      */
-    public ValueBuilder systemProperty(String name, String defaultValue) {
+    public static ValueBuilder systemProperty(String name, String defaultValue) {
         return Builder.systemProperty(name, defaultValue);
     }
 
     // Assertions
     // -----------------------------------------------------------------------
 
-    protected <T> T assertIsInstanceOf(Class<T> expectedType, Object value) {
+    public static <T> T assertIsInstanceOf(Class<T> expectedType, Object value)
{
         assertNotNull("Expected an instance of type: " + expectedType.getName() + " but was
null", value);
         assertTrue("object should be a " + expectedType.getName() + " but was: " + value
+ " with type: "
                    + value.getClass().getName(), expectedType.isInstance(value));
         return expectedType.cast(value);
     }
 
-    protected void assertEndpointUri(Endpoint endpoint, String uri) {
+    public static void assertEndpointUri(Endpoint endpoint, String uri) {
         assertNotNull("Endpoint is null when expecting endpoint for: " + uri, endpoint);
         assertEquals("Endoint uri for: " + endpoint, uri, endpoint.getEndpointUri());
     }
@@ -137,14 +138,14 @@
     /**
      * Asserts the In message on the exchange contains the expected value
      */
-    protected Object assertInMessageHeader(Exchange exchange, String name, Object expected)
{
+    public static Object assertInMessageHeader(Exchange exchange, String name, Object expected)
{
         return assertMessageHeader(exchange.getIn(), name, expected);
     }
 
     /**
      * Asserts the Out message on the exchange contains the expected value
      */
-    protected Object assertOutMessageHeader(Exchange exchange, String name, Object expected)
{
+    public static Object assertOutMessageHeader(Exchange exchange, String name, Object expected)
{
         return assertMessageHeader(exchange.getOut(), name, expected);
     }
 
@@ -155,7 +156,7 @@
      * @param expected the expected value of the OUT message
      * @throws InvalidPayloadException is thrown if the payload is not the expected class
type
      */
-    protected void assertInMessageBodyEquals(Exchange exchange, Object expected) throws InvalidPayloadException
{
+    public static void assertInMessageBodyEquals(Exchange exchange, Object expected) throws
InvalidPayloadException {
         assertNotNull("Should have a response exchange!", exchange);
 
         Object actual;
@@ -167,7 +168,7 @@
         }
         assertEquals("in body of: " + exchange, expected, actual);
 
-        log.debug("Received response: " + exchange + " with in: " + exchange.getIn());
+        LOG.debug("Received response: " + exchange + " with in: " + exchange.getIn());
     }
 
     /**
@@ -177,7 +178,7 @@
      * @param expected the expected value of the OUT message
      * @throws InvalidPayloadException is thrown if the payload is not the expected class
type
      */
-    protected void assertOutMessageBodyEquals(Exchange exchange, Object expected) throws
InvalidPayloadException {
+    public static void assertOutMessageBodyEquals(Exchange exchange, Object expected) throws
InvalidPayloadException {
         assertNotNull("Should have a response exchange!", exchange);
 
         Object actual;
@@ -189,10 +190,10 @@
         }
         assertEquals("output body of: " + exchange, expected, actual);
 
-        log.debug("Received response: " + exchange + " with out: " + exchange.getOut());
+        LOG.debug("Received response: " + exchange + " with out: " + exchange.getOut());
     }
 
-    protected Object assertMessageHeader(Message message, String name, Object expected) {
+    public static Object assertMessageHeader(Message message, String name, Object expected)
{
         Object value = message.getHeader(name);
         assertEquals("Header: " + name + " on Message: " + message, expected, value);
         return value;
@@ -201,7 +202,7 @@
     /**
      * Asserts that the given expression when evaluated returns the given answer
      */
-    protected Object assertExpression(Expression expression, Exchange exchange, Object expected)
{
+    public static Object assertExpression(Expression expression, Exchange exchange, Object
expected) {
         Object value;
         if (expected != null) {
             value = expression.evaluate(exchange, expected.getClass());
@@ -209,7 +210,7 @@
             value = expression.evaluate(exchange, Object.class);
         }
 
-        log.debug("Evaluated expression: " + expression + " on exchange: " + exchange + "
result: " + value);
+        LOG.debug("Evaluated expression: " + expression + " on exchange: " + exchange + "
result: " + value);
 
         assertEquals("Expression: " + expression + " on Exchange: " + exchange, expected,
value);
         return value;
@@ -218,18 +219,18 @@
     /**
      * Asserts that the predicate returns the expected value on the exchange
      */
-    protected void assertPredicateMatches(Predicate predicate, Exchange exchange) {
+    public static void assertPredicateMatches(Predicate predicate, Exchange exchange) {
         assertPredicate(predicate, exchange, true);
     }
 
     /**
      * Asserts that the predicate returns the expected value on the exchange
      */
-    protected void assertPredicateDoesNotMatch(Predicate predicate, Exchange exchange) {
+    public static void assertPredicateDoesNotMatch(Predicate predicate, Exchange exchange)
{
         try {
             PredicateAssertHelper.assertMatches(predicate, "Predicate should match: ", exchange);
         } catch (AssertionError e) {
-            log.debug("Caught expected assertion error: " + e);
+            LOG.debug("Caught expected assertion error: " + e);
         }
         assertPredicate(predicate, exchange, false);
     }
@@ -237,13 +238,13 @@
     /**
      * Asserts that the predicate returns the expected value on the exchange
      */
-    protected boolean assertPredicate(final Predicate predicate, Exchange exchange, boolean
expected) {
+    public static boolean assertPredicate(final Predicate predicate, Exchange exchange, boolean
expected) {
         if (expected) {
             PredicateAssertHelper.assertMatches(predicate, "Predicate failed: ", exchange);
         }
         boolean value = predicate.matches(exchange);
 
-        log.debug("Evaluated predicate: " + predicate + " on exchange: " + exchange + " result:
" + value);
+        LOG.debug("Evaluated predicate: " + predicate + " on exchange: " + exchange + " result:
" + value);
 
         assertEquals("Predicate: " + predicate + " on Exchange: " + exchange, expected, value);
         return value;
@@ -252,7 +253,7 @@
     /**
      * Resolves an endpoint and asserts that it is found
      */
-    protected Endpoint resolveMandatoryEndpoint(CamelContext context, String uri) {
+    public static Endpoint resolveMandatoryEndpoint(CamelContext context, String uri) {
         Endpoint endpoint = context.getEndpoint(uri);
 
         assertNotNull("No endpoint found for URI: " + uri, endpoint);
@@ -263,7 +264,7 @@
     /**
      * Resolves an endpoint and asserts that it is found
      */
-    protected <T extends Endpoint> T resolveMandatoryEndpoint(CamelContext context,
String uri,
+    public static <T extends Endpoint> T resolveMandatoryEndpoint(CamelContext context,
String uri,
                                                               Class<T> endpointType)
{
         T endpoint = context.getEndpoint(uri, endpointType);
 
@@ -284,7 +285,7 @@
         return exchange;
     }
 
-    protected <T> T assertOneElement(List<T> list) {
+    public static <T> T assertOneElement(List<T> list) {
         assertEquals("Size of list should be 1: " + list, 1, list.size());
         return list.get(0);
     }
@@ -292,14 +293,14 @@
     /**
      * Asserts that a list is of the given size
      */
-    protected <T> List<T> assertListSize(List<T> list, int size) {
+    public static <T> List<T> assertListSize(List<T> list, int size) {
         return assertListSize("List", list, size);
     }
 
     /**
      * Asserts that a list is of the given size
      */
-    protected <T> List<T> assertListSize(String message, List<T> list,
int size) {
+    public static <T> List<T> assertListSize(String message, List<T> list,
int size) {
         assertEquals(message + " should be of size: "
                 + size + " but is: " + list, size, list.size());
         return list;
@@ -308,14 +309,14 @@
     /**
      * Asserts that a list is of the given size
      */
-    protected <T> Collection<T> assertCollectionSize(Collection<T> list,
int size) {
+    public static <T> Collection<T> assertCollectionSize(Collection<T>
list, int size) {
         return assertCollectionSize("List", list, size);
     }
 
     /**
      * Asserts that a list is of the given size
      */
-    protected <T> Collection<T> assertCollectionSize(String message, Collection<T>
list, int size) {
+    public static <T> Collection<T> assertCollectionSize(String message, Collection<T>
list, int size) {
         assertEquals(message + " should be of size: "
                 + size + " but is: " + list, size, list.size());
         return list;
@@ -324,7 +325,7 @@
     /**
      * A helper method to create a list of Route objects for a given route builder
      */
-    protected List<Route> getRouteList(RouteBuilder builder) throws Exception {
+    public static List<Route> getRouteList(RouteBuilder builder) throws Exception {
         CamelContext context = new DefaultCamelContext();
         context.addRoutes(builder);
         context.start();
@@ -339,7 +340,7 @@
      * @param text the text to compare
      * @param containedText the text which must be contained inside the other text parameter
      */
-    protected void assertStringContains(String text, String containedText) {
+    public static void assertStringContains(String text, String containedText) {
         assertNotNull("Text should not be null!", text);
         assertTrue("Text: " + text + " does not contain: " + containedText, text.contains(containedText));
     }
@@ -348,7 +349,7 @@
      * If a processor is wrapped with a bunch of DelegateProcessor or DelegateAsyncProcessor
objects
      * this call will drill through them and return the wrapped Processor.
      */
-    protected Processor unwrap(Processor processor) {
+    public static Processor unwrap(Processor processor) {
         while (true) {
             if (processor instanceof DelegateProcessor) {
                 processor = ((DelegateProcessor)processor).getProcessor();
@@ -364,7 +365,7 @@
      * <p/>
      * Returns null if no channel is found.
      */
-    protected Channel unwrapChannel(Processor processor) {
+    public static Channel unwrapChannel(Processor processor) {
         while (true) {
             if (processor instanceof Channel) {
                 return (Channel) processor;

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ContextErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ContextErrorHandlerTest.java?rev=773199&r1=773198&r2=773199&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ContextErrorHandlerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ContextErrorHandlerTest.java
Sat May  9 10:58:36 2009
@@ -50,7 +50,7 @@
         // do nothing here
     }
 
-    protected List<Route> getRouteList(RouteBuilder builder) throws Exception {
+    protected List<Route> getRouteListWithCurrentContext(RouteBuilder builder) throws
Exception {
         context.addRoutes(builder);
         context.start();
         List<Route> answer = context.getRoutes();
@@ -67,7 +67,7 @@
             }
         };
 
-        List<Route> list = getRouteList(builder);
+        List<Route> list = getRouteListWithCurrentContext(builder);
         assertEquals("Number routes created" + list, 1, list.size());
         for (Route route : list) {
             Endpoint key = route.getEndpoint();
@@ -92,7 +92,7 @@
             }
         };
 
-        List<Route> list = getRouteList(builder);
+        List<Route> list = getRouteListWithCurrentContext(builder);
         assertEquals("Number routes created" + list, 2, list.size());
         for (Route route : list) {
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java?rev=773199&r1=773198&r2=773199&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java Sat
May  9 10:58:36 2009
@@ -57,15 +57,6 @@
         return ctx;
     }
 
-    protected List<Route> getRouteList(RouteBuilder builder) throws Exception {
-        CamelContext context = createCamelContext();
-        context.addRoutes(builder);
-        context.start();
-        List<Route> answer = context.getRoutes();
-        context.stop();
-        return answer;
-    }
-
     protected List<Route> buildSimpleRoute() throws Exception {
         // START SNIPPET: e1
         RouteBuilder builder = new RouteBuilder() {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java?rev=773199&r1=773198&r2=773199&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java Sat
May  9 10:58:36 2009
@@ -23,8 +23,8 @@
 import java.util.GregorianCalendar;
 
 import org.apache.camel.Exchange;
-import org.apache.camel.LanguageTestSupport;
 import org.apache.camel.ExpressionIllegalSyntaxException;
+import org.apache.camel.LanguageTestSupport;
 import org.apache.camel.component.file.FileConsumer;
 import org.apache.camel.component.file.FileEndpoint;
 import org.apache.camel.component.file.GenericFile;

Modified: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java?rev=773199&r1=773198&r2=773199&view=diff
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
(original)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/CamelTestSupport.java
Sat May  9 10:58:36 2009
@@ -42,6 +42,8 @@
 import org.apache.camel.spi.Language;
 import org.apache.camel.spring.CamelBeanPostProcessor;
 import org.apache.camel.util.CamelContextHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * A useful base class which creates a {@link org.apache.camel.CamelContext} with some routes
@@ -49,7 +51,7 @@
  *
  * @version $Revision$
  */
-public abstract class CamelTestSupport extends TestSupport {
+public abstract class CamelTestSupport extends TestSupport {    
     protected CamelContext context;
     protected ProducerTemplate template;
     private boolean useRouteBuilder = true;

Modified: camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/TestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/TestSupport.java?rev=773199&r1=773198&r2=773199&view=diff
==============================================================================
--- camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/TestSupport.java
(original)
+++ camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/TestSupport.java
Sat May  9 10:58:36 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.test;
 
 import java.io.File;
+import java.util.Collection;
 import java.util.List;
 
 import junit.framework.TestCase;
@@ -47,23 +48,30 @@
  * @version $Revision$
  */
 public abstract class TestSupport extends TestCase {
-
-    protected transient Log log = LogFactory.getLog(getClass());
-
+    private static final Log LOG = LogFactory.getLog(TestSupport.class);    
+    protected transient Log log = LogFactory.getLog(getClass());    
+    
     // Builder methods for expressions used when testing
     // -------------------------------------------------------------------------
 
     /**
      * Returns a value builder for the given header
      */
-    public ValueBuilder header(String name) {
+    public static ValueBuilder header(String name) {
         return Builder.header(name);
     }
 
     /**
+     * Returns a value builder for the given property
+     */
+    public static ValueBuilder property(String name) {
+        return Builder.property(name);
+    }    
+    
+    /**
      * Returns a predicate and value builder for the inbound body on an exchange
      */
-    public ValueBuilder body() {
+    public static ValueBuilder body() {
         return Builder.body();
     }
 
@@ -71,7 +79,7 @@
      * Returns a predicate and value builder for the inbound message body as a
      * specific type
      */
-    public <T> ValueBuilder bodyAs(Class<T> type) {
+    public static <T> ValueBuilder bodyAs(Class<T> type) {
         return Builder.bodyAs(type);
     }
 
@@ -79,7 +87,7 @@
      * Returns a predicate and value builder for the outbound body on an
      * exchange
      */
-    public ValueBuilder outBody() {
+    public static ValueBuilder outBody() {
         return Builder.outBody();
     }
 
@@ -87,7 +95,7 @@
      * Returns a predicate and value builder for the outbound message body as a
      * specific type
      */
-    public <T> ValueBuilder outBodyAs(Class<T> type) {
+    public static <T> ValueBuilder outBodyAs(Class<T> type) {
         return Builder.outBodyAs(type);
     }
 
@@ -95,7 +103,7 @@
      * Returns a predicate and value builder for the fault body on an
      * exchange
      */
-    public ValueBuilder faultBody() {
+    public static ValueBuilder faultBody() {
         return Builder.faultBody();
     }
 
@@ -103,35 +111,35 @@
      * Returns a predicate and value builder for the fault message body as a
      * specific type
      */
-    public <T> ValueBuilder faultBodyAs(Class<T> type) {
+    public static <T> ValueBuilder faultBodyAs(Class<T> type) {
         return Builder.faultBodyAs(type);
     }
 
     /**
      * Returns a value builder for the given system property
      */
-    public ValueBuilder systemProperty(String name) {
+    public static ValueBuilder systemProperty(String name) {
         return Builder.systemProperty(name);
     }
 
     /**
      * Returns a value builder for the given system property
      */
-    public ValueBuilder systemProperty(String name, String defaultValue) {
+    public static ValueBuilder systemProperty(String name, String defaultValue) {
         return Builder.systemProperty(name, defaultValue);
     }
 
     // Assertions
     // -----------------------------------------------------------------------
 
-    protected <T> T assertIsInstanceOf(Class<T> expectedType, Object value) {
+    public static <T> T assertIsInstanceOf(Class<T> expectedType, Object value)
{
         assertNotNull("Expected an instance of type: " + expectedType.getName() + " but was
null", value);
         assertTrue("object should be a " + expectedType.getName() + " but was: " + value
+ " with type: "
                    + value.getClass().getName(), expectedType.isInstance(value));
         return expectedType.cast(value);
     }
 
-    protected void assertEndpointUri(Endpoint endpoint, String uri) {
+    public static void assertEndpointUri(Endpoint endpoint, String uri) {
         assertNotNull("Endpoint is null when expecting endpoint for: " + uri, endpoint);
         assertEquals("Endoint uri for: " + endpoint, uri, endpoint.getEndpointUri());
     }
@@ -139,14 +147,14 @@
     /**
      * Asserts the In message on the exchange contains the expected value
      */
-    protected Object assertInMessageHeader(Exchange exchange, String name, Object expected)
{
+    public static Object assertInMessageHeader(Exchange exchange, String name, Object expected)
{
         return assertMessageHeader(exchange.getIn(), name, expected);
     }
 
     /**
      * Asserts the Out message on the exchange contains the expected value
      */
-    protected Object assertOutMessageHeader(Exchange exchange, String name, Object expected)
{
+    public static Object assertOutMessageHeader(Exchange exchange, String name, Object expected)
{
         return assertMessageHeader(exchange.getOut(), name, expected);
     }
 
@@ -155,9 +163,9 @@
      *
      * @param exchange the exchange which should have an OUT message
      * @param expected the expected value of the OUT message
-     * @throws org.apache.camel.InvalidPayloadException is thrown if the payload is not the
expected class type
+     * @throws InvalidPayloadException is thrown if the payload is not the expected class
type
      */
-    protected void assertInMessageBodyEquals(Exchange exchange, Object expected) throws InvalidPayloadException
{
+    public static void assertInMessageBodyEquals(Exchange exchange, Object expected) throws
InvalidPayloadException {
         assertNotNull("Should have a response exchange!", exchange);
 
         Object actual;
@@ -169,7 +177,7 @@
         }
         assertEquals("in body of: " + exchange, expected, actual);
 
-        log.debug("Received response: " + exchange + " with in: " + exchange.getIn());
+        LOG.debug("Received response: " + exchange + " with in: " + exchange.getIn());
     }
 
     /**
@@ -177,9 +185,9 @@
      *
      * @param exchange the exchange which should have an OUT message
      * @param expected the expected value of the OUT message
-     * @throws org.apache.camel.InvalidPayloadException is thrown if the payload is not the
expected class type
+     * @throws InvalidPayloadException is thrown if the payload is not the expected class
type
      */
-    protected void assertOutMessageBodyEquals(Exchange exchange, Object expected) throws
InvalidPayloadException {
+    public static void assertOutMessageBodyEquals(Exchange exchange, Object expected) throws
InvalidPayloadException {
         assertNotNull("Should have a response exchange!", exchange);
 
         Object actual;
@@ -191,10 +199,10 @@
         }
         assertEquals("output body of: " + exchange, expected, actual);
 
-        log.debug("Received response: " + exchange + " with out: " + exchange.getOut());
+        LOG.debug("Received response: " + exchange + " with out: " + exchange.getOut());
     }
 
-    protected Object assertMessageHeader(Message message, String name, Object expected) {
+    public static Object assertMessageHeader(Message message, String name, Object expected)
{
         Object value = message.getHeader(name);
         assertEquals("Header: " + name + " on Message: " + message, expected, value);
         return value;
@@ -203,15 +211,15 @@
     /**
      * Asserts that the given expression when evaluated returns the given answer
      */
-    protected Object assertExpression(Expression expression, Exchange exchange, Object expected)
{
-        Object value = expression.evaluate(exchange, Object.class);
-
-        // lets try convert to the type of the expected
+    public static Object assertExpression(Expression expression, Exchange exchange, Object
expected) {
+        Object value;
         if (expected != null) {
-            value = ExchangeHelper.convertToType(exchange, expected.getClass(), value);
+            value = expression.evaluate(exchange, expected.getClass());
+        } else {
+            value = expression.evaluate(exchange, Object.class);
         }
 
-        log.debug("Evaluated expression: " + expression + " on exchange: " + exchange + "
result: " + value);
+        LOG.debug("Evaluated expression: " + expression + " on exchange: " + exchange + "
result: " + value);
 
         assertEquals("Expression: " + expression + " on Exchange: " + exchange, expected,
value);
         return value;
@@ -220,18 +228,18 @@
     /**
      * Asserts that the predicate returns the expected value on the exchange
      */
-    protected void assertPredicateMatches(Predicate predicate, Exchange exchange) {
+    public static void assertPredicateMatches(Predicate predicate, Exchange exchange) {
         assertPredicate(predicate, exchange, true);
     }
 
     /**
      * Asserts that the predicate returns the expected value on the exchange
      */
-    protected void assertPredicateDoesNotMatch(Predicate predicate, Exchange exchange) {
+    public static void assertPredicateDoesNotMatch(Predicate predicate, Exchange exchange)
{
         try {
-            PredicateAssertHelper.assertMatches(predicate, "Predicate should match", exchange);
+            PredicateAssertHelper.assertMatches(predicate, "Predicate should match: ", exchange);
         } catch (AssertionError e) {
-            log.debug("Caught expected assertion error: " + e);
+            LOG.debug("Caught expected assertion error: " + e);
         }
         assertPredicate(predicate, exchange, false);
     }
@@ -239,13 +247,13 @@
     /**
      * Asserts that the predicate returns the expected value on the exchange
      */
-    protected boolean assertPredicate(Predicate predicate, Exchange exchange, boolean expected)
{
+    public static boolean assertPredicate(final Predicate predicate, Exchange exchange, boolean
expected) {
         if (expected) {
-            PredicateAssertHelper.assertMatches(predicate, "Predicate failed", exchange);
+            PredicateAssertHelper.assertMatches(predicate, "Predicate failed: ", exchange);
         }
         boolean value = predicate.matches(exchange);
 
-        log.debug("Evaluated predicate: " + predicate + " on exchange: " + exchange + " result:
" + value);
+        LOG.debug("Evaluated predicate: " + predicate + " on exchange: " + exchange + " result:
" + value);
 
         assertEquals("Predicate: " + predicate + " on Exchange: " + exchange, expected, value);
         return value;
@@ -254,7 +262,7 @@
     /**
      * Resolves an endpoint and asserts that it is found
      */
-    protected Endpoint resolveMandatoryEndpoint(CamelContext context, String uri) {
+    public static Endpoint resolveMandatoryEndpoint(CamelContext context, String uri) {
         Endpoint endpoint = context.getEndpoint(uri);
 
         assertNotNull("No endpoint found for URI: " + uri, endpoint);
@@ -265,7 +273,7 @@
     /**
      * Resolves an endpoint and asserts that it is found
      */
-    protected <T extends Endpoint> T resolveMandatoryEndpoint(CamelContext context,
String uri,
+    public static <T extends Endpoint> T resolveMandatoryEndpoint(CamelContext context,
String uri,
                                                               Class<T> endpointType)
{
         T endpoint = context.getEndpoint(uri, endpointType);
 
@@ -286,7 +294,7 @@
         return exchange;
     }
 
-    protected <T> T assertOneElement(List<T> list) {
+    public static <T> T assertOneElement(List<T> list) {
         assertEquals("Size of list should be 1: " + list, 1, list.size());
         return list.get(0);
     }
@@ -294,15 +302,39 @@
     /**
      * Asserts that a list is of the given size
      */
-    protected <T> List<T> assertListSize(List<T> list, int size) {
-        assertEquals("List should be of size: " + size + " but is: " + list, size, list.size());
+    public static <T> List<T> assertListSize(List<T> list, int size) {
+        return assertListSize("List", list, size);
+    }
+
+    /**
+     * Asserts that a list is of the given size
+     */
+    public static <T> List<T> assertListSize(String message, List<T> list,
int size) {
+        assertEquals(message + " should be of size: "
+                + size + " but is: " + list, size, list.size());
+        return list;
+    }
+
+    /**
+     * Asserts that a list is of the given size
+     */
+    public static <T> Collection<T> assertCollectionSize(Collection<T>
list, int size) {
+        return assertCollectionSize("List", list, size);
+    }
+
+    /**
+     * Asserts that a list is of the given size
+     */
+    public static <T> Collection<T> assertCollectionSize(String message, Collection<T>
list, int size) {
+        assertEquals(message + " should be of size: "
+                + size + " but is: " + list, size, list.size());
         return list;
     }
 
     /**
      * A helper method to create a list of Route objects for a given route builder
      */
-    protected List<Route> getRouteList(RouteBuilder builder) throws Exception {
+    public static List<Route> getRouteList(RouteBuilder builder) throws Exception {
         CamelContext context = new DefaultCamelContext();
         context.addRoutes(builder);
         context.start();
@@ -317,7 +349,7 @@
      * @param text the text to compare
      * @param containedText the text which must be contained inside the other text parameter
      */
-    protected void assertStringContains(String text, String containedText) {
+    public static void assertStringContains(String text, String containedText) {
         assertNotNull("Text should not be null!", text);
         assertTrue("Text: " + text + " does not contain: " + containedText, text.contains(containedText));
     }
@@ -326,7 +358,7 @@
      * If a processor is wrapped with a bunch of DelegateProcessor or DelegateAsyncProcessor
objects
      * this call will drill through them and return the wrapped Processor.
      */
-    protected Processor unwrap(Processor processor) {
+    public static Processor unwrap(Processor processor) {
         while (true) {
             if (processor instanceof DelegateProcessor) {
                 processor = ((DelegateProcessor)processor).getProcessor();
@@ -342,7 +374,7 @@
      * <p/>
      * Returns null if no channel is found.
      */
-    protected Channel unwrapChannel(Processor processor) {
+    public static Channel unwrapChannel(Processor processor) {
         while (true) {
             if (processor instanceof Channel) {
                 return (Channel) processor;
@@ -412,4 +444,4 @@
         }
     }
 
-}
\ No newline at end of file
+}



Mime
View raw message