diff --git a/jaxb/book.xml b/jaxb/book.xml new file mode 100644 index 0000000000..605d531b16 --- /dev/null +++ b/jaxb/book.xml @@ -0,0 +1,5 @@ + + + Book1 + 2016-12-16T17:28:49.718Z + diff --git a/jaxb/pom.xml b/jaxb/pom.xml index 6c36956913..115a632d7b 100644 --- a/jaxb/pom.xml +++ b/jaxb/pom.xml @@ -23,7 +23,13 @@ com.sun.istack istack-commons-runtime - ${istack.version} + 3.0.2 + + + + commons-io + commons-io + 2.5 @@ -43,7 +49,18 @@ logback-core ${logback.version} - + + + junit + junit + ${junit.version} + + + + org.apache.commons + commons-lang3 + 3.5 + @@ -60,7 +77,7 @@ org.eclipse.m2e lifecycle-mapping - ${lifecycle-mapping.version} + 1.0.0 @@ -158,16 +175,14 @@ 2.2.11 - 3.0.2 - 1.7.21 1.1.7 - 1.0.0 - 3.6.0 + 3.5.1 2.3 + 4.12 - \ No newline at end of file + diff --git a/jaxb/sample_book.xml b/jaxb/sample_book.xml new file mode 100644 index 0000000000..605d531b16 --- /dev/null +++ b/jaxb/sample_book.xml @@ -0,0 +1,5 @@ + + + Book1 + 2016-12-16T17:28:49.718Z + diff --git a/jaxb/src/main/java/com/baeldung/jaxb/Book.java b/jaxb/src/main/java/com/baeldung/jaxb/Book.java index 8455d3e6df..b7a5d39ce5 100644 --- a/jaxb/src/main/java/com/baeldung/jaxb/Book.java +++ b/jaxb/src/main/java/com/baeldung/jaxb/Book.java @@ -8,6 +8,10 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlType; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + @XmlRootElement(name = "book") @XmlType(propOrder = { "id", "name", "date" }) public class Book { @@ -53,6 +57,17 @@ public class Book { @Override public String toString() { - return "Book [id=" + id + ", name=" + name + ", author=" + author + ", date=" + date + "]"; + return ToStringBuilder.reflectionToString(this); } + + @Override + public boolean equals(Object obj) { + return EqualsBuilder.reflectionEquals(this, obj); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + } diff --git a/jaxb/src/main/java/com/baeldung/jaxb/Main.java b/jaxb/src/main/java/com/baeldung/jaxb/Main.java index aaf062dd4e..46adfb3c60 100644 --- a/jaxb/src/main/java/com/baeldung/jaxb/Main.java +++ b/jaxb/src/main/java/com/baeldung/jaxb/Main.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.FileReader; import java.io.IOException; import java.util.Date; +import java.util.TimeZone; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -16,7 +17,8 @@ public class Main { book.setId(1L); book.setName("Book1"); book.setAuthor("Author1"); - book.setDate(new Date()); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + book.setDate(new Date(1481909329718L)); JAXBContext context = JAXBContext.newInstance(Book.class); Marshaller marshaller = context.createMarshaller(); diff --git a/jaxb/src/test/java/com/baeldung/jaxb/test/JaxbTest.java b/jaxb/src/test/java/com/baeldung/jaxb/test/JaxbTest.java new file mode 100644 index 0000000000..daf3864436 --- /dev/null +++ b/jaxb/src/test/java/com/baeldung/jaxb/test/JaxbTest.java @@ -0,0 +1,54 @@ +package com.baeldung.jaxb.test; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.Date; +import java.util.TimeZone; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; + +import org.apache.commons.io.FileUtils; +import org.junit.Assert; +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.baeldung.jaxb.Book; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class JaxbTest { + Book book; + JAXBContext context; + + @Before + public void before() throws JAXBException { + book = new Book(); + book.setId(1L); + book.setName("Book1"); + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + book.setDate(new Date(1481909329718L)); + context = JAXBContext.newInstance(Book.class); + } + + @Test + public void marshal() throws JAXBException, IOException { + Marshaller marshaller = context.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.marshal(book, new File("./book.xml")); + String sampleBookXML = FileUtils.readFileToString(new File("./sample_book.xml"), "UTF-8"); + String marshallerBookXML = FileUtils.readFileToString(new File("./book.xml"), "UTF-8"); + Assert.assertEquals(sampleBookXML, marshallerBookXML); + } + + @Test + public void unMashal() throws JAXBException, IOException { + Unmarshaller unmarshaller = context.createUnmarshaller(); + Book unMarshallerbook = (Book) unmarshaller.unmarshal(new FileReader("./book.xml")); + Assert.assertEquals(book, unMarshallerbook); + } +} diff --git a/pom.xml b/pom.xml index 36b1a57773..51373b07cc 100644 --- a/pom.xml +++ b/pom.xml @@ -126,6 +126,7 @@ spring-rest-docs spring-rest spring-security-basic-auth + spring-security-core spring-security-custom-permission spring-security-mvc-custom spring-security-mvc-digest-auth @@ -155,4 +156,4 @@ pdf - \ No newline at end of file + diff --git a/rest-assured/pom.xml b/rest-assured/pom.xml index 3d1abefeb1..bbeef8bb9c 100644 --- a/rest-assured/pom.xml +++ b/rest-assured/pom.xml @@ -215,9 +215,57 @@ 8 + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*IntegrationTest.java + **/*LiveTest.java + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + + 2.8.5 1.8 @@ -255,6 +303,7 @@ 4.12 3.6.0 + 2.19.1 diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2Test.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java similarity index 92% rename from rest-assured/src/test/java/com/baeldung/restassured/RestAssured2Test.java rename to rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java index 067756823b..13ba3ccac9 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2Test.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssured2IntegrationTest.java @@ -15,7 +15,7 @@ import static io.restassured.RestAssured.get; import com.github.tomakehurst.wiremock.WireMockServer; -public class RestAssured2Test { +public class RestAssured2IntegrationTest { private WireMockServer wireMockServer = new WireMockServer(); private static final String EVENTS_PATH = "/odds"; @@ -41,7 +41,7 @@ public class RestAssured2Test { private static String getJson() { - return Util.inputStreamToString(new RestAssured2Test().getClass() + return Util.inputStreamToString(new RestAssured2IntegrationTest().getClass() .getResourceAsStream("/odds.json")); } diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java similarity index 96% rename from rest-assured/src/test/java/com/baeldung/restassured/RestAssuredTest.java rename to rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java index 06f54aae24..f14d9920b6 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredIntegrationTest.java @@ -20,7 +20,7 @@ import com.github.fge.jsonschema.cfg.ValidationConfiguration; import com.github.fge.jsonschema.main.JsonSchemaFactory; import com.github.tomakehurst.wiremock.WireMockServer; -public class RestAssuredTest { +public class RestAssuredIntegrationTest { private WireMockServer wireMockServer = new WireMockServer(); private static final String EVENTS_PATH = "/events?id=390"; @@ -99,7 +99,7 @@ public class RestAssuredTest { } private static String getEventJson() { - return Util.inputStreamToString(RestAssuredTest.class + return Util.inputStreamToString(RestAssuredIntegrationTest.class .getResourceAsStream("/event_0.json")); } diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2Test.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java similarity index 91% rename from rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2Test.java rename to rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java index 597280c7c0..b77f24b15f 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2Test.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXML2IntegrationTest.java @@ -15,7 +15,7 @@ import static io.restassured.RestAssured.get; import com.github.tomakehurst.wiremock.WireMockServer; -public class RestAssuredXML2Test { +public class RestAssuredXML2IntegrationTest { private WireMockServer wireMockServer = new WireMockServer(); private static final String EVENTS_PATH = "/teachers"; @@ -42,7 +42,7 @@ public class RestAssuredXML2Test { private static String getXml() { return Util - .inputStreamToString(new RestAssuredXML2Test().getClass().getResourceAsStream("/teachers.xml")); + .inputStreamToString(new RestAssuredXML2IntegrationTest().getClass().getResourceAsStream("/teachers.xml")); } @After diff --git a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLTest.java b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java similarity index 95% rename from rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLTest.java rename to rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java index 315dc76169..10aef63cdb 100644 --- a/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLTest.java +++ b/rest-assured/src/test/java/com/baeldung/restassured/RestAssuredXMLIntegrationTest.java @@ -25,7 +25,7 @@ import com.github.fge.jsonschema.SchemaVersion; import com.github.fge.jsonschema.cfg.ValidationConfiguration; import com.github.fge.jsonschema.main.JsonSchemaFactory; import com.github.tomakehurst.wiremock.WireMockServer; -public class RestAssuredXMLTest { +public class RestAssuredXMLIntegrationTest { private WireMockServer wireMockServer = new WireMockServer(); private static final String EVENTS_PATH = "/employees"; private static final String APPLICATION_XML = "application/xml"; @@ -88,7 +88,7 @@ public class RestAssuredXMLTest { private static String getXml() { return Util - .inputStreamToString(new RestAssuredXMLTest().getClass().getResourceAsStream("/employees.xml")); + .inputStreamToString(new RestAssuredXMLIntegrationTest().getClass().getResourceAsStream("/employees.xml")); } @After diff --git a/spring-cloud/spring-cloud-ribbon-client/pom.xml b/spring-cloud/spring-cloud-ribbon-client/pom.xml index b85db03383..8aee41f5c4 100644 --- a/spring-cloud/spring-cloud-ribbon-client/pom.xml +++ b/spring-cloud/spring-cloud-ribbon-client/pom.xml @@ -56,6 +56,16 @@ org.springframework.boot spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + + + @@ -77,4 +87,42 @@ + + + + integration + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + \ No newline at end of file diff --git a/spring-integration/pom.xml b/spring-integration/pom.xml index 2fe7e1ad37..0aa8fed598 100644 --- a/spring-integration/pom.xml +++ b/spring-integration/pom.xml @@ -22,6 +22,7 @@ 2.10 3.6.0 1.5.0 + 2.19.1 @@ -68,6 +69,17 @@ com.baeldung.samples.Main + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*IntegrationTest.java + **/*LiveTest.java + + + @@ -128,5 +140,40 @@ ${spring.integration.version} + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index b507a1c629..38443f2022 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -202,6 +202,7 @@ **/*IntegrationTest.java + **/*LiveTest.java true @@ -209,6 +210,27 @@ + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + @@ -245,6 +267,63 @@ + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*IntegrationTest.java + + + **/*LiveTest.java + + + + + + + json + + + + + org.codehaus.cargo + cargo-maven2-plugin + + false + + + + start-server + pre-integration-test + + start + + + + stop-server + post-integration-test + + stop + + + + + + + + diff --git a/spring-rest-docs/pom.xml b/spring-rest-docs/pom.xml index 2e8a70e96b..2acb6b4071 100644 --- a/spring-rest-docs/pom.xml +++ b/spring-rest-docs/pom.xml @@ -65,9 +65,10 @@ org.apache.maven.plugins maven-surefire-plugin - - **/*IntegrationTest.java - + + **/*IntegrationTest.java + **/*LiveTest.java + @@ -96,5 +97,41 @@ + + + integration + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + diff --git a/spring-security-client/spring-security-thymeleaf-authentication/src/main/java/org/baeldung/config/RegistrationController.java b/spring-security-client/spring-security-thymeleaf-authentication/src/main/java/org/baeldung/config/RegistrationController.java index 025001ac44..da8f5f0e73 100644 --- a/spring-security-client/spring-security-thymeleaf-authentication/src/main/java/org/baeldung/config/RegistrationController.java +++ b/spring-security-client/spring-security-thymeleaf-authentication/src/main/java/org/baeldung/config/RegistrationController.java @@ -30,7 +30,7 @@ public class RegistrationController { private static final Logger logger = LoggerFactory.getLogger(RegistrationController.class); @Autowired - AuthenticationManager authenticationManager; + private AuthenticationManager authenticationManager; /** * For demo purposes this need only be a GET request method @@ -49,8 +49,6 @@ public class RegistrationController { String username = "user"; String password = "password"; - String view = "registrationSuccess"; - if (requestQualifiesForManualAuthentication()) { try { authenticate(username, password, request, response); @@ -58,12 +56,12 @@ public class RegistrationController { } catch (BadCredentialsException bce) { logger.debug("Authentication failure: bad credentials"); bce.printStackTrace(); - view = "systemError"; // assume a low-level error, since the registration + return "systemError"; // assume a low-level error, since the registration // form would have been successfully validated } } - return view; + return "registrationSuccess"; } private boolean requestQualifiesForManualAuthentication() { diff --git a/spring-security-custom-permission/pom.xml b/spring-security-custom-permission/pom.xml index b28c0877c4..39dec2805f 100644 --- a/spring-security-custom-permission/pom.xml +++ b/spring-security-custom-permission/pom.xml @@ -150,6 +150,7 @@ maven-surefire-plugin + **/*IntegrationTest.java **/*LiveTest.java @@ -184,6 +185,42 @@ + + integration + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + live