You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by on...@apache.org on 2018/12/04 07:48:20 UTC
[camel] 02/02: CAMEL-12944 - externalize configs as PR #2549 tried
to avoid potentially conflicting jetty port during test execution
This is an automated email from the ASF dual-hosted git repository.
onders pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 65e2f2f7aa3d4b0782404abb7db67880f7025807
Author: onders <on...@apache.org>
AuthorDate: Tue Dec 4 01:03:28 2018 +0300
CAMEL-12944 - externalize configs as PR #2549 tried to avoid potentially conflicting jetty port during test execution
---
.../ribbon/cloud/SpringBeanServiceCallRouteTest.java | 8 --------
...pringDslRibbonPropertiesServiceCallRouteTest.java | 9 ---------
.../cloud/SpringDslRibbonServiceCallRouteTest.java | 8 --------
.../cloud/SpringRibbonServiceCallRouteTest.java | 20 ++++++++++++--------
.../cloud/SpringBeanRibbonServiceCallRouteTest.xml | 18 +++++++++++-------
...SpringDslRibbonPropertiesServiceCallRouteTest.xml | 18 +++++++++++-------
.../cloud/SpringDslRibbonServiceCallRouteTest.xml | 18 +++++++++++-------
.../springbeanribbonservicecallroutetest.properties | 19 +++++++++++++++++++
...slribbonpropertiesservicecallroutetest.properties | 19 +++++++++++++++++++
.../springdslribbonservicecallroutetest.properties | 19 +++++++++++++++++++
10 files changed, 102 insertions(+), 54 deletions(-)
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringBeanServiceCallRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringBeanServiceCallRouteTest.java
index fc264ff..5cbf8c4 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringBeanServiceCallRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringBeanServiceCallRouteTest.java
@@ -42,13 +42,5 @@ public class SpringBeanServiceCallRouteTest extends SpringRibbonServiceCallRoute
RibbonServiceLoadBalancer loadBalancer = (RibbonServiceLoadBalancer)processor.getLoadBalancer();
Assert.assertTrue(loadBalancer.getServiceDiscovery() instanceof StaticServiceDiscovery);
}
-
- protected String getFirstPort() {
- return "9092";
- }
-
- protected String getSecondPort() {
- return "9093";
- }
}
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.java
index 736bed4..56d734f 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.java
@@ -41,14 +41,5 @@ public class SpringDslRibbonPropertiesServiceCallRouteTest extends SpringRibbonS
RibbonServiceLoadBalancer loadBalancer = (RibbonServiceLoadBalancer)processor.getLoadBalancer();
Assert.assertNull(loadBalancer.getServiceDiscovery());
}
-
- protected String getFirstPort() {
- return "9094";
- }
-
- protected String getSecondPort() {
- return "9095";
- }
-
}
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.java
index 271d723..bb5304e 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.java
@@ -42,13 +42,5 @@ public class SpringDslRibbonServiceCallRouteTest extends SpringRibbonServiceCall
RibbonServiceLoadBalancer loadBalancer = (RibbonServiceLoadBalancer)processor.getLoadBalancer();
Assert.assertTrue(loadBalancer.getServiceDiscovery() instanceof StaticServiceDiscovery);
}
-
- protected String getFirstPort() {
- return "9096";
- }
-
- protected String getSecondPort() {
- return "9097";
- }
}
diff --git a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringRibbonServiceCallRouteTest.java b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringRibbonServiceCallRouteTest.java
index 43376d7..a83e210 100644
--- a/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringRibbonServiceCallRouteTest.java
+++ b/components/camel-ribbon/src/test/java/org/apache/camel/component/ribbon/cloud/SpringRibbonServiceCallRouteTest.java
@@ -21,6 +21,7 @@ import java.util.Optional;
import org.apache.camel.Navigate;
import org.apache.camel.Processor;
+import org.apache.camel.PropertyInject;
import org.apache.camel.Route;
import org.apache.camel.impl.cloud.DefaultServiceCallProcessor;
import org.apache.camel.test.spring.CamelSpringTestSupport;
@@ -30,24 +31,27 @@ import org.springframework.test.annotation.DirtiesContext;
@DirtiesContext
public abstract class SpringRibbonServiceCallRouteTest extends CamelSpringTestSupport {
+
+ @PropertyInject("firstPort")
+ private String firstPort;
+
+ @PropertyInject("secondPort")
+ private String secondPort;
+
@Test
public void testServiceCall() throws Exception {
- getMockEndpoint("mock:"+getFirstPort()).expectedMessageCount(1);
- getMockEndpoint("mock:"+getSecondPort()).expectedMessageCount(1);
+ getMockEndpoint("mock:{{firstPort}}").expectedMessageCount(1);
+ getMockEndpoint("mock:{{secondPort}}").expectedMessageCount(1);
getMockEndpoint("mock:result").expectedMessageCount(2);
String out = template.requestBody("direct:start", null, String.class);
String out2 = template.requestBody("direct:start", null, String.class);
- assertEquals(getSecondPort(), out);
- assertEquals(getFirstPort(), out2);
+ assertEquals(secondPort, out);
+ assertEquals(firstPort, out2);
assertMockEndpointsSatisfied();
}
- protected abstract String getSecondPort();
-
- protected abstract String getFirstPort();
-
// ************************************
// Helpers
// ************************************
diff --git a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml
index e69d9a8..692bd68 100644
--- a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml
+++ b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringBeanRibbonServiceCallRouteTest.xml
@@ -24,10 +24,14 @@
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
+ <property name="location" value="classpath:springbeanribbonservicecallroutetest.properties" />
+ </bean>
<!-- setup a static ribbon server list with these 2 servers to start with -->
<bean id="discovery" class="org.apache.camel.impl.cloud.StaticServiceDiscovery">
- <property name="servers" value="localhost:9092,localhost:9093"/>
+ <property name="servers" value="localhost:${firstPort},localhost:${secondPort}"/>
</bean>
<bean id="balancer" class="org.apache.camel.component.ribbon.cloud.RibbonServiceLoadBalancer">
@@ -48,18 +52,18 @@
</route>
<route>
- <from uri="jetty:http://localhost:9092"/>
- <to uri="mock:9092"/>
+ <from uri="jetty:http://localhost:{{firstPort}}"/>
+ <to uri="mock:{{firstPort}}"/>
<transform>
- <constant>9092</constant>
+ <constant>{{firstPort}}</constant>
</transform>
</route>
<route>
- <from uri="jetty:http://localhost:9093"/>
- <to uri="mock:9093"/>
+ <from uri="jetty:http://localhost:{{secondPort}}"/>
+ <to uri="mock:{{secondPort}}"/>
<transform>
- <constant>9093</constant>
+ <constant>{{secondPort}}</constant>
</transform>
</route>
</camelContext>
diff --git a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml
index 0c6aa06..368833e 100644
--- a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml
+++ b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonPropertiesServiceCallRouteTest.xml
@@ -25,31 +25,35 @@
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
+ <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
+ <property name="location" value="classpath:springdslribbonpropertiesservicecallroutetest.properties" />
+ </bean>
+
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="scall">
<from uri="direct:start"/>
<serviceCall name="myService" component="jetty">
<!-- enable ribbon load balancer -->
<ribbonLoadBalancer clientName="myClient">
- <properties key="listOfServers" value="localhost:9094,localhost:9095"/>
+ <properties key="listOfServers" value="localhost:{{firstPort}},localhost:{{secondPort}}"/>
</ribbonLoadBalancer>
</serviceCall>
<to uri="mock:result"/>
</route>
<route>
- <from uri="jetty:http://localhost:9094"/>
- <to uri="mock:9094"/>
+ <from uri="jetty:http://localhost:{{firstPort}}"/>
+ <to uri="mock:{{firstPort}}"/>
<transform>
- <constant>9094</constant>
+ <constant>{{firstPort}}</constant>
</transform>
</route>
<route>
- <from uri="jetty:http://localhost:9095"/>
- <to uri="mock:9095"/>
+ <from uri="jetty:http://localhost:{{secondPort}}"/>
+ <to uri="mock:{{secondPort}}"/>
<transform>
- <constant>9095</constant>
+ <constant>{{secondPort}}</constant>
</transform>
</route>
</camelContext>
diff --git a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml
index 433aec3..63add53 100644
--- a/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml
+++ b/components/camel-ribbon/src/test/resources/org/apache/camel/component/ribbon/cloud/SpringDslRibbonServiceCallRouteTest.xml
@@ -24,6 +24,10 @@
http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
+ <property name="location" value="classpath:springdslribbonservicecallroutetest.properties" />
+ </bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="scall">
@@ -31,7 +35,7 @@
<serviceCall name="myService" component="jetty">
<!-- static list of servers -->
<staticServiceDiscovery>
- <servers>localhost:9096,localhost:9097</servers>
+ <servers>localhost:{{firstPort}},localhost:{{secondPort}}</servers>
</staticServiceDiscovery>
<!-- enable ribbon load balancer -->
@@ -41,18 +45,18 @@
</route>
<route>
- <from uri="jetty:http://localhost:9096"/>
- <to uri="mock:9096"/>
+ <from uri="jetty:http://localhost:{{firstPort}}"/>
+ <to uri="mock:{{firstPort}}"/>
<transform>
- <constant>9096</constant>
+ <constant>{{firstPort}}</constant>
</transform>
</route>
<route>
- <from uri="jetty:http://localhost:9097"/>
- <to uri="mock:9097"/>
+ <from uri="jetty:http://localhost:{{secondPort}}"/>
+ <to uri="mock:{{secondPort}}"/>
<transform>
- <constant>9097</constant>
+ <constant>{{secondPort}}</constant>
</transform>
</route>
</camelContext>
diff --git a/components/camel-ribbon/src/test/resources/springbeanribbonservicecallroutetest.properties b/components/camel-ribbon/src/test/resources/springbeanribbonservicecallroutetest.properties
new file mode 100644
index 0000000..6fc3357
--- /dev/null
+++ b/components/camel-ribbon/src/test/resources/springbeanribbonservicecallroutetest.properties
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+firstPort=9092
+secondPort=9093
diff --git a/components/camel-ribbon/src/test/resources/springdslribbonpropertiesservicecallroutetest.properties b/components/camel-ribbon/src/test/resources/springdslribbonpropertiesservicecallroutetest.properties
new file mode 100644
index 0000000..3019581
--- /dev/null
+++ b/components/camel-ribbon/src/test/resources/springdslribbonpropertiesservicecallroutetest.properties
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+firstPort=9094
+secondPort=9095
diff --git a/components/camel-ribbon/src/test/resources/springdslribbonservicecallroutetest.properties b/components/camel-ribbon/src/test/resources/springdslribbonservicecallroutetest.properties
new file mode 100644
index 0000000..e138a0a
--- /dev/null
+++ b/components/camel-ribbon/src/test/resources/springdslribbonservicecallroutetest.properties
@@ -0,0 +1,19 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+firstPort=9096
+secondPort=9097