Updated Branches: refs/heads/master 32c22d529 -> b8c6b0697
Fixed the hard-coded port usages which recently caused the HL7 test failures on the CI-Server. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b8c6b069 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b8c6b069 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b8c6b069 Branch: refs/heads/master Commit: b8c6b0697536dc8ea47c5c4d974cb127bbdf5704 Parents: 32c22d5 Author: Babak Vahdat <bvah...@apache.org> Authored: Tue Oct 15 10:14:24 2013 +0200 Committer: Babak Vahdat <bvah...@apache.org> Committed: Tue Oct 15 10:14:24 2013 +0200 ---------------------------------------------------------------------- .../component/hl7/HL7MLLPCodecBoundaryTest.java | 7 ++-- .../component/hl7/HL7MLLPCodecLongTest.java | 7 ++-- .../hl7/HL7MLLPCodecPlainStringTest.java | 7 ++-- .../hl7/HL7MLLPCodecStandAndEndBytesTest.java | 7 ++-- .../camel/component/hl7/HL7MLLPCodecTest.java | 7 ++-- .../camel/component/hl7/HL7RouteTest.java | 11 +++--- .../camel/component/hl7/HL7TestSupport.java | 37 ++++++++++++++++++++ 7 files changed, 57 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/b8c6b069/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java index a4c9801..8d842cc 100644 --- a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java +++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecBoundaryTest.java @@ -26,7 +26,6 @@ import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.JndiRegistry; -import org.apache.camel.test.junit4.CamelTestSupport; import org.apache.camel.util.IOHelper; import org.junit.Test; @@ -35,7 +34,7 @@ import org.junit.Test; * Test for situation where the two end bytes are split across different byte * buffers. */ -public class HL7MLLPCodecBoundaryTest extends CamelTestSupport { +public class HL7MLLPCodecBoundaryTest extends HL7TestSupport { protected JndiRegistry createRegistry() throws Exception { JndiRegistry jndi = super.createRegistry(); @@ -48,7 +47,7 @@ public class HL7MLLPCodecBoundaryTest extends CamelTestSupport { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { - from("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec").process(new Processor() { + from("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec").process(new Processor() { public void process(Exchange exchange) throws Exception { // check presence of correct message type exchange.getIn().getBody(MDM_T02.class); @@ -72,7 +71,7 @@ public class HL7MLLPCodecBoundaryTest extends CamelTestSupport { assertEquals(1022, message.length()); MockEndpoint mockEndpoint = getMockEndpoint("mock:result"); mockEndpoint.expectedMessageCount(1); - template.requestBody("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec", message); + template.requestBody("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec", message); mockEndpoint.assertIsSatisfied(); } http://git-wip-us.apache.org/repos/asf/camel/blob/b8c6b069/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java index 4a6d875..96b59e7 100644 --- a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java +++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecLongTest.java @@ -27,7 +27,6 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.JndiRegistry; -import org.apache.camel.test.junit4.CamelTestSupport; import org.apache.camel.util.IOHelper; import org.junit.Test; @@ -36,7 +35,7 @@ import org.junit.Test; /** * Unit test for the HL7MLLP Codec. */ -public class HL7MLLPCodecLongTest extends CamelTestSupport { +public class HL7MLLPCodecLongTest extends HL7TestSupport { protected JndiRegistry createRegistry() throws Exception { JndiRegistry jndi = super.createRegistry(); @@ -54,7 +53,7 @@ public class HL7MLLPCodecLongTest extends CamelTestSupport { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { - from("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec").process(new Processor() { + from("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec").process(new Processor() { public void process(Exchange exchange) throws Exception { assertEquals(70010, exchange.getIn().getBody().toString().length()); MDM_T02 input = (MDM_T02)exchange.getIn().getBody(Message.class); @@ -81,7 +80,7 @@ public class HL7MLLPCodecLongTest extends CamelTestSupport { } message = message.substring(0, message.length() - 1); assertEquals(70010, message.length()); - String out = (String)template.requestBody("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec", message); + String out = (String)template.requestBody("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec", message); assertEquals("some response", out); // END SNIPPET: e2 } http://git-wip-us.apache.org/repos/asf/camel/blob/b8c6b069/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecPlainStringTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecPlainStringTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecPlainStringTest.java index 868857e..7b182b3 100644 --- a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecPlainStringTest.java +++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecPlainStringTest.java @@ -21,14 +21,13 @@ import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.JndiRegistry; -import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; /** * Unit test to demonstrate the HL7MLLPCodec is message format agnostic (don't require the HAPI library). * The message format can be java.lang.String. */ -public class HL7MLLPCodecPlainStringTest extends CamelTestSupport { +public class HL7MLLPCodecPlainStringTest extends HL7TestSupport { protected JndiRegistry createRegistry() throws Exception { JndiRegistry jndi = super.createRegistry(); @@ -48,7 +47,7 @@ public class HL7MLLPCodecPlainStringTest extends CamelTestSupport { mock.expectedBodiesReceived("Bye World"); // send plain hello world as String - Object out = template.requestBody("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec", "Hello World"); + Object out = template.requestBody("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec", "Hello World"); assertMockEndpointsSatisfied(); @@ -61,7 +60,7 @@ public class HL7MLLPCodecPlainStringTest extends CamelTestSupport { return new RouteBuilder() { public void configure() throws Exception { // START SNIPPET: e2 - from("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec") + from("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec") .process(new Processor() { public void process(Exchange exchange) throws Exception { // use plain String as message format http://git-wip-us.apache.org/repos/asf/camel/blob/b8c6b069/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecStandAndEndBytesTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecStandAndEndBytesTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecStandAndEndBytesTest.java index 4c59102..f7c03ac 100644 --- a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecStandAndEndBytesTest.java +++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecStandAndEndBytesTest.java @@ -26,13 +26,12 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.JndiRegistry; -import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; /** * Unit test for the HL7MLLP Codec using different start and end bytes. */ -public class HL7MLLPCodecStandAndEndBytesTest extends CamelTestSupport { +public class HL7MLLPCodecStandAndEndBytesTest extends HL7TestSupport { protected JndiRegistry createRegistry() throws Exception { JndiRegistry jndi = super.createRegistry(); @@ -53,7 +52,7 @@ public class HL7MLLPCodecStandAndEndBytesTest extends CamelTestSupport { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { - from("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec") + from("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec") .process(new Processor() { public void process(Exchange exchange) throws Exception { Message input = exchange.getIn().getBody(Message.class); @@ -81,7 +80,7 @@ public class HL7MLLPCodecStandAndEndBytesTest extends CamelTestSupport { in.append("\r"); in.append(line2); - String out = (String)template.requestBody("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec", in.toString()); + String out = (String)template.requestBody("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec", in.toString()); String[] lines = out.split("\r"); assertEquals("MSH|^~\\&|MYSENDER||||200701011539||ADR^A19||||123", lines[0]); http://git-wip-us.apache.org/repos/asf/camel/blob/b8c6b069/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java index 60922b9..743334b 100644 --- a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java +++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7MLLPCodecTest.java @@ -26,13 +26,12 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.JndiRegistry; -import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; /** * Unit test for the HL7MLLP Codec. */ -public class HL7MLLPCodecTest extends CamelTestSupport { +public class HL7MLLPCodecTest extends HL7TestSupport { protected JndiRegistry createRegistry() throws Exception { JndiRegistry jndi = super.createRegistry(); @@ -51,7 +50,7 @@ public class HL7MLLPCodecTest extends CamelTestSupport { protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { public void configure() throws Exception { - from("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec") + from("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec") .process(new Processor() { public void process(Exchange exchange) throws Exception { Message input = exchange.getIn().getBody(Message.class); @@ -80,7 +79,7 @@ public class HL7MLLPCodecTest extends CamelTestSupport { in.append("\n"); in.append(line2); - String out = (String)template.requestBody("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec", in.toString()); + String out = (String)template.requestBody("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec", in.toString()); // END SNIPPET: e2 String[] lines = out.split("\r"); http://git-wip-us.apache.org/repos/asf/camel/blob/b8c6b069/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7RouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7RouteTest.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7RouteTest.java index 4850a8a..8222e87 100644 --- a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7RouteTest.java +++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7RouteTest.java @@ -28,13 +28,12 @@ import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.impl.JndiRegistry; import org.apache.camel.spi.DataFormat; -import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; /** * Unit test for HL7 routing. */ -public class HL7RouteTest extends CamelTestSupport { +public class HL7RouteTest extends HL7TestSupport { protected JndiRegistry createRegistry() throws Exception { JndiRegistry jndi = super.createRegistry(); @@ -64,7 +63,7 @@ public class HL7RouteTest extends CamelTestSupport { in.append("\r"); in.append(line2); - String out = (String) template.requestBody("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec", in.toString()); + String out = (String) template.requestBody("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec", in.toString()); String[] lines = out.split("\r"); assertEquals("MSH|^~\\&|MYSENDER||||200701011539||ADR^A19||||123", lines[0]); @@ -87,7 +86,7 @@ public class HL7RouteTest extends CamelTestSupport { in.append("\r"); in.append(line2); - String out = (String) template.requestBody("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec", in.toString()); + String out = (String) template.requestBody("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec", in.toString()); String[] lines = out.split("\r"); assertEquals("MSH|^~\\&|MYSENDER||||200701011539||ADT^A01||||123", lines[0]); assertEquals("PID|||123456||Doe^John", lines[1]); @@ -109,7 +108,7 @@ public class HL7RouteTest extends CamelTestSupport { in.append("\r"); in.append(line2); - template.requestBody("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec", in.toString()); + template.requestBody("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec", in.toString()); assertMockEndpointsSatisfied(); } @@ -121,7 +120,7 @@ public class HL7RouteTest extends CamelTestSupport { // START SNIPPET: e1 DataFormat hl7 = new HL7DataFormat(); // we setup or HL7 listener on port 8888 (using the hl7codec) and in sync mode so we can return a response - from("mina2:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec") + from("mina2:tcp://127.0.0.1:" + getPort() + "?sync=true&codec=#hl7codec") // we use the HL7 data format to unmarshal from HL7 stream to the HAPI Message model // this ensures that the camel message has been enriched with hl7 specific headers to // make the routing much easier (see below) http://git-wip-us.apache.org/repos/asf/camel/blob/b8c6b069/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7TestSupport.java ---------------------------------------------------------------------- diff --git a/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7TestSupport.java b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7TestSupport.java new file mode 100644 index 0000000..576b4ea --- /dev/null +++ b/components/camel-hl7/src/test/java/org/apache/camel/component/hl7/HL7TestSupport.java @@ -0,0 +1,37 @@ +/** + * 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.hl7; + +import org.apache.camel.test.AvailablePortFinder; +import org.apache.camel.test.junit4.CamelTestSupport; + +import org.junit.BeforeClass; + +public abstract class HL7TestSupport extends CamelTestSupport { + + private static int port; + + @BeforeClass + public static void initPort() throws Exception { + port = AvailablePortFinder.getNextAvailable(8888); + } + + protected static int getPort() { + return port; + } + +}