You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/08/28 14:06:36 UTC

git commit: CAMEL-6669: Added unit test

Updated Branches:
  refs/heads/master 96261c18f -> aaf91c5b6


CAMEL-6669: Added unit test


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/aaf91c5b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/aaf91c5b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/aaf91c5b

Branch: refs/heads/master
Commit: aaf91c5b6ae9540078662a5e50b805b9600497cb
Parents: 96261c1
Author: Claus Ibsen <da...@apache.org>
Authored: Wed Aug 28 14:06:21 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Wed Aug 28 14:06:21 2013 +0200

----------------------------------------------------------------------
 .../file/FilerProducerDoneFileNameTest.java     | 35 ++++++++++++++++++++
 1 file changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/aaf91c5b/camel-core/src/test/java/org/apache/camel/component/file/FilerProducerDoneFileNameTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FilerProducerDoneFileNameTest.java b/camel-core/src/test/java/org/apache/camel/component/file/FilerProducerDoneFileNameTest.java
index b5212ce..28e956e 100644
--- a/camel-core/src/test/java/org/apache/camel/component/file/FilerProducerDoneFileNameTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FilerProducerDoneFileNameTest.java
@@ -17,23 +17,46 @@
 package org.apache.camel.component.file;
 
 import java.io.File;
+import java.util.Properties;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExpressionIllegalSyntaxException;
+import org.apache.camel.component.properties.PropertiesComponent;
+import org.apache.camel.impl.JndiRegistry;
 
 /**
  * Unit test for writing done files
  */
 public class FilerProducerDoneFileNameTest extends ContextTestSupport {
 
+    private Properties myProp = new Properties();
+
     @Override
     protected void setUp() throws Exception {
         deleteDirectory("target/done");
         super.setUp();
     }
 
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("myProp", myProp);
+        return jndi;
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+
+        PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class);
+        pc.setLocation("ref:myProp");
+
+        return context;
+    }
+
     public void testProducerConstantDoneFileName() throws Exception {
         template.sendBodyAndHeader("file:target/done?doneFileName=done", "Hello World", Exchange.FILE_NAME, "hello.txt");
 
@@ -94,6 +117,18 @@ public class FilerProducerDoneFileNameTest extends ContextTestSupport {
         }
     }
 
+    public void testProducerPlaceholderPrefixDoneFileName() throws Exception {
+        myProp.put("myDir", "target/done");
+
+        template.sendBodyAndHeader("file:{{myDir}}?doneFileName=done-${file:name}", "Hello World", Exchange.FILE_NAME, "hello.txt");
+
+        File file = new File("target/done/hello.txt");
+        assertEquals("File should exists", true, file.exists());
+
+        File done = new File("target/done/done-hello.txt");
+        assertEquals("Done file should exists", true, done.exists());
+    }
+
     @Override
     public boolean isUseRouteBuilder() {
         return false;