camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r984295 - in /camel/trunk/tests/camel-itest-osgi: pom.xml src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java
Date Wed, 11 Aug 2010 03:33:42 GMT
Author: ningjiang
Date: Wed Aug 11 03:33:41 2010
New Revision: 984295

URL: http://svn.apache.org/viewvc?rev=984295&view=rev
Log:
CAMEL-3031 CAMEL-3040 added OSGi integration tests,also fixed the OsgiSpringTestSupport issue


Modified:
    camel/trunk/tests/camel-itest-osgi/pom.xml
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java
    camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java

Modified: camel/trunk/tests/camel-itest-osgi/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/pom.xml?rev=984295&r1=984294&r2=984295&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/pom.xml (original)
+++ camel/trunk/tests/camel-itest-osgi/pom.xml Wed Aug 11 03:33:41 2010
@@ -122,6 +122,24 @@
     <dependency>
       <groupId>org.springframework.osgi</groupId>
       <artifactId>spring-osgi-core</artifactId>
+      <exclusions>
+      	<exclusion>
+      		<groupId>org.springframework</groupId>
+      		<artifactId>org.springframework.aop</artifactId>
+      	</exclusion>
+      	<exclusion>
+      		<groupId>org.springframework</groupId>
+      		<artifactId>org.springframework.core</artifactId>
+      	</exclusion>
+      	<exclusion>
+      		<groupId>org.springframework</groupId>
+      		<artifactId>org.springframework.beans</artifactId>
+      	</exclusion>
+      	<exclusion>
+      		<groupId>org.springframework</groupId>
+      		<artifactId>org.springframework.context</artifactId>
+      	</exclusion>
+      </exclusions>
       <scope>test</scope>
     </dependency>
     <dependency>

Modified: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java?rev=984295&r1=984294&r2=984295&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java
(original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationSpringTestSupport.java
Wed Aug 11 03:33:41 2010
@@ -19,8 +19,6 @@ package org.apache.camel.itest.osgi;
 import org.apache.camel.CamelContext;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spring.SpringCamelContext;
-import org.junit.After;
-import org.junit.Before;
 import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
 
 public abstract class OSGiIntegrationSpringTestSupport extends OSGiIntegrationTestSupport
{
@@ -28,36 +26,16 @@ public abstract class OSGiIntegrationSpr
     protected OsgiBundleXmlApplicationContext applicationContext;
 
     protected abstract OsgiBundleXmlApplicationContext createApplicationContext();
-
-    @Before
-    public void setUp() throws Exception {
-        applicationContext = createApplicationContext();
-        assertNotNull("Should have created a valid spring context", applicationContext);
-        super.setUp();        
-    }
-
-    @After
-    public void tearDown() {
-        try {
-            super.tearDown();
-            if (applicationContext != null) {                
-                if (applicationContext.isActive()) {
-                    applicationContext.destroy();
-                }
-                applicationContext = null;
-            }
-        } catch (Exception exception) {
-            // Don't throw the exception in the tearDown method            
-        }
-    }
     
     @Override
     protected CamelContext createCamelContext() throws Exception {
+        applicationContext = createApplicationContext();        
+        assertNotNull("Should have created a valid spring context", applicationContext);
         applicationContext.setBundleContext(bundleContext);
         applicationContext.refresh();
         String[] names = applicationContext.getBeanNamesForType(SpringCamelContext.class);
         if (names.length == 1) {
-            return applicationContext.getBean(names[0], SpringCamelContext.class);
+            return (SpringCamelContext)applicationContext.getBean(names[0], SpringCamelContext.class);
         } else {
             throw new RuntimeCamelException("can't create a right camel context from the
application context"); 
         }

Modified: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java?rev=984295&r1=984294&r2=984295&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java
(original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/OSGiIntegrationTest.java
Wed Aug 11 03:33:41 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.itest.osgi;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.Test;
@@ -45,5 +46,16 @@ public class OSGiIntegrationTest extends
         template.sendBody("seda:foo", "Hello World");
         assertMockEndpointsSatisfied();        
     }
+    
+    @Test
+    public void testCamelContextName() throws Exception {
+        // should get the context name here
+        assertTrue("Get the wrong camel context name.", context.getName().indexOf("-1") >
0);
+        assertTrue("Get the wrong camel context name.", context.getName().indexOf("camel-1")
< 0);
+        
+        CamelContext context2 = createCamelContext();
+        assertTrue("Get the wrong camel context name.", context2.getName().indexOf("-2")
> 0);
+        assertTrue("Get the wrong camel context name.", context2.getName().indexOf("camel-2")
< 0);
+    }
    
 }
\ No newline at end of file



Mime
View raw message