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 2011/11/29 09:36:13 UTC

svn commit: r1207784 - /camel/trunk/examples/camel-example-osgi-rmi/src/test/java/org/apache/camel/example/osgi/RmiTest.java

Author: ningjiang
Date: Tue Nov 29 08:36:12 2011
New Revision: 1207784

URL: http://svn.apache.org/viewvc?rev=1207784&view=rev
Log:
Do some enhancement on camel-example-osgi-rmi to run the test without start the camel router

Modified:
    camel/trunk/examples/camel-example-osgi-rmi/src/test/java/org/apache/camel/example/osgi/RmiTest.java

Modified: camel/trunk/examples/camel-example-osgi-rmi/src/test/java/org/apache/camel/example/osgi/RmiTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-osgi-rmi/src/test/java/org/apache/camel/example/osgi/RmiTest.java?rev=1207784&r1=1207783&r2=1207784&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-osgi-rmi/src/test/java/org/apache/camel/example/osgi/RmiTest.java (original)
+++ camel/trunk/examples/camel-example-osgi-rmi/src/test/java/org/apache/camel/example/osgi/RmiTest.java Tue Nov 29 08:36:12 2011
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.example.osgi;
 
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.test.junit4.CamelSpringTestSupport;
 import org.junit.Test;
 import org.springframework.context.support.AbstractApplicationContext;
@@ -35,8 +38,20 @@ public class RmiTest extends CamelSpring
 
     @Test
     public void testRmi() throws Exception {
-        String out = template.requestBody("rmi://localhost:37541/helloServiceBean", "Camel", String.class);
-        assertEquals("Hello Camel", out);
+        // Create a new camel context to send the request so we can test the service which is deployed into a container
+        CamelContext camelContext = new DefaultCamelContext();
+        ProducerTemplate myTemplate = camelContext.createProducerTemplate();
+        myTemplate.start();
+        try {
+            String out = myTemplate.requestBody("rmi://localhost:37541/helloServiceBean", "Camel", String.class);
+            assertEquals("Hello Camel", out);
+        } finally {
+            if (myTemplate != null) {
+                template.stop();
+            }
+            camelContext.stop();
+        }
+        
     }
 
 }