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 2011/11/14 09:05:51 UTC
svn commit: r1201623 - in /camel/trunk/tests/camel-itest-osgi/src/test:
java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java
resources/org/apache/camel/itest/osgi/hl7/CamelContext2.xml
Author: davsclaus
Date: Mon Nov 14 08:05:51 2011
New Revision: 1201623
URL: http://svn.apache.org/viewvc?rev=1201623&view=rev
Log:
Added unit test for camel-hl7 using the HAPI api. The HAPI bundle has wrong OSGi metadata and does not work.
Added:
camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java
- copied, changed from r1201618, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodecTest.java
camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/hl7/CamelContext2.xml
- copied, changed from r1201618, camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/hl7/CamelContext.xml
Copied: camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java (from r1201618, camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodecTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java?p2=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java&p1=camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodecTest.java&r1=1201618&r2=1201623&rev=1201623&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodecTest.java (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java Mon Nov 14 08:05:51 2011
@@ -16,9 +16,12 @@
*/
package org.apache.camel.itest.osgi.hl7;
+import ca.uhn.hl7v2.model.v24.message.QRY_A19;
+import ca.uhn.hl7v2.model.v24.segment.MSH;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
@@ -30,11 +33,12 @@ import static org.ops4j.pax.exam.OptionU
import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
@RunWith(JUnit4TestRunner.class)
-public class HL7MLLPCodecTest extends OSGiIntegrationSpringTestSupport implements Processor {
+@Ignore("HAPI bundle is wrong")
+public class HL7MLLPCodec2Test extends OSGiIntegrationSpringTestSupport implements Processor {
@Override
protected OsgiBundleXmlApplicationContext createApplicationContext() {
- return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/hl7/CamelContext.xml"});
+ return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/hl7/CamelContext2.xml"});
}
@Test
@@ -47,7 +51,7 @@ public class HL7MLLPCodecTest extends OS
in.append("\n");
in.append(line2);
- String out = (String)template.requestBody("mina:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec", in.toString());
+ String out = (String)template.requestBody("mina:tcp://127.0.0.1:8889?sync=true&codec=#hl7codec", in.toString());
String[] lines = out.split("\r");
assertEquals("MSH|^~\\&|MYSENDER||||200701011539||ADR^A19||||123", lines[0]);
@@ -55,17 +59,21 @@ public class HL7MLLPCodecTest extends OS
}
public void process(Exchange exchange) throws Exception {
- String out = "MSH|^~\\&|MYSENDER||||200701011539||ADR^A19||||123\rMSA|AA|123\n";
+ QRY_A19 a19 = exchange.getIn().getBody(QRY_A19.class);
+ MSH msh = a19.getMSH();
+ assertEquals("MYSENDER", msh.getSendingApplication().getHd1_NamespaceID().getValue());
+
+ String out = "MSH|^~\\&|MYSENDER||||200701011539||ADR^A19||||123\rMSA|AA|123\n";
exchange.getOut().setBody(out);
}
-
+
@Configuration
public static Option[] configure() {
Option[] options = combine(
getDefaultCamelKarafOptions(),
- // using the features to install the other camel components
+ // using the features to install the other camel components
scanFeatures(getCamelKarafFeatureUrl(), "camel-hl7", "camel-mina"));
-
+
return options;
}
Copied: camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/hl7/CamelContext2.xml (from r1201618, camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/hl7/CamelContext.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/hl7/CamelContext2.xml?p2=camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/hl7/CamelContext2.xml&p1=camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/hl7/CamelContext.xml&r1=1201618&r2=1201623&rev=1201623&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/hl7/CamelContext.xml (original)
+++ camel/trunk/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/hl7/CamelContext2.xml Mon Nov 14 08:05:51 2011
@@ -23,18 +23,21 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
- <bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
- <property name="charset" value="iso-8859-1"/>
- </bean>
+ <bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
+ <property name="charset" value="iso-8859-1"/>
+ </bean>
- <bean id="responseBean" class="org.apache.camel.itest.osgi.hl7.HL7MLLPCodecTest"/>
+ <bean id="responseBean" class="org.apache.camel.itest.osgi.hl7.HL7MLLPCodec2Test"/>
- <camelContext xmlns="http://camel.apache.org/schema/spring">
- <camel:route>
- <camel:from uri="mina:tcp://127.0.0.1:8888?sync=true&codec=#hl7codec"/>
- <camel:process ref="responseBean"/>
- <camel:to uri="mock:result"/>
- </camel:route>
- </camelContext>
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
+ <camel:route>
+ <camel:from uri="mina:tcp://127.0.0.1:8889?sync=true&codec=#hl7codec"/>
+ <unmarshal>
+ <hl7/>
+ </unmarshal>
+ <camel:process ref="responseBean"/>
+ <camel:to uri="mock:result"/>
+ </camel:route>
+ </camelContext>
</beans>