camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: svn commit: r745589 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/builder/ test/java/org/apache/camel/processor/
Date Thu, 19 Feb 2009 05:12:58 GMT
Hi

Shouldn't the unit test convert multiple occurrence? eg add "Foo is
Foo" so we test that it replace both foo's?

On Wed, Feb 18, 2009 at 7:15 PM,  <janstey@apache.org> wrote:
> Author: janstey
> Date: Wed Feb 18 18:15:36 2009
> New Revision: 745589
>
> URL: http://svn.apache.org/viewvc?rev=745589&view=rev
> Log:
> CAMEL-1357 - added regexReplaceAll to builder support
>
> Added:
>    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RegExRouteTest.java
  (with props)
> Modified:
>    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java
>    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
>    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
>
> Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java
> URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java?rev=745589&r1=745588&r2=745589&view=diff
> ==============================================================================
> --- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java (original)
> +++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java Wed Feb
18 18:15:36 2009
> @@ -158,4 +158,22 @@
>         Expression expression = ExpressionBuilder.exchangeExceptionMessageExpression();
>         return new ValueBuilder(expression);
>     }
> +
> +    /**
> +     * Returns an expression that replaces all occurrences of the regular
> +     * expression with the given replacement
> +     */
> +    public static ValueBuilder regexReplaceAll(Expression content, String regex, String
replacement) {
> +        Expression newExp = ExpressionBuilder.regexReplaceAll(content, regex, replacement);
> +        return new ValueBuilder(newExp);
> +    }
> +
> +    /**
> +     * Returns an expression that replaces all occurrences of the regular
> +     * expression with the given replacement
> +     */
> +    public static ValueBuilder regexReplaceAll(Expression content, String regex, Expression
replacement) {
> +        Expression newExp = ExpressionBuilder.regexReplaceAll(content, regex, replacement);
> +        return new ValueBuilder(newExp);
> +    }
>  }
>
> Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
> URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java?rev=745589&r1=745588&r2=745589&view=diff
> ==============================================================================
> --- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
(original)
> +++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/BuilderSupport.java
Wed Feb 18 18:15:36 2009
> @@ -22,6 +22,7 @@
>
>  import org.apache.camel.CamelContext;
>  import org.apache.camel.Endpoint;
> +import org.apache.camel.Expression;
>  import org.apache.camel.NoSuchEndpointException;
>  import org.apache.camel.model.LoggingLevel;
>  import org.apache.camel.processor.SendProcessor;
> @@ -149,6 +150,22 @@
>     }
>
>     /**
> +     * Returns an expression value builder that replaces all occurrences of the
> +     * regular expression with the given replacement
> +     */
> +    public ValueBuilder regexReplaceAll(Expression content, String regex, String replacement)
{
> +        return Builder.regexReplaceAll(content, regex, replacement);
> +    }
> +
> +    /**
> +     * Returns an expression value builder that replaces all occurrences of the
> +     * regular expression with the given replacement
> +     */
> +    public ValueBuilder regexReplaceAll(Expression content, String regex, Expression
replacement) {
> +        return Builder.regexReplaceAll(content, regex, replacement);
> +    }
> +
> +    /**
>      * Returns a <a href="http://camel.apache.org/bean-language.html">bean expression</a>
>      * value builder
>      *
>
> Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
> URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java?rev=745589&r1=745588&r2=745589&view=diff
> ==============================================================================
> --- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java (original)
> +++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java Wed
Feb 18 18:15:36 2009
> @@ -165,7 +165,7 @@
>     }
>
>     /**
> -     * Replaces all occurrencies of the regular expression with the given
> +     * Replaces all occurrences of the regular expression with the given
>      * replacement
>      */
>     public ValueBuilder regexReplaceAll(String regex, String replacement) {
> @@ -174,7 +174,7 @@
>     }
>
>     /**
> -     * Replaces all occurrencies of the regular expression with the given
> +     * Replaces all occurrences of the regular expression with the given
>      * replacement
>      */
>     public ValueBuilder regexReplaceAll(String regex, Expression replacement) {
>
> Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RegExRouteTest.java
> URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RegExRouteTest.java?rev=745589&view=auto
> ==============================================================================
> --- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RegExRouteTest.java
(added)
> +++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RegExRouteTest.java
Wed Feb 18 18:15:36 2009
> @@ -0,0 +1,44 @@
> +/**
> + * 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.processor;
> +
> +import org.apache.camel.ContextTestSupport;
> +import org.apache.camel.builder.RouteBuilder;
> +import org.apache.camel.component.mock.MockEndpoint;
> +
> +public class RegExRouteTest extends ContextTestSupport {
> +    String orignalBody = "Foo";
> +    String replacedBody = "Bar";
> +
> +    public void testSendingMessage() throws Exception {
> +        MockEndpoint result = getMockEndpoint("mock:result");
> +
> +        result.expectedBodiesReceived(replacedBody);
> +
> +        template.sendBody("direct:start", orignalBody);
> +
> +        result.assertIsSatisfied();
> +    }
> +
> +    protected RouteBuilder createRouteBuilder() {
> +        return new RouteBuilder() {
> +            public void configure() {
> +                from("direct:start").setBody(regexReplaceAll(body(), "Foo", "Bar")).to("mock:result");
> +            }
> +        };
> +    }
> +  }
> \ No newline at end of file
>
> Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RegExRouteTest.java
> ------------------------------------------------------------------------------
>    svn:eol-style = native
>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Mime
View raw message