camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1050325 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/language/simple/SimpleLanguage.java test/java/org/apache/camel/language/FileLanguageTest.java
Date Fri, 17 Dec 2010 09:20:29 GMT
Author: davsclaus
Date: Fri Dec 17 09:20:27 2010
New Revision: 1050325

URL: http://svn.apache.org/viewvc?rev=1050325&view=rev
Log:
File language should throw invalid expression if could not resolve, for example misspelt syntax

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java?rev=1050325&r1=1050324&r2=1050325&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
Fri Dec 17 09:20:27 2010
@@ -311,7 +311,7 @@ public class SimpleLanguage extends Simp
         }
     }
     
-    public Expression createSimpleFileExpression(String remainder) {
+    protected Expression createSimpleFileExpression(String remainder) {
         if (ObjectHelper.equal(remainder, "name")) {
             return ExpressionBuilder.fileNameExpression();
         } else if (ObjectHelper.equal(remainder, "name.noext")) {
@@ -337,7 +337,7 @@ public class SimpleLanguage extends Simp
         } else if (ObjectHelper.equal(remainder, "modified")) {
             return ExpressionBuilder.fileLastModifiedExpression();
         }
-        return null;
+        throw new ExpressionIllegalSyntaxException("File language syntax: " + remainder);
     }
 
     public boolean isSingleton() {

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=1050325&r1=1050324&r2=1050325&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 Fri
Dec 17 09:20:27 2010
@@ -59,6 +59,16 @@ public class FileLanguageTest extends La
         assertExpression("${id}.bak", exchange.getIn().getMessageId() + ".bak");
     }
 
+    public void testInvalidSyntax() throws Exception {
+        assertExpression("${file:onlyname}", file.getName());
+        try {
+            assertExpression("${file:onlyName}", file.getName());
+            fail("Should have thrown exception");
+        } catch (ExpressionIllegalSyntaxException e) {
+            assertEquals("Illegal syntax: File language syntax: onlyName", e.getMessage());
+        }
+    }
+
     public void testFile() throws Exception {
         assertExpression("${file:ext}", "txt");
         assertExpression("${file:name.ext}", "txt");



Mime
View raw message