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/17 06:16:10 UTC
svn commit: r637721 - in /activemq/camel/trunk/components/camel-mina/src:
main/java/org/apache/camel/component/mina/
test/java/org/apache/camel/component/mina/
Author: ningjiang
Date: Sun Mar 16 22:16:03 2008
New Revision: 637721
URL: http://svn.apache.org/viewvc?rev=637721&view=rev
Log:
CAMEL-383 patch applied with thanks to George and Claus
Added:
activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHelper.java (with props)
activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java (with props)
activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java (with props)
Modified:
activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaEndpoint.java
activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java
activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaComponentTest.java
activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConverterTest.java
activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java
activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTest.java
activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java
activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaUdpWithInOutUsingPlainSocketTest.java
Modified: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaComponent.java Sun Mar 16 22:16:03 2008
@@ -98,7 +98,7 @@
IoAcceptor acceptor = new VmPipeAcceptor();
SocketAddress address = new VmPipeAddress(connectUri.getPort());
IoConnector connector = new VmPipeConnector();
- return new MinaEndpoint(uri, this, address, acceptor, null, connector, null, false, 0);
+ return new MinaEndpoint(uri, this, address, acceptor, null, connector, null, false, 0, false);
}
protected MinaEndpoint createSocketEndpoint(String uri, URI connectUri, Map parameters) {
@@ -120,8 +120,9 @@
boolean lazySessionCreation = ObjectConverter.toBool(parameters.get("lazySessionCreation"));
long timeout = getTimeoutParameter(parameters);
+ boolean transferExchange = ObjectConverter.toBool(parameters.get("transferExchange"));
- MinaEndpoint endpoint = new MinaEndpoint(uri, this, address, acceptor, acceptorConfig, connector, connectorConfig, lazySessionCreation, timeout);
+ MinaEndpoint endpoint = new MinaEndpoint(uri, this, address, acceptor, acceptorConfig, connector, connectorConfig, lazySessionCreation, timeout, transferExchange);
boolean sync = ObjectConverter.toBool(parameters.get("sync"));
if (sync) {
@@ -169,8 +170,9 @@
boolean lazySessionCreation = ObjectConverter.toBool(parameters.get("lazySessionCreation"));
long timeout = getTimeoutParameter(parameters);
+ boolean transferExchange = false; // transfer exchange is not supported for datagram protocol
- MinaEndpoint endpoint = new MinaEndpoint(uri, this, address, acceptor, acceptorConfig, connector, connectorConfig, lazySessionCreation, timeout);
+ MinaEndpoint endpoint = new MinaEndpoint(uri, this, address, acceptor, acceptorConfig, connector, connectorConfig, lazySessionCreation, timeout, transferExchange);
boolean sync = ObjectConverter.toBool(parameters.get("sync"));
if (sync) {
Modified: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaConsumer.java Sun Mar 16 22:16:03 2008
@@ -78,7 +78,7 @@
getProcessor().process(exchange);
if (ExchangeHelper.isOutCapable(exchange)) {
- Object body = exchange.getOut().getBody();
+ Object body = MinaPayloadHelper.getOut(endpoint, exchange);
boolean failed = exchange.isFailed();
if (failed) {
@@ -117,5 +117,5 @@
acceptor.unbind(address);
super.doStop();
}
-
+
}
Modified: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaEndpoint.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaEndpoint.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaEndpoint.java Sun Mar 16 22:16:03 2008
@@ -45,8 +45,9 @@
private final IoAcceptorConfig acceptorConfig;
private final IoConnectorConfig connectorConfig;
private final boolean lazySessionCreation;
+ private final boolean transferExchange;
- public MinaEndpoint(String endpointUri, MinaComponent component, SocketAddress address, IoAcceptor acceptor, IoAcceptorConfig acceptorConfig, IoConnector connector, IoConnectorConfig connectorConfig, boolean lazySessionCreation, long timeout) {
+ public MinaEndpoint(String endpointUri, MinaComponent component, SocketAddress address, IoAcceptor acceptor, IoAcceptorConfig acceptorConfig, IoConnector connector, IoConnectorConfig connectorConfig, boolean lazySessionCreation, long timeout, boolean transferExchange) {
super(endpointUri, component);
this.address = address;
this.acceptor = acceptor;
@@ -58,6 +59,7 @@
// override default timeout if provided
this.timeout = timeout;
}
+ this.transferExchange = transferExchange;
}
public Producer<MinaExchange> createProducer() throws Exception {
@@ -73,9 +75,9 @@
return new MinaExchange(getContext(), pattern, null);
}
- public MinaExchange createExchange(IoSession session, Object object) {
+ public MinaExchange createExchange(IoSession session, Object payload) {
MinaExchange exchange = new MinaExchange(getContext(), getExchangePattern(), session);
- exchange.getIn().setBody(object);
+ MinaPayloadHelper.setIn(exchange, payload);
return exchange;
}
@@ -111,6 +113,10 @@
public long getTimeout() {
return timeout;
+ }
+
+ public boolean isTransferExchange() {
+ return transferExchange;
}
}
Added: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHelper.java?rev=637721&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHelper.java (added)
+++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHelper.java Sun Mar 16 22:16:03 2008
@@ -0,0 +1,71 @@
+/**
+ * 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.component.mina;
+
+import org.apache.camel.Exchange;
+
+/**
+ * Helper to get and set the correct payload when transfering data using camel-mina.
+ * Always use this helper instead of direct access on the exchange object.
+ * <p/>
+ * This helper ensures that we can also transfer exchange objects over the wire using the
+ * <tt>exchangePayload=true</tt> option.
+ *
+ * @see org.apache.camel.component.mina.MinaPayloadHolder
+ * @version $Revision$
+ */
+public class MinaPayloadHelper {
+
+ public static Object getIn(MinaEndpoint endpoint, Exchange exchange) {
+ if (endpoint.isTransferExchange()) {
+ // we should transfer the entire exchange over the wire (includes in/out)
+ return MinaPayloadHolder.marshal(exchange);
+ } else {
+ // normal transfer using the body only
+ return exchange.getIn().getBody();
+ }
+ }
+
+ public static Object getOut(MinaEndpoint endpoint, Exchange exchange) {
+ if (endpoint.isTransferExchange()) {
+ // we should transfer the entire exchange over the wire (includes in/out)
+ return MinaPayloadHolder.marshal(exchange);
+ } else {
+ // normal transfer using the body only
+ return exchange.getOut().getBody();
+ }
+ }
+
+ public static void setIn(Exchange exchange, Object payload) {
+ if (payload instanceof MinaPayloadHolder) {
+ MinaPayloadHolder.unmarshal(exchange, (MinaPayloadHolder) payload);
+ } else {
+ // normal transfer using the body only
+ exchange.getIn().setBody(payload);
+ }
+ }
+
+ public static void setOut(Exchange exchange, Object payload) {
+ if (payload instanceof MinaPayloadHolder) {
+ MinaPayloadHolder.unmarshal(exchange, (MinaPayloadHolder) payload);
+ } else {
+ // normal transfer using the body only
+ exchange.getOut().setBody(payload);
+ }
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHelper.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java?rev=637721&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java (added)
+++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java Sun Mar 16 22:16:03 2008
@@ -0,0 +1,101 @@
+/**
+ * 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.component.mina;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.LinkedHashMap;
+
+import org.apache.camel.Exchange;
+
+/**
+ * Holder object for sending an exchange over the wire using the MINA ObjectSerializationCodecFactory codec.
+ * This is configured using the <tt>transferExchange=true</tt> option for the TCP protocol.
+ * <p/>
+ * As opposed to normal usage of camel-mina where only the body part of the exchange is transfered, this holder
+ * object serializes the following fields over the wire:
+ * <ul>
+ * <li>in body</li>
+ * <li>out body</li>
+ * <li>in headers</li>
+ * <li>out headers</li>
+ * <li>exchange properties</li>
+ * <li>exception</li>
+ * </ul>
+ *
+ * @version $Revision$
+ */
+public class MinaPayloadHolder implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private Object inBody;
+ private Object outBody;
+ private Map<String, Object> inHeaders = new LinkedHashMap<String, Object>();
+ private Map<String, Object> outHeaders = new LinkedHashMap<String, Object>();
+ private Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ private Throwable exception;
+
+ /**
+ * Creates a payload object with the information from the given exchange.
+ *
+ * @param exchange the exchange
+ * @return the holder object with information copied form the exchange
+ */
+ public static MinaPayloadHolder marshal(Exchange exchange) {
+ MinaPayloadHolder payload = new MinaPayloadHolder();
+
+ payload.inBody = exchange.getIn().getBody();
+ if (exchange.getOut(false) != null) {
+ payload.outBody = exchange.getOut().getBody();
+ }
+ payload.inHeaders.putAll(exchange.getIn().getHeaders());
+ payload.outHeaders.putAll(exchange.getOut().getHeaders());
+ payload.properties.putAll(exchange.getProperties());
+ payload.exception = exchange.getException();
+
+ return payload;
+ }
+
+ /**
+ * Transfers the information from the payload to the exchange.
+ *
+ * @param exchange the exchange to set values from the payload
+ * @param payload the payload with the values
+ */
+ public static void unmarshal(Exchange exchange, MinaPayloadHolder payload) {
+ exchange.getIn().setBody(payload.inBody);
+ exchange.getOut().setBody(payload.outBody);
+ exchange.getIn().setHeaders(payload.inHeaders);
+ exchange.getOut().setHeaders(payload.outHeaders);
+ for (String key : payload.properties.keySet()) {
+ exchange.setProperty(key, payload.properties.get(key));
+ }
+ exchange.setException(payload.exception);
+ }
+
+ public String toString() {
+ return "MinaPayloadHolder{" +
+ "inBody=" + inBody +
+ ", outBody=" + outBody +
+ ", inHeaders=" + inHeaders +
+ ", outHeaders=" + outHeaders +
+ ", properties=" + properties +
+ ", exception=" + exception +
+ '}';
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaPayloadHolder.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/main/java/org/apache/camel/component/mina/MinaProducer.java Sun Mar 16 22:16:03 2008
@@ -63,7 +63,7 @@
openConnection();
}
- Object body = exchange.getIn().getBody();
+ Object body = MinaPayloadHelper.getIn(endpoint, exchange);
if (body == null) {
LOG.warn("No payload for exchange: " + exchange);
} else {
@@ -94,7 +94,7 @@
if (LOG.isDebugEnabled()) {
LOG.debug("Handler message: " + handler.getMessage());
}
- exchange.getOut().setBody(handler.getMessage());
+ MinaPayloadHelper.setOut(exchange, handler.getMessage());
}
} else {
session.write(body);
Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaComponentTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaComponentTest.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaComponentTest.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaComponentTest.java Sun Mar 16 22:16:03 2008
@@ -1,3 +1,22 @@
+/*
+ * 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.component.mina;
import org.apache.camel.ContextTestSupport;
Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConverterTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConverterTest.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConverterTest.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaConverterTest.java Sun Mar 16 22:16:03 2008
@@ -1,3 +1,22 @@
+/*
+ * 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.component.mina;
import junit.framework.TestCase;
Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaEncodingTest.java Sun Mar 16 22:16:03 2008
@@ -23,8 +23,6 @@
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
-import java.nio.charset.Charset;
-
/**
* Unit testing using different encodings with the TCP protocol.
*
Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTest.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTest.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTest.java Sun Mar 16 22:16:03 2008
@@ -1,3 +1,22 @@
+/*
+ * 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.component.mina;
import org.apache.camel.ContextTestSupport;
Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaExchangeTimeOutTest.java Sun Mar 16 22:16:03 2008
@@ -1,3 +1,22 @@
+/*
+ * 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.component.mina;
import org.apache.camel.*;
Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTcpWithIoOutProcessorExceptionTest.java Sun Mar 16 22:16:03 2008
@@ -1,3 +1,22 @@
+/*
+ * 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.component.mina;
import org.apache.camel.ContextTestSupport;
Added: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java?rev=637721&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java (added)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java Sun Mar 16 22:16:03 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.camel.component.mina;
+
+import junit.framework.Assert;
+
+import org.apache.camel.ContextTestSupport;
+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.builder.RouteBuilder;
+
+/**
+ * Unit test for the <tt>transferExchange=true</tt> option.
+ *
+ * @version $Revision$
+ */
+public class MinaTransferExchangeOptionTest extends ContextTestSupport {
+
+ private static final String URI = "mina:tcp://localhost:6321?sync=true&transferExchange=true";
+ private static String id;
+
+ public void testMinaTransferExchangeOption() throws Exception {
+ Endpoint endpoint = context.getEndpoint(URI);
+ Exchange exchange = endpoint.createExchange();
+ id = exchange.getExchangeId();
+
+ Message message = exchange.getIn();
+ message.setBody("Hello!");
+ message.setHeader("cheese", "feta");
+ exchange.setProperty("ham", "old");
+
+ Producer producer = endpoint.createProducer();
+ producer.start();
+ producer.process(exchange);
+
+ Message out = exchange.getOut();
+ assertNotNull(out);
+ System.out.println("out" + out);
+ assertEquals("Goodbye!", out.getBody());
+ assertEquals("cheddar", out.getHeader("cheese"));
+ assertEquals("fresh", exchange.getProperty("salami"));
+ assertEquals(id, exchange.getExchangeId());
+
+ // in should stay the same
+ Message in = exchange.getIn();
+ assertNotNull(in);
+ assertEquals("Hello!", in.getBody());
+ assertEquals("feta", in.getHeader("cheese"));
+ // however the shared properties have changed
+ assertEquals("fresh", exchange.getProperty("salami"));
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from(URI).process(new Processor() {
+ public void process(Exchange e) throws InterruptedException {
+ // to force some delay to test that the id stays the same even though time is 100 millis later
+ Thread.sleep(100);
+
+ Assert.assertNotNull(e.getIn().getBody());
+ Assert.assertNotNull(e.getIn().getHeaders());
+ Assert.assertNotNull(e.getProperties());
+ Assert.assertEquals("Hello!", e.getIn().getBody());
+ Assert.assertEquals("feta", e.getIn().getHeader("cheese"));
+ Assert.assertEquals("old", e.getProperty("ham"));
+ // do not marshal the exchangeId here
+ //Assert.assertEquals(id, e.getExchangeId());
+ Assert.assertEquals(ExchangePattern.InOut, e.getPattern());
+
+ e.getOut().setBody("Goodbye!");
+ e.getOut().setHeader("cheese", "cheddar");
+ e.setProperty("salami", "fresh");
+ }
+ });
+ }
+ };
+ }
+}
Propchange: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaTransferExchangeOptionTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaUdpWithInOutUsingPlainSocketTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaUdpWithInOutUsingPlainSocketTest.java?rev=637721&r1=637720&r2=637721&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaUdpWithInOutUsingPlainSocketTest.java (original)
+++ activemq/camel/trunk/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaUdpWithInOutUsingPlainSocketTest.java Sun Mar 16 22:16:03 2008
@@ -1,3 +1,22 @@
+/*
+ * 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.component.mina;
import org.apache.camel.ContextTestSupport;