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 <bszeti@localhost.localdomain> Authored: Mon Aug 7 10:44:23 2017 -0400 Committer: Claus Ibsen <davscl...@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; + } }