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/08/08 02:35:16 UTC
[1/2] camel git commit: Add test
RestDslPostTest.testMultiplePostTypes to camel-spring-boot
Repository: camel
Updated Branches:
refs/heads/master 71cc69d73 -> 4dc3e7200
Add test RestDslPostTest.testMultiplePostTypes to camel-spring-boot
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2835a56c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2835a56c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2835a56c
Branch: refs/heads/master
Commit: 2835a56ca18b854e4c7b42aefc49f6f914aa7508
Parents: 71cc69d
Author: Balazs Szeti <bs...@localhost.localdomain>
Authored: Fri Aug 4 00:22:05 2017 -0400
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 8 04:30:38 2017 +0200
----------------------------------------------------------------------
components/camel-spring-boot/pom.xml | 5 +
.../camel/spring/boot/issues/CountryPojo.java | 72 +++++++++++
.../spring/boot/issues/RestDslPostTest.java | 122 +++++++++++++++++++
.../camel/spring/boot/issues/UserPojo.java | 71 +++++++++++
4 files changed, 270 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2835a56c/components/camel-spring-boot/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/pom.xml b/components/camel-spring-boot/pom.xml
index 3b5ba84..7393705 100644
--- a/components/camel-spring-boot/pom.xml
+++ b/components/camel-spring-boot/pom.xml
@@ -108,6 +108,11 @@
<artifactId>camel-jetty</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-jackson-starter</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/camel/blob/2835a56c/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
new file mode 100644
index 0000000..1754b1b
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
@@ -0,0 +1,72 @@
+/**
+ * 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/2835a56c/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
new file mode 100644
index 0000000..863e3c2
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
@@ -0,0 +1,122 @@
+/**
+ * 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.Processor;
+import org.apache.camel.Produce;
+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.ToDefinition;
+import org.apache.camel.model.rest.RestBindingMode;
+import org.apache.camel.model.rest.RestDefinition;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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{
+
+ final static 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/2835a56c/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
new file mode 100644
index 0000000..144479b
--- /dev/null
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.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;
+ }
+
+
+
+
+}
[2/2] camel git commit: fix checkstyle issues
Posted by da...@apache.org.
fix checkstyle issues
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4dc3e720
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4dc3e720
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4dc3e720
Branch: refs/heads/master
Commit: 4dc3e7200591b8183b11c95a71dca26b8fa71489
Parents: 2835a56
Author: Balazs Szeti <bs...@localhost.localdomain>
Authored: Mon Aug 7 10:44:23 2017 -0400
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 8 04:30:39 2017 +0200
----------------------------------------------------------------------
.../camel/spring/boot/issues/CountryPojo.java | 66 ++++++++-------
.../spring/boot/issues/RestDslPostTest.java | 86 ++++++++------------
.../camel/spring/boot/issues/UserPojo.java | 61 +++++++-------
3 files changed, 101 insertions(+), 112 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4dc3e720/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
index 1754b1b..b1cf299 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/CountryPojo.java
@@ -37,36 +37,42 @@ public class CountryPojo {
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 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;
- }
+ @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/4dc3e720/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
index 863e3c2..6d835b8 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/RestDslPostTest.java
@@ -19,20 +19,14 @@ 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.Processor;
-import org.apache.camel.Produce;
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.ToDefinition;
import org.apache.camel.model.rest.RestBindingMode;
-import org.apache.camel.model.rest.RestDefinition;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
@@ -46,10 +40,10 @@ import org.springframework.util.SocketUtils;
@RunWith(SpringRunner.class)
@EnableAutoConfiguration
@SpringBootTest(classes = { RestDslPostTest.class })
-public class RestDslPostTest extends Assert{
-
- final static int port = SocketUtils.findAvailableTcpPort(20000);
-
+public class RestDslPostTest extends Assert {
+
+ static final int PORT = SocketUtils.findAvailableTcpPort(20000);
+
@EndpointInject(uri = "mock:user")
protected MockEndpoint resultEndpointUser;
@EndpointInject(uri = "mock:country")
@@ -60,35 +54,34 @@ public class RestDslPostTest extends Assert{
@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);
-
+
+ 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
@@ -97,24 +90,11 @@ public class RestDslPostTest extends Assert{
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();
-
+ 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/4dc3e720/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
index 144479b..e72b92f 100644
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
+++ b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/issues/UserPojo.java
@@ -37,35 +37,38 @@ public class UserPojo {
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 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;
- }
-
-
-
+ @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;
+ }
}