http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/log/LogRouteWithLoggersPresentInRegistryTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/log/LogRouteWithLoggersPresentInRegistryTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/log/LogRouteWithLoggersPresentInRegistryTest.java deleted file mode 100644 index 7de66a7..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/log/LogRouteWithLoggersPresentInRegistryTest.java +++ /dev/null @@ -1,98 +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.core.log; - -import java.io.File; - -import org.apache.camel.CamelContext; -import org.apache.camel.impl.SimpleRegistry; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.apache.camel.osgi.CamelContextFactory; - -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.DoNotModifyLogOption; -import org.ops4j.pax.exam.karaf.options.KarafDistributionConfigurationFileReplacementOption; -import org.slf4j.LoggerFactory; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class LogRouteWithLoggersPresentInRegistryTest extends OSGiIntegrationTestSupport { - - @Test - public void testSendMessageToProvidedLogggerWithSiftLogging() throws Exception { - template.sendBody("log:irrelevant.logger.name?level=info&logger=#mylogger1", "<level>INFO</level>"); - template.sendBody("log:irrelevant.logger.name?level=debug&logger=#mylogger1", "<level>DEBUG</level>"); - template.sendBody("log:irrelevant.logger.name?level=error&logger=#mylogger1", "<level>ERROR</level>"); - - File logDir = new File(System.getProperty("karaf.base"), "data/log"); - File[] files = logDir.listFiles(); - assertEquals(1, files.length); - assertEquals(bundleContext.getBundle().getSymbolicName() + ".log", files[0].getName()); - } - - @Test - public void testSendMessageToCamelCreatedLogggerWithSiftLogging() throws Exception { - template.sendBody("log:org.apache.camel.SIFT.relevant.logger.name?level=info", "<level>INFO</level>"); - template.sendBody("log:org.apache.camel.SIFT.relevant.logger.name?level=debug", "<level>DEBUG</level>"); - template.sendBody("log:org.apache.camel.SIFT.relevant.logger.name?level=error", "<level>ERROR</level>"); - - File logDir = new File(System.getProperty("karaf.base"), "data/log"); - File[] files = logDir.listFiles(); - assertEquals(1, files.length); - assertNotEquals(bundleContext.getBundle().getSymbolicName() + ".log", files[0].getName()); - } - - @Override - public boolean isUseRouteBuilder() { - return false; - } - - @Override - protected CamelContext createCamelContext() throws Exception { - LOG.info("Get the bundleContext is {}", bundleContext); - LOG.info("Application installed as bundle id: {}", bundleContext.getBundle().getBundleId()); - - setThreadContextClassLoader(); - - CamelContextFactory factory = new CamelContextFactory(); - factory.setBundleContext(bundleContext); - SimpleRegistry registry = new SimpleRegistry(); - registry.put("mylogger1", LoggerFactory.getLogger("org.apache.camel.SIFT.l1")); - registry.put("mylogger2", LoggerFactory.getLogger("org.apache.camel.SIFT.l2")); - factory.setRegistry(registry); - CamelContext camelContext = factory.createContext(); - camelContext.setApplicationContextClassLoader(getClass().getClassLoader()); - camelContext.setUseMDCLogging(true); - return camelContext; - } - - @Configuration - public static Option[] configure() throws Exception { - return combine( - getDefaultCamelKarafOptions(), - new DoNotModifyLogOption(), - new KarafDistributionConfigurationFileReplacementOption("etc/org.ops4j.pax.logging.cfg", new File("src/test/resources/log4j.properties")) - ); - } - -}
http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/log/LogRouteWithNonDefaultLoggerTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/log/LogRouteWithNonDefaultLoggerTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/log/LogRouteWithNonDefaultLoggerTest.java deleted file mode 100644 index 0c61013..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/log/LogRouteWithNonDefaultLoggerTest.java +++ /dev/null @@ -1,95 +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.core.log; - -import java.io.File; - -import org.apache.camel.CamelContext; -import org.apache.camel.impl.SimpleRegistry; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.apache.camel.osgi.CamelContextFactory; -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.DoNotModifyLogOption; -import org.ops4j.pax.exam.karaf.options.KarafDistributionConfigurationFileReplacementOption; -import org.slf4j.LoggerFactory; - -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class LogRouteWithNonDefaultLoggerTest extends OSGiIntegrationTestSupport { - - @Test - public void testSendMessageToProvidedLogggerWithSiftLogging() throws Exception { - template.sendBody("log:irrelevant.logger.name?level=info&logger=#mylogger", "<level>INFO</level>"); - template.sendBody("log:irrelevant.logger.name?level=debug&logger=#mylogger", "<level>DEBUG</level>"); - template.sendBody("log:irrelevant.logger.name?level=error&logger=#mylogger", "<level>ERROR</level>"); - - File logDir = new File(System.getProperty("karaf.base"), "data/log"); - File[] files = logDir.listFiles(); - assertEquals(1, files.length); - assertEquals(bundleContext.getBundle().getSymbolicName() + ".log", files[0].getName()); - } - - @Test - public void testSendMessageToRegistryDefaultLogggerWithSiftLogging() throws Exception { - template.sendBody("log:irrelevant.logger.name?level=info", "<level>INFO</level>"); - template.sendBody("log:irrelevant.logger.name?level=debug", "<level>DEBUG</level>"); - template.sendBody("log:irrelevant.logger.name?level=error", "<level>ERROR</level>"); - - File logDir = new File(System.getProperty("karaf.base"), "data/log"); - File[] files = logDir.listFiles(); - assertEquals(1, files.length); - assertEquals(bundleContext.getBundle().getSymbolicName() + ".log", files[0].getName()); - } - - @Override - public boolean isUseRouteBuilder() { - return false; - } - - @Override - protected CamelContext createCamelContext() throws Exception { - LOG.info("Get the bundleContext is {}", bundleContext); - LOG.info("Application installed as bundle id: {}", bundleContext.getBundle().getBundleId()); - - setThreadContextClassLoader(); - - CamelContextFactory factory = new CamelContextFactory(); - factory.setBundleContext(bundleContext); - SimpleRegistry registry = new SimpleRegistry(); - registry.put("mylogger", LoggerFactory.getLogger("org.apache.camel.SIFT")); - factory.setRegistry(registry); - CamelContext camelContext = factory.createContext(); - camelContext.setApplicationContextClassLoader(getClass().getClassLoader()); - camelContext.setUseMDCLogging(true); - return camelContext; - } - - @Configuration - public static Option[] configure() throws Exception { - return combine( - getDefaultCamelKarafOptions(), - new DoNotModifyLogOption(), - new KarafDistributionConfigurationFileReplacementOption("etc/org.ops4j.pax.logging.cfg", new File("src/test/resources/log4j.properties")) - ); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/management/OSGiIntegrationManagedCamelContextTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/management/OSGiIntegrationManagedCamelContextTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/management/OSGiIntegrationManagedCamelContextTest.java deleted file mode 100644 index afa4496..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/management/OSGiIntegrationManagedCamelContextTest.java +++ /dev/null @@ -1,97 +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.core.management; - -import java.net.URL; -import java.util.Set; - -import javax.management.MBeanServer; -import javax.management.ObjectName; - -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 org.ops4j.pax.tinybundles.core.TinyBundles; - -import static org.ops4j.pax.exam.CoreOptions.options; -import static org.ops4j.pax.exam.CoreOptions.provision; -import static org.ops4j.pax.exam.CoreOptions.workingDirectory; - -@RunWith(PaxExam.class) -@Ignore("TODO: fix me") -public class OSGiIntegrationManagedCamelContextTest extends OSGiIntegrationTestSupport { - - protected boolean useJmx() { - return true; - } - - @Test - public void testCamelContextName() throws Exception { - // Wait a while to let the MBeanServer be created - Thread.sleep(1000); - - MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer(); - LOG.info("The MBeanServer is " + mbeanServer); - - Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=context,*"), null); - assertEquals("There should have 2 camelcontext registed", 2, set.size()); - - String camelContextName = context.getName(); - ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + camelContextName + ",type=context,name=\"" + camelContextName + "\""); - - assertTrue("Should be registered", mbeanServer.isRegistered(on)); - String name = (String) mbeanServer.getAttribute(on, "CamelId"); - assertEquals(camelContextName, name); - } - - private static URL getCamelContextInputStream() { - return OSGiIntegrationManagedCamelContextTest.class.getResource("CamelContext.xml"); - } - - @Configuration - public static Option[] configure() throws Exception { - - Option[] options = options( - // install the spring dm profile - //profile("spring.dm").version("1.2.1"), - - // this is how you set the default log level when using pax logging (logProfile) - org.ops4j.pax.exam.CoreOptions.systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"), - - // using the features to install the camel components - scanFeatures(getCamelKarafFeatureUrl(), - "camel-core", "camel-spring", "camel-test"), - //set up the camel context bundle first - provision(TinyBundles.bundle().add("META-INF/spring/CamelContext.xml", getCamelContextInputStream()) - .set(org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME, "org.apache.camel.itest.osgi.CamelContextTinyBundle") - .set(org.osgi.framework.Constants.BUNDLE_NAME, "CamelContextTinyBundle").build()), - - workingDirectory("target/paxrunner/"), - - equinox(), - felix()); - - 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/core/mock/MockXPathTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/mock/MockXPathTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/mock/MockXPathTest.java deleted file mode 100644 index 45553fc..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/mock/MockXPathTest.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.core.mock; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.apache.camel.model.language.XPathExpression; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.PaxExam; - -@RunWith(PaxExam.class) -public class MockXPathTest extends OSGiIntegrationTestSupport { - - @Test - public void testXPathAssertion() throws Exception { - MockEndpoint result = getMockEndpoint("mock:result"); - result.expectedMessageCount(1); - - XPathExpression xpath = new XPathExpression("/foo = 'bar'"); - xpath.setResultType(Boolean.class); - result.allMessages().body().matches(xpath); - - template.sendBody("direct:start", "<foo>bar</foo>"); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start").to("mock:result"); - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/packages/MyRouteBuilder.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/packages/MyRouteBuilder.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/packages/MyRouteBuilder.java deleted file mode 100644 index 2472668..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/packages/MyRouteBuilder.java +++ /dev/null @@ -1,30 +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.core.packages; - -import org.apache.camel.builder.RouteBuilder; -import org.springframework.stereotype.Component; - -@Component -public class MyRouteBuilder extends RouteBuilder { - - @Override - public void configure() throws Exception { - from("direct:start").to("mock:result"); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/packages/OSGiPackageScanTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/packages/OSGiPackageScanTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/packages/OSGiPackageScanTest.java deleted file mode 100644 index 2fa143b..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/packages/OSGiPackageScanTest.java +++ /dev/null @@ -1,44 +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.core.packages; - -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.PaxExam; -import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -@RunWith(PaxExam.class) -public class OSGiPackageScanTest extends OSGiIntegrationSpringTestSupport { - - @Test - public void testSendMessage() throws Exception { - MockEndpoint mock = getMandatoryEndpoint("mock:result", MockEndpoint.class); - assertNotNull("The mock endpoint should not be null", mock); - - mock.expectedBodiesReceived("Hello World"); - template.sendBody("direct:start", "Hello World"); - assertMockEndpointsSatisfied(); - } - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/core/packages/CamelContext.xml"}); - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/properties/PropertiesRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/properties/PropertiesRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/properties/PropertiesRouteTest.java deleted file mode 100644 index c28a009..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/properties/PropertiesRouteTest.java +++ /dev/null @@ -1,51 +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.core.properties; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.properties.PropertiesComponent; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.PaxExam; - - -@RunWith(PaxExam.class) -public class PropertiesRouteTest extends OSGiIntegrationTestSupport { - - @Test - public void testProperties() throws Exception { - getMockEndpoint("mock:result").expectedBodiesReceived("Hello World"); - - template.sendBody("direct:start", "Hello World"); - - assertMockEndpointsSatisfied(); - } - - protected RouteBuilder createRouteBuilder() { - // configure the properties component - PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class); - pc.setLocation("classpath:org/apache/camel/itest/osgi/core/properties/myproperties.properties"); - - return new RouteBuilder() { - public void configure() { - from("direct:start").to("{{cool}}"); - } - }; - } - -} \ 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/core/ref/RefFileEndpointTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/ref/RefFileEndpointTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/ref/RefFileEndpointTest.java deleted file mode 100644 index 87e10c3..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/ref/RefFileEndpointTest.java +++ /dev/null @@ -1,64 +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.core.ref; - -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.file.FileConsumer; -import org.apache.camel.impl.JndiRegistry; -import org.apache.camel.itest.osgi.OSGiIntegrationTestSupport; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.ops4j.pax.exam.junit.PaxExam; - -@RunWith(PaxExam.class) -public class RefFileEndpointTest extends OSGiIntegrationTestSupport { - - private JndiRegistry jndi; - - @Test - public void testRefFileEndpoint() throws Exception { - getMockEndpoint("mock:result").expectedMessageCount(1); - - template.sendBodyAndHeader("file:target/foo", "Hello World", Exchange.FILE_NAME, "hello.txt"); - - assertMockEndpointsSatisfied(); - - FileConsumer consumer = (FileConsumer) context.getRoute("foo").getConsumer(); - assertEquals(3000, consumer.getDelay()); - assertEquals(250, consumer.getInitialDelay()); - } - - @Override - protected JndiRegistry createRegistry() throws Exception { - jndi = super.createRegistry(); - return jndi; - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - deleteDirectory("target/foo"); - jndi.bind("foo", context.getEndpoint("file:target/foo?initialDelay=250&delay=3000&delete=true")); - - from("ref:foo").routeId("foo").to("mock:result"); - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/seda/SedaTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/seda/SedaTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/seda/SedaTest.java deleted file mode 100644 index 47cf50c..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/seda/SedaTest.java +++ /dev/null @@ -1,50 +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.core.seda; - -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.junit.PaxExam; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class SedaTest extends OSGiIntegrationTestSupport { - - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() { - from("seda: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("seda:foo", "Hello World"); - assertMockEndpointsSatisfied(); - } - -} \ 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/core/timer/TimerFiredTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/timer/TimerFiredTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/timer/TimerFiredTest.java deleted file mode 100644 index 4b793d0..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/timer/TimerFiredTest.java +++ /dev/null @@ -1,52 +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.core.timer; - -import org.apache.camel.Exchange; -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.junit.PaxExam; - -@RunWith(PaxExam.class) -public class TimerFiredTest extends OSGiIntegrationTestSupport { - - @Test - public void testFired() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(1); - - assertMockEndpointsSatisfied(); - - Exchange exchange = mock.getExchanges().get(0); - assertEquals("hello", exchange.getProperty(Exchange.TIMER_NAME)); - assertNotNull(exchange.getProperty(Exchange.TIMER_FIRED_TIME)); - assertNotNull(exchange.getIn().getHeader("firedTime")); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() throws Exception { - from("timer://hello").to("mock:result"); - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/validator/ValidatorRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/validator/ValidatorRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/validator/ValidatorRouteTest.java deleted file mode 100644 index 148af2d..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/validator/ValidatorRouteTest.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.core.validator; - -import org.apache.camel.ValidationException; -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.junit.PaxExam; - -@RunWith(PaxExam.class) -public class ValidatorRouteTest extends OSGiIntegrationTestSupport { - - @Test - public void testValidMessage() throws Exception { - getMockEndpoint("mock:valid").expectedMessageCount(1); - getMockEndpoint("mock:invalid").expectedMessageCount(0); - getMockEndpoint("mock:finally").expectedMessageCount(1); - - template.sendBody("direct:start", - "<mail xmlns='http://foo.com/bar'><subject>Hey</subject><body>Hello world!</body></mail>"); - - assertMockEndpointsSatisfied(); - } - - @Test - public void testInvalidMessage() throws Exception { - getMockEndpoint("mock:valid").expectedMessageCount(0); - getMockEndpoint("mock:invalid").expectedMessageCount(1); - getMockEndpoint("mock:finally").expectedMessageCount(1); - - template.sendBody("direct:start", - "<mail xmlns='http://foo.com/bar'><body>Hello world!</body></mail>"); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start") - .doTry() - .to("validator:org/apache/camel/itest/osgi/core/validator/schema.xsd") - .to("mock:valid") - .doCatch(ValidationException.class) - .to("mock:invalid") - .doFinally() - .to("mock:finally") - .end(); - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/vm/VmTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/vm/VmTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/vm/VmTest.java deleted file mode 100644 index 2320dd3..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/vm/VmTest.java +++ /dev/null @@ -1,60 +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.core.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.junit.PaxExam; - -/** - * @version - */ -@RunWith(PaxExam.class) -public class VmTest 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("vm:foo"); - } - }; - routeBuilders[1] = new RouteBuilder() { - @Override - public void configure() throws Exception { - from("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(); - } -} \ 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/core/xslt/XsltBlueprintRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/xslt/XsltBlueprintRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/xslt/XsltBlueprintRouteTest.java deleted file mode 100644 index 05803eb..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/xslt/XsltBlueprintRouteTest.java +++ /dev/null @@ -1,93 +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.core.xslt; - -import java.util.List; - -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -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.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class XsltBlueprintRouteTest extends OSGiBlueprintTestSupport { - private CamelContext camelContext; - private ProducerTemplate mytemplate; - - @Test - public void testSendMessageAndHaveItTransformed() throws Exception { - MockEndpoint endpoint = camelContext.getEndpoint("mock:result", MockEndpoint.class); - endpoint.expectedMessageCount(1); - - mytemplate.sendBody("direct:start", - "<mail><subject>Hey</subject><body>Hello world!</body></mail>"); - - assertMockEndpointsSatisfied(); - - List<Exchange> list = endpoint.getReceivedExchanges(); - Exchange exchange = list.get(0); - String xml = exchange.getIn().getBody(String.class); - - assertNotNull("The transformed XML should not be null", xml); - assertTrue(xml.indexOf("transformed") > -1); - // the cheese tag is in the transform.xsl - assertTrue(xml.indexOf("cheese") > -1); - assertTrue(xml.indexOf("<subject>Hey</subject>") > -1); - assertTrue(xml.indexOf("<body>Hello world!</body>") > -1); - mytemplate.stop(); - } - - protected void doPostSetup() throws Exception { - getInstalledBundle("XsltBlueprintRouteTest").start(); - camelContext = getOsgiService(CamelContext.class, "(camel.context.symbolicname=XsltBlueprintRouteTest)", 10000); - mytemplate = camelContext.createProducerTemplate(); - mytemplate.start(); - } - - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the camel components - loadCamelFeatures("camel-blueprint"), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", XsltBlueprintRouteTest.class.getResource("XsltBlueprintRouter.xml")) - .add("transform.xsl", XsltBlueprintRouteTest.class.getResource("transform.xsl")) - .set(Constants.BUNDLE_SYMBOLICNAME, "XsltBlueprintRouteTest") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build(TinyBundles.withBnd())).noStart() - - ); - - 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/core/xslt/XsltRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/xslt/XsltRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/xslt/XsltRouteTest.java deleted file mode 100644 index e2324e9..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/xslt/XsltRouteTest.java +++ /dev/null @@ -1,57 +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.core.xslt; - -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.junit.PaxExam; - - - -@RunWith(PaxExam.class) -public class XsltRouteTest extends OSGiIntegrationTestSupport { - - @Test - public void testXsltRoute() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>"); - mock.message(0).body().isInstanceOf(String.class); - - template.sendBody("direct:start", "<hello>world!</hello>"); - - assertMockEndpointsSatisfied(); - } - - @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:start") - .to("xslt:org/apache/camel/itest/osgi/core/xslt/example.xsl") - .to("log:result") - .to("mock:result"); - } - }; - } - - - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfBeanSpringRouteTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfBeanSpringRouteTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfBeanSpringRouteTest.java deleted file mode 100644 index 17d142b..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfBeanSpringRouteTest.java +++ /dev/null @@ -1,84 +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; - -import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; - -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.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -import static org.ops4j.pax.exam.CoreOptions.provision; -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class CxfBeanSpringRouteTest extends OSGiIntegrationSpringTestSupport { - - @Test - public void testGetCustomer() throws Exception { - HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/123"); - get.addHeader("Accept" , "application/json"); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { - HttpResponse response = httpclient.execute(get); - assertEquals(200, response.getStatusLine().getStatusCode()); - assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", - EntityUtils.toString(response.getEntity())); - } finally { - httpclient.close(); - } - } - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/cxf/CxfBeanRouter.xml"}); - } - - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions(), - - // using the features to install the camel components - loadCamelFeatures( - "camel-jetty", "camel-http4", "camel-cxf"), - - provision(TinyBundles.bundle() - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.Customer.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.CustomerService.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.CustomerServiceResource.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.Order.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.Product.class) - .set("Export-Package", "org.apache.camel.itest.osgi.cxf.jaxrs.testbean") - .build(TinyBundles.withBnd()))//, - //vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006") - ); - - 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/cxf/CxfProxyExampleTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfProxyExampleTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfProxyExampleTest.java deleted file mode 100644 index 3f5d23d..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/CxfProxyExampleTest.java +++ /dev/null @@ -1,97 +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; - -import org.apache.camel.example.reportincident.InputReportIncident; -import org.apache.camel.example.reportincident.OutputReportIncident; -import org.apache.camel.example.reportincident.ReportIncidentEndpoint; -import org.apache.camel.itest.osgi.OSGiIntegrationSpringTestSupport; -import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; - -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.springframework.osgi.context.support.OsgiBundleXmlApplicationContext; - -import static org.ops4j.pax.exam.CoreOptions.provision; -import static org.ops4j.pax.exam.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class CxfProxyExampleTest extends OSGiIntegrationSpringTestSupport { - - @Test - public void testCxfProxy() throws Exception { - - // create input parameter - InputReportIncident input = new InputReportIncident(); - input.setIncidentId("123"); - input.setIncidentDate("2010-09-28"); - input.setGivenName("Claus"); - input.setFamilyName("Ibsen"); - input.setSummary("Bla"); - input.setDetails("Bla bla"); - input.setEmail("davscl...@apache.org"); - input.setPhone("12345678"); - - // create the webservice client and send the request - // we use CXF to create a client for us as its easier than JAXWS and works - JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); - factory.setServiceClass(ReportIncidentEndpoint.class); - factory.setAddress("http://localhost:9080/camel-itest-osgi/webservices/incident"); - ReportIncidentEndpoint client = factory.create(ReportIncidentEndpoint.class); - OutputReportIncident out = client.reportIncident(input); - - // assert we got a OK back - assertEquals("OK;456", out.getCode()); - LOG.warn("Finish the testing"); - } - - @Override - protected OsgiBundleXmlApplicationContext createApplicationContext() { - return new OsgiBundleXmlApplicationContext(new String[]{"org/apache/camel/itest/osgi/cxf/camel-config.xml"}); - } - - // TODO: CxfConsumer should use OSGi http service (no embedded Jetty) - // TODO: Make this test work with OSGi - - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions(), - - // using the features to install the camel components - loadCamelFeatures("camel-http", "cxf", "camel-cxf"), - - // need to install the generated src as the pax-exam doesn't wrap this bundles - provision(TinyBundles.bundle() - .add(org.apache.camel.example.reportincident.InputReportIncident.class) - .add(org.apache.camel.example.reportincident.OutputReportIncident.class) - .add(org.apache.camel.example.reportincident.ReportIncidentEndpoint.class) - .add(org.apache.camel.example.reportincident.ReportIncidentEndpointService.class) - .add(org.apache.camel.example.reportincident.ObjectFactory.class) - .set("Export-Package", "org.apache.camel.example.reportincident") - .build(TinyBundles.withBnd()))); - - 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/cxf/EnrichBean.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/EnrichBean.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/EnrichBean.java deleted file mode 100644 index f726f48..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/EnrichBean.java +++ /dev/null @@ -1,33 +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; - -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -/** - * @version - */ -public class EnrichBean { - - public Document enrich(Document doc) { - Node node = doc.getElementsByTagName("incidentId").item(0); - node.setTextContent("456"); - return doc; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/RealWebServiceBean.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/RealWebServiceBean.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/RealWebServiceBean.java deleted file mode 100644 index 71ac1d5..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/RealWebServiceBean.java +++ /dev/null @@ -1,50 +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; - -import javax.xml.ws.Endpoint; - -/** - * @version - */ -public class RealWebServiceBean { - - // should be the same address as we have in our route - private String url = "http://localhost:9081/real-webservice"; - - private ReportIncidentEndpointService service = new ReportIncidentEndpointService(); - private Endpoint endpoint; - - public void start() throws Exception { - endpoint = Endpoint.publish(url, service); - } - - public void stop() throws Exception { - if (endpoint != null) { - endpoint.stop(); - } - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/ReportIncidentEndpointService.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/ReportIncidentEndpointService.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/ReportIncidentEndpointService.java deleted file mode 100644 index e68aeb4..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/ReportIncidentEndpointService.java +++ /dev/null @@ -1,34 +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; - -import org.apache.camel.example.reportincident.InputReportIncident; -import org.apache.camel.example.reportincident.OutputReportIncident; -import org.apache.camel.example.reportincident.ReportIncidentEndpoint; - -/** - * @version - */ -public class ReportIncidentEndpointService implements ReportIncidentEndpoint { - - public OutputReportIncident reportIncident(InputReportIncident in) { - OutputReportIncident out = new OutputReportIncident(); - out.setCode("OK;" + in.getIncidentId()); - return out; - } - -} http://git-wip-us.apache.org/repos/asf/camel/blob/6b77d012/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBeanBlueprintRouterTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBeanBlueprintRouterTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBeanBlueprintRouterTest.java deleted file mode 100644 index 0a2c1bf..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBeanBlueprintRouterTest.java +++ /dev/null @@ -1,105 +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.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.itest.osgi.blueprint.OSGiBlueprintTestSupport; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; - -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.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class CxfBeanBlueprintRouterTest extends OSGiBlueprintTestSupport { - - protected void doPostSetup() throws Exception { - getInstalledBundle("CxfBeanBlueprintRouterTest").start(); - getOsgiService(CamelContext.class, "(camel.context.symbolicname=CxfBeanBlueprintRouterTest)", 20000); - } - - @Test - public void testGetCustomer() throws Exception { - HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/123"); - get.addHeader("Accept" , "application/json"); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { - HttpResponse response = httpclient.execute(get); - assertEquals(200, response.getStatusLine().getStatusCode()); - assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", - EntityUtils.toString(response.getEntity())); - } finally { - httpclient.close(); - } - } - - - @Test - public void testGetCustomerWithQuery() throws Exception { - HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers?id=123"); - get.addHeader("Accept" , "application/json"); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { - HttpResponse response = httpclient.execute(get); - assertEquals(200, response.getStatusLine().getStatusCode()); - assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", - EntityUtils.toString(response.getEntity())); - } finally { - httpclient.close(); - } - } - - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions(), - - // using the features to install the camel components - loadCamelFeatures( - "camel-blueprint", "camel-jetty", "camel-http4", "camel-cxf"), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", CxfRsBlueprintRouterTest.class.getResource("CxfBeanBlueprintRouter.xml")) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.Customer.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.CustomerService.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.CustomerServiceResource.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.Order.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.Product.class) - .set(Constants.BUNDLE_SYMBOLICNAME, "CxfBeanBlueprintRouterTest") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart() - //equinox()//, - //vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006") - - ); - - 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/cxf/blueprint/CxfBlueprintRouterTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBlueprintRouterTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBlueprintRouterTest.java deleted file mode 100644 index a839a03..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfBlueprintRouterTest.java +++ /dev/null @@ -1,121 +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.blueprint; - -import org.apache.camel.CamelContext; -import org.apache.camel.example.reportincident.InputReportIncident; -import org.apache.camel.example.reportincident.OutputReportIncident; -import org.apache.camel.example.reportincident.ReportIncidentEndpoint; -import org.apache.camel.itest.osgi.blueprint.OSGiBlueprintTestSupport; -import org.apache.camel.itest.osgi.cxf.ReportIncidentEndpointService; -import org.apache.cxf.endpoint.Server; -import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; -import org.apache.cxf.jaxws.JaxWsServerFactoryBean; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -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.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class CxfBlueprintRouterTest extends OSGiBlueprintTestSupport { - private static Server server; - - @BeforeClass - public static void startServer() { - JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); - sf.setAddress("http://localhost:9002/cxf"); - sf.setServiceBean(new ReportIncidentEndpointService()); - server = sf.create(); - } - - @AfterClass - public static void stopServer() { - if (server != null) { - server.stop(); - } - } - - protected void doPostSetup() throws Exception { - getInstalledBundle("CxfBlueprintRouterTest").start(); - getOsgiService(CamelContext.class, "(camel.context.symbolicname=CxfBlueprintRouterTest)", 20000); - } - - protected static ReportIncidentEndpoint createCXFClient() { - // we use CXF to create a client for us as its easier than JAXWS and works - JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); - factory.setServiceClass(ReportIncidentEndpoint.class); - factory.setAddress("http://localhost:9000/incident"); - return (ReportIncidentEndpoint) factory.create(); - } - - - @Test - public void testRouter() throws Exception { - // create input parameter - InputReportIncident input = new InputReportIncident(); - input.setIncidentId("123"); - input.setIncidentDate("2010-09-28"); - input.setGivenName("Claus"); - input.setFamilyName("Ibsen"); - input.setSummary("Bla"); - input.setDetails("Bla bla"); - input.setEmail("davscl...@apache.org"); - input.setPhone("12345678"); - - // create the webservice client and send the request - ReportIncidentEndpoint client = createCXFClient(); - OutputReportIncident out = client.reportIncident(input); - - // assert we got a OK back - assertEquals("OK;123", out.getCode()); - } - - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions(), - // using the features to install the camel components - loadCamelFeatures( - "camel-blueprint", "camel-cxf"), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", CxfBlueprintRouterTest.class.getResource("CxfBlueprintRouter.xml")) - .add("WSDL/report_incident.wsdl", CxfBlueprintRouterTest.class.getResource("/report_incident.wsdl")) - .add(org.apache.camel.example.reportincident.InputReportIncident.class) - .add(org.apache.camel.example.reportincident.OutputReportIncident.class) - .add(org.apache.camel.example.reportincident.ReportIncidentEndpoint.class) - .add(org.apache.camel.example.reportincident.ReportIncidentEndpointService.class) - .add(org.apache.camel.example.reportincident.ObjectFactory.class) - .set("Export-Package", "org.apache.camel.example.reportincident") - .set(Constants.BUNDLE_SYMBOLICNAME, "CxfBlueprintRouterTest") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build(TinyBundles.withBnd())).noStart() - - ); - - 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/cxf/blueprint/CxfRsBlueprintRouterTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouterTest.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouterTest.java deleted file mode 100644 index 03c46ef..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/blueprint/CxfRsBlueprintRouterTest.java +++ /dev/null @@ -1,212 +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.blueprint; - - -import org.apache.camel.CamelContext; -import org.apache.camel.itest.osgi.blueprint.OSGiBlueprintTestSupport; -import org.apache.camel.itest.osgi.cxf.jaxrs.testbean.CustomerService; -import org.apache.cxf.endpoint.Server; -import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.util.EntityUtils; - -import org.junit.AfterClass; -import org.junit.BeforeClass; -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.OptionUtils.combine; - -@RunWith(PaxExam.class) -public class CxfRsBlueprintRouterTest extends OSGiBlueprintTestSupport { - private static final String PUT_REQUEST = "<Customer><name>Mary</name><id>123</id></Customer>"; - private static final String POST_REQUEST = "<Customer><name>Jack</name></Customer>"; - private static Server server; - - @BeforeClass - public static void startServer() { - JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); - sf.setAddress("http://localhost:9002/rest"); - sf.setServiceBean(new CustomerService()); - sf.setStaticSubresourceResolution(true); - server = sf.create(); - } - - @AfterClass - public static void stopServer() { - if (server != null) { - server.stop(); - } - } - - protected void doPostSetup() throws Exception { - getInstalledBundle("CxfRsBlueprintRouterTest").start(); - getOsgiService(CamelContext.class, "(camel.context.symbolicname=CxfRsBlueprintRouterTest)", 30000); - } - - @Test - public void testGetCustomer() throws Exception { - HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/123"); - get.addHeader("Accept" , "application/json"); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { - HttpResponse response = httpclient.execute(get); - assertEquals(200, response.getStatusLine().getStatusCode()); - - // should either by John or Mary depending on PUT test executed first - String s = EntityUtils.toString(response.getEntity()); - boolean isJohn = "{\"Customer\":{\"id\":123,\"name\":\"John\"}}".equals(s); - boolean isMary = "{\"Customer\":{\"id\":123,\"name\":\"Mary\"}}".equals(s); - assertTrue("Should be John or Mary", isJohn || isMary); - } finally { - httpclient.close(); - } - } - - - @Test - public void testGetCustomerWithQuery() throws Exception { - HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers?id=123"); - get.addHeader("Accept" , "application/json"); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { - HttpResponse response = httpclient.execute(get); - assertEquals(200, response.getStatusLine().getStatusCode()); - assertEquals("{\"Customer\":{\"id\":123,\"name\":\"John\"}}", - EntityUtils.toString(response.getEntity())); - } finally { - httpclient.close(); - } - } - - @Test - public void testGetCustomers() throws Exception { - HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/customers/"); - get.addHeader("Accept" , "application/xml"); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { - HttpResponse response = httpclient.execute(get); - assertEquals(200, response.getStatusLine().getStatusCode()); - // order returned can differ on OS so match for both orders - String s = EntityUtils.toString(response.getEntity()); - assertNotNull(s); - boolean m1 = s.endsWith("<Customers><Customer><id>123</id><name>John</name></Customer><Customer><id>113</id><name>Dan</name></Customer></Customers>"); - boolean m2 = s.endsWith("<Customers><Customer><id>113</id><name>Dan</name></Customer><Customer><id>123</id><name>John</name></Customer></Customers>"); - - if (!m1 && !m2) { - fail("Not expected body returned: " + s); - } - } finally { - httpclient.close(); - } - } - - @Test - public void testGetSubResource() throws Exception { - HttpGet get = new HttpGet("http://localhost:9000/route/customerservice/orders/223/products/323"); - get.addHeader("Accept" , "application/json"); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { - HttpResponse response = httpclient.execute(get); - assertEquals(200, response.getStatusLine().getStatusCode()); - assertEquals("{\"Product\":{\"description\":\"product 323\",\"id\":323}}", - EntityUtils.toString(response.getEntity())); - } finally { - httpclient.close(); - } - } - - @Test - public void testPutConsumer() throws Exception { - HttpPut put = new HttpPut("http://localhost:9000/route/customerservice/customers"); - StringEntity entity = new StringEntity(PUT_REQUEST, "ISO-8859-1"); - entity.setContentType("text/xml; charset=ISO-8859-1"); - put.setEntity(entity); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { - HttpResponse response = httpclient.execute(put); - assertEquals(200, response.getStatusLine().getStatusCode()); - assertEquals("", EntityUtils.toString(response.getEntity())); - } finally { - httpclient.close(); - } - } - - @Test - public void testPostConsumer() throws Exception { - HttpPost post = new HttpPost("http://localhost:9000/route/customerservice/customers"); - post.addHeader("Accept" , "text/xml"); - StringEntity entity = new StringEntity(POST_REQUEST, "ISO-8859-1"); - entity.setContentType("text/xml; charset=ISO-8859-1"); - post.setEntity(entity); - CloseableHttpClient httpclient = HttpClientBuilder.create().build(); - - try { - HttpResponse response = httpclient.execute(post); - assertEquals(200, response.getStatusLine().getStatusCode()); - assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Customer><id>124</id><name>Jack</name></Customer>", - EntityUtils.toString(response.getEntity())); - } finally { - httpclient.close(); - } - - } - - @Configuration - public static Option[] configure() throws Exception { - Option[] options = combine( - getDefaultCamelKarafOptions(), - - // using the features to install the camel components - loadCamelFeatures( - "camel-blueprint", "camel-http4", "camel-cxf"), - - bundle(TinyBundles.bundle() - .add("OSGI-INF/blueprint/test.xml", CxfRsBlueprintRouterTest.class.getResource("CxfRsBlueprintRouter.xml")) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.Customer.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.CustomerService.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.CustomerServiceResource.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.Order.class) - .add(org.apache.camel.itest.osgi.cxf.jaxrs.testbean.Product.class) - .set(Constants.BUNDLE_SYMBOLICNAME, "CxfRsBlueprintRouterTest") - .set(Constants.DYNAMICIMPORT_PACKAGE, "*") - .build()).noStart() - - ); - - 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/cxf/jaxrs/testbean/Customer.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Customer.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Customer.java deleted file mode 100644 index a1a46c0..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/Customer.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 = "Customer") -public class Customer { - private long id; - private String name; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} 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/CustomerService.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/CustomerService.java b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/CustomerService.java deleted file mode 100644 index 7b87556..0000000 --- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/cxf/jaxrs/testbean/CustomerService.java +++ /dev/null @@ -1,151 +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.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Response; - - - -/** - * - * @version - */ -@Path("/customerservice/") -public class CustomerService { - long currentId = 123; - Map<Long, Customer> customers = new HashMap<Long, Customer>(); - Map<Long, Order> orders = new HashMap<Long, Order>(); - - public CustomerService() { - init(); - } - - @GET - @Path("/customers/{id}/") - public Customer getCustomer(@PathParam("id") String id) { - long idNumber = Long.parseLong(id); - Customer c = customers.get(idNumber); - return c; - } - - @GET - @Path("/customers") - public Customer getCustomerByQueryParam(@QueryParam("id") String id) { - long idNumber = Long.parseLong(id); - Customer c = customers.get(idNumber); - return c; - } - - @GET - @Path("/customers/") - @Produces("application/xml") - public List<Customer> getCustomers() { - List<Customer> l = new ArrayList<Customer>(customers.values()); - return l; - } - - - @PUT - @Path("/customers/") - public Response updateCustomer(Customer customer) { - Customer c = customers.get(customer.getId()); - Response r; - if (c != null) { - customers.put(customer.getId(), customer); - r = Response.ok().build(); - } else { - r = Response.notModified().build(); - } - - return r; - } - - @POST - @Path("/customers/") - public Response addCustomer(Customer customer) { - customer.setId(++currentId); - - customers.put(customer.getId(), customer); - - return Response.ok(customer).build(); - } - - @POST - @Path("/customersUniqueResponseCode/") - public Response addCustomerUniqueResponseCode(Customer customer) { - customer.setId(++currentId); - - customers.put(customer.getId(), customer); - - return Response.status(201).entity(customer).build(); - } - - @DELETE - @Path("/customers/{id}/") - public Response deleteCustomer(@PathParam("id") String id) { - long idNumber = Long.parseLong(id); - Customer c = customers.get(idNumber); - - Response r; - if (c != null) { - r = Response.ok().build(); - customers.remove(idNumber); - } else { - r = Response.notModified().build(); - } - - return r; - } - - @Path("/orders/{orderId}/") - public Order getOrder(@PathParam("orderId") String orderId) { - long idNumber = Long.parseLong(orderId); - Order c = orders.get(idNumber); - return c; - } - - final void init() { - Customer c = new Customer(); - c.setName("John"); - c.setId(123); - customers.put(c.getId(), c); - - c = new Customer(); - c.setName("Dan"); - c.setId(113); - customers.put(c.getId(), c); - - Order o = new Order(); - o.setDescription("order 223"); - o.setId(223); - orders.put(o.getId(), o); - } - -}