You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/08/08 10:12:45 UTC

svn commit: r802317 - in /camel/trunk/examples: camel-example-cxf/ camel-example-loan-broker/ camel-example-pojo-messaging/ camel-example-pojo-messaging/src/main/resources/META-INF/spring/ camel-example-pojo-messaging/src/test/ camel-example-pojo-messa...

Author: ningjiang
Date: Sat Aug  8 08:12:44 2009
New Revision: 802317

URL: http://svn.apache.org/viewvc?rev=802317&view=rev
Log:
CAMEL-1892 Added Unit test of example-camel-pojo-messaging

Added:
    camel/trunk/examples/camel-example-pojo-messaging/src/test/
    camel/trunk/examples/camel-example-pojo-messaging/src/test/java/
    camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/
    camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/
    camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/
    camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/example/
    camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/example/pojo_messaging/
    camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/example/pojo_messaging/CamelContextTest.java   (with props)
    camel/trunk/examples/camel-example-pojo-messaging/src/test/resources/
    camel/trunk/examples/camel-example-pojo-messaging/src/test/resources/log4j.properties   (with props)
Modified:
    camel/trunk/examples/camel-example-cxf/pom.xml
    camel/trunk/examples/camel-example-loan-broker/pom.xml
    camel/trunk/examples/camel-example-pojo-messaging/pom.xml
    camel/trunk/examples/camel-example-pojo-messaging/src/main/resources/META-INF/spring/camel-context.xml

Modified: camel/trunk/examples/camel-example-cxf/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/pom.xml?rev=802317&r1=802316&r2=802317&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf/pom.xml (original)
+++ camel/trunk/examples/camel-example-cxf/pom.xml Sat Aug  8 08:12:44 2009
@@ -93,6 +93,7 @@
     <dependency>
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-test</artifactId>
+      <scope>test</scope>
     </dependency>
 
   </dependencies>

Modified: camel/trunk/examples/camel-example-loan-broker/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/pom.xml?rev=802317&r1=802316&r2=802317&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-loan-broker/pom.xml (original)
+++ camel/trunk/examples/camel-example-loan-broker/pom.xml Sat Aug  8 08:12:44 2009
@@ -61,12 +61,6 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
-    
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-test</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
   <build>

Modified: camel/trunk/examples/camel-example-pojo-messaging/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-pojo-messaging/pom.xml?rev=802317&r1=802316&r2=802317&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-pojo-messaging/pom.xml (original)
+++ camel/trunk/examples/camel-example-pojo-messaging/pom.xml Sat Aug  8 08:12:44 2009
@@ -73,6 +73,11 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>

Modified: camel/trunk/examples/camel-example-pojo-messaging/src/main/resources/META-INF/spring/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-pojo-messaging/src/main/resources/META-INF/spring/camel-context.xml?rev=802317&r1=802316&r2=802317&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-pojo-messaging/src/main/resources/META-INF/spring/camel-context.xml (original)
+++ camel/trunk/examples/camel-example-pojo-messaging/src/main/resources/META-INF/spring/camel-context.xml Sat Aug  8 08:12:44 2009
@@ -29,7 +29,7 @@
   <!-- This creates an embedded ActiveMQ Broker -->
   <broker xmlns="http://activemq.apache.org/schema/core" useJmx="false" persistent="false">
     <transportConnectors>
-      <transportConnector uri="tcp://localhost:61616" />
+      <transportConnector uri="vm://localhost" />
     </transportConnectors>
   </broker>
 
@@ -37,7 +37,7 @@
        See http://camel.apache.org/activemq.html for more information.
   -->
   <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
-    <property name="brokerURL" value="failover:tcp://localhost:61616"/>
+    <property name="brokerURL" value="failover:vm://localhost"/>
   </bean>
   
   <!-- END SNIPPET: activemq -->

Added: camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/example/pojo_messaging/CamelContextTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/example/pojo_messaging/CamelContextTest.java?rev=802317&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/example/pojo_messaging/CamelContextTest.java (added)
+++ camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/example/pojo_messaging/CamelContextTest.java Sat Aug  8 08:12:44 2009
@@ -0,0 +1,79 @@
+/**
+ * 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.example.pojo_messaging;
+
+
+import java.io.File;
+
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class CamelContextTest extends CamelSpringTestSupport {
+    
+    protected int getExpectedRouteCount() {
+        return 0;
+    }
+    
+    protected void deleteLockFile() {
+        File file = new File("src/data/message1.xml.camelLock");
+        file.delete();
+        file = new File("src/data/message2.xml.camelLock");
+        file.delete();
+        file = new File("src/data/message3.xml.camelLock");
+        file.delete();
+    }
+    
+    @Before
+    public void setUp() throws Exception {
+        deleteDirectory("target/messages");
+        // delete the lock file
+        deleteLockFile();
+        super.setUp();
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+        super.tearDown();
+        deleteLockFile();
+    }
+    
+    @Test
+    public void testCheckFiles() throws Exception {
+        Thread.sleep(5000);
+       
+        File file = new File("target/messages/emea/hr_pickup");
+        file = file.getAbsoluteFile();
+        assertTrue("The pickup folder should exists", file.exists());
+        assertEquals("There should be 1 dumped files", 1, file.list().length);
+        file = new File("target/messages/amer/hr_pickup");
+        file = file.getAbsoluteFile();
+        assertTrue("The pickup folder should exists", file.exists());
+        assertEquals("There should be 2 dumped files", 2, file.list().length);
+        
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        
+        return new ClassPathXmlApplicationContext(new String[] {"/META-INF/spring/camel-context.xml"});
+    }
+
+}

Propchange: camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/example/pojo_messaging/CamelContextTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/examples/camel-example-pojo-messaging/src/test/java/org/apache/camel/example/pojo_messaging/CamelContextTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/examples/camel-example-pojo-messaging/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-pojo-messaging/src/test/resources/log4j.properties?rev=802317&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-pojo-messaging/src/test/resources/log4j.properties (added)
+++ camel/trunk/examples/camel-example-pojo-messaging/src/test/resources/log4j.properties Sat Aug  8 08:12:44 2009
@@ -0,0 +1,38 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=INFO, file
+
+log4j.logger.org.apache.activemq.spring=WARN
+#log4j.logger.org.apache.camel.component=TRACE
+log4j.logger.org.apache.camel.impl.converter=WARN
+log4j.logger.org.apache.camel.component.cxf=INFO
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+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-cxf-test.log
+log4j.appender.file.append=true

Propchange: camel/trunk/examples/camel-example-pojo-messaging/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/examples/camel-example-pojo-messaging/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/examples/camel-example-pojo-messaging/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain