Author: ningjiang
Date: Tue Aug 23 11:38:32 2011
New Revision: 1160637
URL: http://svn.apache.org/viewvc?rev=1160637&view=rev
Log:
CAMEL-4367 made the Camel-netty option encoder and decoder work
Added:
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
(with props)
Modified:
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
Modified:
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java?rev=1160637&r1=1160636&r2=1160637&view=diff
==============================================================================
---
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
(original)
+++
camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
Tue Aug 23 11:38:32 2011
@@ -122,6 +122,7 @@ public class NettyConfiguration implemen
addToHandlersList(decoders, referencedDecoders,
ChannelUpstreamHandler.class);
// then set parameters with the help of the camel context type
converters
+ EndpointHelper.setReferenceProperties(component.getCamelContext(),
this, parameters);
EndpointHelper.setProperties(component.getCamelContext(), this,
parameters);
// add default encoders and decoders
Added:
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java?rev=1160637&view=auto
==============================================================================
---
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
(added)
+++
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
Tue Aug 23 11:38:32 2011
@@ -0,0 +1,62 @@
+/**
+ * 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.netty;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.jboss.netty.handler.codec.string.StringDecoder;
+import org.jboss.netty.handler.codec.string.StringEncoder;
+import org.junit.Test;
+
+public class NettySingleCodecTest extends BaseNettyTest {
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry registry = super.createRegistry();
+ StringEncoder stringEncoder = new StringEncoder();
+
+ StringDecoder stringDecoder = new StringDecoder();
+
+ registry.bind("encoder", stringEncoder);
+ registry.bind("decoder", stringDecoder);
+ return registry;
+ }
+
+ @Test
+ public void canSupplySingleCodecToEndpointPipeline() throws Exception {
+ String poem = new Poetry().getPoem();
+ MockEndpoint mock = getMockEndpoint("mock:single-codec");
+ mock.expectedBodiesReceived(poem);
+ sendBody("direct:single-codec", poem);
+ mock.await(1, TimeUnit.SECONDS);
+ mock.assertIsSatisfied();
+
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+
from("direct:single-codec").to("netty:tcp://localhost:{{port}}?encoder=#encoder&sync=false");
+
+
from("netty:tcp://localhost:{{port}}?decoder=#decoder&sync=false").to("mock:single-codec");
+ }
+ };
+ }
+}
\ No newline at end of file
Propchange:
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettySingleCodecTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date