Claus, shouldn't you be on vacation? ;)

The method is used in the expression/predicate evaluation.

On Thu, Jul 23, 2009 at 12:22 PM, Claus Ibsen <claus.ib...@gmail.com> wrote:

> Hi
>
> Looks like this method
> - mostRecentExchange
>
> was added in patch but not used in code, e.g. can/should be deleted.
>
>
> On Thu, Jul 23, 2009 at 4:38 PM, <jans...@apache.org> wrote:
> > Author: janstey
> > Date: Thu Jul 23 14:38:52 2009
> > New Revision: 797087
> >
> > URL: http://svn.apache.org/viewvc?rev=797087&view=rev
> > Log:
> > CAMEL-1848 - add support to expect expressions/predicates on mock
> endpoint
> >
> > Modified:
> >
>  
> camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
> >
>  
> camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
> >
>  
> camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java
> >
>  
> camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
> >
> > Modified:
> camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
> > URL:
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java?rev=797087&r1=797086&r2=797087&view=diff
> >
> ==============================================================================
> > ---
> camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
> (original)
> > +++
> camel/trunk/camel-core/src/main/java/org/apache/camel/component/mock/MockEndpoint.java
> Thu Jul 23 14:38:52 2009
> > @@ -38,6 +38,7 @@
> >  import org.apache.camel.Exchange;
> >  import org.apache.camel.Expression;
> >  import org.apache.camel.Message;
> > +import org.apache.camel.Predicate;
> >  import org.apache.camel.Processor;
> >  import org.apache.camel.Producer;
> >  import org.apache.camel.builder.ExpressionClause;
> > @@ -319,12 +320,27 @@
> >             public void run() {
> >                 assertTrue("No header with name " + headerName + "
> found.", actualHeader != null);
> >
> > -                Object actualValue =
> getCamelContext().getTypeConverter().convertTo(actualHeader.getClass(),
> headerValue);
> > -                assertEquals("Header of message", actualValue,
> actualHeader);
> > +                Object actualValue;
> > +                if (actualHeader instanceof Expression) {
> > +                    actualValue =
> ((Expression)actualHeader).evaluate(mostRecentExchange(),
> headerValue.getClass());
> > +                } else if (actualHeader instanceof Predicate) {
> > +                    actualValue =
> ((Predicate)actualHeader).matches(mostRecentExchange());
> > +                } else {
> > +                    actualValue =
> getCamelContext().getTypeConverter().convertTo(headerValue.getClass(),
> actualHeader);
> > +                    assertTrue("There is no type conversion possible
> from " + actualHeader.getClass().getName()
> > +                            + " to " + headerValue.getClass().getName(),
> actualValue != null);
> > +                }
> > +                assertEquals("Header of message", headerValue,
> actualValue);
> >             }
> > +
> > +
> >         });
> >     }
> >
> > +    private Exchange mostRecentExchange() {
> > +        return receivedExchanges.get(receivedExchanges.size() - 1);
> > +    }
> > +
> >     /**
> >      * Adds an expectation that the given property name & value are
> received by this endpoint
> >      */
> >
> > Modified:
> camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
> > URL:
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java?rev=797087&r1=797086&r2=797087&view=diff
> >
> ==============================================================================
> > ---
> camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
> (original)
> > +++
> camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
> Thu Jul 23 14:38:52 2009
> > @@ -102,7 +102,7 @@
> >      */
> >     public void setBatchSize(int batchSize) {
> >         // setting batch size to 0 or negative is like disabling it, so
> we set it as the max value
> > -        // as the code logic is dependt on a batch size having 1..n
> value
> > +        // as the code logic is dependent on a batch size having 1..n
> value
> >         if (batchSize <= 0) {
> >             LOG.debug("Disabling batch size, will only be triggered by
> timeout");
> >             this.batchSize = Integer.MAX_VALUE;
> >
> > Modified:
> camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java
> > URL:
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java?rev=797087&r1=797086&r2=797087&view=diff
> >
> ==============================================================================
> > ---
> camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java
> (original)
> > +++
> camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/DefaultAggregationCollection.java
> Thu Jul 23 14:38:52 2009
> > @@ -72,7 +72,7 @@
> >             LOG.trace("Evaluated expression: " + correlationExpression +
> " as correlation key: " + correlationKey);
> >         }
> >
> > -        // TODO: correlationKey evalutated to null should be skipped by
> default
> > +        // TODO: correlationKey evaluated to null should be skipped by
> default
> >
> >         Exchange oldExchange = aggregated.get(correlationKey);
> >         Exchange newExchange = exchange;
> >
> > Modified:
> camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
> > URL:
> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java?rev=797087&r1=797086&r2=797087&view=diff
> >
> ==============================================================================
> > ---
> camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
> (original)
> > +++
> camel/trunk/camel-core/src/test/java/org/apache/camel/component/mock/MockEndpointTest.java
> Thu Jul 23 14:38:52 2009
> > @@ -21,7 +21,9 @@
> >
> >  import org.apache.camel.ContextTestSupport;
> >  import org.apache.camel.builder.RouteBuilder;
> > +import org.apache.camel.builder.xml.XPathBuilder;
> >  import org.apache.camel.impl.JndiRegistry;
> > +import org.apache.camel.model.language.XPathExpression;
> >
> >  /**
> >  * @version $Revision$
> > @@ -176,6 +178,15 @@
> >         resultEndpoint.assertIsNotSatisfied();
> >     }
> >
> > +    public void testExpressionExpectationOfHeader() throws
> InterruptedException {
> > +        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
> > +        resultEndpoint.reset();
> > +
> > +        resultEndpoint.expectedHeaderReceived("number", 123);
> > +        template.sendBodyAndHeader("direct:a",
> "<foo><id>123</id></foo>", "number", XPathBuilder.xpath("/foo/id",
> Integer.class));
> > +        resultEndpoint.assertIsSatisfied();
> > +    }
> > +
> >     public void testAscending() throws Exception {
> >         MockEndpoint mock = getMockEndpoint("mock:result");
> >         mock.expectsAscending().body();
> > @@ -185,7 +196,7 @@
> >         assertMockEndpointsSatisfied();
> >     }
> >
> > -    public void testAscendingFaied() throws Exception {
> > +    public void testAscendingFailed() throws Exception {
> >         MockEndpoint mock = getMockEndpoint("mock:result");
> >         mock.expectsAscending().body();
> >         mock.expectsAscending().header("counter");
> >
> >
> >
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>



-- 
Cheers,
Jon

http://janstey.blogspot.com/

Reply via email to