Author: ningjiang
Date: Tue Oct 20 13:42:28 2009
New Revision: 827436
URL: http://svn.apache.org/viewvc?rev=827436&view=rev
Log:
MR-191 added more unit test on camel-osgi
Added:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiComponentResolverTest.java
(with props)
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ServiceRegistryTest.java
(contents, props changed)
- copied, changed from r826981,
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelContextFactoryTest.java
camel/trunk/components/camel-osgi/src/test/resources/org/
camel/trunk/components/camel-osgi/src/test/resources/org/apache/
camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/
camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/osgi/
camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/osgi/camelContext.xml
(with props)
Removed:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelContextFactoryTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundleContext.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=827436&r1=827435&r2=827436&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
Tue Oct 20 13:42:28 2009
@@ -410,7 +410,7 @@
exchange.setException(exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
Exception.class));
// and put failure endpoint back as well
exchange.setProperty(Exchange.FAILURE_ENDPOINT,
exchange.getProperty(Exchange.TO_ENDPOINT));
- }
+ }
return;
}
Modified:
camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java?rev=827436&r1=827435&r2=827436&view=diff
==============================================================================
---
camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
(original)
+++
camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
Tue Oct 20 13:42:28 2009
@@ -70,7 +70,7 @@
context.setLanguageResolver(new OsgiLanguageResolver());
addOsgiAnnotationTypeConverterLoader(context);
} else {
- // TODO: should we not thrown an excpetion to not allow it to
startup
+ // TODO: should we not thrown an exception to not allow it to
startup
LOG.warn("BundleContext not set, cannot run in OSGI container");
}
Modified:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundleContext.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundleContext.java?rev=827436&r1=827435&r2=827436&view=diff
==============================================================================
---
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundleContext.java
(original)
+++
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelMockBundleContext.java
Tue Oct 20 13:42:28 2009
@@ -24,8 +24,7 @@
public class CamelMockBundleContext extends MockBundleContext {
public Object getService(ServiceReference reference) {
- String[] classNames = (String[])
reference.getProperty(Constants.OBJECTCLASS);
- System.out.println("The class name is " + classNames[0]);
+ String[] classNames = (String[])
reference.getProperty(Constants.OBJECTCLASS);
if (classNames[0].equals("org.apache.camel.osgi.test.MyService")) {
return new MyService();
} else {
Added:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiComponentResolverTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiComponentResolverTest.java?rev=827436&view=auto
==============================================================================
---
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiComponentResolverTest.java
(added)
+++
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiComponentResolverTest.java
Tue Oct 20 13:42:28 2009
@@ -0,0 +1,41 @@
+/**
+ * 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.osgi;
+
+import java.io.IOException;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Component;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spi.Language;
+import org.junit.Test;
+import org.osgi.framework.BundleContext;
+
+public class OsgiComponentResolverTest extends CamelOsgiTestSupport {
+
+ @Test
+ public void testOsgiResolverFindLanguageTest() throws Exception {
+ BundleContext context = getActivator().getBundle().getBundleContext();
+ CamelContext camelContext = new DefaultCamelContext();
+ OsgiComponentResolver resolver = new OsgiComponentResolver();
+ Component component = resolver.resolveComponent("file_test",
camelContext);
+ assertNotNull("We should find file_test component", component);
+ assertTrue("We should get the file component here", component
instanceof FileComponent);
+ }
+
+}
Propchange:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiComponentResolverTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiComponentResolverTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Copied:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ServiceRegistryTest.java
(from r826981,
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelContextFactoryTest.java)
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ServiceRegistryTest.java?p2=camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ServiceRegistryTest.java&p1=camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelContextFactoryTest.java&r1=826981&r2=827436&rev=827436&view=diff
==============================================================================
---
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/CamelContextFactoryTest.java
(original)
+++
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ServiceRegistryTest.java
Tue Oct 20 13:42:28 2009
@@ -19,17 +19,45 @@
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.osgi.test.MyService;
import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
-public class CamelContextFactoryTest extends CamelOsgiTestSupport {
+public class ServiceRegistryTest extends CamelOsgiTestSupport {
@Test
- public void osigServiceRegistryTest() throws Exception {
+ public void camelContextFactoryServiceRegistryTest() throws Exception {
CamelContextFactory factory = new CamelContextFactory();
factory.setBundleContext(getBundleContext());
DefaultCamelContext context = factory.createContext();
context.start();
MyService myService =
context.getRegistry().lookup(MyService.class.getName(), MyService.class);
assertNotNull("MyService should not be null", myService);
+
+ Object service =
context.getRegistry().lookup(MyService.class.getName());
+ assertNotNull("MyService should not be null", myService);
+
+ service = context.getRegistry().lookupByType(MyService.class);
+ assertNotNull("MyService should not be null", myService);
+ context.stop();
+ }
+
+ @Test
+ public void camelContextFactoryBeanServiceRegistryTest() throws Exception {
+ CamelContextFactoryBean factoryBean = new CamelContextFactoryBean();
+ factoryBean.setBundleContext(getBundleContext());
+ ApplicationContext applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/osgi/camelContext.xml");
+ factoryBean.setApplicationContext(applicationContext);
+ DefaultCamelContext context = factoryBean.createContext();
+ context.start();
+ MyService myService =
context.getRegistry().lookup(MyService.class.getName(), MyService.class);
+ assertNotNull("MyService should not be null", myService);
+
+ Object service =
context.getRegistry().lookup(MyService.class.getName());
+ assertNotNull("MyService should not be null", myService);
+
+ service = context.getRegistry().lookupByType(MyService.class);
+ assertNotNull("MyService should not be null", myService);
+
context.stop();
}
Propchange:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ServiceRegistryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ServiceRegistryTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/ServiceRegistryTest.java
------------------------------------------------------------------------------
svn:mergeinfo =
Added:
camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/osgi/camelContext.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/osgi/camelContext.xml?rev=827436&view=auto
==============================================================================
---
camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/osgi/camelContext.xml
(added)
+++
camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/osgi/camelContext.xml
Tue Oct 20 13:42:28 2009
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:camel="http://camel.apache.org/schema/osgi"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://camel.apache.org/schema/osgi
http://camel.apache.org/schema/osgi/camel-osgi.xsd
+ ">
+
+ <camel:camelContext id="camelContext" />
+
+</beans>
Propchange:
camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/osgi/camelContext.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/osgi/camelContext.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/components/camel-osgi/src/test/resources/org/apache/camel/osgi/camelContext.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml