Author: davsclaus
Date: Sun Oct 19 06:48:09 2008
New Revision: 706013
URL: http://svn.apache.org/viewvc?rev=706013&view=rev
Log:
CAMEL-393: Throws exception if route is now configued properly. CAMEL-998:
Check for camel context provided in start() as well.
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentTest.java
activemq/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java?rev=706013&r1=706012&r2=706013&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultComponent.java
Sun Oct 19 06:48:09 2008
@@ -159,6 +159,7 @@
}
protected void doStart() throws Exception {
+ ObjectHelper.notNull(getCamelContext(), "camelContext");
}
protected void doStop() throws Exception {
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=706013&r1=706012&r2=706013&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
(original)
+++
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
Sun Oct 19 06:48:09 2008
@@ -668,6 +668,9 @@
* together into a single invoice message.
*/
public ExpressionClause<AggregatorType> aggregator() {
+ if (!getOutputs().isEmpty()) {
+ throw new IllegalArgumentException("Aggregator must be the only
output added to the route: " + this);
+ }
AggregatorType answer = new AggregatorType();
addOutput(answer);
return ExpressionClause.createAndSetExpression(answer);
@@ -691,6 +694,9 @@
* @param aggregationStrategy the strategy used for the aggregation
*/
public ExpressionClause<AggregatorType> aggregator(AggregationStrategy
aggregationStrategy) {
+ if (!getOutputs().isEmpty()) {
+ throw new IllegalArgumentException("Aggregator must be the only
output added to the route: " + this);
+ }
AggregatorType answer = new AggregatorType();
answer.setAggregationStrategy(aggregationStrategy);
addOutput(answer);
@@ -707,6 +713,9 @@
* @param aggregationCollection the collection used to perform the
aggregation
*/
public AggregatorType aggregator(AggregationCollection
aggregationCollection) {
+ if (!getOutputs().isEmpty()) {
+ throw new IllegalArgumentException("Aggregator must be the only
output added to the route: " + this);
+ }
AggregatorType answer = new AggregatorType();
answer.setAggregationCollection(aggregationCollection);
addOutput(answer);
@@ -734,6 +743,9 @@
* <code>header("JMSCorrelationID")</code>
*/
public AggregatorType aggregator(Expression correlationExpression) {
+ if (!getOutputs().isEmpty()) {
+ throw new IllegalArgumentException("Aggregator must be the only
output added to the route: " + this);
+ }
AggregatorType answer = new AggregatorType(correlationExpression);
addOutput(answer);
return answer;
@@ -760,6 +772,9 @@
* <code>header("JMSCorrelationID")</code>
*/
public AggregatorType aggregator(Expression correlationExpression,
AggregationStrategy aggregationStrategy) {
+ if (!getOutputs().isEmpty()) {
+ throw new IllegalArgumentException("Aggregator must be the only
output added to the route: " + this);
+ }
AggregatorType answer = new AggregatorType(correlationExpression,
aggregationStrategy);
addOutput(answer);
return answer;
Modified:
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentTest.java?rev=706013&r1=706012&r2=706013&view=diff
==============================================================================
---
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentTest.java
(original)
+++
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultComponentTest.java
Sun Oct 19 06:48:09 2008
@@ -77,4 +77,14 @@
assertEquals(value.intValue(), 4);
}
+ public void testContextShouldBeSet() throws Exception {
+ MyComponent my = new MyComponent(null);
+ try {
+ my.start();
+ fail("Should have thrown a IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertEquals("camelContext must be specified", e.getMessage());
+ }
+ }
+
}
Modified:
activemq/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java?rev=706013&r1=706012&r2=706013&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
(original)
+++
activemq/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpProducerSelectMethodTest.java
Sun Oct 19 06:48:09 2008
@@ -21,7 +21,6 @@
import org.apache.commons.httpclient.HttpMethod;
import java.io.IOException;
-import java.util.Collections;
/**
* Unit test to verify the algorithm for selecting either GET or POST.
@@ -31,7 +30,7 @@
public void testNoDataDefaultIsGet() throws Exception {
HttpComponent component = new HttpComponent();
component.setCamelContext(context);
- HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com", "", Collections.EMPTY_MAP);
+ HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com");
MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET", null);
HttpExchange exchange = producer.createExchange();
@@ -48,7 +47,7 @@
public void testDataDefaultIsPost() throws Exception {
HttpComponent component = new HttpComponent();
component.setCamelContext(context);
- HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com", "", Collections.EMPTY_MAP);
+ HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com");
MyHttpProducer producer = new MyHttpProducer(endpoiont, "POST", null);
HttpExchange exchange = producer.createExchange();
@@ -65,7 +64,7 @@
public void testWithMethodPostInHeader() throws Exception {
HttpComponent component = new HttpComponent();
component.setCamelContext(context);
- HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com", "", Collections.EMPTY_MAP);
+ HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com");
MyHttpProducer producer = new MyHttpProducer(endpoiont, "POST", null);
HttpExchange exchange = producer.createExchange();
@@ -83,7 +82,7 @@
public void testWithMethodGetInHeader() throws Exception {
HttpComponent component = new HttpComponent();
component.setCamelContext(context);
- HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com", "", Collections.EMPTY_MAP);
+ HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com");
MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET", null);
HttpExchange exchange = producer.createExchange();
@@ -101,7 +100,7 @@
public void testWithEndpointQuery() throws Exception {
HttpComponent component = new HttpComponent();
component.setCamelContext(context);
- HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com?q=Camel", "",
Collections.EMPTY_MAP);
+ HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com?q=Camel");
MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET",
"q=Camel");
HttpExchange exchange = producer.createExchange();
@@ -118,7 +117,7 @@
public void testWithQueryInHeader() throws Exception {
HttpComponent component = new HttpComponent();
component.setCamelContext(context);
- HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com", "", Collections.EMPTY_MAP);
+ HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com");
MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET",
"q=Camel");
HttpExchange exchange = producer.createExchange();
@@ -136,7 +135,7 @@
public void testWithQueryInHeaderOverrideEndpoint() throws Exception {
HttpComponent component = new HttpComponent();
component.setCamelContext(context);
- HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com?q=Donkey", "",
Collections.EMPTY_MAP);
+ HttpEndpoint endpoiont = (HttpEndpoint)
component.createEndpoint("http://www.google.com?q=Donkey");
MyHttpProducer producer = new MyHttpProducer(endpoiont, "GET",
"q=Camel");
HttpExchange exchange = producer.createExchange();
Modified:
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java?rev=706013&r1=706012&r2=706013&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java
(original)
+++
activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java
Sun Oct 19 06:48:09 2008
@@ -24,6 +24,7 @@
import org.apache.camel.impl.DefaultProducer;
import org.apache.camel.processor.loadbalancer.LoadBalancer;
import org.apache.camel.processor.loadbalancer.TopicLoadBalancer;
+import org.apache.camel.util.ObjectHelper;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -31,6 +32,7 @@
import static org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException;
+
/**
* An <a href="http://activemq.apache.org/camel/event.html">Event Endpoint</a>
* for working with Spring ApplicationEvents
@@ -63,9 +65,7 @@
}
public Producer<Exchange> createProducer() throws Exception {
- if (applicationContext == null) {
- throw new IllegalStateException("ApplicationContext is null");
- }
+ ObjectHelper.notNull(getApplicationContext(), "applicationContext");
return new DefaultProducer<Exchange>(this) {
public void process(Exchange exchange) throws Exception {
ApplicationEvent event = toApplicationEvent(exchange);