You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ge...@apache.org on 2008/11/04 09:55:43 UTC
svn commit: r711212 - in /servicemix/smx3/branches/servicemix-3.2: ./
archetypes/servicemix-cxf-se-wsdl-first-service-unit/
deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/
deployables/serviceengines/servicemix-cam...
Author: gertv
Date: Tue Nov 4 00:55:42 2008
New Revision: 711212
URL: http://svn.apache.org/viewvc?rev=711212&view=rev
Log:
SM-1673: improve error handling in servicemix-camel
Added:
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiCamelErrorHandlingTestSupport.java (with props)
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyCamelErrorHandlingTest.java (with props)
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyWithErrorHandledTrueSpringDSLTest.java (with props)
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOutCamelErrorHandlingTest.java (with props)
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/SpringJbiTestSupport.java (with props)
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su8-src/
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su8-src/camel-context.xml (with props)
Modified:
servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-cxf-se-wsdl-first-service-unit/ (props changed)
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelProviderEndpoint.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiTestSupport.java
servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/NonJbiCamelEndpointsIntegrationTest.java
servicemix/smx3/branches/servicemix-3.2/platforms/geronimo/deployer/ (props changed)
servicemix/smx3/branches/servicemix-3.2/platforms/geronimo/servicemix/ (props changed)
servicemix/smx3/branches/servicemix-3.2/pom.xml
Propchange: servicemix/smx3/branches/servicemix-3.2/archetypes/servicemix-cxf-se-wsdl-first-service-unit/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Nov 4 00:55:42 2008
@@ -0,0 +1,3 @@
+.classpath
+.project
+target
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelProviderEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelProviderEndpoint.java?rev=711212&r1=711211&r2=711212&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelProviderEndpoint.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/CamelProviderEndpoint.java Tue Nov 4 00:55:42 2008
@@ -92,7 +92,8 @@
}
JbiExchange camelExchange = new JbiExchange(camelEndpoint.getCamelContext(), binding, exchange);
camelProcessor.process(camelExchange);
- if (camelExchange.isFailed()) {
+ if (camelExchange.isFailed()
+ && (camelExchange.getFault(false) == null || camelExchange.getFault(false).getBody() == null)) {
Throwable t = camelExchange.getException();
Exception e;
if (t == null) {
@@ -112,7 +113,8 @@
}
JbiExchange camelExchange = new JbiExchange(camelEndpoint.getCamelContext(), binding, exchange);
camelProcessor.process(camelExchange);
- if (camelExchange.isFailed()) {
+ if (camelExchange.isFailed()
+ && (camelExchange.getFault(false) == null || camelExchange.getFault(false).getBody() == null)) {
Throwable t = camelExchange.getException();
Exception e;
if (t == null) {
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiCamelErrorHandlingTestSupport.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiCamelErrorHandlingTestSupport.java?rev=711212&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiCamelErrorHandlingTestSupport.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiCamelErrorHandlingTestSupport.java Tue Nov 4 00:55:42 2008
@@ -0,0 +1,100 @@
+/*
+ * 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.servicemix.camel;
+
+import java.util.List;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.Fault;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.xml.namespace.QName;
+
+import org.apache.camel.converter.jaxp.StringSource;
+import org.apache.servicemix.MessageExchangeListener;
+import org.apache.servicemix.components.util.ComponentSupport;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.tck.ReceiverComponent;
+
+/**
+ * Tests on handling fault messages with the Camel Exception handler
+ */
+public abstract class JbiCamelErrorHandlingTestSupport extends JbiTestSupport {
+
+ protected static final String MESSAGE = "<just><a>test</a></just>";
+
+ protected ReceiverComponent receiverComponent = new ReceiverComponent();
+
+ @Override
+ protected void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList) {
+ ActivationSpec spec;
+
+ spec = new ActivationSpec(new ReturnFaultComponent());
+ spec.setService(new QName("urn:test", "faulty-service"));
+ spec.setEndpoint("endpoint");
+ activationSpecList.add(spec);
+
+ spec = new ActivationSpec(new ReturnErrorComponent(new IllegalArgumentException("iae error")));
+ spec.setService(new QName("urn:test", "iae-error-service"));
+ spec.setEndpoint("endpoint");
+ activationSpecList.add(spec);
+
+ spec = new ActivationSpec(new ReturnErrorComponent(new IllegalStateException("ise error")));
+ spec.setService(new QName("urn:test", "ise-error-service"));
+ spec.setEndpoint("endpoint");
+ activationSpecList.add(spec);
+
+ spec = new ActivationSpec(new ReturnErrorComponent(new NullPointerException("npe error")));
+ spec.setService(new QName("urn:test", "npe-error-service"));
+ spec.setEndpoint("endpoint");
+ activationSpecList.add(spec);
+
+ spec = new ActivationSpec(receiverComponent);
+ spec.setService(new QName("urn:test", "receiver-service"));
+ spec.setEndpoint("endpoint");
+ activationSpecList.add(spec);
+
+ spec = new ActivationSpec(new MyEchoComponent());
+ spec.setService(new QName("urn:test", "echo-service"));
+ spec.setEndpoint("endpoint");
+ activationSpecList.add(spec);
+ }
+
+ protected static class ReturnErrorComponent extends ComponentSupport implements MessageExchangeListener {
+ private Exception exception;
+
+ public ReturnErrorComponent(Exception exception) {
+ this.exception = exception;
+ }
+
+ public void onMessageExchange(MessageExchange exchange) throws MessagingException {
+ if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+ fail(exchange, exception);
+ }
+ }
+ }
+
+ protected static class ReturnFaultComponent extends ComponentSupport implements MessageExchangeListener {
+ public void onMessageExchange(MessageExchange exchange) throws MessagingException {
+ if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+ Fault fault = exchange.createFault();
+ fault.setContent(new StringSource("<fault/>"));
+ fail(exchange, fault);
+ }
+ }
+ }
+}
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiCamelErrorHandlingTestSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyCamelErrorHandlingTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyCamelErrorHandlingTest.java?rev=711212&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyCamelErrorHandlingTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyCamelErrorHandlingTest.java Tue Nov 4 00:55:42 2008
@@ -0,0 +1,131 @@
+/*
+ * 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.servicemix.camel;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.xml.namespace.QName;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.jaxp.StringSource;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.jbi.FaultException;
+
+/**
+ * Tests on handling fault messages with the Camel Exception handler
+ */
+public class JbiInOnlyCamelErrorHandlingTest extends JbiCamelErrorHandlingTestSupport {
+
+ private static final String MESSAGE = "<just><a>test</a></just>";
+
+ public void testInOnlyWithNoHandleFault() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(1);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOnly exchange = client.createInOnlyExchange();
+ exchange.setService(new QName("urn:test", "no-handle-fault"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ assertEquals(ExchangeStatus.ERROR, exchange.getStatus());
+ assertTrue("A FaultException was expected", exchange.getError() instanceof FaultException);
+
+ errors.assertIsSatisfied();
+ }
+
+ public void testInOnlyWithHandleFault() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(1);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOnly exchange = client.createInOnlyExchange();
+ exchange.setService(new QName("urn:test", "handle-fault"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ assertEquals(ExchangeStatus.ERROR, exchange.getStatus());
+ assertTrue("A FaultException was expected", exchange.getError() instanceof FaultException);
+
+ errors.assertIsSatisfied();
+ }
+
+ public void testInOnlyWithErrorNotHandled() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(1);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOnly exchange = client.createInOnlyExchange();
+ exchange.setService(new QName("urn:test", "error-not-handled"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ assertEquals(ExchangeStatus.ERROR, exchange.getStatus());
+ assertTrue("A IllegalArgumentException was expected", exchange.getError() instanceof IllegalArgumentException);
+
+ errors.assertIsSatisfied();
+ }
+
+ public void testInOnlyWithErrorHandledFalse() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(0);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOnly exchange = client.createInOnlyExchange();
+ exchange.setService(new QName("urn:test", "error-handled-false"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ assertEquals(ExchangeStatus.ERROR, exchange.getStatus());
+ assertTrue("A IllegalStateException was expected", exchange.getError() instanceof IllegalStateException);
+
+ receiverComponent.getMessageList().assertMessagesReceived(1);
+
+ errors.assertIsSatisfied();
+ }
+
+ public void testInOnlyWithErrorHandledTrue() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(0);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOnly exchange = client.createInOnlyExchange();
+ exchange.setService(new QName("urn:test", "error-handled-true"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ assertEquals(ExchangeStatus.DONE, exchange.getStatus());
+
+ receiverComponent.getMessageList().assertMessagesReceived(1);
+
+ errors.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRoutes() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ onException(IllegalStateException.class).handled(false).to("jbi:service:urn:test:receiver-service?mep=in-only");
+ onException(NullPointerException.class).handled(true).to("jbi:service:urn:test:receiver-service?mep=in-only");
+ errorHandler(deadLetterChannel("mock:errors").maximumRedeliveries(1).initialRedeliveryDelay(300));
+ from("jbi:service:urn:test:no-handle-fault").to("jbi:service:urn:test:faulty-service?mep=in-only");
+ from("jbi:service:urn:test:handle-fault").handleFault().to("jbi:service:urn:test:faulty-service?mep=in-only");
+ from("jbi:service:urn:test:error-not-handled").to("jbi:service:urn:test:iae-error-service?mep=in-only");
+ from("jbi:service:urn:test:error-handled-false").to("jbi:service:urn:test:ise-error-service?mep=in-only");
+ from("jbi:service:urn:test:error-handled-true").to("jbi:service:urn:test:npe-error-service?mep=in-only");
+ }
+ };
+ }
+}
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyCamelErrorHandlingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyWithErrorHandledTrueSpringDSLTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyWithErrorHandledTrueSpringDSLTest.java?rev=711212&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyWithErrorHandledTrueSpringDSLTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyWithErrorHandledTrueSpringDSLTest.java Tue Nov 4 00:55:42 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.servicemix.camel;
+
+import java.util.List;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.MessageExchangeListener;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.components.util.ComponentSupport;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.tck.ReceiverComponent;
+
+/**
+ * Tests on handling fault messages with the Camel Exception handler
+ */
+public class JbiInOnlyWithErrorHandledTrueSpringDSLTest extends SpringJbiTestSupport {
+
+ private static final QName TEST_SERVICE = new QName("urn:test", "error-handled-true");
+
+ private ReceiverComponent receiver;
+ private ReceiverComponent deadLetter;
+
+ @Override
+ protected void setUp() throws Exception {
+ receiver = new ReceiverComponent();
+ deadLetter = new ReceiverComponent();
+
+ super.setUp();
+ }
+
+ public void testErrorHandledByExceptionClause() throws Exception {
+ ServiceMixClient smxClient = getServicemixClient();
+ InOnly exchange = smxClient.createInOnlyExchange();
+ exchange.setEndpoint(jbiContainer.getRegistry().getEndpointsForService(TEST_SERVICE)[0]);
+
+ smxClient.sendSync(exchange);
+
+/* not supported in Camel 1.4
+ assertEquals(ExchangeStatus.DONE, exchange.getStatus());
+ receiver.getMessageList().assertMessagesReceived(1);
+ deadLetter.getMessageList().assertMessagesReceived(0); */
+ }
+
+ @Override
+ protected String getServiceUnitName() {
+ return "su8";
+ }
+
+ @Override
+ protected void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList) {
+ activationSpecList.add(createActivationSpec(new ReturnNullPointerExceptionErrorComponent(),
+ new QName("urn:test", "npe-error-service")));
+
+ activationSpecList.add(createActivationSpec(receiver, new QName("urn:test", "receiver-service")));
+ activationSpecList.add(createActivationSpec(deadLetter, new QName("urn:test", "deadLetter-service")));
+ }
+
+ protected static class ReturnNullPointerExceptionErrorComponent extends ComponentSupport implements MessageExchangeListener {
+ public void onMessageExchange(MessageExchange exchange) throws MessagingException {
+ if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+ fail(exchange, new NullPointerException());
+ }
+ }
+ }
+}
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOnlyWithErrorHandledTrueSpringDSLTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOutCamelErrorHandlingTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOutCamelErrorHandlingTest.java?rev=711212&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOutCamelErrorHandlingTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOutCamelErrorHandlingTest.java Tue Nov 4 00:55:42 2008
@@ -0,0 +1,143 @@
+/*
+ * 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.servicemix.camel;
+
+import java.util.List;
+
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.jaxp.StringSource;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.jbi.container.ActivationSpec;
+
+/**
+ * Tests on handling fault messages with the Camel Exception handler
+ */
+public class JbiInOutCamelErrorHandlingTest extends JbiCamelErrorHandlingTestSupport {
+
+ private static final String MESSAGE = "<just><a>test</a></just>";
+
+ public void testInOutWithNoHandleFault() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(0);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOut exchange = client.createInOutExchange();
+ exchange.setService(new QName("urn:test", "no-handle-fault"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ System.err.println(exchange);
+ assertEquals(ExchangeStatus.ACTIVE, exchange.getStatus());
+ assertNotNull(exchange.getFault());
+ client.done(exchange);
+
+ errors.assertIsSatisfied();
+ }
+
+ public void testInOutWithHandleFault() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(1);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOut exchange = client.createInOutExchange();
+ exchange.setService(new QName("urn:test", "handle-fault"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ assertEquals(ExchangeStatus.ACTIVE, exchange.getStatus());
+ assertNotNull(exchange.getFault());
+ client.done(exchange);
+
+ errors.assertIsSatisfied();
+ }
+
+ public void testInOutWithErrorNotHandled() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(1);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOut exchange = client.createInOutExchange();
+ exchange.setService(new QName("urn:test", "error-not-handled"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ assertEquals(ExchangeStatus.ERROR, exchange.getStatus());
+ assertTrue("A IllegalArgumentException was expected", exchange.getError() instanceof IllegalArgumentException);
+
+ errors.assertIsSatisfied();
+ }
+
+ public void testInOutWithErrorHandledFalse() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(0);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOut exchange = client.createInOutExchange();
+ exchange.setService(new QName("urn:test", "error-handled-false"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ assertEquals(ExchangeStatus.ERROR, exchange.getStatus());
+ assertTrue("A IllegalStateException was expected", exchange.getError() instanceof IllegalStateException);
+
+ receiverComponent.getMessageList().assertMessagesReceived(1);
+
+ errors.assertIsSatisfied();
+ }
+
+ public void testInOutWithErrorHandledTrue() throws Exception {
+ MockEndpoint errors = getMockEndpoint("mock:errors");
+ errors.expectedMessageCount(0);
+
+ ServiceMixClient client = new DefaultServiceMixClient(jbiContainer);
+ InOut exchange = client.createInOutExchange();
+ exchange.setService(new QName("urn:test", "error-handled-true"));
+ exchange.getInMessage().setContent(new StringSource(MESSAGE));
+ client.sendSync(exchange);
+ assertEquals(ExchangeStatus.ACTIVE, exchange.getStatus());
+ client.done(exchange);
+
+ receiverComponent.getMessageList().assertMessagesReceived(1);
+
+ errors.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRoutes() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ onException(IllegalStateException.class).handled(false).to("jbi:service:urn:test:receiver-service?mep=in-only");
+ onException(NullPointerException.class).handled(true).to("jbi:service:urn:test:receiver-service?mep=in-only");
+ errorHandler(deadLetterChannel("mock:errors").maximumRedeliveries(1).initialRedeliveryDelay(300));
+ from("jbi:service:urn:test:no-handle-fault").to("jbi:service:urn:test:faulty-service");
+ from("jbi:service:urn:test:handle-fault").handleFault().to("jbi:service:urn:test:faulty-service");
+ from("jbi:service:urn:test:error-not-handled").to("jbi:service:urn:test:iae-error-service");
+ from("jbi:service:urn:test:error-handled-false").to("jbi:service:urn:test:ise-error-service");
+ from("jbi:service:urn:test:error-handled-true").to("jbi:service:urn:test:npe-error-service");
+ }
+ };
+ }
+
+ @Override
+ protected void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList) {
+ super.appendJbiActivationSpecs(activationSpecList);
+ }
+
+}
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiInOutCamelErrorHandlingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej?rev=711212&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej Tue Nov 4 00:55:42 2008
@@ -0,0 +1,54 @@
+***************
+*** 16,29 ****
+ */
+ package org.apache.servicemix.camel;
+
+ import javax.jbi.management.DeploymentException;
+
+ import org.apache.camel.builder.RouteBuilder;
+
+ /**
+ * Test for {@link JbiEndpoint.JbiProducer}
+ */
+- public class JbiProducerTest extends JbiCamelErrorHandlingTestSupport {
+
+ /*
+ * Ensure that no exceptions get thrown when shutting down the routes
+--- 16,32 ----
+ */
+ package org.apache.servicemix.camel;
+
++ import java.util.List;
++
+ import javax.jbi.management.DeploymentException;
+
+ import org.apache.camel.builder.RouteBuilder;
++ import org.apache.servicemix.jbi.container.ActivationSpec;
+
+ /**
+ * Test for {@link JbiEndpoint.JbiProducer}
+ */
++ public class JbiProducerTest extends JbiTestSupport {
+
+ /*
+ * Ensure that no exceptions get thrown when shutting down the routes
+***************
+*** 41,46 ****
+ protected void tearDown() throws Exception {
+ // testing shutdown, so will do this manually
+ }
+
+ @Override
+ protected RouteBuilder createRoutes() {
+--- 44,54 ----
+ protected void tearDown() throws Exception {
+ // testing shutdown, so will do this manually
+ }
++
++ @Override
++ protected void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList) {
++ // no additional activation specs required
++ }
+
+ @Override
+ protected RouteBuilder createRoutes() {
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiTestSupport.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiTestSupport.java?rev=711212&r1=711211&r2=711212&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiTestSupport.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiTestSupport.java Tue Nov 4 00:55:42 2008
@@ -22,6 +22,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.jbi.JBIException;
import javax.xml.namespace.QName;
import org.apache.camel.AsyncCallback;
@@ -35,7 +36,10 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
import org.apache.servicemix.jbi.container.ActivationSpec;
+import org.apache.servicemix.jbi.container.JBIContainer;
import org.apache.servicemix.jbi.container.SpringJBIContainer;
import org.apache.servicemix.tck.ExchangeCompletedListener;
@@ -43,6 +47,7 @@
* @version $Revision: 563665 $
*/
public abstract class JbiTestSupport extends TestSupport {
+
protected Exchange receivedExchange;
protected CamelContext camelContext = new DefaultCamelContext();
@@ -58,6 +63,8 @@
protected String startEndpointUri = "jbi:endpoint:serviceNamespace:serviceA:endpointA";
protected ProducerTemplate<Exchange> client = camelContext.createProducerTemplate();
+
+ protected ServiceMixClient servicemixClient;
/**
* Sends an exchange to the endpoint
@@ -108,42 +115,65 @@
@Override
protected void setUp() throws Exception {
- jbiContainer.setEmbedded(true);
- exchangeCompletedListener = new ExchangeCompletedListener();
-
- CamelJbiComponent component = new CamelJbiComponent();
-
+ configureContainer(jbiContainer);
List<ActivationSpec> activationSpecList = new ArrayList<ActivationSpec>();
-
+
// lets add the Camel endpoint
- ActivationSpec activationSpec = new ActivationSpec();
- activationSpec.setId("camel");
- activationSpec.setService(new QName("camel", "camel"));
- activationSpec.setEndpoint("camelEndpoint");
- activationSpec.setComponent(component);
- activationSpecList.add(activationSpec);
+ CamelJbiComponent component = new CamelJbiComponent();
+ activationSpecList.add(createActivationSpec(component, new QName("camel", "camel"), "camelEndpoint"));
+ // and provide a callback method for adding more services
appendJbiActivationSpecs(activationSpecList);
-
- ActivationSpec[] activationSpecs = activationSpecList
- .toArray(new ActivationSpec[activationSpecList.size()]);
- jbiContainer.setActivationSpecs(activationSpecs);
+ jbiContainer.setActivationSpecs(activationSpecList.toArray(new ActivationSpec[activationSpecList.size()]));
+
jbiContainer.afterPropertiesSet();
+
+ exchangeCompletedListener = new ExchangeCompletedListener();
jbiContainer.addListener(exchangeCompletedListener);
- // lets configure some componnets
- camelContext.addComponent("jbi", component);
-
+ // allow for additional configuration of the compenent (e.g. deploying SU)
+ configureComponent(component);
+
// lets add some routes
- camelContext.addRoutes(createRoutes());
+ RouteBuilder builder = createRoutes();
+ if (builder != null) {
+ camelContext.addRoutes(builder);
+ }
endpoint = camelContext.getEndpoint(startEndpointUri);
- assertNotNull("No endpoint found!", endpoint);
camelContext.start();
}
+ protected void configureComponent(CamelJbiComponent component) throws Exception {
+ // add the ServiceMix Camel component to the CamelContext
+ camelContext.addComponent("jbi", component);
+ }
+
+ protected void configureContainer(final JBIContainer container) throws Exception {
+ container.setEmbedded(true);
+ }
+
+ public ServiceMixClient getServicemixClient() throws JBIException {
+ if (servicemixClient == null) {
+ servicemixClient = new DefaultServiceMixClient(jbiContainer);
+ }
+ return servicemixClient;
+ }
+
+ protected ActivationSpec createActivationSpec(Object component, QName service) {
+ return createActivationSpec(component, service, "endpoint");
+ }
+
+ protected ActivationSpec createActivationSpec(Object component, QName service, String endpointName) {
+ ActivationSpec spec = new ActivationSpec(component);
+ spec.setService(service);
+ spec.setEndpoint(endpointName);
+ return spec;
+ }
+
@Override
protected void tearDown() throws Exception {
+ getServicemixClient().close();
client.stop();
camelContext.stop();
super.tearDown();
@@ -154,8 +184,7 @@
}
- protected abstract void appendJbiActivationSpecs(
- List<ActivationSpec> activationSpecList);
+ protected abstract void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList);
protected abstract RouteBuilder createRoutes();
}
Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/NonJbiCamelEndpointsIntegrationTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/NonJbiCamelEndpointsIntegrationTest.java?rev=711212&r1=711211&r2=711212&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/NonJbiCamelEndpointsIntegrationTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/NonJbiCamelEndpointsIntegrationTest.java Tue Nov 4 00:55:42 2008
@@ -20,7 +20,7 @@
import java.net.URI;
import java.net.URL;
-import javax.jbi.messaging.InOut;
+import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
@@ -39,8 +39,8 @@
* @version $Revision: 1.1 $
*/
public class NonJbiCamelEndpointsIntegrationTest extends TestCase {
- private static final transient Log LOG = LogFactory
- .getLog(NonJbiCamelEndpointsIntegrationTest.class);
+
+ private static final transient Log LOG = LogFactory.getLog(NonJbiCamelEndpointsIntegrationTest.class);
protected String suName = "su1";
@@ -77,7 +77,9 @@
checkResult(exchange);
//assertNotNull(exchange.getMessage("out").getContent());
// TODO: check out the exchange
- client.done(exchange);
+ if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
+ client.done(exchange);
+ }
// Stop and undeploy
component.getServiceUnitManager().stop(suName);
@@ -142,7 +144,7 @@
deleteDir(tempRootDir);
}
- protected InOut createExchange(ServiceMixClient client)
+ protected MessageExchange createExchange(ServiceMixClient client)
throws MessagingException {
return client.createInOutExchange();
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/SpringJbiTestSupport.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/SpringJbiTestSupport.java?rev=711212&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/SpringJbiTestSupport.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/SpringJbiTestSupport.java Tue Nov 4 00:55:42 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.servicemix.camel;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.util.FileUtil;
+
+/**
+ * Enhances {@link JbiTestSupport} to enable SU deployment as well
+ */
+public abstract class SpringJbiTestSupport extends JbiTestSupport {
+
+ private static final Log LOG = LogFactory.getLog(SpringJbiTestSupport.class);
+
+ private File tempRootDir;
+
+ @Override
+ protected void configureComponent(CamelJbiComponent component) throws Exception {
+ super.configureComponent(component);
+
+ // let's add a Camel SU from the camel-context.xml
+ URL url = getClass().getResource(getServiceUnitName() + "-src/camel-context.xml");
+ File path = new File(new URI(url.toString())).getParentFile();
+
+ component.getServiceUnitManager().deploy(getServiceUnitName(), path.getAbsolutePath());
+ component.getServiceUnitManager().init(getServiceUnitName(), path.getAbsolutePath());
+ component.getServiceUnitManager().start(getServiceUnitName());
+
+ }
+
+ @Override
+ protected void configureContainer(JBIContainer container) throws Exception {
+ super.configureContainer(container);
+ jbiContainer.setCreateMBeanServer(false);
+ jbiContainer.setMonitorInstallationDirectory(false);
+ tempRootDir = File.createTempFile("servicemix", "rootDir");
+ tempRootDir.delete();
+ File tempTemp = new File(tempRootDir.getAbsolutePath() + "/temp");
+ if (!tempTemp.mkdirs()) {
+ fail("Unable to create temporary working root directory [" + tempTemp.getAbsolutePath() + "]");
+ }
+ LOG.info("Using temporary root directory [" + tempRootDir.getAbsolutePath() + "]");
+ jbiContainer.setRootDir(tempRootDir.getAbsolutePath());
+
+ jbiContainer.setEmbedded(true);
+ jbiContainer.setCreateJmxConnector(false);
+ jbiContainer.setFlowName("st");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ jbiContainer.stop();
+ jbiContainer.shutDown();
+ FileUtil.deleteFile(tempRootDir);
+ }
+
+ protected abstract String getServiceUnitName();
+
+ @Override
+ protected RouteBuilder createRoutes() {
+ return null;
+ }
+}
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/SpringJbiTestSupport.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su8-src/camel-context.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su8-src/camel-context.xml?rev=711212&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su8-src/camel-context.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su8-src/camel-context.xml Tue Nov 4 00:55:42 2008
@@ -0,0 +1,57 @@
+<?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.
+
+-->
+<!-- START SNIPPET: camel -->
+<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.0.xsd
+ http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+ <!-- not supported by Camel 1.4
+ <bean id="camelTracer" class="org.apache.camel.processor.interceptor.Tracer">
+ <property name="traceExceptions" value="false"/>
+ <property name="traceInterceptors" value="true"/>
+ <property name="logLevel" value="FATAL"/>
+ <property name="logName" value="com.mycompany.messages"/>
+ </bean>
+ -->
+
+
+ <camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route errorHandlerRef="deadLetterErrorHandler">
+ <from uri="jbi:service:urn:test:error-handled-true"/>
+ <onException>
+ <exception>java.lang.NullPointerException</exception>
+ <redeliveryPolicy maximumRedeliveries="0"/>
+ <handled>
+ <constant>true</constant>
+ </handled>
+ <to uri="jbi:service:urn:test:receiver-service?mep=in-only"/>
+ </onException>
+ <to uri="jbi:service:urn:test:npe-error-service?mep=in-only"/>
+ </route>
+ </camelContext>
+
+ <bean id="deadLetterErrorHandler" class="org.apache.camel.builder.DeadLetterChannelBuilder">
+ <property name="defaultDeadLetterEndpointUri" value="jbi:service:urn:test:deadLetter-service?mep=in-only"/>
+ </bean>
+
+</beans>
Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/resources/org/apache/servicemix/camel/su8-src/camel-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/smx3/branches/servicemix-3.2/platforms/geronimo/deployer/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Nov 4 00:55:42 2008
@@ -3,3 +3,4 @@
target
.settings
*.iml
+bin
Propchange: servicemix/smx3/branches/servicemix-3.2/platforms/geronimo/servicemix/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Tue Nov 4 00:55:42 2008
@@ -3,3 +3,4 @@
velocity.log
.settings
*.iml
+bin
Modified: servicemix/smx3/branches/servicemix-3.2/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/pom.xml?rev=711212&r1=711211&r2=711212&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/pom.xml (original)
+++ servicemix/smx3/branches/servicemix-3.2/pom.xml Tue Nov 4 00:55:42 2008
@@ -207,7 +207,7 @@
<activemq-version>4.1.1</activemq-version>
<activeio-version>3.0.0-incubator</activeio-version>
<backport-util-concurrent-version>2.2</backport-util-concurrent-version>
- <camel-version>1.4.0</camel-version>
+ <camel-version>1.5.0</camel-version>
<jencks-version>2.1</jencks-version>
<jetty-version>6.1.12rc1</jetty-version>
<geronimo-version>2.0.1</geronimo-version>
Re: svn commit: r711212 - in /servicemix/smx3/branches/servicemix-3.2:
./ archetypes/servicemix-cxf-se-wsdl-first-service-unit/ deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/
deployables/serviceengines/servicemix-cam...
Posted by Willem Jiang <wi...@gmail.com>.
Hi Gert,
Can you remove the JbiProducerTest.java.rej from the repository ?
I think you did not mean to commit it.
Willem
gertv@apache.org wrote:
> Author: gertv
> Date: Tue Nov 4 00:55:42 2008
> New Revision: 711212
>
> URL: http://svn.apache.org/viewvc?rev=711212&view=rev
> Log:
> SM-1673: improve error handling in servicemix-camel
>
> Added:
> servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej
> Added: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej
> URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej?rev=711212&view=auto
> ==============================================================================
> --- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej (added)
> +++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiProducerTest.java.rej Tue Nov 4 00:55:42 2008
> @@ -0,0 +1,54 @@
> +***************
> +*** 16,29 ****
> + */
> + package org.apache.servicemix.camel;
> +
> + import javax.jbi.management.DeploymentException;
> +
> + import org.apache.camel.builder.RouteBuilder;
> +
> + /**
> + * Test for {@link JbiEndpoint.JbiProducer}
> + */
> +- public class JbiProducerTest extends JbiCamelErrorHandlingTestSupport {
> +
> + /*
> + * Ensure that no exceptions get thrown when shutting down the routes
> +--- 16,32 ----
> + */
> + package org.apache.servicemix.camel;
> +
> ++ import java.util.List;
> ++
> + import javax.jbi.management.DeploymentException;
> +
> + import org.apache.camel.builder.RouteBuilder;
> ++ import org.apache.servicemix.jbi.container.ActivationSpec;
> +
> + /**
> + * Test for {@link JbiEndpoint.JbiProducer}
> + */
> ++ public class JbiProducerTest extends JbiTestSupport {
> +
> + /*
> + * Ensure that no exceptions get thrown when shutting down the routes
> +***************
> +*** 41,46 ****
> + protected void tearDown() throws Exception {
> + // testing shutdown, so will do this manually
> + }
> +
> + @Override
> + protected RouteBuilder createRoutes() {
> +--- 44,54 ----
> + protected void tearDown() throws Exception {
> + // testing shutdown, so will do this manually
> + }
> ++
> ++ @Override
> ++ protected void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList) {
> ++ // no additional activation specs required
> ++ }
> +
> + @Override
> + protected RouteBuilder createRoutes() {
>
> Modified: servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiTestSupport.java
> URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiTestSupport.java?rev=711212&r1=711211&r2=711212&view=diff
> ==============================================================================
> --- servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiTestSupport.java (original)
> +++ servicemix/smx3/branches/servicemix-3.2/deployables/serviceengines/servicemix-camel/src/test/java/org/apache/servicemix/camel/JbiTestSupport.java Tue Nov 4 00:55:42 2008
> @@ -22,6 +22,7 @@
> import java.util.concurrent.TimeUnit;
> import java.util.concurrent.atomic.AtomicBoolean;
>
> +import javax.jbi.JBIException;
> import javax.xml.namespace.QName;
>
> import org.apache.camel.AsyncCallback;
> @@ -35,7 +36,10 @@
> import org.apache.camel.builder.RouteBuilder;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.impl.DefaultCamelContext;
> +import org.apache.servicemix.client.DefaultServiceMixClient;
> +import org.apache.servicemix.client.ServiceMixClient;
> import org.apache.servicemix.jbi.container.ActivationSpec;
> +import org.apache.servicemix.jbi.container.JBIContainer;
> import org.apache.servicemix.jbi.container.SpringJBIContainer;
> import org.apache.servicemix.tck.ExchangeCompletedListener;
>
> @@ -43,6 +47,7 @@
> * @version $Revision: 563665 $
> */
> public abstract class JbiTestSupport extends TestSupport {
> +
> protected Exchange receivedExchange;
>
> protected CamelContext camelContext = new DefaultCamelContext();
> @@ -58,6 +63,8 @@
> protected String startEndpointUri = "jbi:endpoint:serviceNamespace:serviceA:endpointA";
>
> protected ProducerTemplate<Exchange> client = camelContext.createProducerTemplate();
> +
> + protected ServiceMixClient servicemixClient;
>
> /**
> * Sends an exchange to the endpoint
> @@ -108,42 +115,65 @@
>
> @Override
> protected void setUp() throws Exception {
> - jbiContainer.setEmbedded(true);
> - exchangeCompletedListener = new ExchangeCompletedListener();
> -
> - CamelJbiComponent component = new CamelJbiComponent();
> -
> + configureContainer(jbiContainer);
> List<ActivationSpec> activationSpecList = new ArrayList<ActivationSpec>();
> -
> +
> // lets add the Camel endpoint
> - ActivationSpec activationSpec = new ActivationSpec();
> - activationSpec.setId("camel");
> - activationSpec.setService(new QName("camel", "camel"));
> - activationSpec.setEndpoint("camelEndpoint");
> - activationSpec.setComponent(component);
> - activationSpecList.add(activationSpec);
> + CamelJbiComponent component = new CamelJbiComponent();
> + activationSpecList.add(createActivationSpec(component, new QName("camel", "camel"), "camelEndpoint"));
>
> + // and provide a callback method for adding more services
> appendJbiActivationSpecs(activationSpecList);
> -
> - ActivationSpec[] activationSpecs = activationSpecList
> - .toArray(new ActivationSpec[activationSpecList.size()]);
> - jbiContainer.setActivationSpecs(activationSpecs);
> + jbiContainer.setActivationSpecs(activationSpecList.toArray(new ActivationSpec[activationSpecList.size()]));
> +
> jbiContainer.afterPropertiesSet();
> +
> + exchangeCompletedListener = new ExchangeCompletedListener();
> jbiContainer.addListener(exchangeCompletedListener);
>
> - // lets configure some componnets
> - camelContext.addComponent("jbi", component);
> -
> + // allow for additional configuration of the compenent (e.g. deploying SU)
> + configureComponent(component);
> +
> // lets add some routes
> - camelContext.addRoutes(createRoutes());
> + RouteBuilder builder = createRoutes();
> + if (builder != null) {
> + camelContext.addRoutes(builder);
> + }
> endpoint = camelContext.getEndpoint(startEndpointUri);
> - assertNotNull("No endpoint found!", endpoint);
>
> camelContext.start();
> }
>
> + protected void configureComponent(CamelJbiComponent component) throws Exception {
> + // add the ServiceMix Camel component to the CamelContext
> + camelContext.addComponent("jbi", component);
> + }
> +
> + protected void configureContainer(final JBIContainer container) throws Exception {
> + container.setEmbedded(true);
> + }
> +
> + public ServiceMixClient getServicemixClient() throws JBIException {
> + if (servicemixClient == null) {
> + servicemixClient = new DefaultServiceMixClient(jbiContainer);
> + }
> + return servicemixClient;
> + }
> +
> + protected ActivationSpec createActivationSpec(Object component, QName service) {
> + return createActivationSpec(component, service, "endpoint");
> + }
> +
> + protected ActivationSpec createActivationSpec(Object component, QName service, String endpointName) {
> + ActivationSpec spec = new ActivationSpec(component);
> + spec.setService(service);
> + spec.setEndpoint(endpointName);
> + return spec;
> + }
> +
> @Override
> protected void tearDown() throws Exception {
> + getServicemixClient().close();
> client.stop();
> camelContext.stop();
> super.tearDown();
> @@ -154,8 +184,7 @@
> }
>
>
> - protected abstract void appendJbiActivationSpecs(
> - List<ActivationSpec> activationSpecList);
> + protected abstract void appendJbiActivationSpecs(List<ActivationSpec> activationSpecList);
>
> protected abstract RouteBuilder createRoutes();
> }
>