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/03/31 06:50:05 UTC
svn commit: r642875 - in /activemq/camel/trunk/camel-core/src:
main/java/org/apache/camel/model/ main/java/org/apache/camel/processor/
main/java/org/apache/camel/processor/interceptor/
main/java/org/apache/camel/view/ test/java/org/apache/camel/process...
Author: ningjiang
Date: Sun Mar 30 21:49:50 2008
New Revision: 642875
URL: http://svn.apache.org/viewvc?rev=642875&view=rev
Log:
Fixed some CS errors of camel-core
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutingSlipType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/NodeData.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastStreamCachingTest.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/StreamCachingInterceptorTest.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipDataModificationTest.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipTest.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutingSlipType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutingSlipType.java?rev=642875&r1=642874&r2=642875&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutingSlipType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutingSlipType.java Sun Mar 30 21:49:50 2008
@@ -33,18 +33,18 @@
public class RoutingSlipType extends ProcessorType<ProcessorType> {
public static final String ROUTING_SLIP_HEADER = "routingSlipHeader";
public static final String DEFAULT_DELIMITER = ",";
-
+
@XmlAttribute
private String headerName;
@XmlAttribute
private String uriDelimiter;
-
+
public RoutingSlipType() {
- this(ROUTING_SLIP_HEADER, DEFAULT_DELIMITER);
- }
-
+ this(ROUTING_SLIP_HEADER, DEFAULT_DELIMITER);
+ }
+
public RoutingSlipType(String headerName) {
- this(headerName, DEFAULT_DELIMITER);
+ this(headerName, DEFAULT_DELIMITER);
}
public RoutingSlipType(String headerName, String uriDelimiter) {
@@ -54,15 +54,14 @@
@Override
public String toString() {
- return "RoutingSlip[ headerName=" + getHeaderName()
- + " uriDelimiter=" + getUriDelimiter() + "]";
+ return "RoutingSlip[ headerName=" + getHeaderName() + " uriDelimiter=" + getUriDelimiter() + "]";
}
@Override
public Processor createProcessor(RouteContext routeContext) throws Exception {
return new RoutingSlip(getHeaderName(), getUriDelimiter());
}
-
+
@Override
public List<ProcessorType<?>> getOutputs() {
return Collections.EMPTY_LIST;
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java?rev=642875&r1=642874&r2=642875&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RoutingSlip.java Sun Mar 30 21:49:50 2008
@@ -16,36 +16,35 @@
*/
package org.apache.camel.processor;
+
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.Producer;
-import org.apache.camel.impl.MessageSupport;
import org.apache.camel.impl.ServiceSupport;
-import org.apache.camel.model.FromType;
import org.apache.camel.model.RoutingSlipType;
import org.apache.camel.util.CollectionStringBuffer;
import org.apache.camel.util.ExchangeHelper;
-import static org.apache.camel.util.ObjectHelper.notNull;
import org.apache.camel.util.ProducerCache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import static org.apache.camel.util.ObjectHelper.notNull;
+
/**
* Implements a <a
* href="http://activemq.apache.org/camel/routing-slip.html">Routing Slip</a>
* pattern where the list of actual endpoints to send a message exchange to are
* dependent on the value of a message header.
- *
*/
public class RoutingSlip extends ServiceSupport implements Processor {
private static final transient Log LOG = LogFactory.getLog(RoutingSlip.class);
- private final String header;
+ private final String header;
private final String uriDelimiter;
-
- private ProducerCache<Exchange> producerCache = new ProducerCache<Exchange>();
+
+ private ProducerCache<Exchange> producerCache = new ProducerCache<Exchange>();
public RoutingSlip(String header) {
this(header, RoutingSlipType.DEFAULT_DELIMITER);
@@ -61,27 +60,26 @@
@Override
public String toString() {
- return "RoutingSlip[header=" + header +
- " uriDelimiter=" + uriDelimiter + "]";
+ return "RoutingSlip[header=" + header + " uriDelimiter=" + uriDelimiter + "]";
}
public void process(Exchange exchange) throws Exception {
Message message = exchange.getIn();
- String[] recipients = recipients(message);
+ String[] recipients = recipients(message);
Exchange current = exchange;
- for (String nextRecipient : recipients) {
+ for (String nextRecipient : recipients) {
Endpoint<Exchange> endpoint = resolveEndpoint(exchange, nextRecipient);
Producer<Exchange> producer = producerCache.getProducer(endpoint);
Exchange ex = endpoint.createExchange(ExchangePattern.InOut);
- updateRoutingSlip(current);
+ updateRoutingSlip(current);
copyOutToIn(ex, current);
-
+
producer.process(ex);
- current = ex;
- }
+ current = ex;
+ }
ExchangeHelper.copyResults(exchange, current);
}
@@ -102,7 +100,8 @@
}
/**
- * Returns the outbound message if available. Otherwise return the inbound message.
+ * Returns the outbound message if available. Otherwise return the inbound
+ * message.
*/
private Message getResultMessage(Exchange exchange) {
Message message = exchange.getOut(false);
@@ -115,18 +114,20 @@
}
/**
- * Return the list of recipients defined in the routing slip in the specified message.
+ * Return the list of recipients defined in the routing slip in the
+ * specified message.
*/
private String[] recipients(Message message) {
Object headerValue = message.getHeader(header);
- if (headerValue != null && !headerValue.equals("")) {
+ if (headerValue != null && !headerValue.equals("")) {
return headerValue.toString().split(uriDelimiter);
}
return new String[] {};
}
/**
- * Return a string representation of the element list with the first element removed.
+ * Return a string representation of the element list with the first element
+ * removed.
*/
private String removeFirstElement(String[] elements) {
CollectionStringBuffer updatedElements = new CollectionStringBuffer(uriDelimiter);
@@ -134,22 +135,22 @@
updatedElements.append(elements[i]);
}
return updatedElements.toString();
- }
-
+ }
+
/**
* Copy the outbound data in 'source' to the inbound data in 'result'.
*/
private void copyOutToIn(Exchange result, Exchange source) {
result.setException(source.getException());
-
+
Message fault = source.getFault(false);
if (fault != null) {
result.getFault(true).copyFrom(fault);
}
-
+
result.setIn(getResultMessage(source));
result.getProperties().clear();
- result.getProperties().putAll(source.getProperties());
+ result.getProperties().putAll(source.getProperties());
}
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java?rev=642875&r1=642874&r2=642875&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java Sun Mar 30 21:49:50 2008
@@ -1,4 +1,3 @@
-
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -27,7 +26,7 @@
import org.apache.camel.processor.Interceptor;
/**
- * {@link Interceptor} that converts a message into a re-readable format
+ * {@link Interceptor} that converts a message into a re-readable format
*/
public class StreamCachingInterceptor extends Interceptor {
@@ -48,16 +47,16 @@
this();
setProcessor(processor);
}
-
+
/**
* Remove this interceptor from the given list of interceptors
* @param interceptors the list of interceptos
*/
public static void noStreamCaching(List<InterceptorType> interceptors) {
- for (int i = 0 ; i < interceptors.size() ; i++) {
+ for (int i = 0; i < interceptors.size(); i++) {
InterceptorType interceptor = interceptors.get(i);
- if (interceptor instanceof InterceptorRef &&
- ((InterceptorRef) interceptor).getInterceptor() instanceof StreamCachingInterceptor) {
+ if (interceptor instanceof InterceptorRef
+ && ((InterceptorRef)interceptor).getInterceptor() instanceof StreamCachingInterceptor) {
interceptors.remove(interceptor);
}
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/NodeData.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/NodeData.java?rev=642875&r1=642874&r2=642875&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/NodeData.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/NodeData.java Sun Mar 30 21:49:50 2008
@@ -14,13 +14,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+/**
+ * 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.view;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.camel.model.AggregatorType;
import org.apache.camel.model.ChoiceType;
import org.apache.camel.model.FilterType;
@@ -28,15 +43,14 @@
import org.apache.camel.model.OtherwiseType;
import org.apache.camel.model.ProcessorType;
import org.apache.camel.model.RecipientListType;
-import org.apache.camel.model.RoutingSlipType;
import org.apache.camel.model.ResequencerType;
+import org.apache.camel.model.RoutingSlipType;
import org.apache.camel.model.SplitterType;
import org.apache.camel.model.ToType;
import org.apache.camel.model.WhenType;
import static org.apache.camel.util.ObjectHelper.isNotNullAndNonEmpty;
import static org.apache.camel.util.ObjectHelper.isNullOrBlank;
-
/**
* Represents a node in the EIP diagram tree
*
@@ -100,7 +114,7 @@
} else if (node instanceof RecipientListType) {
this.image = imagePrefix + "RecipientListIcon.png";
this.nodeType = "Recipient List";
- } else if (node instanceof RoutingSlipType) {
+ } else if (node instanceof RoutingSlipType) {
this.image = imagePrefix + "RoutingTableIcon.png";
this.nodeType = "Routing Slip";
this.url = "http://activemq.apache.org/camel/routing-slip.html";
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastStreamCachingTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastStreamCachingTest.java?rev=642875&r1=642874&r2=642875&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastStreamCachingTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastStreamCachingTest.java Sun Mar 30 21:49:50 2008
@@ -36,7 +36,7 @@
protected MockEndpoint x;
protected MockEndpoint y;
protected MockEndpoint z;
-
+
public void testSendingAMessageUsingMulticastConvertsToReReadable() throws Exception {
x.expectedBodiesReceived("<input/>+output");
y.expectedBodiesReceived("<input/>+output");
@@ -45,11 +45,11 @@
template.send("direct:a", new Processor() {
public void process(Exchange exchange) {
Message in = exchange.getIn();
- in.setBody(new StreamSource(new StringReader("<input/>")));
+ in.setBody(new StreamSource(new StringReader("<input/>")));
in.setHeader("foo", "bar");
}
});
-
+
assertMockEndpointsSatisifed();
}
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/StreamCachingInterceptorTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/StreamCachingInterceptorTest.java?rev=642875&r1=642874&r2=642875&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/StreamCachingInterceptorTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/StreamCachingInterceptorTest.java Sun Mar 30 21:49:50 2008
@@ -1,3 +1,19 @@
+/**
+ * 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.processor.interceptor;
import java.io.StringReader;
@@ -15,39 +31,39 @@
import org.apache.camel.processor.DelegateProcessor;
public class StreamCachingInterceptorTest extends ContextTestSupport {
-
+
private MockEndpoint a;
private MockEndpoint b;
-
+
public void testConvertStreamSourceWithRouteBuilderStreamCaching() throws Exception {
a.expectedMessageCount(1);
-
+
StreamSource message = new StreamSource(new StringReader("<hello>world!</hello>"));
template.sendBody("direct:a", message);
assertMockEndpointsSatisifed();
assertTrue(a.assertExchangeReceived(0).getIn().getBody() instanceof StreamCache);
}
-
+
public void testConvertStreamSourceWithRouteOnlyStreamCaching() throws Exception {
b.expectedMessageCount(1);
-
+
StreamSource message = new StreamSource(new StringReader("<hello>world!</hello>"));
template.sendBody("direct:b", message);
assertMockEndpointsSatisifed();
assertTrue(b.assertExchangeReceived(0).getIn().getBody() instanceof StreamCache);
}
-
+
public void testIgnoreAlreadyRereadable() throws Exception {
a.expectedMessageCount(1);
-
+
template.sendBody("direct:a", "<hello>world!</hello>");
assertMockEndpointsSatisifed();
assertTrue(a.assertExchangeReceived(0).getIn().getBody() instanceof String);
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -57,18 +73,18 @@
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
-
+
public void configure() {
//Stream caching for a single route...
from("direct:a").streamCaching().to("mock:a");
-
+
//... or for all the following routes in this builder
streamCaching();
from("direct:b").to("mock:b");
}
};
}
-
+
public void testNoStreamCaching() throws Exception {
List<InterceptorType> interceptors = new LinkedList<InterceptorType>();
InterceptorRef streamCache = new InterceptorRef(new StreamCachingInterceptor());
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipDataModificationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipDataModificationTest.java?rev=642875&r1=642874&r2=642875&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipDataModificationTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipDataModificationTest.java Sun Mar 30 21:49:50 2008
@@ -31,13 +31,13 @@
import org.apache.commons.logging.LogFactory;
public class RoutingSlipDataModificationTest extends ContextTestSupport {
- private static final transient Log LOG = LogFactory.getLog(RoutingSlipDataModificationTest.class);
protected static final String ANSWER = "answer";
protected static final String ROUTING_SLIP_HEADER = "routingSlipHeader";
+ private static final transient Log LOG = LogFactory.getLog(RoutingSlipDataModificationTest.class);
protected MyBean myBean = new MyBean(ROUTING_SLIP_HEADER);
public void testModificationOfDataAlongRoute()
- throws Exception {
+ throws Exception {
MockEndpoint x = getMockEndpoint("mock:x");
MockEndpoint y = getMockEndpoint("mock:y");
MockEndpoint z = getMockEndpoint("mock:z");
@@ -50,12 +50,12 @@
assertMockEndpointsSatisifed();
}
-
+
protected void sendBody() {
template.sendBodyAndHeader("direct:a", ANSWER, ROUTING_SLIP_HEADER,
"mock:x,bean:myBean?method=modifyData,mock:y,mock:z");
}
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -70,7 +70,7 @@
answer.bind("myBean", myBean);
return answer;
}
-
+
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
@@ -79,7 +79,7 @@
// END SNIPPET: example
}
};
- }
+ }
public static class MyBean {
private String routingSlipHeader;
@@ -92,11 +92,11 @@
}
public String modifyData(
- @Body String body,
- @Headers Map<String, Object> headers,
+ @Body String body,
+ @Headers Map<String, Object> headers,
@OutHeaders Map<String, Object> outHeaders) {
outHeaders.put(routingSlipHeader, headers.get(routingSlipHeader));
return body + body;
}
- }
+ }
}
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipTest.java?rev=642875&r1=642874&r2=642875&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipTest.java Sun Mar 30 21:49:50 2008
@@ -26,7 +26,7 @@
protected static final String ROUTING_SLIP_HEADER = "routingSlipHeader";
public void testUpdatingOfRoutingSlipAllDefaults()
- throws Exception {
+ throws Exception {
MockEndpoint x = getMockEndpoint("mock:x");
MockEndpoint y = getMockEndpoint("mock:y");
MockEndpoint z = getMockEndpoint("mock:z");
@@ -56,7 +56,7 @@
sendBody("direct:b", "aRoutingSlipHeader", ",");
assertMockEndpointsSatisifed();
- }
+ }
public void testUpdatingOfRoutingSlipHeaderAndDelimiterSet() throws Exception {
MockEndpoint x = getMockEndpoint("mock:x");
@@ -72,8 +72,8 @@
sendBody("direct:c", "aRoutingSlipHeader", "#");
assertMockEndpointsSatisifed();
- }
-
+ }
+
public void testMessagePassingThrough() throws Exception {
MockEndpoint end = getMockEndpoint("mock:end");
end.expectedMessageCount(1);
@@ -81,7 +81,7 @@
sendBody("direct:a", ROUTING_SLIP_HEADER, ",");
assertMockEndpointsSatisifed();
- }
+ }
public void testEmptyRoutingSlip() throws Exception {
MockEndpoint end = getMockEndpoint("mock:end");
@@ -89,7 +89,7 @@
sendBodyWithEmptyRoutingSlip();
- assertMockEndpointsSatisifed();
+ assertMockEndpointsSatisifed();
}
public void testNoRoutingSlip() throws Exception {
@@ -98,29 +98,29 @@
sendBodyWithNoRoutingSlip();
- assertMockEndpointsSatisifed();
- }
-
+ assertMockEndpointsSatisifed();
+ }
+
protected void sendBody(String endpoint, String header, String delimiter) {
template.sendBodyAndHeader(endpoint, ANSWER, header,
"mock:x" + delimiter + "mock:y" + delimiter + "mock:z");
- }
-
+ }
+
protected void sendBodyWithEmptyRoutingSlip() {
template.sendBodyAndHeader("direct:a", ANSWER, ROUTING_SLIP_HEADER, "");
}
protected void sendBodyWithNoRoutingSlip() {
template.sendBody("direct:a", ANSWER);
- }
-
+ }
+
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
// START SNIPPET: e1
from("direct:a").routingSlip().to("mock:end");
// END SNIPPET: e1
-
+
// START SNIPPET: e2
from("direct:b").routingSlip("aRoutingSlipHeader");
// END SNIPPET: e2
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java?rev=642875&r1=642874&r2=642875&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/routingslip/RoutingSlipWithExceptionTest.java Sun Mar 30 21:49:50 2008
@@ -31,9 +31,9 @@
protected static final String ANSWER = "answer";
protected static final String ROUTING_SLIP_HEADER = "routingSlipHeader";
+ protected MyBean myBean = new MyBean();
private MockEndpoint endEndpoint;
private MockEndpoint exceptionEndpoint;
- protected MyBean myBean = new MyBean();
private MockEndpoint exceptionSettingEndpoint;
public void testNoException() throws Exception {
@@ -43,7 +43,7 @@
sendRoutingSlipWithNoExceptionThrowingComponent();
assertEndpointsSatisfied();
- }
+ }
public void testWithExceptionThrowingComponentFirstInList() throws Exception {
endEndpoint.expectedMessageCount(0);
@@ -52,7 +52,7 @@
sendRoutingSlipWithExceptionThrowingComponentFirstInList();
assertEndpointsSatisfied();
- }
+ }
public void testWithExceptionThrowingComponentSecondInList() throws Exception {
endEndpoint.expectedMessageCount(0);
@@ -61,20 +61,20 @@
sendRoutingSlipWithExceptionThrowingComponentSecondInList();
assertEndpointsSatisfied();
- }
-
+ }
+
public void testWithExceptionSettingComponentFirstInList() throws Exception {
endEndpoint.expectedMessageCount(0);
- exceptionEndpoint.expectedMessageCount(1);
+ exceptionEndpoint.expectedMessageCount(1);
sendRoutingSlipWithExceptionSettingComponentFirstInList();
assertEndpointsSatisfied();
- }
+ }
public void testWithExceptionSettingComponentSecondInList() throws Exception {
endEndpoint.expectedMessageCount(0);
- exceptionEndpoint.expectedMessageCount(1);
+ exceptionEndpoint.expectedMessageCount(1);
sendRoutingSlipWithExceptionSettingComponentSecondInList();
@@ -83,9 +83,9 @@
private void assertEndpointsSatisfied() throws InterruptedException {
MockEndpoint.assertIsSatisfied(5, TimeUnit.SECONDS, endEndpoint, exceptionEndpoint);
- }
-
-
+ }
+
+
protected void sendRoutingSlipWithExceptionThrowingComponentFirstInList() {
template.sendBodyAndHeader("direct:start", ANSWER, ROUTING_SLIP_HEADER,
"myBean?method=throwException,mock:x");
@@ -94,37 +94,37 @@
protected void sendRoutingSlipWithExceptionThrowingComponentSecondInList() {
template.sendBodyAndHeader("direct:start", ANSWER, ROUTING_SLIP_HEADER,
"mock:a,myBean?method=throwException");
- }
-
+ }
+
protected void sendRoutingSlipWithNoExceptionThrowingComponent() {
template.sendBodyAndHeader("direct:start", ANSWER, ROUTING_SLIP_HEADER,
"mock:a");
- }
+ }
protected void sendRoutingSlipWithExceptionSettingComponentFirstInList() {
template.sendBodyAndHeader("direct:start", ANSWER, ROUTING_SLIP_HEADER,
"mock:exceptionSetting,mock:a");
- }
+ }
protected void sendRoutingSlipWithExceptionSettingComponentSecondInList() {
template.sendBodyAndHeader("direct:start", ANSWER, ROUTING_SLIP_HEADER,
"mock:a,mock:exceptionSetting");
- }
-
+ }
+
@Override
protected void setUp() throws Exception {
- super.setUp();
-
- endEndpoint = resolveMandatoryEndpoint("mock:noexception", MockEndpoint.class);
- exceptionEndpoint = resolveMandatoryEndpoint("mock:exception", MockEndpoint.class);
- exceptionSettingEndpoint = resolveMandatoryEndpoint("mock:exceptionSetting", MockEndpoint.class);
+ super.setUp();
+
+ endEndpoint = resolveMandatoryEndpoint("mock:noexception", MockEndpoint.class);
+ exceptionEndpoint = resolveMandatoryEndpoint("mock:exception", MockEndpoint.class);
+ exceptionSettingEndpoint = resolveMandatoryEndpoint("mock:exceptionSetting", MockEndpoint.class);
exceptionSettingEndpoint.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setException(new Exception("Throw me!"));
}
- });
-
+ });
+
Object lookedUpBean = context.getRegistry().lookup("myBean");
assertSame("Lookup of 'myBean' should return same object!", myBean, lookedUpBean);
}
@@ -135,19 +135,19 @@
answer.bind("myBean", myBean);
return answer;
}
-
+
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
from("direct:start").
- tryBlock().
- routingSlip().
- to("mock:noexception").
- handle(Exception.class).to("mock:exception");
+ tryBlock().
+ routingSlip().to("mock:noexception").
+ handle(Exception.class).
+ to("mock:exception");
}
};
- }
-
+ }
+
public static class MyBean {
public MyBean() {
}
@@ -155,5 +155,5 @@
public void throwException() throws Exception {
throw new Exception("Throw me!");
}
- }
+ }
}