http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/CustomerServiceResource.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/CustomerServiceResource.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/CustomerServiceResource.java deleted file mode 100644 index 4e3f9b5..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/CustomerServiceResource.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * 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.cxf.jaxrs.testbean; - -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; - -/** - * - * @version - */ -// START SNIPPET: example -@Path("/customerservice/") -public class CustomerServiceResource { - - public CustomerServiceResource() { - } - - @GET - @Path("/customers/{id}/") - public Customer getCustomer(@PathParam("id") String id) { - return null; - } - - @PUT - @Path("/customers/") - public Response updateCustomer(Customer customer) { - return null; - } -} -// END SNIPPET: example
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Order.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Order.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Order.java deleted file mode 100644 index 85d1104..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Order.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * 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.cxf.jaxrs.testbean; - -import java.util.HashMap; -import java.util.Map; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - * @version - */ -@XmlRootElement(name = "Order") -public class Order { - private long id; - private String description; - private Map<Long, Product> products = new HashMap<Long, Product>(); - - public Order() { - init(); - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String d) { - this.description = d; - } - - @GET - @Path("products/{productId}/") - public Product getProduct(@PathParam("productId")int productId) { - Product p = products.get(new Long(productId)); - return p; - } - - final void init() { - Product p = new Product(); - p.setId(323); - p.setDescription("product 323"); - products.put(p.getId(), p); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Product.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Product.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Product.java deleted file mode 100644 index 31b696a..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Product.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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.cxf.jaxrs.testbean; - -import javax.xml.bind.annotation.XmlRootElement; - -/** - * - * @version - */ -@XmlRootElement(name = "Product") -public class Product { - private long id; - private String description; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getDescription() { - return description; - } - - public void setDescription(String d) { - this.description = d; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/DisruptorTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/DisruptorTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/DisruptorTest.java deleted file mode 100644 index ff65269..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/DisruptorTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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.disruptor; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.karaf.options.KarafDistributionConfigurationFileExtendOption; - -import static org.ops4j.pax.exam.OptionUtils.combine; - - -/** - * @version - */ -@RunWith(PaxExam.class) -public class DisruptorTest extends OSGiIntegrationTestSupport { - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() { - from("disruptor:foo").to("mock:bar"); - } - }; - } - - @Test - public void testSendMessage() throws Exception { - MockEndpoint mock = getMandatoryEndpoint("mock:bar", MockEndpoint.class); - assertNotNull("The mock endpoint should not be null", mock); - - mock.expectedBodiesReceived("Hello World"); - template.sendBody("disruptor:foo", "Hello World"); - assertMockEndpointsSatisfied(); - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // disruptor requires sun.misc packages - new KarafDistributionConfigurationFileExtendOption("etc/jre.properties", "jre-1.6", ",sun.misc"), - new KarafDistributionConfigurationFileExtendOption("etc/jre.properties", "jre-1.7", ",sun.misc"), - new KarafDistributionConfigurationFileExtendOption("etc/jre.properties", "jre-1.8", ",sun.misc"), - // using the features to install the other camel components - loadCamelFeatures("camel-disruptor")); - - return options; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/vm/DisruptorVmTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/vm/DisruptorVmTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/vm/DisruptorVmTest.java deleted file mode 100644 index 54693c8..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/disruptor/vm/DisruptorVmTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * 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.disruptor.vm; - -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.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.exam.karaf.options.KarafDistributionConfigurationFileExtendOption; - -import static org.ops4j.pax.exam.OptionUtils.combine; - - - -/** - * @version - */ -@RunWith(PaxExam.class) -public class DisruptorVmTest extends OSGiIntegrationTestSupport { - - @Override - protected RouteBuilder[] createRouteBuilders() throws Exception { - RouteBuilder[] routeBuilders = new RouteBuilder[2]; - routeBuilders[0] = new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start") - .to("disruptor-vm:foo"); - } - }; - routeBuilders[1] = new RouteBuilder() { - @Override - public void configure() throws Exception { - from("disruptor-vm:foo?concurrentConsumers=5") - .to("mock:result"); - } - }; - - return routeBuilders; - } - - @Test - public void testSendMessage() throws Exception { - getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); - - template.sendBody("direct:start", "Hello World"); - - assertMockEndpointsSatisfied(); - } - - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // disruptor requires sun.misc packages - new KarafDistributionConfigurationFileExtendOption("etc/jre.properties", "jre-1.6", ",sun.misc"), - new KarafDistributionConfigurationFileExtendOption("etc/jre.properties", "jre-1.7", ",sun.misc"), - new KarafDistributionConfigurationFileExtendOption("etc/jre.properties", "jre-1.8", ",sun.misc"), - // using the features to install the other camel components - loadCamelFeatures("camel-disruptor")); - - return options; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/DozerTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/DozerTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/DozerTest.java deleted file mode 100644 index 95d66d2..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/DozerTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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.dozer; - -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport; -import org.apache.camel.itest.osgi.dozer.service.Customer; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -import static org.ops4j.pax.exam.OptionUtils.combine; - - -/** - * @version - */ -@RunWith(PaxExam.class) -public class DozerTest extends OSGiIntegrationSpringTestSupport { - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/dozer/CamelContext.xml"}); - } - - @Test - public void testDozer() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMessageCount(1); - // should be the model customer - mock.message(0).body().isInstanceOf(org.apache.camel.itest.osgi.dozer.model.Customer.class); - // and assert the model contains the expected data - mock.message(0).simple("${body.firstName} == Homer"); - mock.message(0).simple("${body.lastName} == Simpson"); - mock.message(0).simple("${body.address.streetMame} == 'Somestreet 123'"); - mock.message(0).simple("${body.address.zipCode} == 26000"); - - Customer serviceCustomer = new Customer(); - serviceCustomer.setFirstName("Homer"); - serviceCustomer.setLastName("Simpson"); - serviceCustomer.setStreet("Somestreet 123"); - serviceCustomer.setZip("26000"); - - template.sendBody("direct:start", serviceCustomer); - - assertMockEndpointsSatisfied(); - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the other camel components - loadCamelFeatures("camel-dozer")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/model/Address.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/model/Address.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/model/Address.java deleted file mode 100644 index 4484c2d..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/model/Address.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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.dozer.model; - -/** - * @version - */ -public class Address { - - private String zipCode; - private String streetName; - - public String getZipCode() { - return zipCode; - } - - public void setZipCode(String zipCode) { - this.zipCode = zipCode; - } - - public String getStreetName() { - return streetName; - } - - public void setStreetName(String streetName) { - this.streetName = streetName; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/model/Customer.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/model/Customer.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/model/Customer.java deleted file mode 100644 index c4774a2..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/model/Customer.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * 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.dozer.model; - -/** - * @version - */ -public class Customer { - - private String firstName; - private String lastName; - private Address address; - - public Customer() { - } - - public Customer(String firstName, String lastName, Address address) { - this.firstName = firstName; - this.lastName = lastName; - this.address = address; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public Address getAddress() { - return address; - } - - public void setAddress(Address address) { - this.address = address; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/service/Customer.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/service/Customer.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/service/Customer.java deleted file mode 100644 index ffefe1a..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/dozer/service/Customer.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * 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.dozer.service; - -/** - * @version - */ -public class Customer { - - private String firstName; - private String lastName; - private String street; - private String zip; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getStreet() { - return street; - } - - public void setStreet(String street) { - this.street = street; - } - - public String getZip() { - return zip; - } - - public void setZip(String zip) { - this.zip = zip; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/exec/ExecTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/exec/ExecTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/exec/ExecTest.java deleted file mode 100644 index 36867c2..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/exec/ExecTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * 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.exec; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -@Ignore("We need a test which runs on all platforms") -public class ExecTest extends OSGiIntegrationTestSupport { - - @Test - public void testExec() throws Exception { - getMockEndpoint("mock:result").expectedBodiesReceived("test"); - template.sendBody("direct:exec", "test"); - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("direct:exec").to("exec:echo?args=-n test").to("mock:result"); - } - }; - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the other camel components - loadCamelFeatures("camel-exec")); - - return options; - } - - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerFileTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerFileTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerFileTest.java deleted file mode 100644 index 36e5a95..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerFileTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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.freemarker; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.util.IOHelper; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.PaxExam; - -@RunWith(PaxExam.class) -public class FreemarkerFileTest extends FreemarkerTest { - - @Override - public void setUp() throws Exception { - deleteDirectory("mydir"); - createDirectory("mydir"); - - InputStream is = FreemarkerFileTest.class.getResourceAsStream("/org/apache/camel/itest/osgi/freemarker/example.ftl"); - - File dest = new File("mydir/example.ftl"); - FileOutputStream fos = new FileOutputStream(dest, false); - IOHelper.copyAndCloseInput(is, fos); - fos.close(); - - super.setUp(); - } - - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("direct:a").to("freemarker:file:mydir/example.ftl"); - } - }; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java deleted file mode 100644 index d19c171..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/freemarker/FreemarkerTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * 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.freemarker; - -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; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class FreemarkerTest extends OSGiIntegrationTestSupport { - - @Test - public void testReceivesResponse() throws Exception { - assertRespondsWith("foo", "<hello>foo</hello>"); - assertRespondsWith("bar", "<hello>bar</hello>"); - } - - 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); - } - - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("direct:a").to("freemarker:org/apache/camel/itest/osgi/freemarker/example.ftl"); - } - }; - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the other camel components - loadCamelFeatures("camel-freemarker")); - - return options; - } - - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.java deleted file mode 100644 index bc4285a..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpConsumeTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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.ftp; - -import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class FtpConsumeTest extends OSGiIntegrationSpringTestSupport { - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/ftp/FtpConsumeTest.xml"}); - } - - @Test - public void testFtp() throws Exception { - // just sleep a bit, the ftp consumer cannot connect to the server, but - // we just wanna test that the camel-ftp component can create a endpoint/consumer in osgi - Thread.sleep(3000); - } - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the camel components - loadCamelFeatures("camel-ftp") - - ); - - return options; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpServerBean.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpServerBean.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpServerBean.java deleted file mode 100644 index b72b87e..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpServerBean.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * 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.ftp; - -import java.net.URL; - -import org.apache.camel.util.ObjectHelper; -import org.apache.ftpserver.FtpServer; -import org.apache.ftpserver.FtpServerFactory; -import org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory; -import org.apache.ftpserver.ftplet.UserManager; -import org.apache.ftpserver.listener.ListenerFactory; -import org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor; -import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class FtpServerBean { - - public static final String FTP_ROOT_DIR = "./res/home/"; - private static final Logger LOG = LoggerFactory.getLogger(FtpServerBean.class); - - private static FtpServer ftpServer; - private static int port; - - private FtpServerBean() { - // utility class - } - - public static int getPort() { - return port; - } - - public static void startServer() throws Exception { - initPort(); - LOG.info("Starting FTP server on port " + port); - initFtpServer(); - ftpServer.start(); - } - - private static void initPort() { - port = 21002; - } - - public static void shutdownServer() throws Exception { - LOG.info("Shutting down FTP server with port " + port); - try { - ftpServer.stop(); - ftpServer = null; - port = 0; - } catch (Exception e) { - // ignore while shutting down as we could be polling during shutdown - // and get errors when the ftp server is stopping. This is only an issue - // since we host the ftp server embedded in the same jvm for unit testing - } - } - - public static void initFtpServer() throws Exception { - if (port < 21000) { - throw new IllegalArgumentException("Port number is not initialized in an expected range: " + getPort()); - } - - FtpServerFactory serverFactory = new FtpServerFactory(); - - // setup user management to read our users.properties and use clear text passwords - URL url = ObjectHelper.loadResourceAsURL("users.properties"); - - // use factory to create user manager - PropertiesUserManagerFactory pumf = new PropertiesUserManagerFactory(); - pumf.setUrl(url); - pumf.setPasswordEncryptor(new ClearTextPasswordEncryptor()); - pumf.setAdminName("admin"); - UserManager uman = pumf.createUserManager(); - - serverFactory.setUserManager(uman); - - NativeFileSystemFactory fsf = new NativeFileSystemFactory(); - fsf.setCreateHome(true); - serverFactory.setFileSystem(fsf); - - ListenerFactory factory = new ListenerFactory(); - factory.setPort(port); - serverFactory.addListener("default", factory.createListener()); - - ftpServer = serverFactory.createServer(); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpTest.java deleted file mode 100644 index ffd57b8..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/ftp/FtpTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * 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.ftp; - -import org.apache.camel.Exchange; -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.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -@Ignore("Not fully implemented, see TODO") -public class FtpTest extends OSGiIntegrationSpringTestSupport { - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/ftp/CamelContext.xml"}); - } - - @Test - public void testFtp() throws Exception { - getMockEndpoint("mock:result").expectedMessageCount(1); - - template.sendBodyAndHeader("ftp://localhost:21002?username=admin&password=admin", "Hello World", Exchange.FILE_NAME, "hello.txt"); - - assertMockEndpointsSatisfied(); - } - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - - getDefaultCamelKarafOptions(), - // using the features to install the camel components - loadCamelFeatures("jetty", "camel-ftp"), - - // ftp server bundles - mavenBundle().groupId("org.apache.mina").artifactId("mina-core").version("2.0.0"), - mavenBundle().groupId("org.apache.ftpserver").artifactId("ftpserver-core").version("1.0.5"), - mavenBundle().groupId("org.apache.ftpserver").artifactId("ftplet-api").version("1.0.5"), - - /*felix(),*/ equinox()); - - return options; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/groovy/GroovyTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/groovy/GroovyTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/groovy/GroovyTest.java deleted file mode 100644 index d030adc..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/groovy/GroovyTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * 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.groovy; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.ops4j.pax.exam.OptionUtils.combine; - - -@RunWith(PaxExam.class) -public class GroovyTest extends OSGiIntegrationTestSupport { - - @Test - public void testGroovyLanguage() throws Exception { - MockEndpoint result = getMockEndpoint("mock:result"); - result.expectedBodiesReceived("Hello is processed!"); - template.sendBody("direct:groovy", "Hello"); - result.assertIsSatisfied(); - } - - @Override - protected CamelContext createCamelContext() throws Exception { - CamelContext context = super.createCamelContext(); - // without this, "groovy.lang.*" classes will be loaded by classloader of camel-spring bundle - context.setApplicationContextClassLoader(this.getClass().getClassLoader()); - return context; - } - - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("direct:groovy").setBody().groovy("request.body + ' is processed!'").to("mock:result"); - } - }; - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the other camel components - loadCamelFeatures("camel-groovy")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hawtdb/HawtDBAggregateRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hawtdb/HawtDBAggregateRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hawtdb/HawtDBAggregateRouteTest.java deleted file mode 100644 index 8890989..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hawtdb/HawtDBAggregateRouteTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * 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.hawtdb; - -import java.util.concurrent.TimeUnit; - -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.hawtdb.HawtDBAggregationRepository; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.apache.camel.processor.aggregate.AggregationStrategy; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class HawtDBAggregateRouteTest extends OSGiIntegrationTestSupport { - - @Test - public void testHawtDBAggregateRoute() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:aggregated"); - mock.expectedBodiesReceived("ABCDE"); - - template.sendBodyAndHeader("direct:start", "A", "id", 123); - template.sendBodyAndHeader("direct:start", "B", "id", 123); - template.sendBodyAndHeader("direct:start", "C", "id", 123); - template.sendBodyAndHeader("direct:start", "D", "id", 123); - template.sendBodyAndHeader("direct:start", "E", "id", 123); - - assertMockEndpointsSatisfied(30, TimeUnit.SECONDS); - - // from endpoint should be preserved - assertEquals("direct://start", mock.getReceivedExchanges().get(0).getFromEndpoint().getEndpointUri()); - } - - @Override - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - // delete the data directory - deleteDirectory("target/data"); - - // create the hawtdb repo - HawtDBAggregationRepository repo = new HawtDBAggregationRepository("repo1", "target/data/hawtdb.dat"); - - // here is the Camel route where we aggregate - from("direct:start") - .aggregate(header("id"), new MyAggregationStrategy()) - // use our created hawtdb repo as aggregation repository - .completionSize(5).aggregationRepository(repo) - .to("mock:aggregated"); - } - }; - } - - public static class MyAggregationStrategy implements AggregationStrategy { - - public Exchange aggregate(Exchange oldExchange, Exchange newExchange) { - if (oldExchange == null) { - return newExchange; - } - String body1 = oldExchange.getIn().getBody(String.class); - String body2 = newExchange.getIn().getBody(String.class); - - oldExchange.getIn().setBody(body1 + body2); - return oldExchange; - } - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the other camel components - loadCamelFeatures("camel-hawtdb")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hazelcast/HazelcastTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hazelcast/HazelcastTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hazelcast/HazelcastTest.java deleted file mode 100644 index 8ff20c8..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hazelcast/HazelcastTest.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * 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.hazelcast; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.hazelcast.HazelcastConstants; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.ops4j.pax.exam.OptionUtils.combine; - - -@RunWith(PaxExam.class) -public class HazelcastTest extends OSGiIntegrationTestSupport { - - @Test - public void testAtomicNumber() throws Exception { - String reply = template.requestBody("direct:getatomic", null, String.class); - assertNotNull(reply); - long value = Long.parseLong(reply); - assertEquals("Should be 0", 0L, value); - - template.sendBody("direct:setatomic", 100L); - reply = template.requestBody("direct:getatomic", null, String.class); - assertNotNull(reply); - value = Long.parseLong(reply); - assertEquals("Should be 100", 100L, value); - } - - @Test - public void testMap() throws Exception { - SimpleObject item1 = new SimpleObject(1L, "Some value"); - SimpleObject item2 = new SimpleObject(2L, "Some other value"); - - template.sendBodyAndHeader("direct:mapput", item1, HazelcastConstants.OBJECT_ID, "1"); - template.sendBodyAndHeader("direct:mapput", item2, HazelcastConstants.OBJECT_ID, "2"); - - Object result2 = template.requestBodyAndHeader("direct:mapget", null, HazelcastConstants.OBJECT_ID, "2"); - assertNotNull(result2); - assertEquals("Should be equal", item2, result2); - Object result1 = template.requestBodyAndHeader("direct:mapget", null, HazelcastConstants.OBJECT_ID, "1"); - assertNotNull(result1); - assertEquals("Should be equal", item1, result1); - Object resul3 = template.requestBodyAndHeader("direct:mapget", null, HazelcastConstants.OBJECT_ID, "3"); - assertNull(resul3); - } - - @Test - public void testQueue() throws Exception { - SimpleObject item1 = new SimpleObject(1L, "Some value"); - SimpleObject item2 = new SimpleObject(2L, "Some other value"); - - template.sendBodyAndHeader("direct:queueput", item1, HazelcastConstants.OPERATION, HazelcastConstants.ADD_OPERATION); - template.sendBodyAndHeader("direct:queueput", item2, HazelcastConstants.OPERATION, HazelcastConstants.ADD_OPERATION); - - Object result1 = template.requestBody("direct:queuepoll", new Object()); - assertNotNull(result1); - assertEquals("Should be equal", item1, result1); - Object result2 = template.requestBody("direct:queuepoll", new Object()); - assertNotNull(result2); - assertEquals("Should be equal", item1, result1); - Object resul3 = template.requestBody("direct:queuepoll", new Object()); - assertNull(resul3); - } - - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - - //Atomic number - from("direct:getatomic") - .setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION)) - .toF("hazelcast:atomicvalue:myvalue"); - - from("direct:setatomic") - .setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.SETVALUE_OPERATION)) - .toF("hazelcast:atomicvalue:myvalue"); - - //Map - from("direct:mapput") - .setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION)) - .toF("hazelcast:map:mymap", HazelcastConstants.MAP_PREFIX); - - from("direct:mapget") - .setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.GET_OPERATION)) - .toF("hazelcast:map:mymap"); - - //Queue - from("direct:queueput") - .setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.PUT_OPERATION)) - .toF("hazelcast:queue:myqueue"); - - from("direct:queuepoll") - .setHeader(HazelcastConstants.OPERATION, constant(HazelcastConstants.POLL_OPERATION)) - .toF("hazelcast:queue:myqueue"); - } - }; - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the other camel components - loadCamelFeatures("camel-hazelcast")); - - return options; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hazelcast/SimpleObject.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hazelcast/SimpleObject.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hazelcast/SimpleObject.java deleted file mode 100644 index 6620a3f..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hazelcast/SimpleObject.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * 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.hazelcast; - -import java.io.Serializable; - -public class SimpleObject implements Serializable { - - private static final long serialVersionUID = 1L; - private Long id; - private Object value; - - public SimpleObject(Long id) { - this.id = id; - } - - public SimpleObject(Long id, Object value) { - this.id = id; - this.value = value; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - SimpleObject that = (SimpleObject) o; - - if (!id.equals(that.id)) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - return id.hashCode(); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hdfs/HdfsBlueprintRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hdfs/HdfsBlueprintRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hdfs/HdfsBlueprintRouteTest.java deleted file mode 100644 index 009cd44..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hdfs/HdfsBlueprintRouteTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * 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.hdfs; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.itest.osgi.blueprint.OSGiBlueprintTestSupport; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.ops4j.pax.tinybundles.core.TinyBundles; -import org.osgi.framework.Constants; - -import static org.ops4j.pax.exam.CoreOptions.provision; -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class HdfsBlueprintRouteTest extends OSGiBlueprintTestSupport { - - @Test - public void testWriteAndReadString() throws Exception { - if (isJavaVendor("IBM")) { - // Hadoop doesn't run on IBM JDK - return; - } - - if (isPlatform("windows")) { - // and does not work well on windows - return; - } - - getInstalledBundle("CamelBlueprintHdfsTestBundle").start(); - CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintHdfsTestBundle)", 20000); - - ProducerTemplate template = ctx.createProducerTemplate(); - template.sendBody("direct:start", "CIAO"); - - MockEndpoint resultEndpoint = ctx.getEndpoint("mock:result", MockEndpoint.class); - resultEndpoint.expectedMessageCount(1); - resultEndpoint.assertIsSatisfied(); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = combine( - getDefaultCamelKarafOptions(), - provision(TinyBundles.bundle() - .add("core-default.xml", HdfsRouteTest.class.getResource("/core-default.xml")) - .add("hdfs-default.xml", HdfsRouteTest.class.getResource("/hdfs-default.xml")) - .add("OSGI-INF/blueprint/test.xml", HdfsRouteTest.class.getResource("blueprintCamelContext.xml")) - .set(Constants.BUNDLE_SYMBOLICNAME, "CamelBlueprintHdfsTestBundle") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()), - - // using the features to install the camel components - loadCamelFeatures( - "camel-blueprint", "camel-hdfs2")); - - return options; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hdfs/HdfsRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hdfs/HdfsRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hdfs/HdfsRouteTest.java deleted file mode 100644 index 99a19b4..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hdfs/HdfsRouteTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * 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.hdfs; - -import java.io.File; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.hadoop.io.NullWritable; -import org.apache.hadoop.io.SequenceFile; -import org.apache.hadoop.io.Text; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class HdfsRouteTest extends OSGiIntegrationTestSupport { - //Hadoop doesn't run on IBM JDK - private static final boolean SKIP = System.getProperty("java.vendor").contains("IBM"); - - @Test - public void testReadString() throws Exception { - if (SKIP) { - return; - } - -// final Path file = new Path("hdfs://localhost:9000/tmp/test/test-hdfs-file"); - final Path file = new Path(new File("../../../../target/test/test-camel-string").getAbsolutePath()); - org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration(); - // now set classes for filesystems. This is normally done using java.util.ServiceLoader which doesn't - // work inside OSGi. - conf.setClass("fs.file.impl", org.apache.hadoop.fs.LocalFileSystem.class, FileSystem.class); - conf.setClass("fs.hdfs.impl", org.apache.hadoop.hdfs.DistributedFileSystem.class, FileSystem.class); - SequenceFile.Writer writer = SequenceFile.createWriter(conf, SequenceFile.Writer.file(file), - SequenceFile.Writer.keyClass(NullWritable.class), SequenceFile.Writer.valueClass(Text.class)); - NullWritable keyWritable = NullWritable.get(); - Text valueWritable = new Text(); - String value = "CIAO!"; - valueWritable.set(value); - writer.append(keyWritable, valueWritable); - writer.sync(); - writer.close(); - - context.addRoutes(new RouteBuilder() { - public void configure() { -// from("hdfs2://localhost:9000/tmp/test/test-hdfs-file?fileSystemType=HDFS&fileType=SEQUENCE_FILE&initialDelay=0").to("mock:result"); - from("hdfs2:///" + file.toUri() + "?fileSystemType=LOCAL&fileType=SEQUENCE_FILE&initialDelay=0").to("mock:result"); - } - }); - context.start(); - - MockEndpoint resultEndpoint = context.getEndpoint("mock:result", MockEndpoint.class); - resultEndpoint.expectedMessageCount(1); - resultEndpoint.assertIsSatisfied(); - } - - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the camel components - scanFeatures(getCamelKarafFeatureUrl(), "camel-hdfs2") - ); - - return options; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7DataFormatTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7DataFormatTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7DataFormatTest.java deleted file mode 100644 index 3752090..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7DataFormatTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * 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.hl7; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class HL7DataFormatTest extends OSGiIntegrationTestSupport { - - @Test - public void testUnmarshal() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:unmarshal"); - mock.expectedMessageCount(1); - - String body = createHL7AsString(); - template.sendBody("direct:unmarshal", body); - - assertMockEndpointsSatisfied(); - } - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("direct:unmarshal").unmarshal().hl7().to("mock:unmarshal"); - } - }; - } - - private static String createHL7AsString() { - String line1 = "MSH|^~\\&|REQUESTING|ICE|INHOUSE|RTH00|20080808093202||ORM^O01|0808080932027444985|P|2.4|||AL|NE|||"; - String line2 = "PID|1||ICE999999^^^ICE^ICE||Testpatient^Testy^^^Mr||19740401|M|||123 Barrel Drive^^^^SW18 4RT|||||2||||||||||||||"; - String line3 = "NTE|1||Free text for entering clinical details|"; - String line4 = "PV1|1||^^^^^^^^Admin Location|||||||||||||||NHS|"; - String line5 = "ORC|NW|213||175|REQ||||20080808093202|ahsl^^Administrator||G999999^TestDoctor^GPtests^^^^^^NAT|^^^^^^^^Admin Location | 819600|200808080932||RTH00||ahsl^^Administrator||"; - String line6 = "OBR|1|213||CCOR^Serum Cortisol ^ JRH06|||200808080932||0.100||||||^|G999999^TestDoctor^GPtests^^^^^^NAT|819600|ADM162||||||820|||^^^^^R||||||||"; - String line7 = "OBR|2|213||GCU^Serum Copper ^ JRH06 |||200808080932||0.100||||||^|G999999^TestDoctor^GPtests^^^^^^NAT|819600|ADM162||||||820|||^^^^^R||||||||"; - String line8 = "OBR|3|213||THYG^Serum Thyroglobulin ^JRH06|||200808080932||0.100||||||^|G999999^TestDoctor^GPtests^^^^^^NAT|819600|ADM162||||||820|||^^^^^R||||||||"; - - StringBuilder body = new StringBuilder(); - body.append(line1); - body.append("\n"); - body.append(line2); - body.append("\n"); - body.append(line3); - body.append("\n"); - body.append(line4); - body.append("\n"); - body.append(line5); - body.append("\n"); - body.append(line6); - body.append("\n"); - body.append(line7); - body.append("\n"); - body.append(line8); - return body.toString(); - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the other camel components - loadCamelFeatures("camel-hl7")); - - return options; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java deleted file mode 100644 index 3653c28..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodec2Test.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * 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.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.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -@Ignore("TODO need to find a way fix the hl7codec setting issue") -public class HL7MLLPCodec2Test extends OSGiIntegrationSpringTestSupport implements Processor { - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/hl7/CamelContext2.xml"}); - } - - @Test - public void testSendHL7Message() throws Exception { - String line1 = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4"; - String line2 = "QRD|200612211200|R|I|GetPatient|||1^RD|0101701234|DEM||"; - - StringBuilder in = new StringBuilder(); - in.append(line1); - in.append("\n"); - in.append(line2); - - 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]); - assertEquals("MSA|AA|123", lines[1]); - } - - public void process(Exchange exchange) throws Exception { - 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 - loadCamelFeatures("camel-hl7", "camel-mina")); - - return options; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodecTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodecTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodecTest.java deleted file mode 100644 index 6859c46..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/hl7/HL7MLLPCodecTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * 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.hl7; - -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.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -@Ignore("TODO need to find a way fix the hl7codec setting issue") -public class HL7MLLPCodecTest extends OSGiIntegrationSpringTestSupport implements Processor { - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/hl7/CamelContext.xml"}); - } - - @Test - public void testSendHL7Message() throws Exception { - String line1 = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4"; - String line2 = "QRD|200612211200|R|I|GetPatient|||1^RD|0101701234|DEM||"; - - StringBuilder in = new StringBuilder(); - in.append(line1); - 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[] lines = out.split("\r"); - assertEquals("MSH|^~\\&|MYSENDER||||200701011539||ADR^A19||||123", lines[0]); - assertEquals("MSA|AA|123", lines[1]); - } - - public void process(Exchange exchange) throws Exception { - 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 - loadCamelFeatures("camel-hl7", "camel-mina")); - - return options; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/http/HttpTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/http/HttpTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/http/HttpTest.java deleted file mode 100644 index b4e7f11..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/http/HttpTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * 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.http; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -/** - * - */ -@RunWith(PaxExam.class) -public class HttpTest extends OSGiIntegrationTestSupport { - - @Test - public void testHttpGet() throws Exception { - String reply = template.requestBody("http://localhost:9081/foo", null, String.class); - assertEquals("Bye World", reply); - } - - @Test - public void testHttpPost() throws Exception { - String reply = template.requestBody("http://localhost:9081/foo", "Hello World", String.class); - assertEquals("Bye World", reply); - } - - @Test - @Ignore("Requires online internet for testing") - public void testHttpGoogle() throws Exception { - String reply = template.requestBody("http://www.google.se", null, String.class); - assertNotNull(reply); - log.info(reply); - } - - protected RouteBuilder createRouteBuilder() { - return new RouteBuilder() { - public void configure() { - from("jetty:http://0.0.0.0:9081/foo") - .transform(constant("Bye World")); - } - }; - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the other camel components - loadCamelFeatures("camel-jetty", "camel-http")); - - return options; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/http/HttpTypeConverterTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/http/HttpTypeConverterTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/http/HttpTypeConverterTest.java deleted file mode 100644 index 3fbf4c1..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/http/HttpTypeConverterTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * 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.http; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Collection; -import java.util.Locale; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletResponse; - -import org.apache.camel.Exchange; -import org.apache.camel.Message; -import org.apache.camel.impl.DefaultMessage; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.Configuration; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.junit.PaxExam; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class HttpTypeConverterTest extends OSGiIntegrationTestSupport { - - static HttpServletResponse servletResponse = new HttpServletResponse() { - public void addCookie(Cookie cookie) { - } - - public void addDateHeader(String name, long date) { - } - - public void addHeader(String name, String value) { - } - - public void addIntHeader(String name, int value) { - } - - public boolean containsHeader(String name) { - return false; - } - - public String encodeRedirectURL(String url) { - return null; - } - - public String encodeRedirectUrl(String url) { - return null; - } - - public String encodeURL(String url) { - return null; - } - - public String encodeUrl(String url) { - return null; - } - - public void sendError(int sc) throws IOException { - } - - public void sendError(int sc, String msg) throws IOException { - } - - public void sendRedirect(String location) throws IOException { - } - - public void setDateHeader(String name, long date) { - } - - public void setHeader(String name, String value) { - } - - public void setIntHeader(String name, int value) { - } - - public void setStatus(int sc) { - } - - public void setStatus(int sc, String sm) { - } - - public void flushBuffer() throws IOException { - } - - public int getBufferSize() { - return 1024; - } - - public String getCharacterEncoding() { - return null; - } - - public String getContentType() { - return null; - } - - public String getHeader(String s) { - return null; - } - - public Collection<String> getHeaderNames() { - return null; - } - - public Collection<String> getHeaders(String s) { - return null; - } - - public int getStatus() { - return 0; - } - - public Locale getLocale() { - return null; - } - - public ServletOutputStream getOutputStream() throws IOException { - return null; - } - - public PrintWriter getWriter() throws IOException { - return null; - } - - public boolean isCommitted() { - return true; - } - - public void reset() { - } - - public void resetBuffer() { - } - - public void setBufferSize(int size) { - } - - public void setCharacterEncoding(String charset) { - } - - public void setContentLength(int len) { - } - - public void setContentLengthLong(long len) { - } - - public void setContentType(String type) { - } - - public void setLocale(Locale loc) { - } - - }; - - public boolean isUseRouteBuilder() { - return false; - } - - @Test - public void testHttpConverter() throws Exception { - Message message = new DefaultMessage(); - message.setHeader(Exchange.HTTP_SERVLET_RESPONSE, servletResponse); - HttpServletResponse result = context.getTypeConverter().convertTo(HttpServletResponse.class, message); - Assert.assertNotNull("The http converter doesn't work", result); - - } - - @Configuration - public static Option[] configure() { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the other camel components - loadCamelFeatures("camel-http")); - - return options; - } - - -}