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 2008/05/27 03:40:44 UTC
svn commit: r660348 - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/management/
camel-core/src/test/java/org/apache/camel/processor/
components/camel-spring/src/test/java/org/apache/camel/spring/
Author: ningjiang
Date: Mon May 26 18:40:41 2008
New Revision: 660348
URL: http://svn.apache.org/viewvc?rev=660348&view=rev
Log:
Add a testcase to show the code fault of InstrumenationLifeCycleStrategy
Added:
activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelChoiceWithManagementTest.java (with props)
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java?rev=660348&r1=660347&r2=660348&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java Mon May 26 18:40:41 2008
@@ -136,8 +136,9 @@
routeContext.addInterceptStrategy(new InstrumentationInterceptStrategy(counterMap));
// TODO we need to find other way to instrument the route.
- // below codes adding wrap the processor with all the processors which are already wrapped
- // by the InstrumentationInterceptStrategy
+ // Below codes will wrap the interceptor (route instrumentation processor) to
+ // the each processors which are already wrapped by the InstrumentationInterceptStrategy,
+ // And the router couter will be increased when the processors process the exchange
/*
// Add an InstrumentationProcessor at the beginning of each route and
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java?rev=660348&r1=660347&r2=660348&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java Mon May 26 18:40:41 2008
@@ -32,6 +32,8 @@
public void testSendToFirstWhen() throws Exception {
String body = "<one/>";
x.expectedBodiesReceived(body);
+ // The SpringChoiceTest.java can't setup the header by Spring configure file
+ // x.expectedHeaderReceived("name", "a");
expectsMessageCount(0, y, z);
sendMessage("bar", body);
Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelChoiceWithManagementTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelChoiceWithManagementTest.java?rev=660348&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelChoiceWithManagementTest.java (added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelChoiceWithManagementTest.java Mon May 26 18:40:41 2008
@@ -0,0 +1,124 @@
+/**
+ * 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.spring;
+
+
+import junit.framework.Assert;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.CamelTemplate;
+
+import static org.apache.camel.component.mock.MockEndpoint.expectsMessageCount;
+
+/**
+ * @version $Revision$
+ */
+public class CamelChoiceWithManagementTest extends ContextTestSupport {
+ private SpringInstrumentationAgent agent;
+ private MockEndpoint a;
+ private MockEndpoint b;
+ private MockEndpoint c;
+ private MockEndpoint d;
+ private MockEndpoint e;
+
+ protected void setUp() throws Exception {
+ context = createCamelContext();
+ assertValidContext(context);
+
+
+ template = new CamelTemplate<Exchange>(context);
+ agent = new SpringInstrumentationAgent();
+ agent.setCamelContext(context);
+ agent.enableJmx();
+ agent.start();
+ RouteBuilder[] builders = createRouteBuilders();
+ for (RouteBuilder builder : builders) {
+ context.addRoutes(builder);
+ }
+ startCamelContext();
+ a = getMockEndpoint("mock:a");
+ b = getMockEndpoint("mock:b");
+ c = getMockEndpoint("mock:c");
+ d = getMockEndpoint("mock:d");
+ e = getMockEndpoint("mock:e");
+ }
+
+ protected void tearDown() throws Exception {
+ agent.stop();
+ super.tearDown();
+ }
+
+ public void testFirstChoiceRoute() throws Exception {
+ final String body = "<one/>";
+ a.expectedBodiesReceived(body);
+ a.expectedHeaderReceived("CBR1", "Yes");
+ c.expectedBodiesReceived(body);
+ c.expectedHeaderReceived("CBR1", "Yes");
+ c.expectedHeaderReceived("Validation", "Yes");
+ expectsMessageCount(0, b, d, e);
+
+ template.send("direct:start", new Processor() {
+
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setBody(body);
+ exchange.getIn().setHeader("CBR1", "Yes");
+ }
+ });
+
+ assertMockEndpointsSatisifed();
+
+ }
+
+ public void testOtherwise() throws Exception {
+ final String body = "<None/>";
+ e.expectedBodiesReceived(body);
+
+ expectsMessageCount(0, a, b, c, d);
+
+ template.send("direct:start", new Processor() {
+
+ public void process(Exchange exchange) throws Exception {
+ exchange.getIn().setBody(body);
+ }
+ });
+
+ assertMockEndpointsSatisifed();
+
+ }
+
+
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+
+ from("direct:start")
+ .choice()
+ .when(header("CBR1").isEqualTo("Yes")).to("mock:a").setHeader("Validation", "Yes")
+ .when(header("CBR1").isEqualTo("No")).to("mock:b").end()
+ .choice().when(header("Validation").isEqualTo("Yes")).to("mock:c")
+ .when(header("Validation").isEqualTo("No")).to("mock:d").otherwise().to("mock:e").end();
+
+ }
+ };
+ }
+}
Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelChoiceWithManagementTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelChoiceWithManagementTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date