Re: [mule-scm] [mule][24692] branches/mule-3.3.x/core/src: MULE-6340 Validator and UntilSuccesful do not support plan text values for ack expression

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [mule-scm] [mule][24692] branches/mule-3.3.x/core/src: MULE-6340 Validator and UntilSuccesful do not support plan text values for ack expression

Pablo Kraan
Hi Dan, looks like this revision breaks PatternFlowStateTestCase. Can you review it?

Pablo

On Sat, Jul 28, 2012 at 12:56 AM, <[hidden email]> wrote:

Diff

Modified: branches/mule-3.3.x/core/src/main/java/org/mule/construct/Validator.java (24691 => 24692)


--- branches/mule-3.3.x/core/src/main/java/org/mule/construct/Validator.java	2012-07-27 22:39:54 UTC (rev 24691)
+++ branches/mule-3.3.x/core/src/main/java/org/mule/construct/Validator.java	2012-07-28 03:56:23 UTC (rev 24692)
@@ -10,12 +10,9 @@
 
 package org.mule.construct;
 
-import java.util.Collections;
-
-import org.apache.commons.lang.Validate;
 import org.mule.MessageExchangePattern;
+import org.mule.RequestContext;
 import org.mule.VoidMuleEvent;
-import org.mule.RequestContext;
 import org.mule.api.ExceptionPayload;
 import org.mule.api.MuleContext;
 import org.mule.api.MuleEvent;
@@ -40,6 +37,10 @@
 import org.mule.routing.ChoiceRouter;
 import org.mule.util.StringUtils;
 
+import java.util.Collections;
+
+import org.apache.commons.lang.Validate;
+
 public class Validator extends AbstractConfigurationPattern
 {
     private final OutboundEndpoint outboundEndpoint;
@@ -166,7 +167,8 @@
 
     private void validateExpression(String expression) throws FlowConstructInvalidException
     {
-        if (!muleContext.getExpressionManager().isExpression(expression))
+        if (muleContext.getExpressionManager().isExpression(expression)
+            && muleContext.getExpressionManager().isValidExpression(expression))
         {
             throw new FlowConstructInvalidException(
                 MessageFactory.createStaticMessage("Invalid expression in Validator: " + expression), this);

Modified: branches/mule-3.3.x/core/src/main/java/org/mule/routing/UntilSuccessful.java (24691 => 24692)


--- branches/mule-3.3.x/core/src/main/java/org/mule/routing/UntilSuccessful.java	2012-07-27 22:39:54 UTC (rev 24691)
+++ branches/mule-3.3.x/core/src/main/java/org/mule/routing/UntilSuccessful.java	2012-07-28 03:56:23 UTC (rev 24692)
@@ -20,6 +20,7 @@
 import org.mule.api.MuleRuntimeException;
 import org.mule.api.endpoint.EndpointBuilder;
 import org.mule.api.endpoint.EndpointException;
+import org.mule.api.expression.InvalidExpressionException;
 import org.mule.api.lifecycle.InitialisationException;
 import org.mule.api.processor.MessageProcessor;
 import org.mule.api.retry.RetryCallback;
@@ -128,10 +129,17 @@
         }
         failureExpressionFilter.setMuleContext(muleContext);
 
-        if ((ackExpression != null) && (!muleContext.getExpressionManager().isExpression(ackExpression)))
+        if (ackExpression != null && muleContext.getExpressionManager().isExpression(ackExpression))
         {
-            throw new InitialisationException(MessageFactory.createStaticMessage("Invalid ackExpression: "
-                                                                                 + ackExpression), this);
+            try
+            {
+                muleContext.getExpressionManager().validateExpression(ackExpression);
+            }
+            catch (InvalidExpressionException iee)
+            {
+                throw new InitialisationException(
+                    MessageFactory.createStaticMessage("Invalid ackExpression: " + ackExpression), this);
+            }
         }
 
         String flowName = flowConstruct.getName();

Modified: branches/mule-3.3.x/core/src/test/java/org/mule/construct/ValidatorTestCase.java (24691 => 24692)


--- branches/mule-3.3.x/core/src/test/java/org/mule/construct/ValidatorTestCase.java	2012-07-27 22:39:54 UTC (rev 24691)
+++ branches/mule-3.3.x/core/src/test/java/org/mule/construct/ValidatorTestCase.java	2012-07-28 03:56:23 UTC (rev 24692)
@@ -10,6 +10,8 @@
 
 package org.mule.construct;
 
+import static org.junit.Assert.assertEquals;
+
 import org.mule.MessageExchangePattern;
 import org.mule.api.MuleEvent;
 import org.mule.api.endpoint.OutboundEndpoint;
@@ -21,8 +23,6 @@
 
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-
 public class ValidatorTestCase extends AbstractFlowConstuctTestCase
 {
     private Validator validator;
@@ -66,8 +66,8 @@
     {
         validator.initialise();
         validator.start();
-        final MuleEvent response = directInboundMessageSource.process(MuleTestUtils.getTestEvent(
-            "abc", muleContext));
+        final MuleEvent response = directInboundMessageSource.process(MuleTestUtils.getTestEvent("abc",
+            muleContext));
 
         assertEquals("BAD:abc", response.getMessageAsString());
     }
@@ -105,4 +105,18 @@
 
         assertEquals("ERROR:123", response.getMessageAsString());
     }
+
+    @Test
+    public void testPlainTextAckExpression() throws Exception
+    {
+        final OutboundEndpoint failingOutboundEndpoint = MuleTestUtils.getTestOutboundEndpoint(
+            MessageExchangePattern.REQUEST_RESPONSE, muleContext, "test://AlwaysFail", testConnector);
+
+        validator = new Validator("test-validator", muleContext, directInboundMessageSource,
+            failingOutboundEndpoint, new PayloadTypeFilter(Integer.class), "GOOD", "BAR", "ERROR");
+
+        validator.initialise();
+        validator.start();
+    }
+
 }

Modified: branches/mule-3.3.x/core/src/test/java/org/mule/routing/UntilSuccessfulTestCase.java (24691 => 24692)


--- branches/mule-3.3.x/core/src/test/java/org/mule/routing/UntilSuccessfulTestCase.java	2012-07-27 22:39:54 UTC (rev 24691)
+++ branches/mule-3.3.x/core/src/test/java/org/mule/routing/UntilSuccessfulTestCase.java	2012-07-28 03:56:23 UTC (rev 24692)
@@ -208,6 +208,14 @@
         untilSuccessful.start();
         ponderUntilEventProcessed(testEvent);
     }
+    
+    @Test
+    public void testPlainTextAckExpression() throws Exception
+    {
+        untilSuccessful.setAckExpression("ACK");
+        untilSuccessful.initialise();
+        untilSuccessful.start();
+    }
 
     private void ponderUntilEventProcessed(final MuleEvent testEvent)
         throws InterruptedException, MuleException

To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email