Author: ningjiang
Date: Fri Oct 30 04:08:11 2009
New Revision: 831193
URL: http://svn.apache.org/viewvc?rev=831193&view=rev
Log:
CAMEL-2119 create camel-context.xml to hold the spring java configure class
Added:
camel/trunk/examples/camel-example-spring-javaconfig/src/main/resources/META-INF/spring/
camel/trunk/examples/camel-example-spring-javaconfig/src/main/resources/META-INF/spring/camel-context.xml
(with props)
Modified:
camel/trunk/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java
Added:
camel/trunk/examples/camel-example-spring-javaconfig/src/main/resources/META-INF/spring/camel-context.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-spring-javaconfig/src/main/resources/META-INF/spring/camel-context.xml?rev=831193&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-spring-javaconfig/src/main/resources/META-INF/spring/camel-context.xml
(added)
+++
camel/trunk/examples/camel-example-spring-javaconfig/src/main/resources/META-INF/spring/camel-context.xml
Fri Oct 30 04:08:11 2009
@@ -0,0 +1,34 @@
+<?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.
+-->
+
+<!-- Configures the Camel Context-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+ <!-- START SNIPPET: ex -->
+ <!-- first, define your individual @Configuration classes as beans -->
+ <bean class="org.apache.camel.example.spring.javaconfig.MyRouteConfig"/>
+
+ <!-- be sure to include the JavaConfig bean post-processor -->
+ <bean
class="org.springframework.config.java.process.ConfigurationPostProcessor"/>
+
+ <!-- END SNIPPET: ex -->
+
+</beans>
Propchange:
camel/trunk/examples/camel-example-spring-javaconfig/src/main/resources/META-INF/spring/camel-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-spring-javaconfig/src/main/resources/META-INF/spring/camel-context.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/examples/camel-example-spring-javaconfig/src/main/resources/META-INF/spring/camel-context.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified:
camel/trunk/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java?rev=831193&r1=831192&r2=831193&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java
(original)
+++
camel/trunk/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java
Fri Oct 30 04:08:11 2009
@@ -16,16 +16,29 @@
*/
package org.apache.camel.example.spring.javaconfig;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
import junit.framework.TestCase;
+import org.apache.camel.CamelContext;
import org.apache.camel.spring.javaconfig.Main;
/**
* @version $Revision$
*/
public class IntegrationTest extends TestCase {
-
+
public void testCamelRulesDeployCorrectlyInSpring() throws Exception {
// let's boot up the Spring application context for 2 seconds to check
that it works OK
Main.main("-duration", "2s", "-bp",
"org.apache.camel.example.spring.javaconfig");
}
+
+ public void testStartApplicationContext() throws Exception {
+ // test to boot up the application context from spring configuration
+ ApplicationContext context = new
ClassPathXmlApplicationContext("/META-INF/spring/camel-context.xml");
+ String[] names = context.getBeanNamesForType(CamelContext.class);
+ assertEquals("There should be a camel context ", 1, names.length);
+ CamelContext camelContext = (CamelContext) context.getBean(names[0]);
+ assertNotNull(camelContext);
+ Thread.sleep(2000);
+ }
}