You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/07/27 08:22:30 UTC
svn commit: r979549 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
Author: davsclaus
Date: Tue Jul 27 06:22:29 2010
New Revision: 979549
URL: http://svn.apache.org/viewvc?rev=979549&view=rev
Log:
CAMEL-2991: Fixed issue with restarting CamelContext and not being able to restart routes.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=979549&r1=979548&r2=979549&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Tue Jul 27 06:22:29 2010
@@ -1178,6 +1178,11 @@ public class DefaultCamelContext extends
// stop the lazy created so they can be re-created on restart
forceStopLazyInitialization();
+ // reset values (mark routes as not initialized so they can be started again)
+ routeDefinitionInitiated = false;
+ firstStartDone = false;
+ defaultRouteStartupOrder = 1000;
+
stopWatch.stop();
if (LOG.isInfoEnabled()) {
LOG.info("Uptime: " + getUptime());
Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java?rev=979549&r1=979548&r2=979549&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/cxfbean/CxfBeanTest.java Tue Jul 27 06:22:29 2010
@@ -22,6 +22,7 @@ import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Holder;
+import org.apache.camel.CamelContext;
import org.apache.camel.component.cxf.util.CxfUtils;
import org.apache.camel.wsdl_first.Person;
import org.apache.camel.wsdl_first.PersonService;
@@ -33,6 +34,8 @@ import org.apache.http.entity.StringEnti
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
@@ -46,10 +49,13 @@ import static org.junit.Assert.assertEqu
public class CxfBeanTest extends AbstractJUnit4SpringContextTests {
private static final String PUT_REQUEST = "<Customer><name>Mary</name><id>113</id></Customer>";
private static final String POST_REQUEST = "<Customer><name>Jack</name></Customer>";
+
+ @Autowired
+ @Qualifier("camel")
+ protected CamelContext camelContext;
@Test
public void testGetConsumer() throws Exception {
-
URL url = new URL("http://localhost:9000/customerservice/customers/123");
InputStream in = url.openStream();
@@ -60,10 +66,28 @@ public class CxfBeanTest extends Abstrac
in = url.openStream();
assertEquals("{\"Product\":{\"description\":\"product 323\",\"id\":323}}", CxfUtils.getStringFromInputStream(in));
// END SNIPPET: clientInvocation
-
}
@Test
+ public void testGetConsumerAfterReStartCamelContext() throws Exception {
+ URL url = new URL("http://localhost:9000/customerservice/customers/123");
+
+ InputStream in = url.openStream();
+ assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", CxfUtils.getStringFromInputStream(in));
+ in.close();
+
+ camelContext.stop();
+ camelContext.start();
+
+ url = new URL("http://localhost:9000/customerservice/orders/223/products/323");
+ in = url.openStream();
+
+ assertEquals("{\"Product\":{\"description\":\"product 323\",\"id\":323}}",
+ CxfUtils.getStringFromInputStream(in));
+ in.close();
+ }
+
+ @Test
public void testPutConsumer() throws Exception {
HttpPut put = new HttpPut("http://localhost:9000/customerservice/customers");
StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1");