camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [2/2] git commit: Added an unit test for GoogleDriveFilesConverter
Date Tue, 09 Sep 2014 06:50:13 GMT
Added an unit test for GoogleDriveFilesConverter


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

Branch: refs/heads/master
Commit: 66a52403b9fd46dd687119775cf4a9dd9cbfc877
Parents: a1777c7
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Tue Sep 9 14:47:39 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Tue Sep 9 14:49:59 2014 +0800

----------------------------------------------------------------------
 .../services/org/apache/camel/TypeConverter     |  2 +-
 .../drive/GoogleDriveFilesConverterTest.java    | 57 ++++++++++++++++++++
 .../src/test/resources/log4j.properties         |  8 ++-
 3 files changed, 65 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/66a52403/components/camel-google-drive/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
b/components/camel-google-drive/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
index aaf5393..ec2888d 100644
--- a/components/camel-google-drive/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
+++ b/components/camel-google-drive/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
@@ -14,4 +14,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-org.apache.camel.component.google.drive
+org.apache.camel.component.google.drive.GoogleDriveFilesConverter

http://git-wip-us.apache.org/repos/asf/camel/blob/66a52403/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/GoogleDriveFilesConverterTest.java
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/GoogleDriveFilesConverterTest.java
b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/GoogleDriveFilesConverterTest.java
new file mode 100644
index 0000000..eb5b0db
--- /dev/null
+++ b/components/camel-google-drive/src/test/java/org/apache/camel/component/google/drive/GoogleDriveFilesConverterTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.google.drive;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class GoogleDriveFilesConverterTest extends CamelTestSupport {
+    
+    @Override
+    protected void doPreSetup() throws Exception {
+        deleteDirectory("target/file-test");
+    }
+        
+    @Test
+    public void converterTest() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        
+        template.sendBodyAndHeader("file://target/file-test/", "Hello World", Exchange.FILE_NAME,
"hello.txt");
+        
+        assertMockEndpointsSatisfied();
+        
+        Message result = mock.getExchanges().get(0).getIn();
+        assertTrue("We should get google file instance here", result.getBody() instanceof
com.google.api.services.drive.model.File);
+        
+    }
+    
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                
+                from("file://target/file-test?initialDelay=2000").convertBodyTo(com.google.api.services.drive.model.File.class).to("mock:result");
+            }
+        };
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/66a52403/components/camel-google-drive/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-google-drive/src/test/resources/log4j.properties b/components/camel-google-drive/src/test/resources/log4j.properties
index a937abd..a7831cd 100644
--- a/components/camel-google-drive/src/test/resources/log4j.properties
+++ b/components/camel-google-drive/src/test/resources/log4j.properties
@@ -17,7 +17,7 @@
 #
 # The logging properties used
 #
-log4j.rootLogger=INFO, out
+log4j.rootLogger=INFO, file
 
 # uncomment the following line to turn on Camel debugging
 #log4j.logger.org.apache.camel=DEBUG
@@ -28,3 +28,9 @@ log4j.appender.out.layout=org.apache.log4j.PatternLayout
 log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
 #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
 
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.file.file=target/camel-google-drive-test.log
+log4j.appender.file.append=true
\ No newline at end of file


Mime
View raw message