Repository: camel Updated Branches: refs/heads/master 0ee67aa36 -> 09cbccad2
http://git-wip-us.apache.org/repos/asf/camel/blob/0a69e327/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutInheritedOverrideTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutInheritedOverrideTest.java b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutInheritedOverrideTest.java new file mode 100644 index 0000000..0094a4b --- /dev/null +++ b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutInheritedOverrideTest.java @@ -0,0 +1,34 @@ +/** + * 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.test.spring; + +import java.util.concurrent.TimeUnit; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +@ShutdownTimeout +public class CamelSpringRunnerShutdownTimeoutInheritedOverrideTest + extends CamelSpringRunnerShutdownTimeoutTest { + + @Test + @Override + public void testShutdownTimeout() throws Exception { + assertEquals(10, camelContext.getShutdownStrategy().getTimeout()); + assertEquals(TimeUnit.SECONDS, camelContext.getShutdownStrategy().getTimeUnit()); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0a69e327/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutInheritedTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutInheritedTest.java b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutInheritedTest.java new file mode 100644 index 0000000..f744f9b --- /dev/null +++ b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutInheritedTest.java @@ -0,0 +1,22 @@ +/** + * 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.test.spring; + +public class CamelSpringRunnerShutdownTimeoutInheritedTest + extends CamelSpringRunnerShutdownTimeoutTest { + +} http://git-wip-us.apache.org/repos/asf/camel/blob/0a69e327/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutTest.java b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutTest.java new file mode 100644 index 0000000..8227877 --- /dev/null +++ b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerShutdownTimeoutTest.java @@ -0,0 +1,34 @@ +/** + * 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.test.spring; + +import java.util.concurrent.TimeUnit; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +@ShutdownTimeout(value = 11, timeUnit = TimeUnit.MILLISECONDS) +public class CamelSpringRunnerShutdownTimeoutTest + extends CamelSpringRunnerPlainTest { + + @Test + @Override + public void testShutdownTimeout() throws Exception { + assertEquals(11, camelContext.getShutdownStrategy().getTimeout()); + assertEquals(TimeUnit.MILLISECONDS, camelContext.getShutdownStrategy().getTimeUnit()); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0a69e327/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerUseAdviceWithTest.java ---------------------------------------------------------------------- diff --git a/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerUseAdviceWithTest.java b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerUseAdviceWithTest.java new file mode 100644 index 0000000..3d30b46 --- /dev/null +++ b/components/camel-test-spring/src/test/java/org/apache/camel/test/spring/CamelSpringRunnerUseAdviceWithTest.java @@ -0,0 +1,52 @@ +/** + * 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.test.spring; + +import org.apache.camel.ServiceStatus; +import org.apache.camel.util.StopWatch; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +@UseAdviceWith +public class CamelSpringRunnerUseAdviceWithTest extends CamelSpringRunnerPlainTest { + + @Before + public void testContextStarted() throws Exception { + + assertEquals(ServiceStatus.Stopped, camelContext.getStatus()); + assertEquals(ServiceStatus.Stopped, camelContext2.getStatus()); + camelContext.start(); + camelContext2.start(); + + // just sleep a little to simulate testing take a bit time + Thread.sleep(1000); + } + + @Test + public void testStopwatch() { + StopWatch stopWatch = StopWatchTestExecutionListener.getStopWatch(); + + assertNotNull(stopWatch); + long taken = stopWatch.taken(); + assertTrue(taken + " > 0, but was: " + taken, taken > 0); + assertTrue(taken + " < 3000, but was: " + taken, taken < 3000); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/0a69e327/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml ---------------------------------------------------------------------- diff --git a/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml deleted file mode 100644 index f6e171c..0000000 --- a/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringJUnit4ClassRunnerPlainTest-context.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation=" - http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "> - - <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true"> - <packageScan> - <package>org.apache.camel.test.spring</package> - </packageScan> - <route> - <from uri="direct:start"/> - <to uri="mock:a"/> - <transform> - <simple>Hello ${body}</simple> - </transform> - <to uri="mock:b"/> - </route> - </camelContext> - - <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer"> - <property name="location" value="classpath:org/apache/camel/test/spring/test.properties"/> - </bean> - - <camelContext id="camelContext2" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true"> - <route> - <from uri="direct:start2"/> - <to uri="mock:c"/> - <transform> - <simple>Hello ${body}</simple> - </transform> - <to uri="log:org.apache.camel.test.junit4.spring"/> - <to uri="seda:context2.seda"/> - </route> - </camelContext> - -</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/0a69e327/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringRunnerPlainTest-context.xml ---------------------------------------------------------------------- diff --git a/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringRunnerPlainTest-context.xml b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringRunnerPlainTest-context.xml new file mode 100644 index 0000000..f6e171c --- /dev/null +++ b/components/camel-test-spring/src/test/resources/org/apache/camel/test/spring/CamelSpringRunnerPlainTest-context.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd "> + + <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true"> + <packageScan> + <package>org.apache.camel.test.spring</package> + </packageScan> + <route> + <from uri="direct:start"/> + <to uri="mock:a"/> + <transform> + <simple>Hello ${body}</simple> + </transform> + <to uri="mock:b"/> + </route> + </camelContext> + + <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer"> + <property name="location" value="classpath:org/apache/camel/test/spring/test.properties"/> + </bean> + + <camelContext id="camelContext2" xmlns="http://camel.apache.org/schema/spring" trace="true" autoStartup="true"> + <route> + <from uri="direct:start2"/> + <to uri="mock:c"/> + <transform> + <simple>Hello ${body}</simple> + </transform> + <to uri="log:org.apache.camel.test.junit4.spring"/> + <to uri="seda:context2.seda"/> + </route> + </camelContext> + +</beans> \ No newline at end of file