You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/09/09 14:18:55 UTC
[02/14] camel git commit: CAMEL-11756: camel-spring-boot2 - Work in
progress
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallTest.java
new file mode 100644
index 0000000..cf85d8f
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/cloud/CamelCloudServiceCallTest.java
@@ -0,0 +1,126 @@
+/**
+ * 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.spring.boot.cloud;
+
+import java.util.Properties;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+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.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertiesPropertySource;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@DirtiesContext
+@RunWith(SpringRunner.class)
+@SpringBootApplication
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ CamelCloudServiceCallTest.TestConfiguration.class,
+ CamelCloudServiceCallTest.SpringBootPropertySourceConfig.class
+ }
+
+)
+public class CamelCloudServiceCallTest {
+ @Autowired
+ private ProducerTemplate template;
+
+ @Test
+ public void testServiceCall() throws Exception {
+ Assert.assertEquals(String.valueOf(SpringBootPropertyUtil.PORT1), template.requestBody("direct:start", null, String.class));
+ Assert.assertEquals(String.valueOf(SpringBootPropertyUtil.PORT3), template.requestBody("direct:start", null, String.class));
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public static class TestConfiguration {
+ @Bean
+ public RouteBuilder myRouteBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .serviceCall("custom-svc-list/hello");
+
+ fromF("jetty:http://localhost:%d/hello", SpringBootPropertyUtil.PORT1)
+ .transform()
+ .constant(SpringBootPropertyUtil.PORT1);
+ fromF("jetty:http://localhost:%d/hello", SpringBootPropertyUtil.PORT2)
+ .transform()
+ .constant(SpringBootPropertyUtil.PORT2);
+ fromF("jetty:http://localhost:%d/hello", SpringBootPropertyUtil.PORT3)
+ .transform()
+ .constant(SpringBootPropertyUtil.PORT3);
+ }
+ };
+ }
+ }
+
+ private static Properties getAllProperties() {
+
+ Properties prop = new Properties();
+ prop.put("service.name", "custom-svc-list");
+ prop.put("camel.cloud.load-balancer.enabled", false);
+ prop.put("camel.cloud.service-call.component", "jetty");
+ prop.put("camel.cloud.service-discovery.services[custom-svc-list]", SpringBootPropertyUtil.getDiscoveryServices());
+ prop.put("camel.cloud.service-filter.blacklist[custom-svc-list]", SpringBootPropertyUtil.getServiceFilterBlacklist());
+ prop.put("ribbon.enabled", false);
+ prop.put("debug", false);
+ return prop;
+ }
+
+
+
+ // *************************************
+ // Config
+ //
+
+ @Configuration
+ public static class SpringBootPropertySourceConfig {
+
+ @Autowired
+ private ConfigurableEnvironment env;
+
+ @Bean
+ @Lazy(false)
+ public MutablePropertySources springBootPropertySource() {
+
+ MutablePropertySources sources = env.getPropertySources();
+ sources.addFirst(new PropertiesPropertySource("boot-test-property", CamelCloudServiceCallTest.getAllProperties()));
+ return sources;
+
+ }
+ }
+
+
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/cloud/SpringBootPropertyUtil.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/cloud/SpringBootPropertyUtil.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/cloud/SpringBootPropertyUtil.java
new file mode 100644
index 0000000..59a5c9f
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/cloud/SpringBootPropertyUtil.java
@@ -0,0 +1,57 @@
+/**
+ * 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.spring.boot.cloud;
+
+import org.apache.camel.test.AvailablePortFinder;
+
+public final class SpringBootPropertyUtil {
+
+ public static final int PORT1 = AvailablePortFinder.getNextAvailable();
+ public static final int PORT2 = AvailablePortFinder.getNextAvailable();
+ public static final int PORT3 = AvailablePortFinder.getNextAvailable();
+ public static final String HOSTNAME = "localhost:";
+
+ private SpringBootPropertyUtil() {
+
+ }
+
+
+ public static String getDiscoveryServices() {
+
+ StringBuffer dservice = new StringBuffer();
+ dservice.append(HOSTNAME);
+ dservice.append(PORT1);
+ dservice.append(",");
+ dservice.append(HOSTNAME);
+ dservice.append(PORT2);
+ dservice.append(",");
+ dservice.append(HOSTNAME);
+ dservice.append(PORT3);
+ return dservice.toString();
+
+ }
+
+ public static String getServiceFilterBlacklist() {
+
+ StringBuffer filterBlacklistString = new StringBuffer();
+ filterBlacklistString.append(HOSTNAME);
+ filterBlacklistString.append(PORT2);
+ return filterBlacklistString.toString();
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/componentroute/ComponentRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/componentroute/ComponentRoute.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/componentroute/ComponentRoute.java
new file mode 100644
index 0000000..984179c
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/componentroute/ComponentRoute.java
@@ -0,0 +1,36 @@
+/**
+ * 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.spring.boot.componentroute;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ComponentRoute extends RouteBuilder {
+
+ // We inject this field to make sure that template creation doesn't affects routes collecting.
+ @Autowired
+ ProducerTemplate producerTemplate;
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:componentRoute").to("mock:componentRoute");
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/componentroute/ComponentRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/componentroute/ComponentRouteTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/componentroute/ComponentRouteTest.java
new file mode 100644
index 0000000..45b8a28
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/componentroute/ComponentRouteTest.java
@@ -0,0 +1,55 @@
+/**
+ * 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.spring.boot.componentroute;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+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.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootApplication
+@SpringBootTest(classes = ComponentRouteTest.class)
+public class ComponentRouteTest extends Assert {
+
+ @EndpointInject(uri = "mock:componentRoute")
+ MockEndpoint mock;
+
+ @Autowired
+ ProducerTemplate producerTemplate;
+
+ @Test
+ public void shouldNotProvideConverter() throws InterruptedException {
+ // Given
+ String msg = "msg";
+ mock.expectedBodiesReceived(msg);
+
+ // When
+ producerTemplate.sendBody("direct:componentRoute", msg);
+
+ // Then
+ mock.assertIsSatisfied();
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyComponent.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyComponent.java
new file mode 100644
index 0000000..04c2a81
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyComponent.java
@@ -0,0 +1,38 @@
+/**
+ * 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.spring.boot.dummy;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+public class DummyComponent extends DefaultComponent {
+
+ private int counter;
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ Endpoint answer = new DummyEndpoint(uri, this);
+ setProperties(answer, parameters);
+ return answer;
+ }
+
+ public int increment() {
+ return ++counter;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyConsumer.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyConsumer.java
new file mode 100644
index 0000000..bf05043
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyConsumer.java
@@ -0,0 +1,54 @@
+/**
+ * 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.spring.boot.dummy;
+
+import java.io.IOException;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultConsumer;
+
+public class DummyConsumer extends DefaultConsumer {
+
+ private boolean failOnRestart = true;
+
+ public DummyConsumer(Endpoint endpoint, Processor processor) {
+ super(endpoint, processor);
+ }
+
+ @Override
+ public DummyEndpoint getEndpoint() {
+ return (DummyEndpoint) super.getEndpoint();
+ }
+
+ public boolean isFailOnRestart() {
+ return failOnRestart;
+ }
+
+ public void setFailOnRestart(boolean failOnRestart) {
+ this.failOnRestart = failOnRestart;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ int counter = getEndpoint().getComponent().increment();
+ if (counter == 2) {
+ throw new IOException("Forced error on restart");
+ }
+ super.doStart();
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyEndpoint.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyEndpoint.java
new file mode 100644
index 0000000..4ae60cf
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/dummy/DummyEndpoint.java
@@ -0,0 +1,63 @@
+/**
+ * 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.spring.boot.dummy;
+
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+
+public class DummyEndpoint extends DefaultEndpoint {
+
+ private boolean failOnRestart = true;
+
+ public DummyEndpoint(String endpointUri, Component component) {
+ super(endpointUri, component);
+ }
+
+ @Override
+ public DummyComponent getComponent() {
+ return (DummyComponent) super.getComponent();
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ throw new UnsupportedOperationException("Cannot produce");
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ DummyConsumer consumer = new DummyConsumer(this, processor);
+ configureConsumer(consumer);
+ consumer.setFailOnRestart(failOnRestart);
+ return consumer;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public boolean isFailOnRestart() {
+ return failOnRestart;
+ }
+
+ public void setFailOnRestart(boolean failOnRestart) {
+ this.failOnRestart = failOnRestart;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
new file mode 100644
index 0000000..b1cf299
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
@@ -0,0 +1,78 @@
+/**
+ * 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.spring.boot.issues;
+
+public class CountryPojo {
+
+ private String iso;
+ private String country;
+
+ public String getIso() {
+ return iso;
+ }
+
+ public void setIso(String iso) {
+ this.iso = iso;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((country == null) ? 0 : country.hashCode());
+ result = prime * result + ((iso == null) ? 0 : iso.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ CountryPojo other = (CountryPojo) obj;
+ if (country == null) {
+ if (other.country != null) {
+ return false;
+ }
+ } else if (!country.equals(other.country)) {
+ return false;
+ }
+ if (iso == null) {
+ if (other.iso != null) {
+ return false;
+ }
+ } else if (!iso.equals(other.iso)) {
+ return false;
+ }
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
new file mode 100644
index 0000000..6d835b8
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
@@ -0,0 +1,102 @@
+/**
+ * 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.spring.boot.issues;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.ExchangeBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.rest.RestBindingMode;
+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.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.util.SocketUtils;
+
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootTest(classes = { RestDslPostTest.class })
+public class RestDslPostTest extends Assert {
+
+ static final int PORT = SocketUtils.findAvailableTcpPort(20000);
+
+ @EndpointInject(uri = "mock:user")
+ protected MockEndpoint resultEndpointUser;
+ @EndpointInject(uri = "mock:country")
+ protected MockEndpoint resultEndpointCountry;
+
+ @Autowired
+ protected ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @Test
+ public void testMultiplePostTypes() throws Exception {
+
+ UserPojo user = new UserPojo();
+ user.setId(1);
+ user.setName("My Name");
+ resultEndpointUser.expectedBodiesReceived(user);
+ resultEndpointUser.expectedMessageCount(1);
+
+ CountryPojo country = new CountryPojo();
+ country.setCountry("England");
+ country.setIso("EN");
+ resultEndpointCountry.expectedBodiesReceived(country);
+ resultEndpointCountry.expectedMessageCount(1);
+
+ ExchangeBuilder builder = ExchangeBuilder.anExchange(context)
+ .withHeader(Exchange.HTTP_METHOD, HttpMethod.POST)
+ .withHeader(Exchange.ACCEPT_CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ Exchange outExchangeUser = builder.withBody("{\"id\": 1, \"name\": \"My Name\"}").build();
+ Exchange outExchangeCountry = builder.withBody("{\"iso\": \"EN\", \"country\": \"England\"}").build();
+
+ template.send("jetty:http://localhost:" + PORT + "/user", outExchangeUser);
+ template.send("jetty:http://localhost:" + PORT + "/country", outExchangeCountry);
+
+ resultEndpointCountry.assertIsSatisfied();
+ resultEndpointUser.assertIsSatisfied();
+
+ }
+
+ @Configuration
+ public static class ContextConfig {
+ @Bean
+ public RouteBuilder route() {
+ return new RouteBuilder() {
+ public void configure() {
+ restConfiguration().host("localhost").port(PORT).bindingMode(RestBindingMode.json);
+
+ rest("/").post("/user").type(UserPojo.class).route().to("mock:user").endRest().post("/country")
+ .type(CountryPojo.class).route().to("mock:country").endRest();
+
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/SimpleOgnlTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/SimpleOgnlTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/SimpleOgnlTest.java
new file mode 100644
index 0000000..72024e2
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/SimpleOgnlTest.java
@@ -0,0 +1,69 @@
+/**
+ * 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.spring.boot.issues;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@EnableAutoConfiguration
+@SpringBootTest(classes = { SimpleOgnlTest.class })
+public class SimpleOgnlTest {
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint resultEndpoint;
+
+ @Produce(uri = "direct:start")
+ protected ProducerTemplate template;
+
+ @Test
+ public void testSimpleOgnlListExpression() throws Exception {
+ List<String> list = new ArrayList<String>();
+ list.add("one");
+ list.add("two");
+
+ resultEndpoint.expectedBodiesReceived(list.get(0));
+
+ template.sendBody(list);
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ @Configuration
+ public static class ContextConfig {
+ @Bean
+ public RouteBuilder route() {
+ return new RouteBuilder() {
+ public void configure() {
+ from("direct:start").setBody(simple("${body[0]}")).to("mock:result");
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/StreamCachingTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/StreamCachingTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/StreamCachingTest.java
new file mode 100644
index 0000000..d0a5fea
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/StreamCachingTest.java
@@ -0,0 +1,96 @@
+/**
+ * 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.spring.boot.issues;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.List;
+
+import static java.util.Arrays.asList;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.SpringTypeConverter;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.core.convert.ConversionService;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.core.convert.support.DefaultConversionService;
+
+public class StreamCachingTest extends CamelTestSupport {
+
+ public static final String URI_END_OF_ROUTE = "mock:end_of_route";
+
+ @EndpointInject(uri = URI_END_OF_ROUTE)
+ private MockEndpoint endOfRoute;
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ context.getTypeConverterRegistry().addFallbackTypeConverter(springTypeConverter(context, new ConversionService[]{new DefaultConversionService()}), true);
+
+ from("direct:foo")
+ .streamCaching()
+ .bean(MyBean.class)
+ .to(URI_END_OF_ROUTE);
+ }
+ };
+ }
+
+ @Test
+ public void streamCachingWithSpring() throws Exception {
+ endOfRoute.expectedMessageCount(1);
+
+ template.sendBody("direct:foo", new FileInputStream(new File("src/test/resources/logback.xml")));
+
+ endOfRoute.assertIsSatisfied();
+ }
+
+ public static class MyBean {
+ public List<Integer> someNumbers() {
+ return asList(1, 2, 3);
+ }
+ }
+
+ /**
+ * Copied from org.apache.camel.spring.boot.TypeConversionConfiguration (they are package protected)
+ **/
+ @Bean
+ SpringTypeConverter springTypeConverter(CamelContext camelContext, ConversionService[] conversionServices) {
+ SpringTypeConverter springTypeConverter = new SpringTypeConverter(asList(conversionServices));
+ camelContext.getTypeConverterRegistry().addFallbackTypeConverter(springTypeConverter, true);
+ return springTypeConverter;
+ }
+
+ @ConditionalOnMissingBean
+ @Bean
+ ConversionService defaultCamelConversionService(ApplicationContext applicationContext) {
+ DefaultConversionService service = new DefaultConversionService();
+ for (Converter converter : applicationContext.getBeansOfType(Converter.class).values()) {
+ service.addConverter(converter);
+ }
+ return service;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
new file mode 100644
index 0000000..e72b92f
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
@@ -0,0 +1,74 @@
+/**
+ * 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.spring.boot.issues;
+
+public class UserPojo {
+
+ private int id;
+ private String name;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + id;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ UserPojo other = (UserPojo) obj;
+ if (id != other.id) {
+ return false;
+ }
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java
new file mode 100644
index 0000000..ccf2bf0
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/AdviceWithTest.java
@@ -0,0 +1,68 @@
+/**
+ * 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.spring.boot.mockendpoints;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.AdviceWithRouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.test.spring.CamelSpringBootRunner;
+import org.apache.camel.test.spring.UseAdviceWith;
+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;
+
+@RunWith(CamelSpringBootRunner.class)
+@UseAdviceWith
+@SpringBootApplication
+@SpringBootTest(classes = AdviceWithTest.class)
+public class AdviceWithTest {
+
+ @Autowired
+ ProducerTemplate producerTemplate;
+
+ @Autowired
+ ModelCamelContext camelContext;
+
+ @Test
+ public void shouldMockEndpoints() throws Exception {
+ camelContext.getRouteDefinitions().get(0).adviceWith(camelContext, new AdviceWithRouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ replaceFromWith("seda:start");
+ weaveAddLast().to("mock:result");
+ }
+ });
+
+ camelContext.start();
+
+ MockEndpoint mock = camelContext.getEndpoint("mock:result", MockEndpoint.class);
+
+ // Given
+ String msg = "msg";
+ mock.expectedBodiesReceived(msg);
+
+ // When
+ producerTemplate.sendBody("seda:start", msg);
+
+ // Then
+ mock.assertIsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/MockEndpointsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/MockEndpointsTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/MockEndpointsTest.java
new file mode 100644
index 0000000..e721dfa
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/MockEndpointsTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.spring.boot.mockendpoints;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.FluentProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.spring.CamelSpringBootRunner;
+import org.apache.camel.test.spring.MockEndpoints;
+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;
+
+@RunWith(CamelSpringBootRunner.class)
+@MockEndpoints
+@SpringBootApplication
+@SpringBootTest(classes = MockEndpointsTest.class)
+public class MockEndpointsTest {
+
+ @Autowired
+ FluentProducerTemplate producerTemplate;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Test
+ public void shouldMockEndpoints() throws Exception {
+ MockEndpoint mock = camelContext.getEndpoint("mock://seda:foo", MockEndpoint.class);
+
+ // Given
+ String msg = "msg";
+ mock.expectedBodiesReceived(msg);
+
+ // When
+ producerTemplate.withBody(msg).to("direct:start").send();
+
+ // Then
+ mock.assertIsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/MyRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/MyRoute.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/MyRoute.java
new file mode 100644
index 0000000..1abb466
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/mockendpoints/MyRoute.java
@@ -0,0 +1,30 @@
+/**
+ * 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.spring.boot.mockendpoints;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class MyRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("seda:foo");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
new file mode 100644
index 0000000..d1adfcf
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/parent/SpringBootRefreshContextTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.spring.boot.parent;
+
+import org.apache.camel.RoutesBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.boot.RoutesCollector;
+import org.junit.Test;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SpringBootRefreshContextTest {
+
+ @Test
+ public void shouldOnlyCollectRoutesOnce() {
+ GenericApplicationContext parent = new GenericApplicationContext();
+ parent.refresh();
+ ConfigurableApplicationContext context = new SpringApplicationBuilder(Configuration.class).web(false).parent(parent).run();
+ ContextRefreshedEvent refreshEvent = new ContextRefreshedEvent(context);
+ RoutesCollector collector = context.getBean(RoutesCollector.class);
+ collector.onApplicationEvent(refreshEvent); //no changes should happen here
+ }
+
+}
+
+@SpringBootApplication
+class Configuration {
+
+ @Bean
+ RoutesBuilder routes() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("seda:test").to("mock:test");
+ }
+ };
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/BarRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/BarRoute.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/BarRoute.java
new file mode 100644
index 0000000..4b83c99
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/BarRoute.java
@@ -0,0 +1,30 @@
+/**
+ * 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.spring.boot.routefilter;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BarRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("mock:bar");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/BarTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/BarTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/BarTest.java
new file mode 100644
index 0000000..ca4a168
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/BarTest.java
@@ -0,0 +1,54 @@
+/**
+ * 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.spring.boot.routefilter;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.test.spring.CamelSpringBootRunner;
+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;
+
+@RunWith(CamelSpringBootRunner.class)
+@SpringBootApplication
+@SpringBootTest(classes = BarTest.class,
+ properties = {"camel.springboot.java-routes-include-pattern=**/Bar*"})
+public class BarTest {
+
+ @Autowired
+ ProducerTemplate producerTemplate;
+
+ @Autowired
+ ModelCamelContext camelContext;
+
+ @Test
+ public void shouldSendToBar() throws Exception {
+ // Given
+ MockEndpoint mock = camelContext.getEndpoint("mock:bar", MockEndpoint.class);
+ mock.expectedBodiesReceived("Hello Bar");
+
+ // When
+ producerTemplate.sendBody("direct:start", "Hello Bar");
+
+ // Then
+ mock.assertIsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/DrinkRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/DrinkRoute.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/DrinkRoute.java
new file mode 100644
index 0000000..824a123
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/DrinkRoute.java
@@ -0,0 +1,30 @@
+/**
+ * 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.spring.boot.routefilter;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DrinkRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("mock:foo");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/FooRoute.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/FooRoute.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/FooRoute.java
new file mode 100644
index 0000000..8914569
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/FooRoute.java
@@ -0,0 +1,30 @@
+/**
+ * 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.spring.boot.routefilter;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class FooRoute extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("mock:foo");
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/FooTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/FooTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/FooTest.java
new file mode 100644
index 0000000..ccc6640
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/routefilter/FooTest.java
@@ -0,0 +1,54 @@
+/**
+ * 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.spring.boot.routefilter;
+
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.test.spring.CamelSpringBootRunner;
+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;
+
+@RunWith(CamelSpringBootRunner.class)
+@SpringBootApplication()
+@SpringBootTest(classes = BarTest.class,
+ properties = {"camel.springboot.java-routes-exclude-pattern=**/Bar*,**/Drink*"})
+public class FooTest {
+
+ @Autowired
+ ProducerTemplate producerTemplate;
+
+ @Autowired
+ ModelCamelContext camelContext;
+
+ @Test
+ public void shouldSendToFoo() throws Exception {
+ // Given
+ MockEndpoint mock = camelContext.getEndpoint("mock:foo", MockEndpoint.class);
+ mock.expectedBodiesReceived("Hello Foo");
+
+ // When
+ producerTemplate.sendBody("direct:start", "Hello Foo");
+
+ // Then
+ mock.assertIsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/security/CamelSSLAutoConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/security/CamelSSLAutoConfigurationTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/security/CamelSSLAutoConfigurationTest.java
new file mode 100644
index 0000000..3a6b1ad
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/security/CamelSSLAutoConfigurationTest.java
@@ -0,0 +1,68 @@
+/**
+ * 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.spring.boot.security;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.util.jsse.GlobalSSLContextParametersSupplier;
+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.context.ApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Testing the ssl configuration
+ */
+@RunWith(SpringRunner.class)
+@SpringBootApplication
+@DirtiesContext
+@ContextConfiguration(classes = {CamelSSLAutoConfiguration.class, CamelAutoConfiguration.class})
+@SpringBootTest(properties = {
+ "camel.ssl.config.cert-alias=web",
+ "camel.ssl.config.key-managers.key-password=changeit",
+ "camel.ssl.config.key-managers.key-store.password=changeit",
+ "camel.ssl.config.key-managers.key-store.type=PKCS12",
+ "camel.ssl.config.trust-managers.key-store.password=changeit",
+ "camel.ssl.config.trust-managers.key-store.type=jks"
+})
+public class CamelSSLAutoConfigurationTest {
+
+ @Autowired
+ private ApplicationContext applicationContext;
+
+ @Test
+ public void checkSSLPropertiesPresent() {
+ GlobalSSLContextParametersSupplier supplier = applicationContext.getBean(GlobalSSLContextParametersSupplier.class);
+ assertNotNull(supplier);
+ assertNotNull(supplier.get());
+ assertEquals("web", supplier.get().getCertAlias());
+ assertNotNull(supplier.get().getKeyManagers());
+ assertEquals("changeit", supplier.get().getKeyManagers().getKeyPassword());
+ assertNotNull(supplier.get().getTrustManagers());
+ assertNotNull(supplier.get().getTrustManagers().getKeyStore());
+ assertEquals("jks", supplier.get().getTrustManagers().getKeyStore().getType());
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/security/CamelSSLNoConfigTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/security/CamelSSLNoConfigTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/security/CamelSSLNoConfigTest.java
new file mode 100644
index 0000000..21b8efa
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/security/CamelSSLNoConfigTest.java
@@ -0,0 +1,53 @@
+/**
+ * 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.spring.boot.security;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.util.jsse.GlobalSSLContextParametersSupplier;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * Testing that the ssl configuration is not created if a subproperty of "camel.ssl.config." (note the last dot) is not present.
+ */
+@RunWith(SpringRunner.class)
+@SpringBootApplication
+@DirtiesContext
+@ContextConfiguration(classes = {CamelSSLAutoConfiguration.class, CamelAutoConfiguration.class})
+@SpringBootTest(properties = {
+ "camel.ssl.configxxx=true"
+})
+public class CamelSSLNoConfigTest {
+
+ @Autowired
+ private ApplicationContext applicationContext;
+
+ @Test(expected = NoSuchBeanDefinitionException.class)
+ public void checkSSLPropertiesNotPresent() {
+ applicationContext.getBean(GlobalSSLContextParametersSupplier.class);
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperTest.java
new file mode 100644
index 0000000..9af219f
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/CamelPropertiesHelperTest.java
@@ -0,0 +1,170 @@
+/**
+ * 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.spring.boot.util;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+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.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DirtiesContext
+@SpringBootApplication
+@SpringBootTest(
+ classes = {
+ CamelPropertiesHelperTest.TestConfiguration.class
+ }
+)
+public class CamelPropertiesHelperTest {
+
+ @Autowired
+ ApplicationContext context;
+
+ @Autowired
+ CamelContext camelContext;
+
+ @Configuration
+ static class TestConfiguration {
+ @Bean(name = "myCoolOption")
+ MyOption myCoolBean() {
+ return new MyOption();
+ }
+ }
+
+ static class MyOption {
+ }
+
+ static class MyClass {
+
+ private int id;
+ private String name;
+ private MyOption option;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public MyOption getOption() {
+ return option;
+ }
+
+ public void setOption(MyOption option) {
+ this.option = option;
+ }
+ }
+
+ @Test
+ public void testSetCamelProperties() throws Exception {
+ MyClass target = new MyClass();
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("id", "123");
+ map.put("name", "Donald Duck");
+ map.put("option", "myCoolOption");
+
+ CamelPropertiesHelper.setCamelProperties(camelContext, target, map, true);
+
+ Assert.assertEquals("Should configure all options", 0, map.size());
+ Assert.assertEquals(123, target.getId());
+ Assert.assertEquals("Donald Duck", target.getName());
+ Assert.assertSame(context.getBean("myCoolOption"), target.getOption());
+ }
+
+ @Test
+ public void testSetCamelPropertiesReference() throws Exception {
+ MyClass target = new MyClass();
+
+ Map<String, Object> map = new HashMap<>();
+ map.put("id", "123");
+ map.put("name", "Donald Duck");
+ map.put("option", "#myCoolOption");
+
+ CamelPropertiesHelper.setCamelProperties(camelContext, target, map, true);
+
+ Assert.assertEquals("Should configure all options", 0, map.size());
+ Assert.assertEquals(123, target.getId());
+ Assert.assertEquals("Donald Duck", target.getName());
+ Assert.assertSame(context.getBean("myCoolOption"), target.getOption());
+ }
+
+ @Test
+ public void testSetCamelPropertiesUnknownOption() throws Exception {
+ MyClass target = new MyClass();
+
+ Map<String, Object> map = new LinkedHashMap<>();
+ map.put("id", "123");
+ map.put("name", "Donald Duck");
+ map.put("option", "#myCoolOption");
+ map.put("unknown", "foo");
+
+ try {
+ CamelPropertiesHelper.setCamelProperties(camelContext, target, map, true);
+ Assert.fail("Should have thrown exception");
+ } catch (IllegalArgumentException e) {
+ // expected
+ Assert.assertTrue(e.getMessage().startsWith("Cannot configure option [unknown] with value [foo]"));
+ }
+
+ Assert.assertEquals("Should configure the three first options", 1, map.size());
+ Assert.assertEquals(123, target.getId());
+ Assert.assertEquals("Donald Duck", target.getName());
+ Assert.assertSame(context.getBean("myCoolOption"), target.getOption());
+ }
+
+ @Test
+ public void testSetCamelPropertiesUnknownOptionIgnore() throws Exception {
+ MyClass target = new MyClass();
+
+ Map<String, Object> map = new LinkedHashMap<>();
+ map.put("id", "123");
+ map.put("name", "Donald Duck");
+ map.put("option", "#myCoolOption");
+ map.put("unknown", "foo");
+
+ CamelPropertiesHelper.setCamelProperties(camelContext, target, map, false);
+
+ Assert.assertEquals("Should configure the three first options", 1, map.size());
+ Assert.assertEquals(123, target.getId());
+ Assert.assertEquals("Donald Duck", target.getName());
+ Assert.assertSame(context.getBean("myCoolOption"), target.getOption());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest1.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest1.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest1.java
new file mode 100644
index 0000000..b8155b7
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest1.java
@@ -0,0 +1,49 @@
+/**
+ * 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.spring.boot.util;
+
+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.context.ApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DirtiesContext
+@SpringBootApplication
+@SpringBootTest(
+ classes = {
+ GroupConditionTestBase.TestConfiguration.class
+ },
+ properties = {
+ "test.group.enabled=false",
+ "test.group.my-class.enabled=true"
+ }
+)
+public class GroupConditionTest1 extends GroupConditionTestBase {
+ @Autowired
+ ApplicationContext context;
+
+ @Test
+ public void testCondition() {
+ Assert.assertEquals(1, context.getBeansOfType(MyClass.class).size());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest2.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest2.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest2.java
new file mode 100644
index 0000000..f981acc
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest2.java
@@ -0,0 +1,49 @@
+/**
+ * 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.spring.boot.util;
+
+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.context.ApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DirtiesContext
+@SpringBootApplication
+@SpringBootTest(
+ classes = {
+ GroupConditionTest2.TestConfiguration.class
+ },
+ properties = {
+ "test.group.enabled=false",
+ "test.group.my-class.enabled=false"
+ }
+)
+public class GroupConditionTest2 extends GroupConditionTestBase {
+ @Autowired
+ ApplicationContext context;
+
+ @Test
+ public void testCondition() {
+ Assert.assertEquals(0, context.getBeansOfType(MyClass.class).size());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest3.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest3.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest3.java
new file mode 100644
index 0000000..f266d69
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest3.java
@@ -0,0 +1,49 @@
+/**
+ * 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.spring.boot.util;
+
+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.context.ApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DirtiesContext
+@SpringBootApplication
+@SpringBootTest(
+ classes = {
+ GroupConditionTest3.TestConfiguration.class
+ },
+ properties = {
+ "test.group.enabled=true",
+ "test.group.my-class.enabled=false"
+ }
+)
+public class GroupConditionTest3 extends GroupConditionTestBase {
+ @Autowired
+ ApplicationContext context;
+
+ @Test
+ public void testCondition() {
+ Assert.assertEquals(0, context.getBeansOfType(MyClass.class).size());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest4.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest4.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest4.java
new file mode 100644
index 0000000..4de3782
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTest4.java
@@ -0,0 +1,49 @@
+/**
+ * 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.spring.boot.util;
+
+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.context.ApplicationContext;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DirtiesContext
+@SpringBootApplication
+@SpringBootTest(
+ classes = {
+ GroupConditionTest4.TestConfiguration.class
+ },
+ properties = {
+ "test.group.enabled=true",
+ "test.group.my-class.enabled=true"
+ }
+)
+public class GroupConditionTest4 extends GroupConditionTestBase {
+ @Autowired
+ ApplicationContext context;
+
+ @Test
+ public void testCondition() {
+ Assert.assertEquals(1, context.getBeansOfType(MyClass.class).size());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTestBase.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTestBase.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTestBase.java
new file mode 100644
index 0000000..39e8fdb
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/GroupConditionTestBase.java
@@ -0,0 +1,41 @@
+/**
+ * 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.spring.boot.util;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Conditional;
+import org.springframework.context.annotation.Configuration;
+
+public class GroupConditionTestBase {
+ @Configuration
+ static class TestConfiguration {
+ @Bean
+ @Conditional(TestConfiguration.Conditions.class)
+ public MyClass stringComponent() {
+ return new MyClass();
+ }
+
+ static class Conditions extends GroupCondition {
+ public Conditions() {
+ super("test.group", "test.group.my-class");
+ }
+ }
+ }
+
+ static class MyClass {
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/cb70f538/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/HierarchicalPropertiesEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/HierarchicalPropertiesEvaluatorTest.java b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/HierarchicalPropertiesEvaluatorTest.java
new file mode 100644
index 0000000..6ed08f4
--- /dev/null
+++ b/components/camel-spring-boot2/src/test/java/org/apache/camel/spring/boot/util/HierarchicalPropertiesEvaluatorTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.spring.boot.util;
+
+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.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@DirtiesContext
+@SpringBootApplication
+@SpringBootTest(
+ classes = {
+ HierarchicalPropertiesEvaluatorTest.TestConfiguration.class
+ },
+ properties = {
+ "test.group1.enabled=true",
+ "test.group1.subgroup1.enabled=false",
+ "test.group1.subgroup2.enabled=true",
+ "test.group2.enabled=false",
+ "test.group2.subgroup1.enabled=false",
+ "test.group2.subgroup2.enabled=true",
+ "test.group2.subgroup3.enabled=false"
+ }
+)
+public class HierarchicalPropertiesEvaluatorTest {
+ @Autowired
+ Environment environment;
+
+ @Test
+ public void testEvaluator() {
+ Assert.assertFalse(HierarchicalPropertiesEvaluator.evaluate(environment, "test.group1", "test.group1.subgroup1"));
+ Assert.assertTrue(HierarchicalPropertiesEvaluator.evaluate(environment, "test.group1", "test.group1.subgroup2"));
+ Assert.assertFalse(HierarchicalPropertiesEvaluator.evaluate(environment, "test.group2", "test.group2.subgroup1"));
+ Assert.assertTrue(HierarchicalPropertiesEvaluator.evaluate(environment, "test.group2", "test.group2.subgroup2"));
+ Assert.assertFalse(HierarchicalPropertiesEvaluator.evaluate(environment, "test.group2", "test.group2.subgroup3"));
+ }
+
+ @Configuration
+ static class TestConfiguration {
+ }
+}