Repository: camel Updated Branches: refs/heads/master 105c0de09 -> fe4af678b
CAMEL-11125: adding a tests to check deadlock Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/fe4af678 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/fe4af678 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/fe4af678 Branch: refs/heads/master Commit: fe4af678bd0e6395ca20eeac43aed0f803933edf Parents: 812b98d Author: Nicola Ferraro <ni.ferr...@gmail.com> Authored: Tue May 9 16:16:53 2017 +0200 Committer: Nicola Ferraro <ni.ferr...@gmail.com> Committed: Tue May 9 16:17:03 2017 +0200 ---------------------------------------------------------------------- .../test/ReactiveStreamsDefaultEngineTest.java | 71 ++++++++ .../test/ReactiveStreamsNamedEngineTest.java | 142 +--------------- .../test/ReactiveStreamsRegistryEngineTest.java | 140 +--------------- .../ReactiveStreamsServiceTestSupport.java | 166 +++++++++++++++++++ 4 files changed, 245 insertions(+), 274 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/fe4af678/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsDefaultEngineTest.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsDefaultEngineTest.java b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsDefaultEngineTest.java new file mode 100644 index 0000000..c306ca0 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsDefaultEngineTest.java @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.reactive.streams.springboot.test; + +import org.apache.camel.CamelContext; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; +import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; +import org.apache.camel.component.reactive.streams.engine.DefaultCamelReactiveStreamsService; +import org.apache.camel.component.reactive.streams.springboot.ReactiveStreamsComponentAutoConfiguration; +import org.apache.camel.component.reactive.streams.springboot.ReactiveStreamsServiceAutoConfiguration; +import org.apache.camel.spring.boot.CamelAutoConfiguration; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * Checking that the deadlock does not occur when the {@code CamelReactiveStreamsService} is not injected anywhere. + */ +@RunWith(SpringRunner.class) +@SpringBootApplication +@DirtiesContext +@SpringBootTest( + classes = { + ReactiveStreamsServiceAutoConfiguration.class, + ReactiveStreamsComponentAutoConfiguration.class, + CamelAutoConfiguration.class + } +) +public class ReactiveStreamsDefaultEngineTest { + @Autowired + private CamelContext context; + + @Test + public void testAutoConfiguration() throws Exception { + + new RouteBuilder() { + @Override + public void configure() throws Exception { + from("reactive-streams:data") + .log("${body}"); + } + }.addRoutesToCamelContext(context); + + Assert.assertTrue(context.getStatus().isStarted()); + CamelReactiveStreamsService service = CamelReactiveStreams.get(context); + Assert.assertTrue(service instanceof DefaultCamelReactiveStreamsService); + } + + +} + http://git-wip-us.apache.org/repos/asf/camel/blob/fe4af678/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsNamedEngineTest.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsNamedEngineTest.java b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsNamedEngineTest.java index 1fb289e..03c2ec8 100644 --- a/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsNamedEngineTest.java +++ b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsNamedEngineTest.java @@ -16,25 +16,16 @@ */ package org.apache.camel.component.reactive.streams.springboot.test; -import java.util.function.Function; - import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.component.reactive.streams.ReactiveStreamsConsumer; -import org.apache.camel.component.reactive.streams.ReactiveStreamsProducer; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; -import org.apache.camel.component.reactive.streams.engine.CamelSubscriber; -import org.apache.camel.component.reactive.streams.engine.DefaultCamelReactiveStreamsService; import org.apache.camel.component.reactive.streams.springboot.ReactiveStreamsComponentAutoConfiguration; import org.apache.camel.component.reactive.streams.springboot.ReactiveStreamsServiceAutoConfiguration; +import org.apache.camel.component.reactive.streams.springboot.test.support.ReactiveStreamsServiceTestSupport; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.reactivestreams.Publisher; -import org.reactivestreams.Subscriber; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; @@ -69,137 +60,12 @@ public class ReactiveStreamsNamedEngineTest { } @Component("my-engine") - static class MyEngine implements CamelReactiveStreamsService { - - @Override - public Publisher<Exchange> fromStream(String s) { - return null; - } - - @Override - public <T> Publisher<T> fromStream(String s, Class<T> aClass) { - return null; - } - - @Override - public Subscriber<Exchange> streamSubscriber(String s) { - return null; - } - - @Override - public <T> Subscriber<T> streamSubscriber(String s, Class<T> aClass) { - return null; - } - - @Override - public Publisher<Exchange> toStream(String s, Object o) { - return null; - } - - @Override - public Function<?, ? extends Publisher<Exchange>> toStream(String s) { - return null; - } - - @Override - public <T> Publisher<T> toStream(String s, Object o, Class<T> aClass) { - return null; - } - - @Override - public <T> Function<Object, Publisher<T>> toStream(String s, Class<T> aClass) { - return null; - } - - @Override - public Publisher<Exchange> from(String s) { - return null; - } - - @Override - public <T> Publisher<T> from(String s, Class<T> aClass) { - return null; - } - - @Override - public Subscriber<Exchange> subscriber(String s) { - return null; - } - - @Override - public <T> Subscriber<T> subscriber(String s, Class<T> aClass) { - return null; - } - - @Override - public Publisher<Exchange> to(String s, Object o) { - return null; - } - - @Override - public Function<Object, Publisher<Exchange>> to(String s) { - return null; - } + static class MyEngine extends ReactiveStreamsServiceTestSupport { - @Override - public <T> Publisher<T> to(String s, Object o, Class<T> aClass) { - return null; + public MyEngine() { + super("my-engine"); } - @Override - public <T> Function<Object, Publisher<T>> to(String s, Class<T> aClass) { - return null; - } - - @Override - public void process(String s, Function<? super Publisher<Exchange>, ?> function) { - - } - - @Override - public <T> void process(String s, Class<T> aClass, Function<? super Publisher<T>, ?> function) { - - } - - @Override - public void attachCamelProducer(String s, ReactiveStreamsProducer producer) { - - } - - @Override - public void detachCamelProducer(String s) { - - } - - @Override - public void sendCamelExchange(String s, Exchange exchange) { - - } - - @Override - public CamelSubscriber attachCamelConsumer(String s, ReactiveStreamsConsumer consumer) { - return null; - } - - @Override - public void detachCamelConsumer(String s) { - - } - - @Override - public void start() throws Exception { - - } - - @Override - public void stop() throws Exception { - - } - - @Override - public String getId() { - return "my-engine"; - } } } http://git-wip-us.apache.org/repos/asf/camel/blob/fe4af678/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsRegistryEngineTest.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsRegistryEngineTest.java b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsRegistryEngineTest.java index 421033f..5e1ec0c 100644 --- a/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsRegistryEngineTest.java +++ b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/ReactiveStreamsRegistryEngineTest.java @@ -16,23 +16,16 @@ */ package org.apache.camel.component.reactive.streams.springboot.test; -import java.util.function.Function; - import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.component.reactive.streams.ReactiveStreamsConsumer; -import org.apache.camel.component.reactive.streams.ReactiveStreamsProducer; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreams; import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; -import org.apache.camel.component.reactive.streams.engine.CamelSubscriber; import org.apache.camel.component.reactive.streams.springboot.ReactiveStreamsComponentAutoConfiguration; import org.apache.camel.component.reactive.streams.springboot.ReactiveStreamsServiceAutoConfiguration; +import org.apache.camel.component.reactive.streams.springboot.test.support.ReactiveStreamsServiceTestSupport; import org.apache.camel.spring.boot.CamelAutoConfiguration; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.reactivestreams.Publisher; -import org.reactivestreams.Subscriber; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; @@ -64,137 +57,12 @@ public class ReactiveStreamsRegistryEngineTest { } @Component("my-engine") - static class MyEngine implements CamelReactiveStreamsService { - - @Override - public Publisher<Exchange> fromStream(String s) { - return null; - } - - @Override - public <T> Publisher<T> fromStream(String s, Class<T> aClass) { - return null; - } - - @Override - public Subscriber<Exchange> streamSubscriber(String s) { - return null; - } - - @Override - public <T> Subscriber<T> streamSubscriber(String s, Class<T> aClass) { - return null; - } - - @Override - public Publisher<Exchange> toStream(String s, Object o) { - return null; - } - - @Override - public Function<?, ? extends Publisher<Exchange>> toStream(String s) { - return null; - } - - @Override - public <T> Publisher<T> toStream(String s, Object o, Class<T> aClass) { - return null; - } - - @Override - public <T> Function<Object, Publisher<T>> toStream(String s, Class<T> aClass) { - return null; - } - - @Override - public Publisher<Exchange> from(String s) { - return null; - } - - @Override - public <T> Publisher<T> from(String s, Class<T> aClass) { - return null; - } - - @Override - public Subscriber<Exchange> subscriber(String s) { - return null; - } - - @Override - public <T> Subscriber<T> subscriber(String s, Class<T> aClass) { - return null; - } - - @Override - public Publisher<Exchange> to(String s, Object o) { - return null; - } - - @Override - public Function<Object, Publisher<Exchange>> to(String s) { - return null; - } + static class MyEngine extends ReactiveStreamsServiceTestSupport { - @Override - public <T> Publisher<T> to(String s, Object o, Class<T> aClass) { - return null; + public MyEngine() { + super("my-engine"); } - @Override - public <T> Function<Object, Publisher<T>> to(String s, Class<T> aClass) { - return null; - } - - @Override - public void process(String s, Function<? super Publisher<Exchange>, ?> function) { - - } - - @Override - public <T> void process(String s, Class<T> aClass, Function<? super Publisher<T>, ?> function) { - - } - - @Override - public void attachCamelProducer(String s, ReactiveStreamsProducer producer) { - - } - - @Override - public void detachCamelProducer(String s) { - - } - - @Override - public void sendCamelExchange(String s, Exchange exchange) { - - } - - @Override - public CamelSubscriber attachCamelConsumer(String s, ReactiveStreamsConsumer consumer) { - return null; - } - - @Override - public void detachCamelConsumer(String s) { - - } - - @Override - public void start() throws Exception { - - } - - @Override - public void stop() throws Exception { - - } - - @Override - public String getId() { - return "my-engine"; - } } } http://git-wip-us.apache.org/repos/asf/camel/blob/fe4af678/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/support/ReactiveStreamsServiceTestSupport.java ---------------------------------------------------------------------- diff --git a/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/support/ReactiveStreamsServiceTestSupport.java b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/support/ReactiveStreamsServiceTestSupport.java new file mode 100644 index 0000000..fe679b5 --- /dev/null +++ b/platforms/spring-boot/components-starter/camel-reactive-streams-starter/src/test/java/org/apache/camel/component/reactive/streams/springboot/test/support/ReactiveStreamsServiceTestSupport.java @@ -0,0 +1,166 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.reactive.streams.springboot.test.support; + +import java.util.function.Function; + +import org.apache.camel.Exchange; +import org.apache.camel.component.reactive.streams.ReactiveStreamsConsumer; +import org.apache.camel.component.reactive.streams.ReactiveStreamsProducer; +import org.apache.camel.component.reactive.streams.api.CamelReactiveStreamsService; +import org.apache.camel.component.reactive.streams.engine.CamelSubscriber; +import org.reactivestreams.Publisher; +import org.reactivestreams.Subscriber; + +public class ReactiveStreamsServiceTestSupport implements CamelReactiveStreamsService { + + private String id; + + public ReactiveStreamsServiceTestSupport(String id) { + this.id = id; + } + + @Override + public Publisher<Exchange> fromStream(String s) { + return null; + } + + @Override + public <T> Publisher<T> fromStream(String s, Class<T> aClass) { + return null; + } + + @Override + public Subscriber<Exchange> streamSubscriber(String s) { + return null; + } + + @Override + public <T> Subscriber<T> streamSubscriber(String s, Class<T> aClass) { + return null; + } + + @Override + public Publisher<Exchange> toStream(String s, Object o) { + return null; + } + + @Override + public Function<?, ? extends Publisher<Exchange>> toStream(String s) { + return null; + } + + @Override + public <T> Publisher<T> toStream(String s, Object o, Class<T> aClass) { + return null; + } + + @Override + public <T> Function<Object, Publisher<T>> toStream(String s, Class<T> aClass) { + return null; + } + + @Override + public Publisher<Exchange> from(String s) { + return null; + } + + @Override + public <T> Publisher<T> from(String s, Class<T> aClass) { + return null; + } + + @Override + public Subscriber<Exchange> subscriber(String s) { + return null; + } + + @Override + public <T> Subscriber<T> subscriber(String s, Class<T> aClass) { + return null; + } + + @Override + public Publisher<Exchange> to(String s, Object o) { + return null; + } + + @Override + public Function<Object, Publisher<Exchange>> to(String s) { + return null; + } + + @Override + public <T> Publisher<T> to(String s, Object o, Class<T> aClass) { + return null; + } + + @Override + public <T> Function<Object, Publisher<T>> to(String s, Class<T> aClass) { + return null; + } + + @Override + public void process(String s, Function<? super Publisher<Exchange>, ?> function) { + + } + + @Override + public <T> void process(String s, Class<T> aClass, Function<? super Publisher<T>, ?> function) { + + } + + @Override + public void attachCamelProducer(String s, ReactiveStreamsProducer producer) { + + } + + @Override + public void detachCamelProducer(String s) { + + } + + @Override + public void sendCamelExchange(String s, Exchange exchange) { + + } + + @Override + public CamelSubscriber attachCamelConsumer(String s, ReactiveStreamsConsumer consumer) { + return null; + } + + @Override + public void detachCamelConsumer(String s) { + + } + + @Override + public void start() throws Exception { + + } + + @Override + public void stop() throws Exception { + + } + + @Override + public String getId() { + return id; + } +}