You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2010/09/20 10:34:11 UTC
svn commit: r998825 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/
tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mina/
tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/netty/
Author: davsclaus
Date: Mon Sep 20 08:34:10 2010
New Revision: 998825
URL: http://svn.apache.org/viewvc?rev=998825&view=rev
Log:
CAMEL-3126: Added more osgi unit tests.
Added:
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mina/
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mina/MinaTest.java
- copied, changed from r998823, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/netty/
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/netty/NettyTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=998825&r1=998824&r2=998825&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Mon Sep 20 08:34:10 2010
@@ -403,7 +403,7 @@ public interface CamelContext extends Su
*
* @param routeId the route id
* @throws Exception is thrown if the route could not be shutdown for whatever reason
- * @deprecated use {@link #stopRoute(String)}
+ * @deprecated use {@link #stopRoute(String)} and {@link #removeRoute(String)}
*/
@Deprecated
void shutdownRoute(String routeId) throws Exception;
@@ -415,7 +415,7 @@ public interface CamelContext extends Su
* @param timeout timeout
* @param timeUnit the unit to use
* @throws Exception is thrown if the route could not be shutdown for whatever reason
- * @deprecated use {@link #stopRoute(String, long, java.util.concurrent.TimeUnit)}
+ * @deprecated use {@link #stopRoute(String, long, java.util.concurrent.TimeUnit)} and {@link #removeRoute(String)}
*/
@Deprecated
void shutdownRoute(String routeId, long timeout, TimeUnit timeUnit) throws Exception;
Copied: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mina/MinaTest.java (from r998823, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mina/MinaTest.java?p2=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mina/MinaTest.java&p1=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java&r1=998823&r2=998825&rev=998825&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/mina/MinaTest.java Mon Sep 20 08:34:10 2010
@@ -14,12 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.itest.osgi.freemarker;
+package org.apache.camel.itest.osgi.mina;
-import org.apache.camel.Exchange;
-import org.apache.camel.InvalidPayloadException;
-import org.apache.camel.Message;
-import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
import org.junit.Test;
@@ -36,29 +32,24 @@ import static org.ops4j.pax.exam.contain
import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
@RunWith(JUnit4TestRunner.class)
-public class FreemarkerTest extends OSGiIntegrationTestSupport {
+public class MinaTest extends OSGiIntegrationTestSupport {
@Test
- public void testReceivesResponse() throws Exception {
- assertRespondsWith("foo", "<hello>foo</hello>");
- assertRespondsWith("bar", "<hello>bar</hello>");
- }
+ public void testMina() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("World");
- protected void assertRespondsWith(final String value, String expectedBody) throws InvalidPayloadException {
- Exchange response = template.request("direct:a", new Processor() {
- public void process(Exchange exchange) throws Exception {
- Message in = exchange.getIn();
- in.setBody("answer");
- in.setHeader("cheese", value);
- }
- });
- assertOutMessageBodyEquals(response, expectedBody);
+ String reply = template.requestBody("mina:tcp://localhost:8877?textline=true", "World", String.class);
+ assertEquals("Bye World", reply);
+
+ assertMockEndpointsSatisfied();
}
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from("direct:a").to("freemarker:org/apache/camel/itest/osgi/freemarker/example.ftl");
+ from("mina:tcp://localhost:8877?textline=true")
+ .to("mock:result")
+ .transform(body().prepend("Bye "));
}
};
}
@@ -73,7 +64,7 @@ public class FreemarkerTest extends OSGi
// using the features to install the camel components
scanFeatures(getCamelKarafFeatureUrl(),
- "camel-core", "camel-spring", "camel-test", "camel-freemarker"),
+ "camel-core", "camel-test", "camel-mina"),
workingDirectory("target/paxrunner/"),
Added: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/netty/NettyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/netty/NettyTest.java?rev=998825&view=auto
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/netty/NettyTest.java (added)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/netty/NettyTest.java Mon Sep 20 08:34:10 2010
@@ -0,0 +1,75 @@
+/**
+ * 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.itest.osgi.netty;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+import static org.ops4j.pax.exam.CoreOptions.equinox;
+import static org.ops4j.pax.exam.CoreOptions.felix;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.profile;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
+
+@RunWith(JUnit4TestRunner.class)
+public class NettyTest extends OSGiIntegrationTestSupport {
+
+ @Test
+ public void testNetty() throws Exception {
+ getMockEndpoint("mock:result").expectedBodiesReceived("World");
+
+ String reply = template.requestBody("netty:tcp://localhost:8876?textline=true", "World", String.class);
+ assertEquals("Bye World", reply);
+
+ assertMockEndpointsSatisfied();
+ }
+
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("netty:tcp://localhost:8876?textline=true")
+ .to("mock:result")
+ .transform(body().prepend("Bye "));
+ }
+ };
+ }
+
+ @Configuration
+ public static Option[] configure() {
+ Option[] options = options(
+ // install the spring dm profile
+ profile("spring.dm").version("1.2.0"),
+ // this is how you set the default log level when using pax logging (logProfile)
+ org.ops4j.pax.exam.CoreOptions.systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+
+ // using the features to install the camel components
+ scanFeatures(getCamelKarafFeatureUrl(),
+ "camel-core", "camel-test", "camel-netty"),
+
+ workingDirectory("target/paxrunner/"),
+
+ felix(), equinox());
+
+ return options;
+ }
+}
\ No newline at end of file