camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r601971 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/component/file/FileEndpoint.java test/java/org/apache/camel/component/file/FileConfigureTest.java
Date Fri, 07 Dec 2007 03:31:23 GMT
Author: hadrian
Date: Thu Dec  6 19:31:22 2007
New Revision: 601971

URL: http://svn.apache.org/viewvc?rev=601971&view=rev
Log:
Patch for CAMEL-249.  Applied with thanks!

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java?rev=601971&r1=601970&r2=601971&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
Thu Dec  6 19:31:22 2007
@@ -109,8 +109,7 @@
      */
     public void configureMessage(File file, Message message) {
         message.setBody(file);
-        String path = file.getPath();
-        String relativePath = path.substring(path.length());
+        String relativePath = file.getPath().substring(getFile().getPath().length());
         if (relativePath.startsWith(File.separator) || relativePath.startsWith("/")) {
             relativePath = relativePath.substring(1);
         }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java?rev=601971&r1=601970&r2=601971&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
(original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConfigureTest.java
Thu Dec  6 19:31:22 2007
@@ -19,12 +19,15 @@
 import java.io.File;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultMessage;
 
 /**
  * @version $Revision: 1.1 $
  */
 public class FileConfigureTest extends ContextTestSupport {
     private static final String EXPECT_PATH = "target" + File.separator + "foo" + File.separator
+ "bar";
+    private static final String EXPECT_FILE = "some" + File.separator + "nested" + File.separator
+ "filename.txt";
 
     public void testUriConfigurations() throws Exception {
         assertFileEndpoint("file://target/foo/bar", EXPECT_PATH);
@@ -47,5 +50,10 @@
         File file = endpoint.getFile();
         String path = file.getPath();
         assertEquals("For uri: " + endpointUri + " the file is not equal", expectedPath,
path);
+        
+        File consumedFile = new File(expectedPath + (expectedPath.endsWith(File.separator)
? "" : File.separator) + EXPECT_FILE);
+        Message message = new DefaultMessage();
+        endpoint.configureMessage(consumedFile, message);
+        assertEquals(EXPECT_FILE, message.getHeader(FileComponent.HEADER_FILE_NAME));  
     }
 }



Mime
View raw message