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 2009/01/24 15:05:37 UTC

svn commit: r737359 [2/2] - in /camel/trunk/camel-core/src: main/java/org/apache/camel/component/file/ main/java/org/apache/camel/component/file/strategy/ main/resources/META-INF/services/org/apache/camel/ test/java/org/apache/camel/component/file/

Modified: camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter?rev=737359&r1=737358&r2=737359&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter (original)
+++ camel/trunk/camel-core/src/main/resources/META-INF/services/org/apache/camel/TypeConverter Sat Jan 24 14:05:36 2009
@@ -15,4 +15,5 @@
 # limitations under the License.
 #
 
-org.apache.camel.converter
\ No newline at end of file
+org.apache.camel.converter
+org.apache.camel.component.file
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileConsumeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileConsumeTest.java?rev=737359&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileConsumeTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileConsumeTest.java Sat Jan 24 14:05:36 2009
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.HashMap;
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+/**
+ * Simple unit test to consume a new file
+ */
+public class NewFileConsumeTest extends ContextTestSupport {
+
+    private CountDownLatch latch = new CountDownLatch(1);
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    public void testNewFileConsumer() throws Exception {
+        deleteDirectory("target/consumefile");
+
+        NewFileComponent comp = new NewFileComponent();
+        comp.setCamelContext(context);
+
+        // create a file to consume
+        createDirectory("target/consumefile");
+        FileOutputStream fos = new FileOutputStream(new File("target/consumefile/hello.txt"));
+        fos.write("Hello World".getBytes());
+        fos.close();
+
+        Endpoint endpoint = comp.createEndpoint("newfile://target/consumefile", "target/consumefile", new HashMap());
+        Consumer consumer = endpoint.createConsumer(new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                assertNotNull(exchange);
+                String body = exchange.getIn().getBody(String.class);
+                assertEquals("Hello World", body);
+                latch.countDown();
+            }
+        });
+        consumer.start();
+        latch.await();
+
+        consumer.stop();
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileConsumeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileConsumeTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java?rev=737359&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java Sat Jan 24 14:05:36 2009
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.file;
+
+import java.io.File;
+import java.util.HashMap;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+/**
+ * Simple unit test to produce a new file
+ */
+public class NewFileProduceTest extends ContextTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    public void testNewFileProducer() throws Exception {
+        deleteDirectory("target/producefile");
+
+        NewFileComponent comp = new NewFileComponent();
+        comp.setCamelContext(context);
+
+        Endpoint endpoint = comp.createEndpoint("newfile://target/producefile", "target/producefile", new HashMap());
+        template.send(endpoint, new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "bye.txt");
+                exchange.getIn().setBody("Bye World");
+            }
+        });
+
+        File file = new File("target/producefile/bye.txt");
+        file = file.getAbsoluteFile();
+        assertTrue("The file should have been created", file.exists());
+    }
+
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/NewFileProduceTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date