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/ef6e305a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ef6e305a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ef6e305a

Branch: refs/heads/camel-2.12.x
Commit: ef6e305a07a911e54f3ceffb72b870edf41fcdbc
Parents: 9fd39ac
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Aug 28 14:06:21 2013 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Fri Aug 30 10:10:25 2013 +0200

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


http://git-wip-us.apache.org/repos/asf/camel/blob/ef6e305a/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;

Reply via email to