From 4639d467053417321836b30a43903a7f501ba103 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Fri, 7 Oct 2016 18:16:04 +0530 Subject: [PATCH 01/52] Modify test cases for About Page --- selenium-junit-testng/pom.xml | 4 +- .../baeldung/selenium/SeleniumExample.java | 39 ++++++++++++++++++- .../selenium/junit/TestSeleniumWithJUnit.java | 34 ++++++++++------ .../testng/TestSeleniumWithTestNG.java | 19 ++++++--- 4 files changed, 76 insertions(+), 20 deletions(-) diff --git a/selenium-junit-testng/pom.xml b/selenium-junit-testng/pom.xml index bf5a082fba..c6461816af 100644 --- a/selenium-junit-testng/pom.xml +++ b/selenium-junit-testng/pom.xml @@ -37,12 +37,12 @@ junit junit - 4.8.1 + 4.12 org.testng testng - 6.9.10 + 6.9.13.6 \ No newline at end of file diff --git a/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java index d8b248df81..7661354aab 100644 --- a/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java +++ b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java @@ -1,15 +1,22 @@ package main.java.com.baeldung.selenium; +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class SeleniumExample { private WebDriver webDriver; private String url = "http://www.baeldung.com/"; - + public SeleniumExample() { webDriver = new FirefoxDriver(); + webDriver.manage().window().maximize(); + webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); webDriver.get(url); } @@ -21,4 +28,34 @@ public class SeleniumExample { return webDriver.getTitle(); } + public void getAboutBaeldungPage() { + closeOverlay(); + clickAboutLink(); + clickAboutUsLink(); + } + + private void closeOverlay() { + List webElementList = webDriver.findElements(By.tagName("a")); + if (webElementList != null && !webElementList.isEmpty()) { + for (WebElement webElement : webElementList) { + if (webElement.getAttribute("title").equalsIgnoreCase("Close")) { + webElement.click(); + } + } + } + } + + private void clickAboutLink() { + webDriver.findElement(By.partialLinkText("About")).click(); + } + + private void clickAboutUsLink() { + webDriver.findElement(By.partialLinkText("About Baeldung.")).click(); + } + + public boolean isAuthorInformationAvailable() { + return webDriver + .findElement(By.xpath("//*[contains(text(), 'Eugen – an engineer')]")) + .isDisplayed(); + } } diff --git a/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java b/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java index dabb1e1988..85c20f62a5 100644 --- a/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java +++ b/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java @@ -1,31 +1,41 @@ package test.java.com.baeldung.selenium.junit; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; import main.java.com.baeldung.selenium.SeleniumExample; -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; public class TestSeleniumWithJUnit { - private SeleniumExample seleniumExample; - private String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials"; + private static SeleniumExample seleniumExample; + private String expecteTilteAboutBaeldungPage = "About Baeldung | Baeldung"; - @Before - public void setUp() { + @BeforeClass + public static void setUp() { seleniumExample = new SeleniumExample(); } - @After - public void tearDown() { + @AfterClass + public static void tearDown() { seleniumExample.closeWindow(); } @Test - public void whenPageIsLoaded_thenTitleIsAsPerExpectation() { - String actualTitle = seleniumExample.getTitle(); - assertNotNull(actualTitle); - assertEquals(actualTitle, expectedTitle); + public void whenAboutBaeldungIsLoaded_thenAboutEugenIsMentionedOnPage() { + try { + seleniumExample.getAboutBaeldungPage(); + String actualTitle = seleniumExample.getTitle(); + assertNotNull(actualTitle); + assertEquals(actualTitle, expecteTilteAboutBaeldungPage); + assertTrue(seleniumExample.isAuthorInformationAvailable()); + } catch (Exception exception) { + exception.printStackTrace(); + seleniumExample.closeWindow(); + } } + } diff --git a/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java b/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java index 78ef8b8dfb..40b0424820 100644 --- a/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java +++ b/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java @@ -1,6 +1,8 @@ package test.java.com.baeldung.selenium.testng; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; import main.java.com.baeldung.selenium.SeleniumExample; import org.testng.annotations.AfterSuite; @@ -10,7 +12,7 @@ import org.testng.annotations.Test; public class TestSeleniumWithTestNG { private SeleniumExample seleniumExample; - private String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials"; + private String expecteTilteAboutBaeldungPage = "About Baeldung | Baeldung"; @BeforeSuite public void setUp() { @@ -23,9 +25,16 @@ public class TestSeleniumWithTestNG { } @Test - public void whenPageIsLoaded_thenTitleIsAsPerExpectation() { - String actualTitle = seleniumExample.getTitle(); - assertNotNull(actualTitle); - assertEquals(actualTitle, expectedTitle); + public void whenAboutBaeldungIsLoaded_thenAboutEugenIsMentionedOnPage() { + try { + seleniumExample.getAboutBaeldungPage(); + String actualTitle = seleniumExample.getTitle(); + assertNotNull(actualTitle); + assertEquals(actualTitle, expecteTilteAboutBaeldungPage); + assertTrue(seleniumExample.isAuthorInformationAvailable()); + } catch (Exception exception) { + exception.printStackTrace(); + seleniumExample.closeWindow(); + } } } From 0d2e13392bb352a14b9f5e2a3168202e7b6cc6fe Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Sun, 9 Oct 2016 08:15:55 +0530 Subject: [PATCH 02/52] Implementing Java 8 streaming API for-next loop --- .../main/java/com/baeldung/selenium/SeleniumExample.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java index 7661354aab..1007bf7503 100644 --- a/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java +++ b/selenium-junit-testng/src/main/java/com/baeldung/selenium/SeleniumExample.java @@ -37,11 +37,7 @@ public class SeleniumExample { private void closeOverlay() { List webElementList = webDriver.findElements(By.tagName("a")); if (webElementList != null && !webElementList.isEmpty()) { - for (WebElement webElement : webElementList) { - if (webElement.getAttribute("title").equalsIgnoreCase("Close")) { - webElement.click(); - } - } + webElementList.stream().filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title"))).findAny().get().click(); } } From 131b695268342726e8e7e78d77ca8b983912164b Mon Sep 17 00:00:00 2001 From: Thai Nguyen Date: Thu, 13 Oct 2016 11:17:46 +0700 Subject: [PATCH 03/52] Refactors Apache CXF JAXRS implementation --- .../java/com/baeldung/cxf/jaxrs/implementation/Course.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java index 9ab74bea58..802a19e961 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java @@ -61,13 +61,11 @@ public class Course { @Path("{studentOrder}") public Response deleteStudent(@PathParam("studentOrder") int studentOrder) { Student student = students.get(studentOrder); - Response response; if (student != null) { students.remove(studentOrder); - response = Response.ok().build(); + return Response.ok().build(); } else { - response = Response.notModified().build(); + return Response.notModified().build(); } - return response; } } \ No newline at end of file From cef8adfdaebc62faa9fa2baeaa190fd0de94d296 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Fri, 14 Oct 2016 15:36:00 +0530 Subject: [PATCH 04/52] Changes as per Live Test guidelines --- selenium-junit-testng/pom.xml | 28 ++++++++++++++++--- ...it.java => SeleniumWithJUnitLiveTest.java} | 2 +- ...G.java => SeleniumWithTestNGLiveTest.java} | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) rename selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/{TestSeleniumWithJUnit.java => SeleniumWithJUnitLiveTest.java} (96%) rename selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/{TestSeleniumWithTestNG.java => SeleniumWithTestNGLiveTest.java} (96%) diff --git a/selenium-junit-testng/pom.xml b/selenium-junit-testng/pom.xml index c6461816af..f964f94ed4 100644 --- a/selenium-junit-testng/pom.xml +++ b/selenium-junit-testng/pom.xml @@ -20,14 +20,34 @@ maven-surefire-plugin 2.19.1 - - - Test*.java - + true + + **/*LiveTest.java + + + + + live + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*LiveTest.java + + + + + + + + org.seleniumhq.selenium diff --git a/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java b/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/SeleniumWithJUnitLiveTest.java similarity index 96% rename from selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java rename to selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/SeleniumWithJUnitLiveTest.java index 85c20f62a5..f8d9a5dada 100644 --- a/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/TestSeleniumWithJUnit.java +++ b/selenium-junit-testng/src/test/java/com/baeldung/selenium/junit/SeleniumWithJUnitLiveTest.java @@ -9,7 +9,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -public class TestSeleniumWithJUnit { +public class SeleniumWithJUnitLiveTest { private static SeleniumExample seleniumExample; private String expecteTilteAboutBaeldungPage = "About Baeldung | Baeldung"; diff --git a/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java b/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/SeleniumWithTestNGLiveTest.java similarity index 96% rename from selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java rename to selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/SeleniumWithTestNGLiveTest.java index 40b0424820..5ec9ade39f 100644 --- a/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/TestSeleniumWithTestNG.java +++ b/selenium-junit-testng/src/test/java/com/baeldung/selenium/testng/SeleniumWithTestNGLiveTest.java @@ -9,7 +9,7 @@ import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; -public class TestSeleniumWithTestNG { +public class SeleniumWithTestNGLiveTest { private SeleniumExample seleniumExample; private String expecteTilteAboutBaeldungPage = "About Baeldung | Baeldung"; From 4a2546b8fc4a1abfcf6fff91b8a46b4fae41d69f Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Tue, 18 Oct 2016 21:58:50 +0530 Subject: [PATCH 05/52] Changes for integration test --- selenium-junit-testng/pom.xml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/selenium-junit-testng/pom.xml b/selenium-junit-testng/pom.xml index f964f94ed4..9ad601fdcd 100644 --- a/selenium-junit-testng/pom.xml +++ b/selenium-junit-testng/pom.xml @@ -15,18 +15,6 @@ 1.8 - - org.apache.maven.plugins - maven-surefire-plugin - 2.19.1 - - true - - **/*LiveTest.java - - - - @@ -37,6 +25,7 @@ org.apache.maven.plugins maven-surefire-plugin + 2.19.1 **/*LiveTest.java From 278ada7e7f605bd5729ed78c27e611aba8136839 Mon Sep 17 00:00:00 2001 From: Sandeep Kumar Date: Wed, 19 Oct 2016 12:38:32 +0530 Subject: [PATCH 06/52] Default Unit Test changes --- selenium-junit-testng/pom.xml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/selenium-junit-testng/pom.xml b/selenium-junit-testng/pom.xml index 9ad601fdcd..861c0b1986 100644 --- a/selenium-junit-testng/pom.xml +++ b/selenium-junit-testng/pom.xml @@ -15,6 +15,18 @@ 1.8 + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + true + + **/*UnitTest.java + + + + @@ -27,9 +39,9 @@ maven-surefire-plugin 2.19.1 - - **/*LiveTest.java - + + **/*LiveTest.java + From 29ae3bc0102500ca55f3431f6cf3f30b6e553519 Mon Sep 17 00:00:00 2001 From: DOHA Date: Wed, 19 Oct 2016 14:02:32 +0200 Subject: [PATCH 07/52] configure integration test --- spring-data-couchbase-2/pom.xml | 13 ++++++++++++- ... => PersonRepositoryServiceIntegrationTest.java} | 2 +- ...eTest.java => PersonServiceIntegrationTest.java} | 2 +- ...va => PersonTemplateServiceIntegrationTest.java} | 2 +- ...=> StudentRepositoryServiceIntegrationTest.java} | 2 +- ...Test.java => StudentServiceIntegrationTest.java} | 2 +- ...a => StudentTemplateServiceIntegrationTest.java} | 2 +- ...t.java => CampusServiceImplIntegrationTest.java} | 2 +- ...t.java => PersonServiceImplIntegrationTest.java} | 2 +- ....java => StudentServiceImplIntegrationTest.java} | 2 +- 10 files changed, 21 insertions(+), 10 deletions(-) rename spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/{PersonRepositoryServiceTest.java => PersonRepositoryServiceIntegrationTest.java} (78%) rename spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/{PersonServiceTest.java => PersonServiceIntegrationTest.java} (98%) rename spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/{PersonTemplateServiceTest.java => PersonTemplateServiceIntegrationTest.java} (79%) rename spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/{StudentRepositoryServiceTest.java => StudentRepositoryServiceIntegrationTest.java} (78%) rename spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/{StudentServiceTest.java => StudentServiceIntegrationTest.java} (98%) rename spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/{StudentTemplateServiceTest.java => StudentTemplateServiceIntegrationTest.java} (79%) rename spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/{CampusServiceImplTest.java => CampusServiceImplIntegrationTest.java} (98%) rename spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/{PersonServiceImplTest.java => PersonServiceImplIntegrationTest.java} (98%) rename spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/{StudentServiceImplTest.java => StudentServiceImplIntegrationTest.java} (98%) diff --git a/spring-data-couchbase-2/pom.xml b/spring-data-couchbase-2/pom.xml index d24ef4aeaa..6716f82246 100644 --- a/spring-data-couchbase-2/pom.xml +++ b/spring-data-couchbase-2/pom.xml @@ -86,6 +86,17 @@ 1.7 + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*IntegrationTest.java + **/*LiveTest.java + + + @@ -99,7 +110,7 @@ 1.1.3 1.7.12 4.11 - + 2.19.1 diff --git a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonRepositoryServiceTest.java b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonRepositoryServiceIntegrationTest.java similarity index 78% rename from spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonRepositoryServiceTest.java rename to spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonRepositoryServiceIntegrationTest.java index ce5cf7667d..d710e57def 100644 --- a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonRepositoryServiceTest.java +++ b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonRepositoryServiceIntegrationTest.java @@ -3,7 +3,7 @@ package org.baeldung.spring.data.couchbase.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -public class PersonRepositoryServiceTest extends PersonServiceTest { +public class PersonRepositoryServiceIntegrationTest extends PersonServiceIntegrationTest { @Autowired @Qualifier("PersonRepositoryService") diff --git a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonServiceTest.java b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonServiceIntegrationTest.java similarity index 98% rename from spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonServiceTest.java rename to spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonServiceIntegrationTest.java index c3bf9f2138..4044183849 100644 --- a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonServiceTest.java +++ b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonServiceIntegrationTest.java @@ -20,7 +20,7 @@ import com.couchbase.client.java.CouchbaseCluster; import com.couchbase.client.java.document.JsonDocument; import com.couchbase.client.java.document.json.JsonObject; -public abstract class PersonServiceTest extends IntegrationTest { +public abstract class PersonServiceIntegrationTest extends IntegrationTest { static final String typeField = "_class"; static final String john = "John"; diff --git a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonTemplateServiceTest.java b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonTemplateServiceIntegrationTest.java similarity index 79% rename from spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonTemplateServiceTest.java rename to spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonTemplateServiceIntegrationTest.java index 0238fa21fb..e19df8fc84 100644 --- a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonTemplateServiceTest.java +++ b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/PersonTemplateServiceIntegrationTest.java @@ -3,7 +3,7 @@ package org.baeldung.spring.data.couchbase.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -public class PersonTemplateServiceTest extends PersonServiceTest { +public class PersonTemplateServiceIntegrationTest extends PersonServiceIntegrationTest { @Autowired @Qualifier("PersonTemplateService") diff --git a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentRepositoryServiceTest.java b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentRepositoryServiceIntegrationTest.java similarity index 78% rename from spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentRepositoryServiceTest.java rename to spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentRepositoryServiceIntegrationTest.java index 040453fd73..3b3f2a531a 100644 --- a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentRepositoryServiceTest.java +++ b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentRepositoryServiceIntegrationTest.java @@ -3,7 +3,7 @@ package org.baeldung.spring.data.couchbase.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -public class StudentRepositoryServiceTest extends StudentServiceTest { +public class StudentRepositoryServiceIntegrationTest extends StudentServiceIntegrationTest { @Autowired @Qualifier("StudentRepositoryService") diff --git a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentServiceTest.java b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentServiceIntegrationTest.java similarity index 98% rename from spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentServiceTest.java rename to spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentServiceIntegrationTest.java index 0bf2c5d673..fba549a9e5 100644 --- a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentServiceTest.java +++ b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentServiceIntegrationTest.java @@ -22,7 +22,7 @@ import com.couchbase.client.java.CouchbaseCluster; import com.couchbase.client.java.document.JsonDocument; import com.couchbase.client.java.document.json.JsonObject; -public abstract class StudentServiceTest extends IntegrationTest { +public abstract class StudentServiceIntegrationTest extends IntegrationTest { static final String typeField = "_class"; static final String joe = "Joe"; diff --git a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentTemplateServiceTest.java b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentTemplateServiceIntegrationTest.java similarity index 79% rename from spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentTemplateServiceTest.java rename to spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentTemplateServiceIntegrationTest.java index dd5be8e059..29fd605bc6 100644 --- a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentTemplateServiceTest.java +++ b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase/service/StudentTemplateServiceIntegrationTest.java @@ -3,7 +3,7 @@ package org.baeldung.spring.data.couchbase.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; -public class StudentTemplateServiceTest extends StudentServiceTest { +public class StudentTemplateServiceIntegrationTest extends StudentServiceIntegrationTest { @Autowired @Qualifier("StudentTemplateService") diff --git a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/CampusServiceImplTest.java b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/CampusServiceImplIntegrationTest.java similarity index 98% rename from spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/CampusServiceImplTest.java rename to spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/CampusServiceImplIntegrationTest.java index d3982e1ecc..71648cf59b 100644 --- a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/CampusServiceImplTest.java +++ b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/CampusServiceImplIntegrationTest.java @@ -18,7 +18,7 @@ import org.springframework.data.geo.Distance; import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Point; -public class CampusServiceImplTest extends MultiBucketIntegationTest { +public class CampusServiceImplIntegrationTest extends MultiBucketIntegationTest { @Autowired private CampusServiceImpl campusService; diff --git a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/PersonServiceImplTest.java b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/PersonServiceImplIntegrationTest.java similarity index 98% rename from spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/PersonServiceImplTest.java rename to spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/PersonServiceImplIntegrationTest.java index e1a880d9da..819798d536 100644 --- a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/PersonServiceImplTest.java +++ b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/PersonServiceImplIntegrationTest.java @@ -21,7 +21,7 @@ import com.couchbase.client.java.CouchbaseCluster; import com.couchbase.client.java.document.JsonDocument; import com.couchbase.client.java.document.json.JsonObject; -public class PersonServiceImplTest extends MultiBucketIntegationTest { +public class PersonServiceImplIntegrationTest extends MultiBucketIntegationTest { static final String typeField = "_class"; static final String john = "John"; diff --git a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/StudentServiceImplTest.java b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/StudentServiceImplIntegrationTest.java similarity index 98% rename from spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/StudentServiceImplTest.java rename to spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/StudentServiceImplIntegrationTest.java index c503726377..f37f11744d 100644 --- a/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/StudentServiceImplTest.java +++ b/spring-data-couchbase-2/src/test/java/org/baeldung/spring/data/couchbase2b/service/StudentServiceImplIntegrationTest.java @@ -23,7 +23,7 @@ import com.couchbase.client.java.CouchbaseCluster; import com.couchbase.client.java.document.JsonDocument; import com.couchbase.client.java.document.json.JsonObject; -public class StudentServiceImplTest extends MultiBucketIntegationTest { +public class StudentServiceImplIntegrationTest extends MultiBucketIntegationTest { static final String typeField = "_class"; static final String joe = "Joe"; From 7d59175bb6969b3e43e373de06a315d8e0f4f95d Mon Sep 17 00:00:00 2001 From: maibin Date: Wed, 19 Oct 2016 16:19:08 +0200 Subject: [PATCH 08/52] Executable WAR (#757) * Expression-Based Access Control PermitAll, hasRole, hasAnyRole etc. I modified classes regards to Security * Added test cases for Spring Security Expressions * Handler Interceptor - logging example * Test for logger interceptor * Removed conflicted part * UserInterceptor (adding user information to model) * Spring Handler Interceptor - session timers * Spring Security CSRF attack protection with Thymeleaf * Fix and(); * Logger update * Changed config for Thymeleaf * Thymeleaf Natural Processing and Inlining * Expression Utility Objects, Thymeleaf * listOfStudents edited * Thymeleaf layout decorators * Executable Jar with Maven * Maven War executable --- spring-thymeleaf/pom.xml | 113 ++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 37 deletions(-) diff --git a/spring-thymeleaf/pom.xml b/spring-thymeleaf/pom.xml index d2b3be1651..e59ce77e57 100644 --- a/spring-thymeleaf/pom.xml +++ b/spring-thymeleaf/pom.xml @@ -166,47 +166,86 @@ ${maven-surefire-plugin.version} - **/*IntegrationTest.java - **/*LiveTest.java + **/*IntegrationTest.java + **/*LiveTest.java - + + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + 8082 + + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.0 + + + tomcat-run + + exec-war-only + + package + + / + false + webapp.jar + utf-8 + + + + - - - integration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*LiveTest.java - - - **/*IntegrationTest.java - - - - - - - json - - - - - - - + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + From 09825ca25ad14739a27213e341a9f8b9fa59ae95 Mon Sep 17 00:00:00 2001 From: DOHA Date: Wed, 19 Oct 2016 16:25:35 +0200 Subject: [PATCH 09/52] add integration test profile --- spring-data-cassandra/pom.xml | 51 +++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/spring-data-cassandra/pom.xml b/spring-data-cassandra/pom.xml index e5f8779942..5c1a42b8bd 100644 --- a/spring-data-cassandra/pom.xml +++ b/spring-data-cassandra/pom.xml @@ -23,6 +23,7 @@ 2.1.9.2 2.1.9.2 2.0-0 + 2.19.1 @@ -108,6 +109,52 @@ 1.7 - - + + 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 + + + + + + + From e4f1be2daa87bdbd1c212d7de905c87ac3004667 Mon Sep 17 00:00:00 2001 From: DOHA Date: Wed, 19 Oct 2016 16:45:26 +0200 Subject: [PATCH 10/52] add integration test profile --- spring-cucumber/pom.xml | 52 +++++++++++++++++-- ...Test.java => CucumberIntegrationTest.java} | 2 +- ...efs.java => OtherDefsIntegrationTest.java} | 2 +- ...Defs.java => StepDefsIntegrationTest.java} | 2 +- 4 files changed, 52 insertions(+), 6 deletions(-) rename spring-cucumber/src/test/java/com/baeldung/{CucumberTest.java => CucumberIntegrationTest.java} (83%) rename spring-cucumber/src/test/java/com/baeldung/{OtherDefs.java => OtherDefsIntegrationTest.java} (85%) rename spring-cucumber/src/test/java/com/baeldung/{StepDefs.java => StepDefsIntegrationTest.java} (93%) diff --git a/spring-cucumber/pom.xml b/spring-cucumber/pom.xml index f3b9c983f0..b493962a75 100644 --- a/spring-cucumber/pom.xml +++ b/spring-cucumber/pom.xml @@ -73,17 +73,63 @@ - - - + + + org.springframework.boot spring-boot-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + **/*LiveTest.java + + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + diff --git a/spring-cucumber/src/test/java/com/baeldung/CucumberTest.java b/spring-cucumber/src/test/java/com/baeldung/CucumberIntegrationTest.java similarity index 83% rename from spring-cucumber/src/test/java/com/baeldung/CucumberTest.java rename to spring-cucumber/src/test/java/com/baeldung/CucumberIntegrationTest.java index c31a35b271..56eb810c09 100644 --- a/spring-cucumber/src/test/java/com/baeldung/CucumberTest.java +++ b/spring-cucumber/src/test/java/com/baeldung/CucumberIntegrationTest.java @@ -6,5 +6,5 @@ import org.junit.runner.RunWith; @RunWith(Cucumber.class) @CucumberOptions(features = "src/test/resources") -public class CucumberTest { +public class CucumberIntegrationTest { } \ No newline at end of file diff --git a/spring-cucumber/src/test/java/com/baeldung/OtherDefs.java b/spring-cucumber/src/test/java/com/baeldung/OtherDefsIntegrationTest.java similarity index 85% rename from spring-cucumber/src/test/java/com/baeldung/OtherDefs.java rename to spring-cucumber/src/test/java/com/baeldung/OtherDefsIntegrationTest.java index edbc14f319..17f298c3fb 100644 --- a/spring-cucumber/src/test/java/com/baeldung/OtherDefs.java +++ b/spring-cucumber/src/test/java/com/baeldung/OtherDefsIntegrationTest.java @@ -3,7 +3,7 @@ package com.baeldung; import cucumber.api.java.en.Given; import cucumber.api.java.en.When; -public class OtherDefs extends SpringIntegrationTest { +public class OtherDefsIntegrationTest extends SpringIntegrationTest { @When("^the client calls /baeldung$") public void the_client_issues_POST_hello() throws Throwable { executePost("http://localhost:8080/baeldung"); diff --git a/spring-cucumber/src/test/java/com/baeldung/StepDefs.java b/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java similarity index 93% rename from spring-cucumber/src/test/java/com/baeldung/StepDefs.java rename to spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java index 865a1e13fa..8220d5e861 100644 --- a/spring-cucumber/src/test/java/com/baeldung/StepDefs.java +++ b/spring-cucumber/src/test/java/com/baeldung/StepDefsIntegrationTest.java @@ -9,7 +9,7 @@ import cucumber.api.java.en.And; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; -public class StepDefs extends SpringIntegrationTest { +public class StepDefsIntegrationTest extends SpringIntegrationTest { @When("^the client calls /version$") public void the_client_issues_GET_version() throws Throwable { From 72bdf6c2be5671079e7959683a051523177c554e Mon Sep 17 00:00:00 2001 From: Thai Nguyen Date: Wed, 19 Oct 2016 22:27:02 +0700 Subject: [PATCH 11/52] Changes HTTP request handling methods, adds negative test cases --- .../cxf/jaxrs/implementation/Baeldung.java | 17 +++--- .../cxf/jaxrs/implementation/Course.java | 34 ++++++++---- .../cxf/jaxrs/implementation/Student.java | 10 ++++ .../src/main/resources/changed_course.xml | 4 ++ .../src/main/resources/conflict_student.xml | 4 ++ .../{student.xml => created_student.xml} | 1 - .../{course.xml => non_existent_course.xml} | 0 .../src/main/resources/unchanged_course.xml | 4 ++ .../cxf/jaxrs/implementation/ServiceTest.java | 54 ++++++++++++++++--- 9 files changed, 101 insertions(+), 27 deletions(-) create mode 100644 apache-cxf/cxf-jaxrs-implementation/src/main/resources/changed_course.xml create mode 100644 apache-cxf/cxf-jaxrs-implementation/src/main/resources/conflict_student.xml rename apache-cxf/cxf-jaxrs-implementation/src/main/resources/{student.xml => created_student.xml} (82%) rename apache-cxf/cxf-jaxrs-implementation/src/main/resources/{course.xml => non_existent_course.xml} (100%) create mode 100644 apache-cxf/cxf-jaxrs-implementation/src/main/resources/unchanged_course.xml diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Baeldung.java b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Baeldung.java index 592df4b7c3..39872f4e32 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Baeldung.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Baeldung.java @@ -44,15 +44,16 @@ public class Baeldung { @PUT @Path("courses/{courseOrder}") - public Response putCourse(@PathParam("courseOrder") int courseOrder, Course course) { - Course existingCourse = courses.get(courseOrder); - - if (existingCourse == null || existingCourse.getId() != course.getId() || !(existingCourse.getName().equals(course.getName()))) { - courses.put(courseOrder, course); - return Response.ok().build(); + public Response updateCourse(@PathParam("courseOrder") int courseOrder, Course course) { + Course existingCourse = courses.get(courseOrder); + if (existingCourse == null) { + return Response.status(Response.Status.NOT_FOUND).build(); } - - return Response.notModified().build(); + if (existingCourse.equals(course)) { + return Response.notModified().build(); + } + courses.put(courseOrder, course); + return Response.ok().build(); } @Path("courses/{courseOrder}/students") diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java index 32689a332f..efb7191290 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java @@ -3,6 +3,7 @@ package com.baeldung.cxf.jaxrs.implementation; import javax.ws.rs.*; import javax.ws.rs.core.Response; import javax.xml.bind.annotation.XmlRootElement; + import java.util.ArrayList; import java.util.List; @@ -35,31 +36,42 @@ public class Course { public void setStudents(List students) { this.students = students; } - + @GET @Path("{studentOrder}") - public Student getStudent(@PathParam("studentOrder")int studentOrder) { + public Student getStudent(@PathParam("studentOrder") int studentOrder) { return students.get(studentOrder); } - + @POST - public Response postStudent(Student student) { + public Response createStudent(Student student) { if (students == null) { students = new ArrayList<>(); } + if (students.contains(student)) { + return Response.status(Response.Status.CONFLICT).build(); + } students.add(student); return Response.ok(student).build(); } - + @DELETE @Path("{studentOrder}") public Response deleteStudent(@PathParam("studentOrder") int studentOrder) { - Student student = students.get(studentOrder); - if (student != null) { - students.remove(studentOrder); - return Response.ok().build(); - } else { - return Response.notModified().build(); + if (students == null || studentOrder >= students.size()) { + return Response.status(Response.Status.NOT_FOUND).build(); } + students.remove(studentOrder); + return Response.ok().build(); + } + + @Override + public int hashCode() { + return id + name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return (obj instanceof Course) && (id == ((Course) obj).getId()) && (name.equals(((Course) obj).getName())); } } \ No newline at end of file diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Student.java b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Student.java index de782e4edb..bd3dad0f5e 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Student.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Student.java @@ -22,4 +22,14 @@ public class Student { public void setName(String name) { this.name = name; } + + @Override + public int hashCode() { + return id + name.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return (obj instanceof Student) && (id == ((Student) obj).getId()) && (name.equals(((Student) obj).getName())); + } } \ No newline at end of file diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/resources/changed_course.xml b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/changed_course.xml new file mode 100644 index 0000000000..097cf2ce58 --- /dev/null +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/changed_course.xml @@ -0,0 +1,4 @@ + + 2 + Apache CXF Support for RESTful + \ No newline at end of file diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/resources/conflict_student.xml b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/conflict_student.xml new file mode 100644 index 0000000000..ccf97edb2e --- /dev/null +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/conflict_student.xml @@ -0,0 +1,4 @@ + + 1 + Student A + \ No newline at end of file diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/resources/student.xml b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/created_student.xml similarity index 82% rename from apache-cxf/cxf-jaxrs-implementation/src/main/resources/student.xml rename to apache-cxf/cxf-jaxrs-implementation/src/main/resources/created_student.xml index 7fb6189815..068c9dae4b 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/main/resources/student.xml +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/created_student.xml @@ -1,4 +1,3 @@ - 3 Student C diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/resources/course.xml b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/non_existent_course.xml similarity index 100% rename from apache-cxf/cxf-jaxrs-implementation/src/main/resources/course.xml rename to apache-cxf/cxf-jaxrs-implementation/src/main/resources/non_existent_course.xml diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/resources/unchanged_course.xml b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/unchanged_course.xml new file mode 100644 index 0000000000..5936fdc094 --- /dev/null +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/unchanged_course.xml @@ -0,0 +1,4 @@ + + 1 + REST with Spring + \ No newline at end of file diff --git a/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java b/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java index 8c606436c8..8d06518df2 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java @@ -34,24 +34,57 @@ public class ServiceTest { } @Test - public void whenPutCourse_thenCorrect() throws IOException { + public void whenUpdateNonExistentCourse_thenReceiveNotFoundResponse() throws IOException { HttpPut httpPut = new HttpPut(BASE_URL + "3"); - InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("course.xml"); + InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("non_existent_course.xml"); + httpPut.setEntity(new InputStreamEntity(resourceStream)); + httpPut.setHeader("Content-Type", "text/xml"); + + HttpResponse response = client.execute(httpPut); + assertEquals(404, response.getStatusLine().getStatusCode()); + } + + @Test + public void whenUpdateUnchangedCourse_thenReceiveNotModifiedResponse() throws IOException { + HttpPut httpPut = new HttpPut(BASE_URL + "1"); + InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("unchanged_course.xml"); + httpPut.setEntity(new InputStreamEntity(resourceStream)); + httpPut.setHeader("Content-Type", "text/xml"); + + HttpResponse response = client.execute(httpPut); + assertEquals(304, response.getStatusLine().getStatusCode()); + } + + @Test + public void whenUpdateValidCourse_thenReceiveOKResponse() throws IOException { + HttpPut httpPut = new HttpPut(BASE_URL + "2"); + InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("changed_course.xml"); httpPut.setEntity(new InputStreamEntity(resourceStream)); httpPut.setHeader("Content-Type", "text/xml"); HttpResponse response = client.execute(httpPut); assertEquals(200, response.getStatusLine().getStatusCode()); - Course course = getCourse(3); - assertEquals(3, course.getId()); + Course course = getCourse(2); + assertEquals(2, course.getId()); assertEquals("Apache CXF Support for RESTful", course.getName()); } + + @Test + public void whenCreateConflictStudent_thenReceiveConflictResponse() throws IOException { + HttpPost httpPost = new HttpPost(BASE_URL + "1/students"); + InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("conflict_student.xml"); + httpPost.setEntity(new InputStreamEntity(resourceStream)); + httpPost.setHeader("Content-Type", "text/xml"); + + HttpResponse response = client.execute(httpPost); + assertEquals(409, response.getStatusLine().getStatusCode()); + } @Test - public void whenPostStudent_thenCorrect() throws IOException { + public void whenCreateValidStudent_thenReceiveOKResponse() throws IOException { HttpPost httpPost = new HttpPost(BASE_URL + "2/students"); - InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("student.xml"); + InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("created_student.xml"); httpPost.setEntity(new InputStreamEntity(resourceStream)); httpPost.setHeader("Content-Type", "text/xml"); @@ -64,7 +97,14 @@ public class ServiceTest { } @Test - public void whenDeleteStudent_thenCorrect() throws IOException { + public void whenDeleteInvalidStudent_thenReceiveNotFoundResponse() throws IOException { + HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/2"); + HttpResponse response = client.execute(httpDelete); + assertEquals(404, response.getStatusLine().getStatusCode()); + } + + @Test + public void whenDeleteValidStudent_thenReceiveOKResponse() throws IOException { HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/0"); HttpResponse response = client.execute(httpDelete); assertEquals(200, response.getStatusLine().getStatusCode()); From 15ab6c6326927cdb3fc0d3f81cf90335aa4f9f28 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Date: Thu, 20 Oct 2016 16:41:38 +0700 Subject: [PATCH 12/52] Changes order parameter to id --- .../cxf/jaxrs/implementation/Baeldung.java | 31 ++++++++++++------- .../cxf/jaxrs/implementation/Course.java | 29 ++++++++++------- .../src/main/resources/conflict_student.xml | 4 +-- .../cxf/jaxrs/implementation/ServiceTest.java | 6 ++-- 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Baeldung.java b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Baeldung.java index 39872f4e32..9dd63cf3ac 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Baeldung.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Baeldung.java @@ -37,27 +37,36 @@ public class Baeldung { } @GET - @Path("courses/{courseOrder}") - public Course getCourse(@PathParam("courseOrder") int courseOrder) { - return courses.get(courseOrder); + @Path("courses/{courseId}") + public Course getCourse(@PathParam("courseId") int courseId) { + return findById(courseId); } @PUT - @Path("courses/{courseOrder}") - public Response updateCourse(@PathParam("courseOrder") int courseOrder, Course course) { - Course existingCourse = courses.get(courseOrder); + @Path("courses/{courseId}") + public Response updateCourse(@PathParam("courseId") int courseId, Course course) { + Course existingCourse = findById(courseId); if (existingCourse == null) { return Response.status(Response.Status.NOT_FOUND).build(); } if (existingCourse.equals(course)) { - return Response.notModified().build(); + return Response.notModified().build(); } - courses.put(courseOrder, course); + courses.put(courseId, course); return Response.ok().build(); } - @Path("courses/{courseOrder}/students") - public Course pathToStudent(@PathParam("courseOrder") int courseOrder) { - return courses.get(courseOrder); + @Path("courses/{courseId}/students") + public Course pathToStudent(@PathParam("courseId") int courseId) { + return findById(courseId); + } + + private Course findById(int id) { + for (Map.Entry course : courses.entrySet()) { + if (course.getKey() == id) { + return course.getValue(); + } + } + return null; } } \ No newline at end of file diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java index efb7191290..dfbe8eef1d 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java @@ -11,7 +11,7 @@ import java.util.List; public class Course { private int id; private String name; - private List students; + private List students = new ArrayList<>(); public int getId() { return id; @@ -38,16 +38,13 @@ public class Course { } @GET - @Path("{studentOrder}") - public Student getStudent(@PathParam("studentOrder") int studentOrder) { - return students.get(studentOrder); + @Path("{studentId}") + public Student getStudent(@PathParam("studentId") int studentId) { + return findById(studentId); } @POST public Response createStudent(Student student) { - if (students == null) { - students = new ArrayList<>(); - } if (students.contains(student)) { return Response.status(Response.Status.CONFLICT).build(); } @@ -56,14 +53,24 @@ public class Course { } @DELETE - @Path("{studentOrder}") - public Response deleteStudent(@PathParam("studentOrder") int studentOrder) { - if (students == null || studentOrder >= students.size()) { + @Path("{studentId}") + public Response deleteStudent(@PathParam("studentId") int studentId) { + Student student = findById(studentId); + if (student == null) { return Response.status(Response.Status.NOT_FOUND).build(); } - students.remove(studentOrder); + students.remove(student); return Response.ok().build(); } + + private Student findById(int id) { + for (Student student : students) { + if (student.getId() == id) { + return student; + } + } + return null; + } @Override public int hashCode() { diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/resources/conflict_student.xml b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/conflict_student.xml index ccf97edb2e..7d083dbdc9 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/main/resources/conflict_student.xml +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/resources/conflict_student.xml @@ -1,4 +1,4 @@ - 1 - Student A + 2 + Student B \ No newline at end of file diff --git a/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java b/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java index 8d06518df2..b8fc833194 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java @@ -91,21 +91,21 @@ public class ServiceTest { HttpResponse response = client.execute(httpPost); assertEquals(200, response.getStatusLine().getStatusCode()); - Student student = getStudent(2, 0); + Student student = getStudent(2, 3); assertEquals(3, student.getId()); assertEquals("Student C", student.getName()); } @Test public void whenDeleteInvalidStudent_thenReceiveNotFoundResponse() throws IOException { - HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/2"); + HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/3"); HttpResponse response = client.execute(httpDelete); assertEquals(404, response.getStatusLine().getStatusCode()); } @Test public void whenDeleteValidStudent_thenReceiveOKResponse() throws IOException { - HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/0"); + HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/1"); HttpResponse response = client.execute(httpDelete); assertEquals(200, response.getStatusLine().getStatusCode()); From 4d54080b3ec57559b0c1d842fcb885a23340f3c5 Mon Sep 17 00:00:00 2001 From: Nikhil Khatwani Date: Thu, 20 Oct 2016 16:00:31 +0530 Subject: [PATCH 13/52] Fixed Failing EchoTest --- .../java/nio/selector/EchoServer.java | 26 ++++++++++++++----- .../baeldung/java/nio/selector/EchoTest.java | 7 +++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/java/nio/selector/EchoServer.java b/core-java/src/main/java/com/baeldung/java/nio/selector/EchoServer.java index aedcbb319b..285d4e51fc 100644 --- a/core-java/src/main/java/com/baeldung/java/nio/selector/EchoServer.java +++ b/core-java/src/main/java/com/baeldung/java/nio/selector/EchoServer.java @@ -1,14 +1,15 @@ package com.baeldung.java.nio.selector; +import java.io.File; +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; import java.nio.channels.ServerSocketChannel; import java.nio.channels.SocketChannel; -import java.nio.channels.Selector; -import java.nio.channels.SelectionKey; -import java.nio.ByteBuffer; -import java.io.IOException; -import java.util.Set; import java.util.Iterator; -import java.net.InetSocketAddress; +import java.util.Set; public class EchoServer { @@ -47,4 +48,15 @@ public class EchoServer { } } } -} + + public static Process start() throws IOException, InterruptedException { + String javaHome = System.getProperty("java.home"); + String javaBin = javaHome + File.separator + "bin" + File.separator + "java"; + String classpath = System.getProperty("java.class.path"); + String className = EchoServer.class.getCanonicalName(); + + ProcessBuilder builder = new ProcessBuilder(javaBin, "-cp", classpath, className); + + return builder.start(); + } +} \ No newline at end of file diff --git a/core-java/src/test/java/com/baeldung/java/nio/selector/EchoTest.java b/core-java/src/test/java/com/baeldung/java/nio/selector/EchoTest.java index 63da2fe2bf..d1ac6df5e4 100644 --- a/core-java/src/test/java/com/baeldung/java/nio/selector/EchoTest.java +++ b/core-java/src/test/java/com/baeldung/java/nio/selector/EchoTest.java @@ -2,17 +2,20 @@ package com.baeldung.java.nio.selector; import static org.junit.Assert.assertEquals; +import java.io.IOException; + import org.junit.Test; public class EchoTest { @Test - public void givenClient_whenServerEchosMessage_thenCorrect() { + public void givenClient_whenServerEchosMessage_thenCorrect() throws IOException, InterruptedException { + Process process = EchoServer.start(); EchoClient client = EchoClient.start(); String resp1 = client.sendMessage("hello"); String resp2 = client.sendMessage("world"); assertEquals("hello", resp1); assertEquals("world", resp2); + process.destroy(); } - } From b6e9223fed08d43d78241020b39f8b01d9507aa9 Mon Sep 17 00:00:00 2001 From: Thai Nguyen Date: Thu, 20 Oct 2016 17:47:34 +0700 Subject: [PATCH 14/52] Refactors Apache CXF support for REST --- .../com/baeldung/cxf/jaxrs/implementation/Course.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java index dfbe8eef1d..dba9b9c661 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/main/java/com/baeldung/cxf/jaxrs/implementation/Course.java @@ -45,8 +45,10 @@ public class Course { @POST public Response createStudent(Student student) { - if (students.contains(student)) { - return Response.status(Response.Status.CONFLICT).build(); + for (Student element : students) { + if (element.getId() == student.getId()) { + return Response.status(Response.Status.CONFLICT).build(); + } } students.add(student); return Response.ok(student).build(); @@ -62,7 +64,7 @@ public class Course { students.remove(student); return Response.ok().build(); } - + private Student findById(int id) { for (Student student : students) { if (student.getId() == id) { From 017dc13db1ebf30907a7cb05b42b619a765803fd Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 20 Oct 2016 13:44:16 +0200 Subject: [PATCH 15/52] add integration test profile --- spring-boot/pom.xml | 46 +++++++++++++++++++ ...ebjarsdemoApplicationIntegrationTest.java} | 2 +- ...Test.java => CommitIdIntegrationTest.java} | 4 +- ...SpringBootApplicationIntegrationTest.java} | 2 +- ...java => SpringBootJPAIntegrationTest.java} | 2 +- ...ava => SpringBootMailIntegrationTest.java} | 2 +- ...s.java => ApplicationIntegrationTest.java} | 2 +- ...va => DemoApplicationIntegrationTest.java} | 2 +- ...java => FooRepositoryIntegrationTest.java} | 4 +- ...a => HibernateSessionIntegrationTest.java} | 4 +- ...=> NoHibernateSessionIntegrationTest.java} | 4 +- ... DetailsServiceClientIntegrationTest.java} | 2 +- .../data-flow-shell/spring-shell.log | 1 + 13 files changed, 62 insertions(+), 15 deletions(-) rename spring-boot/src/test/java/com/baeldung/{WebjarsdemoApplicationTests.java => WebjarsdemoApplicationIntegrationTest.java} (89%) rename spring-boot/src/test/java/com/baeldung/git/{CommitIdTest.java => CommitIdIntegrationTest.java} (93%) rename spring-boot/src/test/java/org/baeldung/{SpringBootApplicationTest.java => SpringBootApplicationIntegrationTest.java} (97%) rename spring-boot/src/test/java/org/baeldung/{SpringBootJPATest.java => SpringBootJPAIntegrationTest.java} (95%) rename spring-boot/src/test/java/org/baeldung/{SpringBootMailTest.java => SpringBootMailIntegrationTest.java} (98%) rename spring-boot/src/test/java/org/baeldung/boot/{ApplicationTests.java => ApplicationIntegrationTest.java} (92%) rename spring-boot/src/test/java/org/baeldung/boot/{DemoApplicationTests.java => DemoApplicationIntegrationTest.java} (90%) rename spring-boot/src/test/java/org/baeldung/boot/repository/{FooRepositoryTest.java => FooRepositoryIntegrationTest.java} (84%) rename spring-boot/src/test/java/org/baeldung/boot/repository/{HibernateSessionTest.java => HibernateSessionIntegrationTest.java} (88%) rename spring-boot/src/test/java/org/baeldung/boot/repository/{NoHibernateSessionTest.java => NoHibernateSessionIntegrationTest.java} (81%) rename spring-boot/src/test/java/org/baeldung/client/{DetailsServiceClientTest.java => DetailsServiceClientIntegrationTest.java} (96%) create mode 100644 spring-cloud-data-flow/data-flow-shell/spring-shell.log diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index 5281b9b2c0..a2555259b0 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -133,10 +133,56 @@ 2.2.1 + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + **/*LiveTest.java + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + spring-snapshots diff --git a/spring-boot/src/test/java/com/baeldung/WebjarsdemoApplicationTests.java b/spring-boot/src/test/java/com/baeldung/WebjarsdemoApplicationIntegrationTest.java similarity index 89% rename from spring-boot/src/test/java/com/baeldung/WebjarsdemoApplicationTests.java rename to spring-boot/src/test/java/com/baeldung/WebjarsdemoApplicationIntegrationTest.java index c43b13ea0b..3558682b97 100644 --- a/spring-boot/src/test/java/com/baeldung/WebjarsdemoApplicationTests.java +++ b/spring-boot/src/test/java/com/baeldung/WebjarsdemoApplicationIntegrationTest.java @@ -9,7 +9,7 @@ import org.springframework.test.context.web.WebAppConfiguration; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = WebjarsdemoApplication.class) @WebAppConfiguration -public class WebjarsdemoApplicationTests { +public class WebjarsdemoApplicationIntegrationTest { @Test public void contextLoads() { diff --git a/spring-boot/src/test/java/com/baeldung/git/CommitIdTest.java b/spring-boot/src/test/java/com/baeldung/git/CommitIdIntegrationTest.java similarity index 93% rename from spring-boot/src/test/java/com/baeldung/git/CommitIdTest.java rename to spring-boot/src/test/java/com/baeldung/git/CommitIdIntegrationTest.java index c0fc1befd3..348d594c05 100644 --- a/spring-boot/src/test/java/com/baeldung/git/CommitIdTest.java +++ b/spring-boot/src/test/java/com/baeldung/git/CommitIdIntegrationTest.java @@ -12,9 +12,9 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @ContextConfiguration(classes = CommitIdApplication.class) -public class CommitIdTest { +public class CommitIdIntegrationTest { - private static final Logger LOG = LoggerFactory.getLogger(CommitIdTest.class); + private static final Logger LOG = LoggerFactory.getLogger(CommitIdIntegrationTest.class); @Value("${git.commit.message.short:UNKNOWN}") private String commitMessage; diff --git a/spring-boot/src/test/java/org/baeldung/SpringBootApplicationTest.java b/spring-boot/src/test/java/org/baeldung/SpringBootApplicationIntegrationTest.java similarity index 97% rename from spring-boot/src/test/java/org/baeldung/SpringBootApplicationTest.java rename to spring-boot/src/test/java/org/baeldung/SpringBootApplicationIntegrationTest.java index 1255180e44..3c5444942c 100644 --- a/spring-boot/src/test/java/org/baeldung/SpringBootApplicationTest.java +++ b/spring-boot/src/test/java/org/baeldung/SpringBootApplicationIntegrationTest.java @@ -26,7 +26,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) @WebAppConfiguration -public class SpringBootApplicationTest { +public class SpringBootApplicationIntegrationTest { @Autowired private WebApplicationContext webApplicationContext; private MockMvc mockMvc; diff --git a/spring-boot/src/test/java/org/baeldung/SpringBootJPATest.java b/spring-boot/src/test/java/org/baeldung/SpringBootJPAIntegrationTest.java similarity index 95% rename from spring-boot/src/test/java/org/baeldung/SpringBootJPATest.java rename to spring-boot/src/test/java/org/baeldung/SpringBootJPAIntegrationTest.java index 8a6b5139fe..233684bc24 100644 --- a/spring-boot/src/test/java/org/baeldung/SpringBootJPATest.java +++ b/spring-boot/src/test/java/org/baeldung/SpringBootJPAIntegrationTest.java @@ -13,7 +13,7 @@ import static org.junit.Assert.assertNotNull; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) -public class SpringBootJPATest { +public class SpringBootJPAIntegrationTest { @Autowired private GenericEntityRepository genericEntityRepository; diff --git a/spring-boot/src/test/java/org/baeldung/SpringBootMailTest.java b/spring-boot/src/test/java/org/baeldung/SpringBootMailIntegrationTest.java similarity index 98% rename from spring-boot/src/test/java/org/baeldung/SpringBootMailTest.java rename to spring-boot/src/test/java/org/baeldung/SpringBootMailIntegrationTest.java index f4ce158661..cec25f20f9 100644 --- a/spring-boot/src/test/java/org/baeldung/SpringBootMailTest.java +++ b/spring-boot/src/test/java/org/baeldung/SpringBootMailIntegrationTest.java @@ -24,7 +24,7 @@ import static org.junit.Assert.assertThat; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Application.class) -public class SpringBootMailTest { +public class SpringBootMailIntegrationTest { @Autowired private JavaMailSender javaMailSender; diff --git a/spring-boot/src/test/java/org/baeldung/boot/ApplicationTests.java b/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java similarity index 92% rename from spring-boot/src/test/java/org/baeldung/boot/ApplicationTests.java rename to spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java index 7911465048..57a8abc1ee 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/ApplicationTests.java +++ b/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java @@ -10,7 +10,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class) @TestPropertySource("classpath:exception.properties") -public class ApplicationTests { +public class ApplicationIntegrationTest { @Test public void contextLoads() { } diff --git a/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationTests.java b/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java similarity index 90% rename from spring-boot/src/test/java/org/baeldung/boot/DemoApplicationTests.java rename to spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java index 7f9b2ba912..4fcea35b4a 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationTests.java +++ b/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java @@ -9,7 +9,7 @@ import org.springframework.test.context.web.WebAppConfiguration; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = DemoApplication.class) @WebAppConfiguration -public class DemoApplicationTests { +public class DemoApplicationIntegrationTest { @Test public void contextLoads() { diff --git a/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryTest.java b/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java similarity index 84% rename from spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryTest.java rename to spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java index 9de7790a75..a844b26b2d 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryTest.java +++ b/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java @@ -2,7 +2,7 @@ package org.baeldung.boot.repository; import static org.junit.Assert.assertThat; -import org.baeldung.boot.DemoApplicationTests; +import org.baeldung.boot.DemoApplicationIntegrationTest; import org.baeldung.boot.model.Foo; import static org.hamcrest.Matchers.notNullValue; @@ -14,7 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @Transactional -public class FooRepositoryTest extends DemoApplicationTests { +public class FooRepositoryIntegrationTest extends DemoApplicationIntegrationTest { @Autowired private FooRepository fooRepository; diff --git a/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionTest.java b/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java similarity index 88% rename from spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionTest.java rename to spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java index 4cb1b60cde..be992bcc36 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionTest.java +++ b/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java @@ -4,7 +4,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; -import org.baeldung.boot.ApplicationTests; +import org.baeldung.boot.ApplicationIntegrationTest; import org.baeldung.boot.model.Foo; import org.baeldung.session.exception.repository.FooRepository; import org.junit.Test; @@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional; @Transactional @TestPropertySource("classpath:exception-hibernate.properties") -public class HibernateSessionTest extends ApplicationTests { +public class HibernateSessionIntegrationTest extends ApplicationIntegrationTest { @Autowired private FooRepository fooRepository; diff --git a/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionTest.java b/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java similarity index 81% rename from spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionTest.java rename to spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java index 5f5a49841a..55b7fa7216 100644 --- a/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionTest.java +++ b/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java @@ -1,6 +1,6 @@ package org.baeldung.boot.repository; -import org.baeldung.boot.ApplicationTests; +import org.baeldung.boot.ApplicationIntegrationTest; import org.baeldung.boot.model.Foo; import org.baeldung.session.exception.repository.FooRepository; import org.hibernate.HibernateException; @@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @Transactional -public class NoHibernateSessionTest extends ApplicationTests { +public class NoHibernateSessionIntegrationTest extends ApplicationIntegrationTest { @Autowired private FooRepository fooRepository; diff --git a/spring-boot/src/test/java/org/baeldung/client/DetailsServiceClientTest.java b/spring-boot/src/test/java/org/baeldung/client/DetailsServiceClientIntegrationTest.java similarity index 96% rename from spring-boot/src/test/java/org/baeldung/client/DetailsServiceClientTest.java rename to spring-boot/src/test/java/org/baeldung/client/DetailsServiceClientIntegrationTest.java index ba0da968ad..5627855aa3 100644 --- a/spring-boot/src/test/java/org/baeldung/client/DetailsServiceClientTest.java +++ b/spring-boot/src/test/java/org/baeldung/client/DetailsServiceClientIntegrationTest.java @@ -16,7 +16,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat @RunWith(SpringRunner.class) @RestClientTest(DetailsServiceClient.class) -public class DetailsServiceClientTest { +public class DetailsServiceClientIntegrationTest { @Autowired private DetailsServiceClient client; diff --git a/spring-cloud-data-flow/data-flow-shell/spring-shell.log b/spring-cloud-data-flow/data-flow-shell/spring-shell.log new file mode 100644 index 0000000000..d497215e2a --- /dev/null +++ b/spring-cloud-data-flow/data-flow-shell/spring-shell.log @@ -0,0 +1 @@ +// dataflow 1.2.0.RELEASE log opened at 2016-10-20 13:13:20 From a4f8b50c4f6a1e95a88e991459fa3f07419f28a8 Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 20 Oct 2016 13:49:04 +0200 Subject: [PATCH 16/52] add integration test profile --- spring-autowire/pom.xml | 41 +++++++++++++++++++ ...st.java => FooServiceIntegrationTest.java} | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) rename spring-autowire/src/test/java/com/baeldung/autowire/sample/{FooServiceTest.java => FooServiceIntegrationTest.java} (94%) diff --git a/spring-autowire/pom.xml b/spring-autowire/pom.xml index e28efdae61..fd03c77605 100644 --- a/spring-autowire/pom.xml +++ b/spring-autowire/pom.xml @@ -57,7 +57,48 @@ 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 + + + + + + + diff --git a/spring-autowire/src/test/java/com/baeldung/autowire/sample/FooServiceTest.java b/spring-autowire/src/test/java/com/baeldung/autowire/sample/FooServiceIntegrationTest.java similarity index 94% rename from spring-autowire/src/test/java/com/baeldung/autowire/sample/FooServiceTest.java rename to spring-autowire/src/test/java/com/baeldung/autowire/sample/FooServiceIntegrationTest.java index 50e89fcc55..34ba7902ca 100644 --- a/spring-autowire/src/test/java/com/baeldung/autowire/sample/FooServiceTest.java +++ b/spring-autowire/src/test/java/com/baeldung/autowire/sample/FooServiceIntegrationTest.java @@ -10,7 +10,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = AppConfig.class, loader = AnnotationConfigContextLoader.class) -public class FooServiceTest { +public class FooServiceIntegrationTest { @Autowired FooService fooService; From 5a0c407987dfd93eb6672170c7665b3f850bb005 Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 20 Oct 2016 14:14:55 +0200 Subject: [PATCH 17/52] add integration test profile --- spring-all/pom.xml | 58 ++++++++++++------- ...syncAnnotationExampleIntegrationTest.java} | 2 +- ....java => AsyncWithXMLIntegrationTest.java} | 2 +- ... ControllerAnnotationIntegrationTest.java} | 2 +- ...st.java => ControllerIntegrationTest.java} | 2 +- ... DataAccessAnnotationIntegrationTest.java} | 2 +- ...taAccessFieldCallbackIntegrationTest.java} | 2 +- ...t.java => EmployeeDAOIntegrationTest.java} | 2 +- ...ProfileWithAnnotationIntegrationTest.java} | 2 +- ...ProfileWithAnnotationIntegrationTest.java} | 2 +- ...PlaceHolderPropertiesIntegrationTest.java} | 2 +- ...pertySourcePropertiesIntegrationTest.java} | 2 +- ...uledAnnotationExampleIntegrationTest.java} | 2 +- ...hedulingWithXmlConfigIntegrationTest.java} | 2 +- ...> AttributeAnnotationIntegrationTest.java} | 2 +- ...a => CacheRefinementsIntegrationTest.java} | 2 +- ...va => ComposedMappingIntegrationTest.java} | 2 +- ...nConstructorInjectionIntegrationTest.java} | 2 +- ...> ImplicitConstructorIntegrationTest.java} | 2 +- ...faultMethodsInjectionIntegrationTest.java} | 2 +- ...java => TransactionalIntegrationTest.java} | 2 +- ...ava => ObjectProviderIntegrationTest.java} | 2 +- ...a => ScopeAnnotationsIntegrationTest.java} | 2 +- ...ousCustomSpringEventsIntegrationTest.java} | 2 +- ...textRefreshedListenerIntegrationTest.java} | 2 +- ...ousCustomSpringEventsIntegrationTest.java} | 2 +- ...java => SpringStartupIntegrationTest.java} | 2 +- ...pringStartupXMLConfigIntegrationTest.java} | 2 +- 28 files changed, 63 insertions(+), 49 deletions(-) rename spring-all/src/test/java/org/baeldung/async/{AsyncAnnotationExampleTest.java => AsyncAnnotationExampleIntegrationTest.java} (97%) rename spring-all/src/test/java/org/baeldung/async/{AsyncWithXMLTest.java => AsyncWithXMLIntegrationTest.java} (95%) rename spring-all/src/test/java/org/baeldung/controller/{ControllerAnnotationTest.java => ControllerAnnotationIntegrationTest.java} (95%) rename spring-all/src/test/java/org/baeldung/controller/{ControllerTest.java => ControllerIntegrationTest.java} (98%) rename spring-all/src/test/java/org/baeldung/customannotation/{DataAccessAnnotationTest.java => DataAccessAnnotationIntegrationTest.java} (97%) rename spring-all/src/test/java/org/baeldung/customannotation/{DataAccessFieldCallbackTest.java => DataAccessFieldCallbackIntegrationTest.java} (97%) rename spring-all/src/test/java/org/baeldung/jdbc/{EmployeeDAOTest.java => EmployeeDAOIntegrationTest.java} (99%) rename spring-all/src/test/java/org/baeldung/profiles/{DevProfileWithAnnotationTest.java => DevProfileWithAnnotationIntegrationTest.java} (93%) rename spring-all/src/test/java/org/baeldung/profiles/{ProductionProfileWithAnnotationTest.java => ProductionProfileWithAnnotationIntegrationTest.java} (94%) rename spring-all/src/test/java/org/baeldung/properties/parentchild/{ParentChildPropertyPlaceHolderPropertiesTest.java => ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java} (96%) rename spring-all/src/test/java/org/baeldung/properties/parentchild/{ParentChildPropertySourcePropertiesTest.java => ParentChildPropertySourcePropertiesIntegrationTest.java} (96%) rename spring-all/src/test/java/org/baeldung/scheduling/{ScheduledAnnotationExampleTest.java => ScheduledAnnotationExampleIntegrationTest.java} (90%) rename spring-all/src/test/java/org/baeldung/scheduling/{SchedulingWithXmlConfigTest.java => SchedulingWithXmlConfigIntegrationTest.java} (89%) rename spring-all/src/test/java/org/baeldung/spring43/attributeannotations/{AttributeAnnotationTest.java => AttributeAnnotationIntegrationTest.java} (94%) rename spring-all/src/test/java/org/baeldung/spring43/cache/{CacheRefinementsTest.java => CacheRefinementsIntegrationTest.java} (92%) rename spring-all/src/test/java/org/baeldung/spring43/composedmapping/{ComposedMappingTest.java => ComposedMappingIntegrationTest.java} (94%) rename spring-all/src/test/java/org/baeldung/spring43/ctor/{ConfigurationConstructorInjectionTest.java => ConfigurationConstructorInjectionIntegrationTest.java} (85%) rename spring-all/src/test/java/org/baeldung/spring43/ctor/{ImplicitConstructorTest.java => ImplicitConstructorIntegrationTest.java} (86%) rename spring-all/src/test/java/org/baeldung/spring43/defaultmethods/{DefaultMethodsInjectionTest.java => DefaultMethodsInjectionIntegrationTest.java} (87%) rename spring-all/src/test/java/org/baeldung/spring43/defaultmethods/{TransactionalTest.java => TransactionalIntegrationTest.java} (76%) rename spring-all/src/test/java/org/baeldung/spring43/depresolution/{ObjectProviderTest.java => ObjectProviderIntegrationTest.java} (87%) rename spring-all/src/test/java/org/baeldung/spring43/scopeannotations/{ScopeAnnotationsTest.java => ScopeAnnotationsIntegrationTest.java} (97%) rename spring-all/src/test/java/org/baeldung/springevents/asynchronous/{AsynchronousCustomSpringEventsTest.java => AsynchronousCustomSpringEventsIntegrationTest.java} (93%) rename spring-all/src/test/java/org/baeldung/springevents/synchronous/{ContextRefreshedListenerTest.java => ContextRefreshedListenerIntegrationTest.java} (92%) rename spring-all/src/test/java/org/baeldung/springevents/synchronous/{SynchronousCustomSpringEventsTest.java => SynchronousCustomSpringEventsIntegrationTest.java} (93%) rename spring-all/src/test/java/org/baeldung/startup/{SpringStartupTest.java => SpringStartupIntegrationTest.java} (97%) rename spring-all/src/test/java/org/baeldung/startup/{SpringStartupXMLConfigTest.java => SpringStartupXMLConfigIntegrationTest.java} (93%) diff --git a/spring-all/pom.xml b/spring-all/pom.xml index 003cdacc2c..23f2531b51 100644 --- a/spring-all/pom.xml +++ b/spring-all/pom.xml @@ -224,7 +224,7 @@ maven-surefire-plugin - + **/*IntegrationTest.java @@ -232,31 +232,45 @@ - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - - + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + 4.3.1.RELEASE diff --git a/spring-all/src/test/java/org/baeldung/async/AsyncAnnotationExampleTest.java b/spring-all/src/test/java/org/baeldung/async/AsyncAnnotationExampleIntegrationTest.java similarity index 97% rename from spring-all/src/test/java/org/baeldung/async/AsyncAnnotationExampleTest.java rename to spring-all/src/test/java/org/baeldung/async/AsyncAnnotationExampleIntegrationTest.java index 2f41766cb6..0c010cf732 100644 --- a/spring-all/src/test/java/org/baeldung/async/AsyncAnnotationExampleTest.java +++ b/spring-all/src/test/java/org/baeldung/async/AsyncAnnotationExampleIntegrationTest.java @@ -13,7 +13,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { SpringAsyncConfig.class }, loader = AnnotationConfigContextLoader.class) -public class AsyncAnnotationExampleTest { +public class AsyncAnnotationExampleIntegrationTest { @Autowired private AsyncComponent asyncAnnotationExample; diff --git a/spring-all/src/test/java/org/baeldung/async/AsyncWithXMLTest.java b/spring-all/src/test/java/org/baeldung/async/AsyncWithXMLIntegrationTest.java similarity index 95% rename from spring-all/src/test/java/org/baeldung/async/AsyncWithXMLTest.java rename to spring-all/src/test/java/org/baeldung/async/AsyncWithXMLIntegrationTest.java index b91666261c..ffaa653a9a 100644 --- a/spring-all/src/test/java/org/baeldung/async/AsyncWithXMLTest.java +++ b/spring-all/src/test/java/org/baeldung/async/AsyncWithXMLIntegrationTest.java @@ -8,7 +8,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:springAsync-config.xml") -public class AsyncWithXMLTest { +public class AsyncWithXMLIntegrationTest { @Autowired private AsyncComponent asyncAnnotationExample; diff --git a/spring-all/src/test/java/org/baeldung/controller/ControllerAnnotationTest.java b/spring-all/src/test/java/org/baeldung/controller/ControllerAnnotationIntegrationTest.java similarity index 95% rename from spring-all/src/test/java/org/baeldung/controller/ControllerAnnotationTest.java rename to spring-all/src/test/java/org/baeldung/controller/ControllerAnnotationIntegrationTest.java index 84bc3a8033..82c8704360 100644 --- a/spring-all/src/test/java/org/baeldung/controller/ControllerAnnotationTest.java +++ b/spring-all/src/test/java/org/baeldung/controller/ControllerAnnotationIntegrationTest.java @@ -21,7 +21,7 @@ import org.springframework.web.servlet.ModelAndView; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration(classes = { WebConfig.class }, loader = AnnotationConfigWebContextLoader.class) -public class ControllerAnnotationTest { +public class ControllerAnnotationIntegrationTest { private MockMvc mockMvc; diff --git a/spring-all/src/test/java/org/baeldung/controller/ControllerTest.java b/spring-all/src/test/java/org/baeldung/controller/ControllerIntegrationTest.java similarity index 98% rename from spring-all/src/test/java/org/baeldung/controller/ControllerTest.java rename to spring-all/src/test/java/org/baeldung/controller/ControllerIntegrationTest.java index 47915b8ce9..8e8a021530 100644 --- a/spring-all/src/test/java/org/baeldung/controller/ControllerTest.java +++ b/spring-all/src/test/java/org/baeldung/controller/ControllerIntegrationTest.java @@ -20,7 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration({ "classpath:test-mvc.xml" }) -public class ControllerTest { +public class ControllerIntegrationTest { private MockMvc mockMvc; diff --git a/spring-all/src/test/java/org/baeldung/customannotation/DataAccessAnnotationTest.java b/spring-all/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java similarity index 97% rename from spring-all/src/test/java/org/baeldung/customannotation/DataAccessAnnotationTest.java rename to spring-all/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java index ec0d46876e..ae3d53fb9b 100644 --- a/spring-all/src/test/java/org/baeldung/customannotation/DataAccessAnnotationTest.java +++ b/spring-all/src/test/java/org/baeldung/customannotation/DataAccessAnnotationIntegrationTest.java @@ -14,7 +14,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { CustomAnnotationConfiguration.class }) -public class DataAccessAnnotationTest { +public class DataAccessAnnotationIntegrationTest { @DataAccess(entity = Person.class) private GenericDAO personGenericDAO; diff --git a/spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackTest.java b/spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java similarity index 97% rename from spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackTest.java rename to spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java index e47d03c961..bab2574cd2 100644 --- a/spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackTest.java +++ b/spring-all/src/test/java/org/baeldung/customannotation/DataAccessFieldCallbackIntegrationTest.java @@ -17,7 +17,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { CustomAnnotationConfiguration.class }) -public class DataAccessFieldCallbackTest { +public class DataAccessFieldCallbackIntegrationTest { @Autowired private ConfigurableListableBeanFactory configurableListableBeanFactory; diff --git a/spring-all/src/test/java/org/baeldung/jdbc/EmployeeDAOTest.java b/spring-all/src/test/java/org/baeldung/jdbc/EmployeeDAOIntegrationTest.java similarity index 99% rename from spring-all/src/test/java/org/baeldung/jdbc/EmployeeDAOTest.java rename to spring-all/src/test/java/org/baeldung/jdbc/EmployeeDAOIntegrationTest.java index d544409254..4a92aa838f 100644 --- a/spring-all/src/test/java/org/baeldung/jdbc/EmployeeDAOTest.java +++ b/spring-all/src/test/java/org/baeldung/jdbc/EmployeeDAOIntegrationTest.java @@ -15,7 +15,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { SpringJdbcConfig.class }, loader = AnnotationConfigContextLoader.class) -public class EmployeeDAOTest { +public class EmployeeDAOIntegrationTest { @Autowired private EmployeeDAO employeeDao; diff --git a/spring-all/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationTest.java b/spring-all/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java similarity index 93% rename from spring-all/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationTest.java rename to spring-all/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java index 2b65928da8..cf5ca132e6 100644 --- a/spring-all/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationTest.java +++ b/spring-all/src/test/java/org/baeldung/profiles/DevProfileWithAnnotationIntegrationTest.java @@ -12,7 +12,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("dev") @ContextConfiguration(classes = { SpringProfilesConfig.class }, loader = AnnotationConfigContextLoader.class) -public class DevProfileWithAnnotationTest { +public class DevProfileWithAnnotationIntegrationTest { @Autowired DatasourceConfig datasourceConfig; diff --git a/spring-all/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationTest.java b/spring-all/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java similarity index 94% rename from spring-all/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationTest.java rename to spring-all/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java index 551636bd31..5bacaef07b 100644 --- a/spring-all/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationTest.java +++ b/spring-all/src/test/java/org/baeldung/profiles/ProductionProfileWithAnnotationIntegrationTest.java @@ -13,7 +13,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ActiveProfiles("production") @ContextConfiguration(classes = { SpringProfilesConfig.class }, loader = AnnotationConfigContextLoader.class) -public class ProductionProfileWithAnnotationTest { +public class ProductionProfileWithAnnotationIntegrationTest { @Autowired DatasourceConfig datasourceConfig; diff --git a/spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesTest.java b/spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java similarity index 96% rename from spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesTest.java rename to spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java index 92af3f52f0..e0eccc978a 100644 --- a/spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesTest.java +++ b/spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java @@ -18,7 +18,7 @@ import org.springframework.web.context.WebApplicationContext; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextHierarchy({ @ContextConfiguration(classes = ParentConfig2.class), @ContextConfiguration(classes = ChildConfig2.class) }) -public class ParentChildPropertyPlaceHolderPropertiesTest { +public class ParentChildPropertyPlaceHolderPropertiesIntegrationTest { @Autowired private WebApplicationContext wac; diff --git a/spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesTest.java b/spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesIntegrationTest.java similarity index 96% rename from spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesTest.java rename to spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesIntegrationTest.java index 3ffd490c87..e9990523a7 100644 --- a/spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesTest.java +++ b/spring-all/src/test/java/org/baeldung/properties/parentchild/ParentChildPropertySourcePropertiesIntegrationTest.java @@ -18,7 +18,7 @@ import org.springframework.web.context.WebApplicationContext; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextHierarchy({ @ContextConfiguration(classes = ParentConfig.class), @ContextConfiguration(classes = ChildConfig.class) }) -public class ParentChildPropertySourcePropertiesTest { +public class ParentChildPropertySourcePropertiesIntegrationTest { @Autowired private WebApplicationContext wac; diff --git a/spring-all/src/test/java/org/baeldung/scheduling/ScheduledAnnotationExampleTest.java b/spring-all/src/test/java/org/baeldung/scheduling/ScheduledAnnotationExampleIntegrationTest.java similarity index 90% rename from spring-all/src/test/java/org/baeldung/scheduling/ScheduledAnnotationExampleTest.java rename to spring-all/src/test/java/org/baeldung/scheduling/ScheduledAnnotationExampleIntegrationTest.java index 9317c7bb7f..c5ca78aaa1 100644 --- a/spring-all/src/test/java/org/baeldung/scheduling/ScheduledAnnotationExampleTest.java +++ b/spring-all/src/test/java/org/baeldung/scheduling/ScheduledAnnotationExampleIntegrationTest.java @@ -8,7 +8,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { SpringSchedulingConfig.class }, loader = AnnotationConfigContextLoader.class) -public class ScheduledAnnotationExampleTest { +public class ScheduledAnnotationExampleIntegrationTest { @Test public void testScheduledAnnotation() throws InterruptedException { diff --git a/spring-all/src/test/java/org/baeldung/scheduling/SchedulingWithXmlConfigTest.java b/spring-all/src/test/java/org/baeldung/scheduling/SchedulingWithXmlConfigIntegrationTest.java similarity index 89% rename from spring-all/src/test/java/org/baeldung/scheduling/SchedulingWithXmlConfigTest.java rename to spring-all/src/test/java/org/baeldung/scheduling/SchedulingWithXmlConfigIntegrationTest.java index 0fca4d21c8..08df73f8fd 100644 --- a/spring-all/src/test/java/org/baeldung/scheduling/SchedulingWithXmlConfigTest.java +++ b/spring-all/src/test/java/org/baeldung/scheduling/SchedulingWithXmlConfigIntegrationTest.java @@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:springScheduled-config.xml") -public class SchedulingWithXmlConfigTest { +public class SchedulingWithXmlConfigIntegrationTest { @Test public void testXmlBasedScheduling() throws InterruptedException { diff --git a/spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationTest.java b/spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java similarity index 94% rename from spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationTest.java rename to spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java index 5162a067d7..fff2716a64 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/attributeannotations/AttributeAnnotationIntegrationTest.java @@ -17,7 +17,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @ContextConfiguration(classes = AttributeAnnotationConfiguration.class) @WebAppConfiguration -public class AttributeAnnotationTest extends AbstractJUnit4SpringContextTests { +public class AttributeAnnotationIntegrationTest extends AbstractJUnit4SpringContextTests { private MockMvc mockMvc; diff --git a/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsTest.java b/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java similarity index 92% rename from spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsTest.java rename to spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java index bfd6e5047c..986932dafe 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/cache/CacheRefinementsIntegrationTest.java @@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import static org.junit.Assert.assertEquals; @ContextConfiguration(classes = CacheRefinementsConfiguration.class) -public class CacheRefinementsTest extends AbstractJUnit4SpringContextTests { +public class CacheRefinementsIntegrationTest extends AbstractJUnit4SpringContextTests { private ExecutorService executorService = Executors.newFixedThreadPool(10); diff --git a/spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingTest.java b/spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java similarity index 94% rename from spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingTest.java rename to spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java index 75d828c3d3..d0af48cd0e 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/composedmapping/ComposedMappingIntegrationTest.java @@ -17,7 +17,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @ContextConfiguration(classes = ComposedMappingConfiguration.class) @WebAppConfiguration -public class ComposedMappingTest extends AbstractJUnit4SpringContextTests { +public class ComposedMappingIntegrationTest extends AbstractJUnit4SpringContextTests { @Autowired private AppointmentService appointmentService; diff --git a/spring-all/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionTest.java b/spring-all/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java similarity index 85% rename from spring-all/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionTest.java rename to spring-all/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java index 3edf693a13..871a985479 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/ctor/ConfigurationConstructorInjectionIntegrationTest.java @@ -8,7 +8,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import static org.junit.Assert.assertNotNull; @ContextConfiguration(classes = { FooRepositoryConfiguration.class, FooServiceConfiguration.class }) -public class ConfigurationConstructorInjectionTest extends AbstractJUnit4SpringContextTests { +public class ConfigurationConstructorInjectionIntegrationTest extends AbstractJUnit4SpringContextTests { @Autowired public FooService fooService; diff --git a/spring-all/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorTest.java b/spring-all/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java similarity index 86% rename from spring-all/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorTest.java rename to spring-all/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java index be0cf77a62..83fa11294e 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/ctor/ImplicitConstructorIntegrationTest.java @@ -8,7 +8,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import static org.junit.Assert.assertNotNull; @ContextConfiguration("classpath:implicit-ctor-context.xml") -public class ImplicitConstructorTest extends AbstractJUnit4SpringContextTests { +public class ImplicitConstructorIntegrationTest extends AbstractJUnit4SpringContextTests { @Autowired private FooService fooService; diff --git a/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionTest.java b/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java similarity index 87% rename from spring-all/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionTest.java rename to spring-all/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java index e29d89a679..956df44821 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/DefaultMethodsInjectionIntegrationTest.java @@ -10,7 +10,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import static org.junit.Assert.assertEquals; @ContextConfiguration("classpath:defaultmethods-context.xml") -public class DefaultMethodsInjectionTest extends AbstractJUnit4SpringContextTests { +public class DefaultMethodsInjectionIntegrationTest extends AbstractJUnit4SpringContextTests { @Autowired private IDateHolder dateHolder; diff --git a/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTest.java b/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java similarity index 76% rename from spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTest.java rename to spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java index 89c96ba1d4..b4ac7e8ccf 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/defaultmethods/TransactionalIntegrationTest.java @@ -5,7 +5,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; @ContextConfiguration(classes = TransactionalTestConfiguration.class) -public class TransactionalTest extends AbstractTransactionalJUnit4SpringContextTests implements ITransactionalTest { +public class TransactionalIntegrationTest extends AbstractTransactionalJUnit4SpringContextTests implements ITransactionalTest { @Test public void whenDefaultMethodAnnotatedWithBeforeTransaction_thenDefaultMethodIsExecuted() { diff --git a/spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderTest.java b/spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java similarity index 87% rename from spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderTest.java rename to spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java index eeeb005f81..6d06bfdc2a 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/depresolution/ObjectProviderIntegrationTest.java @@ -8,7 +8,7 @@ import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import static org.junit.Assert.assertNotNull; @ContextConfiguration(classes = ObjectProviderConfiguration.class) -public class ObjectProviderTest extends AbstractJUnit4SpringContextTests { +public class ObjectProviderIntegrationTest extends AbstractJUnit4SpringContextTests { @Autowired private FooService fooService; diff --git a/spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsTest.java b/spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java similarity index 97% rename from spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsTest.java rename to spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java index ecf14f0d6c..69cce15029 100644 --- a/spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsTest.java +++ b/spring-all/src/test/java/org/baeldung/spring43/scopeannotations/ScopeAnnotationsIntegrationTest.java @@ -19,7 +19,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @ContextConfiguration(classes = ScopeAnnotationsConfiguration.class) @WebAppConfiguration -public class ScopeAnnotationsTest extends AbstractJUnit4SpringContextTests { +public class ScopeAnnotationsIntegrationTest extends AbstractJUnit4SpringContextTests { private MockMvc mockMvc; diff --git a/spring-all/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsTest.java b/spring-all/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java similarity index 93% rename from spring-all/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsTest.java rename to spring-all/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java index 2b45ae4e68..e12baed7e0 100644 --- a/spring-all/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsTest.java +++ b/spring-all/src/test/java/org/baeldung/springevents/asynchronous/AsynchronousCustomSpringEventsIntegrationTest.java @@ -10,7 +10,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { AsynchronousSpringEventsConfig.class }, loader = AnnotationConfigContextLoader.class) -public class AsynchronousCustomSpringEventsTest { +public class AsynchronousCustomSpringEventsIntegrationTest { @Autowired private CustomSpringEventPublisher publisher; diff --git a/spring-all/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerTest.java b/spring-all/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java similarity index 92% rename from spring-all/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerTest.java rename to spring-all/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java index d971698e3f..ac8758bbf6 100644 --- a/spring-all/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerTest.java +++ b/spring-all/src/test/java/org/baeldung/springevents/synchronous/ContextRefreshedListenerIntegrationTest.java @@ -9,7 +9,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { SynchronousSpringEventsConfig.class }, loader = AnnotationConfigContextLoader.class) -public class ContextRefreshedListenerTest { +public class ContextRefreshedListenerIntegrationTest { @Test public void testContextRefreshedListener() throws InterruptedException { diff --git a/spring-all/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsTest.java b/spring-all/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java similarity index 93% rename from spring-all/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsTest.java rename to spring-all/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java index b559ca9fc9..f9783f57dc 100644 --- a/spring-all/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsTest.java +++ b/spring-all/src/test/java/org/baeldung/springevents/synchronous/SynchronousCustomSpringEventsIntegrationTest.java @@ -9,7 +9,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { SynchronousSpringEventsConfig.class }, loader = AnnotationConfigContextLoader.class) -public class SynchronousCustomSpringEventsTest { +public class SynchronousCustomSpringEventsIntegrationTest { @Autowired private CustomSpringEventPublisher publisher; diff --git a/spring-all/src/test/java/org/baeldung/startup/SpringStartupTest.java b/spring-all/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java similarity index 97% rename from spring-all/src/test/java/org/baeldung/startup/SpringStartupTest.java rename to spring-all/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java index 523a27c2c4..6263482948 100644 --- a/spring-all/src/test/java/org/baeldung/startup/SpringStartupTest.java +++ b/spring-all/src/test/java/org/baeldung/startup/SpringStartupIntegrationTest.java @@ -12,7 +12,7 @@ import org.springframework.test.context.support.AnnotationConfigContextLoader; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { SpringStartupConfig.class }, loader = AnnotationConfigContextLoader.class) -public class SpringStartupTest { +public class SpringStartupIntegrationTest { @Autowired private ApplicationContext ctx; diff --git a/spring-all/src/test/java/org/baeldung/startup/SpringStartupXMLConfigTest.java b/spring-all/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java similarity index 93% rename from spring-all/src/test/java/org/baeldung/startup/SpringStartupXMLConfigTest.java rename to spring-all/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java index 19a35bb92b..a46d24fa3b 100644 --- a/spring-all/src/test/java/org/baeldung/startup/SpringStartupXMLConfigTest.java +++ b/spring-all/src/test/java/org/baeldung/startup/SpringStartupXMLConfigIntegrationTest.java @@ -9,7 +9,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:startupConfig.xml") -public class SpringStartupXMLConfigTest { +public class SpringStartupXMLConfigIntegrationTest { @Autowired private ApplicationContext ctx; From c1017af8a09d9b10a5821c237a01d263b785084e Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 20 Oct 2016 14:21:12 +0200 Subject: [PATCH 18/52] add integration test profile --- spring-akka/pom.xml | 51 ++++++++++++++++++- ...st.java => SpringAkkaIntegrationTest.java} | 2 +- 2 files changed, 50 insertions(+), 3 deletions(-) rename spring-akka/src/test/java/org/baeldung/akka/{SpringAkkaTest.java => SpringAkkaIntegrationTest.java} (94%) diff --git a/spring-akka/pom.xml b/spring-akka/pom.xml index 6299448ec8..eb33ca4848 100644 --- a/spring-akka/pom.xml +++ b/spring-akka/pom.xml @@ -65,9 +65,54 @@ + + 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 + + + + + + + 4.3.2.RELEASE @@ -75,6 +120,8 @@ 4.12 3.5.1 + 2.19.1 + \ No newline at end of file diff --git a/spring-akka/src/test/java/org/baeldung/akka/SpringAkkaTest.java b/spring-akka/src/test/java/org/baeldung/akka/SpringAkkaIntegrationTest.java similarity index 94% rename from spring-akka/src/test/java/org/baeldung/akka/SpringAkkaTest.java rename to spring-akka/src/test/java/org/baeldung/akka/SpringAkkaIntegrationTest.java index e5351e9d0f..c5da0f747e 100644 --- a/spring-akka/src/test/java/org/baeldung/akka/SpringAkkaTest.java +++ b/spring-akka/src/test/java/org/baeldung/akka/SpringAkkaIntegrationTest.java @@ -20,7 +20,7 @@ import static akka.pattern.Patterns.ask; import static org.baeldung.akka.SpringExtension.SPRING_EXTENSION_PROVIDER; @ContextConfiguration(classes = AppConfiguration.class) -public class SpringAkkaTest extends AbstractJUnit4SpringContextTests { +public class SpringAkkaIntegrationTest extends AbstractJUnit4SpringContextTests { @Autowired private ActorSystem system; From 511d96614d086daf4216e880b8de09b4aff3dd53 Mon Sep 17 00:00:00 2001 From: Sameera Date: Thu, 20 Oct 2016 23:10:17 +0530 Subject: [PATCH 19/52] PrintScreen code samples moved to core-java module --- .../com/baeldung/printscreen}/Screenshot.java | 2 +- .../baeldung/printscreen}/ScreenshotTest.java | 2 +- printscreen/pom.xml | 26 ------------------- 3 files changed, 2 insertions(+), 28 deletions(-) rename {printscreen/src/main/java/org/baeldung/corejava => core-java/src/main/java/com/baeldung/printscreen}/Screenshot.java (97%) rename {printscreen/src/test/java/org/baeldung/corejava => core-java/src/test/java/com/baeldung/printscreen}/ScreenshotTest.java (95%) delete mode 100644 printscreen/pom.xml diff --git a/printscreen/src/main/java/org/baeldung/corejava/Screenshot.java b/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java similarity index 97% rename from printscreen/src/main/java/org/baeldung/corejava/Screenshot.java rename to core-java/src/main/java/com/baeldung/printscreen/Screenshot.java index d33761932f..500860640a 100644 --- a/printscreen/src/main/java/org/baeldung/corejava/Screenshot.java +++ b/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java @@ -1,4 +1,4 @@ -package org.baeldung.corejava;; +package com.baeldung.printscreen; import javax.imageio.ImageIO; import java.awt.*; diff --git a/printscreen/src/test/java/org/baeldung/corejava/ScreenshotTest.java b/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java similarity index 95% rename from printscreen/src/test/java/org/baeldung/corejava/ScreenshotTest.java rename to core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java index 588c2eea78..5c0341cb36 100644 --- a/printscreen/src/test/java/org/baeldung/corejava/ScreenshotTest.java +++ b/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java @@ -1,4 +1,4 @@ -package org.baeldung.corejava; +package com.baeldung.printscreen; import org.junit.After; import org.junit.Before; diff --git a/printscreen/pom.xml b/printscreen/pom.xml deleted file mode 100644 index ddb813a7a2..0000000000 --- a/printscreen/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - 4.0.0 - - com.baeldung - corejava-printscreen - 1.0-SNAPSHOT - jar - - How to Print Screen in Java - https://github.com/eugenp/tutorials - - - UTF-8 - 4.12 - - - - - junit - junit - ${junit.version} - test - - - From cdbd83e8518b2cf0dcf66ce8d64b105fde479015 Mon Sep 17 00:00:00 2001 From: DOHA Date: Thu, 20 Oct 2016 21:53:32 +0200 Subject: [PATCH 20/52] add integration test profile --- spring-mvc-java/pom.xml | 54 ++++++++++++------- ...arDependencyA => CircularDependencyA.java} | 0 ...arDependencyB => CircularDependencyB.java} | 0 .../CircularDependencyIntegrationTest.java | 35 ++++++++++++ .../circulardependency/CircularDependencyTest | 35 ------------ .../{TestConfig => TestConfig.java} | 0 .../HtmlUnitAndSpringIntegrationTest.java | 4 +- 7 files changed, 73 insertions(+), 55 deletions(-) rename spring-mvc-java/src/main/java/com/baeldung/circulardependency/{CircularDependencyA => CircularDependencyA.java} (100%) rename spring-mvc-java/src/main/java/com/baeldung/circulardependency/{CircularDependencyB => CircularDependencyB.java} (100%) create mode 100644 spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyIntegrationTest.java delete mode 100644 spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyTest rename spring-mvc-java/src/test/java/com/baeldung/circulardependency/{TestConfig => TestConfig.java} (100%) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 8248343105..011de70ad2 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -208,28 +208,44 @@ - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - - jetty8x - embedded - - - - - - - 8082 - - - - + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + 4.2.5.RELEASE diff --git a/spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyA b/spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyA.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyA rename to spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyA.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyB b/spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyB.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyB rename to spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyB.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyIntegrationTest.java new file mode 100644 index 0000000000..42847f4dd1 --- /dev/null +++ b/spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyIntegrationTest.java @@ -0,0 +1,35 @@ +package com.baeldung.circulardependency; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { TestConfig.class }) +public class CircularDependencyIntegrationTest { + + @Autowired + ApplicationContext context; + + @Bean + public CircularDependencyA getCircularDependencyA() { + return new CircularDependencyA(); + } + + @Bean + public CircularDependencyB getCircularDependencyB() { + return new CircularDependencyB(); + } + + @Test + public void givenCircularDependency_whenSetterInjection_thenItWorks() { + final CircularDependencyA circA = context.getBean(CircularDependencyA.class); + + Assert.assertEquals("Hi!", circA.getCircB().getMessage()); + } +} diff --git a/spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyTest b/spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyTest deleted file mode 100644 index 4229f21f10..0000000000 --- a/spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyTest +++ /dev/null @@ -1,35 +0,0 @@ -package com.baeldung.circulardependency; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { TestConfig.class }) -public class CircularDependencyTest { - - @Autowired - ApplicationContext context; - - @Bean - public CircularDependencyA getCircularDependencyA() { - return new CircularDependencyA(); - } - - @Bean - public CircularDependencyB getCircularDependencyB() { - return new CircularDependencyB(); - } - - @Test - public void givenCircularDependency_whenSetterInjection_thenItWorks() { - final CircularDependencyA circA = context.getBean(CircularDependencyA.class); - - Assert.assertEquals("Hi!", circA.getCircB().getMessage()); - } -} diff --git a/spring-mvc-java/src/test/java/com/baeldung/circulardependency/TestConfig b/spring-mvc-java/src/test/java/com/baeldung/circulardependency/TestConfig.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/circulardependency/TestConfig rename to spring-mvc-java/src/test/java/com/baeldung/circulardependency/TestConfig.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringIntegrationTest.java index 7a23908fe5..406975b6cc 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringIntegrationTest.java +++ b/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringIntegrationTest.java @@ -5,6 +5,7 @@ import java.net.MalformedURLException; import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -39,9 +40,10 @@ public class HtmlUnitAndSpringIntegrationTest { // @Test + @Ignore("Related view message.html does not exist check MessageController") public void givenAMessage_whenSent_thenItShows() throws FailingHttpStatusCodeException, MalformedURLException, IOException { final String text = "Hello world!"; - HtmlPage page = webClient.getPage("http://localhost/message/showForm"); + final HtmlPage page = webClient.getPage("http://localhost/message/showForm"); System.out.println(page.asXml()); final HtmlTextInput messageText = page.getHtmlElementById("message"); From fd1a5796a91be4db4d30c2166c98e4a94a39046d Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 20 Oct 2016 23:10:14 +0200 Subject: [PATCH 21/52] Refactor Screenshot examples --- .../com/baeldung/printscreen/Screenshot.java | 13 +++++------- .../baeldung/printscreen/ScreenshotTest.java | 21 ++++--------------- .../ehcache/SquareCalculatorTest.java | 18 ++++++++-------- 3 files changed, 18 insertions(+), 34 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java b/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java index 500860640a..7c29a61842 100644 --- a/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java +++ b/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java @@ -7,20 +7,17 @@ import java.io.File; public class Screenshot { - private String filePath; - private String filenamePrefix; - private String fileType; - private int timeToWait; + private final String filePath; + private final String filenamePrefix; + private final String fileType; - public Screenshot(String filePath, String filenamePrefix, - String fileType, int timeToWait) { + public Screenshot(String filePath, String filenamePrefix, String fileType) { this.filePath = filePath; this.filenamePrefix = filenamePrefix; this.fileType = fileType; - this.timeToWait = timeToWait; } - public void getScreenshot() throws Exception { + public void getScreenshot(int timeToWait) throws Exception { Thread.sleep(timeToWait); Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); Robot robot = new Robot(); diff --git a/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java b/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java index 5c0341cb36..895f514f4a 100644 --- a/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java +++ b/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java @@ -1,34 +1,21 @@ package com.baeldung.printscreen; import org.junit.After; -import org.junit.Before; import org.junit.Test; import java.io.File; -import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; public class ScreenshotTest { - private Screenshot screenshot; - private String filePath; - private String fileName; - private String fileType; - private File file; - - @Before - public void setUp() throws Exception { - filePath = ""; - fileName = "Screenshot"; - fileType = "jpg"; - file = new File(filePath + fileName + "." + fileType); - screenshot = new Screenshot(filePath, fileName, fileType, 2000); - } + private Screenshot screenshot = new Screenshot("", "Screenshot", "jpg"); + private File file = new File("Screenshot.jpg"); @Test public void testGetScreenshot() throws Exception { - screenshot.getScreenshot(); + screenshot.getScreenshot(2000); assertTrue(file.exists()); } diff --git a/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorTest.java b/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorTest.java index 875fd2a25e..ab7aebf7a1 100644 --- a/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorTest.java +++ b/spring-all/src/test/java/org/baeldung/ehcache/SquareCalculatorTest.java @@ -1,20 +1,20 @@ package org.baeldung.ehcache; -import static org.junit.Assert.*; - import org.baeldung.ehcache.calculator.SquaredCalculator; import org.baeldung.ehcache.config.CacheHelper; import org.junit.Before; import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class SquareCalculatorTest { - SquaredCalculator squaredCalculator = new SquaredCalculator(); - CacheHelper cacheHelper = new CacheHelper(); + private SquaredCalculator squaredCalculator = new SquaredCalculator(); + private CacheHelper cacheHelper = new CacheHelper(); @Before public void setup() { squaredCalculator.setCache(cacheHelper); - } @Test @@ -22,7 +22,7 @@ public class SquareCalculatorTest { for (int i = 10; i < 15; i++) { assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); System.out.println("Square value of " + i + " is: " - + squaredCalculator.getSquareValueOfNumber(i) + "\n"); + + squaredCalculator.getSquareValueOfNumber(i) + "\n"); } } @@ -31,13 +31,13 @@ public class SquareCalculatorTest { for (int i = 10; i < 15; i++) { assertFalse(cacheHelper.getSquareNumberCache().containsKey(i)); System.out.println("Square value of " + i + " is: " - + squaredCalculator.getSquareValueOfNumber(i) + "\n"); + + squaredCalculator.getSquareValueOfNumber(i) + "\n"); } - + for (int i = 10; i < 15; i++) { assertTrue(cacheHelper.getSquareNumberCache().containsKey(i)); System.out.println("Square value of " + i + " is: " - + squaredCalculator.getSquareValueOfNumber(i) + "\n"); + + squaredCalculator.getSquareValueOfNumber(i) + "\n"); } } } From 89754421a293f8882b6b7cb4f632d5a027c67db6 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 20 Oct 2016 23:14:05 +0200 Subject: [PATCH 22/52] Refactor Screenshot examples 2 --- .../com/baeldung/printscreen/Screenshot.java | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java b/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java index 7c29a61842..27fd84e374 100644 --- a/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java +++ b/core-java/src/main/java/com/baeldung/printscreen/Screenshot.java @@ -7,14 +7,10 @@ import java.io.File; public class Screenshot { - private final String filePath; - private final String filenamePrefix; - private final String fileType; + private final String path; - public Screenshot(String filePath, String filenamePrefix, String fileType) { - this.filePath = filePath; - this.filenamePrefix = filenamePrefix; - this.fileType = fileType; + public Screenshot(String path) { + this.path = path; } public void getScreenshot(int timeToWait) throws Exception { @@ -22,14 +18,6 @@ public class Screenshot { Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); Robot robot = new Robot(); BufferedImage img = robot.createScreenCapture(rectangle); - ImageIO.write(img, fileType, setupFileNamePath()); - } - - private File setupFileNamePath() { - return new File(filePath + filenamePrefix + "." + fileType); - } - - private Rectangle getScreenSizedRectangle(final Dimension d) { - return new Rectangle(0, 0, d.width, d.height); + ImageIO.write(img, "jpg", new File(path)); } } From 1018c4b3fb3acedac854011e69cac0c925560284 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 20 Oct 2016 23:18:50 +0200 Subject: [PATCH 23/52] Refactor JedisTest --- .../src/test/java/com/baeldung/JedisTest.java | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/redis/src/test/java/com/baeldung/JedisTest.java b/redis/src/test/java/com/baeldung/JedisTest.java index 766fd7b5e9..582bb266aa 100644 --- a/redis/src/test/java/com/baeldung/JedisTest.java +++ b/redis/src/test/java/com/baeldung/JedisTest.java @@ -1,28 +1,15 @@ package com.baeldung; +import org.junit.*; +import redis.clients.jedis.*; +import redis.embedded.RedisServer; + import java.io.IOException; import java.time.Duration; import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import redis.clients.jedis.Jedis; -import redis.clients.jedis.JedisPool; -import redis.clients.jedis.JedisPoolConfig; -import redis.clients.jedis.Pipeline; -import redis.clients.jedis.Response; -import redis.clients.jedis.Transaction; -import redis.embedded.RedisServer; - -/** - * Unit test for Redis Java library - Jedis. - */ public class JedisTest { private Jedis jedis; @@ -140,9 +127,9 @@ public class JedisTest { scores.put("PlayerTwo", 1500.0); scores.put("PlayerThree", 8200.0); - for (String player : scores.keySet()) { + scores.keySet().forEach(player -> { jedis.zadd(key, scores.get(player), player); - } + }); Set players = jedis.zrevrange(key, 0, 1); Assert.assertEquals("PlayerThree", players.iterator().next()); From 395a6731d9a1bfac956c820ca8e86f0b3f0026ea Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 21 Oct 2016 00:11:19 +0200 Subject: [PATCH 24/52] add integration test profile --- rest-testing/pom.xml | 42 +++++++++++++++++++ ...Test.java => CucumberIntegrationTest.java} | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) rename rest-testing/src/test/java/com/baeldung/rest/cucumber/{CucumberTest.java => CucumberIntegrationTest.java} (84%) diff --git a/rest-testing/pom.xml b/rest-testing/pom.xml index 819e8de8a5..90c160af15 100644 --- a/rest-testing/pom.xml +++ b/rest-testing/pom.xml @@ -148,12 +148,54 @@ 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 + + + + **/*UnitTest.java + + + **/*IntegrationTest.java + **/*LiveTest.java + + + + + + + json + + + + + + + + 2.7.8 diff --git a/rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberTest.java b/rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberIntegrationTest.java similarity index 84% rename from rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberTest.java rename to rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberIntegrationTest.java index 041de592e9..f80178a43d 100644 --- a/rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberTest.java +++ b/rest-testing/src/test/java/com/baeldung/rest/cucumber/CucumberIntegrationTest.java @@ -6,5 +6,5 @@ import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions(features = "classpath:Feature") -public class CucumberTest { +public class CucumberIntegrationTest { } \ No newline at end of file From 13cf6590ba0e0e5738a6cf8c7d51b35503a4010a Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 21 Oct 2016 00:24:15 +0200 Subject: [PATCH 25/52] add integration test profile --- querydsl/pom.xml | 49 +++++++++++++++++++ ...est.java => PersonDaoIntegrationTest.java} | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) rename querydsl/src/test/java/org/baeldung/dao/{PersonDaoTest.java => PersonDaoIntegrationTest.java} (98%) diff --git a/querydsl/pom.xml b/querydsl/pom.xml index bed0cf90e5..13528526ea 100644 --- a/querydsl/pom.xml +++ b/querydsl/pom.xml @@ -20,6 +20,7 @@ 5.2.1.Final 4.1.3 1.7.21 + 2.19.1 @@ -166,7 +167,55 @@ + + + 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 + + + + + + + + \ No newline at end of file diff --git a/querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java b/querydsl/src/test/java/org/baeldung/dao/PersonDaoIntegrationTest.java similarity index 98% rename from querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java rename to querydsl/src/test/java/org/baeldung/dao/PersonDaoIntegrationTest.java index 0e5996a8c8..a666aea8da 100644 --- a/querydsl/src/test/java/org/baeldung/dao/PersonDaoTest.java +++ b/querydsl/src/test/java/org/baeldung/dao/PersonDaoIntegrationTest.java @@ -17,7 +17,7 @@ import junit.framework.Assert; @RunWith(SpringJUnit4ClassRunner.class) @Transactional @TransactionConfiguration(defaultRollback = true) -public class PersonDaoTest { +public class PersonDaoIntegrationTest { @Autowired private PersonDao personDao; From 60d60508c38580ddcb2763794b895d152be4b784 Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 21 Oct 2016 13:08:10 +0200 Subject: [PATCH 26/52] add integration test profile --- mapstruct/pom.xml | 52 ++++++++++++++++++- ...urceDestinationMapperIntegrationTest.java} | 2 +- 2 files changed, 51 insertions(+), 3 deletions(-) rename mapstruct/src/test/java/com/baeldung/mapper/{SimpleSourceDestinationMapperTest.java => SimpleSourceDestinationMapperIntegrationTest.java} (96%) diff --git a/mapstruct/pom.xml b/mapstruct/pom.xml index 4159ef35c9..aaa3e95f8c 100644 --- a/mapstruct/pom.xml +++ b/mapstruct/pom.xml @@ -55,6 +55,54 @@ - - + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + **/*IntegrationTest.java + **/*LiveTest.java + + + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + diff --git a/mapstruct/src/test/java/com/baeldung/mapper/SimpleSourceDestinationMapperTest.java b/mapstruct/src/test/java/com/baeldung/mapper/SimpleSourceDestinationMapperIntegrationTest.java similarity index 96% rename from mapstruct/src/test/java/com/baeldung/mapper/SimpleSourceDestinationMapperTest.java rename to mapstruct/src/test/java/com/baeldung/mapper/SimpleSourceDestinationMapperIntegrationTest.java index a7addf33a7..31d60c0d7d 100644 --- a/mapstruct/src/test/java/com/baeldung/mapper/SimpleSourceDestinationMapperTest.java +++ b/mapstruct/src/test/java/com/baeldung/mapper/SimpleSourceDestinationMapperIntegrationTest.java @@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:applicationContext.xml") -public class SimpleSourceDestinationMapperTest { +public class SimpleSourceDestinationMapperIntegrationTest { @Autowired SimpleSourceDestinationMapper simpleSourceDestinationMapper; From 60a1c5f481e2db0911cbaf7b4106bd95b63c5d71 Mon Sep 17 00:00:00 2001 From: DOHA Date: Fri, 21 Oct 2016 14:02:01 +0200 Subject: [PATCH 27/52] add integration test profile --- jooq-spring/pom.xml | 47 +++++++++++++++++++ ...=> PersistenceContextIntegrationTest.java} | 2 +- ...eryTest.java => QueryIntegrationTest.java} | 4 +- ...st.java => SpringBootIntegrationTest.java} | 2 +- 4 files changed, 51 insertions(+), 4 deletions(-) rename jooq-spring/src/test/java/com/baeldung/jooq/introduction/{PersistenceContext.java => PersistenceContextIntegrationTest.java} (98%) rename jooq-spring/src/test/java/com/baeldung/jooq/introduction/{QueryTest.java => QueryIntegrationTest.java} (97%) rename jooq-spring/src/test/java/com/baeldung/jooq/springboot/{SpringBootTest.java => SpringBootIntegrationTest.java} (99%) diff --git a/jooq-spring/pom.xml b/jooq-spring/pom.xml index e77ff0cbfd..96a3de11db 100644 --- a/jooq-spring/pom.xml +++ b/jooq-spring/pom.xml @@ -161,9 +161,55 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + **/*LiveTest.java + + + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + 3.7.3 1.4.191 @@ -173,6 +219,7 @@ 4.12 3.5.1 + 2.19.1 \ No newline at end of file diff --git a/jooq-spring/src/test/java/com/baeldung/jooq/introduction/PersistenceContext.java b/jooq-spring/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java similarity index 98% rename from jooq-spring/src/test/java/com/baeldung/jooq/introduction/PersistenceContext.java rename to jooq-spring/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java index df628f9f78..06290ae8db 100644 --- a/jooq-spring/src/test/java/com/baeldung/jooq/introduction/PersistenceContext.java +++ b/jooq-spring/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java @@ -22,7 +22,7 @@ import javax.sql.DataSource; @ComponentScan({ "com.baeldung.jooq.introduction.db.public_.tables" }) @EnableTransactionManagement @PropertySource("classpath:intro_config.properties") -public class PersistenceContext { +public class PersistenceContextIntegrationTest { @Autowired private Environment environment; diff --git a/jooq-spring/src/test/java/com/baeldung/jooq/introduction/QueryTest.java b/jooq-spring/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java similarity index 97% rename from jooq-spring/src/test/java/com/baeldung/jooq/introduction/QueryTest.java rename to jooq-spring/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java index 68f975dd6d..28bc4c63c7 100644 --- a/jooq-spring/src/test/java/com/baeldung/jooq/introduction/QueryTest.java +++ b/jooq-spring/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java @@ -17,10 +17,10 @@ import static com.baeldung.jooq.introduction.db.public_.tables.AuthorBook.AUTHOR import static com.baeldung.jooq.introduction.db.public_.tables.Book.BOOK; import static org.junit.Assert.assertEquals; -@ContextConfiguration(classes = PersistenceContext.class) +@ContextConfiguration(classes = PersistenceContextIntegrationTest.class) @Transactional(transactionManager = "transactionManager") @RunWith(SpringJUnit4ClassRunner.class) -public class QueryTest { +public class QueryIntegrationTest { @Autowired private DSLContext dsl; diff --git a/jooq-spring/src/test/java/com/baeldung/jooq/springboot/SpringBootTest.java b/jooq-spring/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java similarity index 99% rename from jooq-spring/src/test/java/com/baeldung/jooq/springboot/SpringBootTest.java rename to jooq-spring/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java index f9427f30fb..fa3f342ecd 100644 --- a/jooq-spring/src/test/java/com/baeldung/jooq/springboot/SpringBootTest.java +++ b/jooq-spring/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals; @SpringApplicationConfiguration(Application.class) @Transactional("transactionManager") @RunWith(SpringJUnit4ClassRunner.class) -public class SpringBootTest { +public class SpringBootIntegrationTest { @Autowired private DSLContext dsl; From 1d3ac0836f12ccb5a59fb619b2bcfd339e89fbaa Mon Sep 17 00:00:00 2001 From: Eugen Date: Fri, 21 Oct 2016 20:50:38 +0300 Subject: [PATCH 28/52] Update README.md --- spring-all/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-all/README.md b/spring-all/README.md index aae98440f3..90ae69300a 100644 --- a/spring-all/README.md +++ b/spring-all/README.md @@ -15,3 +15,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Guide To Running Logic on Startup in Spring](http://www.baeldung.com/running-setup-logic-on-startup-in-spring) - [Quick Guide to Spring Controllers](http://www.baeldung.com/spring-controllers) - [Quick Guide to Spring Bean Scopes](http://www.baeldung.com/spring-bean-scopes) +- [Introduction To Ehcache](http://www.baeldung.com/ehcache) From d55903a667e6d494c4dbdc9d68108bcd6dc9c695 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Sat, 22 Oct 2016 07:16:14 +0200 Subject: [PATCH 29/52] BAEL-276 - URL encoding --- .../encoderdecoder/EncoderDecoder.java | 72 +++++++++++++++---- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/core-java-8/src/test/java/com/baeldung/encoderdecoder/EncoderDecoder.java b/core-java-8/src/test/java/com/baeldung/encoderdecoder/EncoderDecoder.java index 62d2663994..208a23eb91 100644 --- a/core-java-8/src/test/java/com/baeldung/encoderdecoder/EncoderDecoder.java +++ b/core-java-8/src/test/java/com/baeldung/encoderdecoder/EncoderDecoder.java @@ -3,36 +3,82 @@ package com.baeldung.encoderdecoder; import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; public class EncoderDecoder { - @Test - public void givenPlainURL_whenUsingUTF8EncodingScheme_thenEncodeURL() throws UnsupportedEncodingException { - String plainURL = "http://www.baeldung.com" ; - String encodedURL = URLEncoder.encode(plainURL, StandardCharsets.UTF_8.toString()); + private static final String URL = "http://www.baeldung.com?key1=value+1&key2=value%40%21%242&key3=value%253"; + private static final Logger LOGGER = LoggerFactory.getLogger(EncoderDecoder.class); - Assert.assertThat("http%3A%2F%2Fwww.baeldung.com", CoreMatchers.is(encodedURL)); + private String encodeValue(String value) { + String encoded = null; + try { + encoded = URLEncoder.encode(value, StandardCharsets.UTF_8.toString()); + } catch (UnsupportedEncodingException e) { + LOGGER.error("Error encoding parameter {}", e.getMessage(), e); + } + return encoded; + } + + + private String decode(String value) { + String decoded = null; + try { + decoded = URLDecoder.decode(value, StandardCharsets.UTF_8.toString()); + } catch (UnsupportedEncodingException e) { + LOGGER.error("Error encoding parameter {}", e.getMessage(), e); + } + return decoded; } @Test - public void givenEncodedURL_whenUsingUTF8EncodingScheme_thenDecodeURL() throws UnsupportedEncodingException { - String encodedURL = "http%3A%2F%2Fwww.baeldung.com" ; - String decodedURL = URLDecoder.decode(encodedURL, StandardCharsets.UTF_8.toString()); + public void givenURL_whenAnalyze_thenCorrect() throws Exception { + URL url = new URL(URL); - Assert.assertThat("http://www.baeldung.com", CoreMatchers.is(decodedURL)); + Assert.assertThat(url.getProtocol(), CoreMatchers.is("http")); + Assert.assertThat(url.getHost(), CoreMatchers.is("www.baeldung.com")); + Assert.assertThat(url.getQuery(), CoreMatchers.is("key1=value+1&key2=value%40%21%242&key3=value%253")); } @Test - public void givenEncodedURL_whenUsingWrongEncodingScheme_thenDecodeInvalidURL() throws UnsupportedEncodingException { - String encodedURL = "http%3A%2F%2Fwww.baeldung.com"; + public void givenRequestParam_whenUTF8Scheme_thenEncode() throws Exception { + Map requestParams = new HashMap<>(); + requestParams.put("key1", "value 1"); + requestParams.put("key2", "value@!$2"); + requestParams.put("key3", "value%3"); - String decodedURL = URLDecoder.decode(encodedURL, StandardCharsets.UTF_16.toString()); + String encodedQuery = requestParams.keySet().stream() + .map(key -> key + "=" + encodeValue(requestParams.get(key))) + .collect(Collectors.joining("&")); + String encodedURL = "http://www.baeldung.com?" + encodedQuery; - Assert.assertFalse("http://www.baeldung.com".equals(decodedURL)); + Assert.assertThat(URL, CoreMatchers.is(encodedURL)); } + + @Test + public void givenRequestParam_whenUTF8Scheme_thenDecodeRequestParams() throws Exception { + URL url = new URL(URL); + String query = url.getQuery(); + + String decodedQuery = Arrays.stream(query.split("&")) + .map(param -> param.split("=")[0] + "=" + decode(param.split("=")[1])) + .collect(Collectors.joining("&")); + + Assert.assertEquals( + "http://www.baeldung.com?key1=value 1&key2=value@!$2&key3=value%3", url.getProtocol() + "://" + url.getHost() + "?" + decodedQuery); + } + } From 37ccb60f1d312e3de9049569e2d8c15c886fa3f7 Mon Sep 17 00:00:00 2001 From: ambrusadrianz Date: Sat, 22 Oct 2016 15:50:19 +0300 Subject: [PATCH 30/52] [BAEL-123] Created an example about custom AccessDecisionVoters in Spring Security. (#728) * Created an example about custom AccessDecisionVoters in Spring Security. * Added module in root pom file. * Added test cases --- pom.xml | 1 + spring-security-custom-voter/pom.xml | 96 +++++++++++++++++++ .../main/java/org/baeldung/Application.java | 12 +++ .../baeldung/security/MinuteBasedVoter.java | 38 ++++++++ .../baeldung/security/WebSecurityConfig.java | 69 +++++++++++++ .../baeldung/security/XmlSecurityConfig.java | 15 +++ .../main/java/org/baeldung/web/MvcConfig.java | 18 ++++ .../src/main/resources/spring-security.xml | 40 ++++++++ .../src/main/resources/templates/private.html | 10 ++ .../src/main/webapp/WEB-INF/web.xml | 47 +++++++++ .../test/java/org/baeldung/web/LiveTest.java | 42 ++++++++ 11 files changed, 388 insertions(+) create mode 100644 spring-security-custom-voter/pom.xml create mode 100644 spring-security-custom-voter/src/main/java/org/baeldung/Application.java create mode 100644 spring-security-custom-voter/src/main/java/org/baeldung/security/MinuteBasedVoter.java create mode 100644 spring-security-custom-voter/src/main/java/org/baeldung/security/WebSecurityConfig.java create mode 100644 spring-security-custom-voter/src/main/java/org/baeldung/security/XmlSecurityConfig.java create mode 100644 spring-security-custom-voter/src/main/java/org/baeldung/web/MvcConfig.java create mode 100644 spring-security-custom-voter/src/main/resources/spring-security.xml create mode 100644 spring-security-custom-voter/src/main/resources/templates/private.html create mode 100644 spring-security-custom-voter/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-security-custom-voter/src/test/java/org/baeldung/web/LiveTest.java diff --git a/pom.xml b/pom.xml index eee9f07ab9..9979ff95a5 100644 --- a/pom.xml +++ b/pom.xml @@ -107,6 +107,7 @@ spring-security-basic-auth spring-security-custom-permission + spring-security-custom-voter spring-security-mvc-custom spring-security-mvc-digest-auth spring-security-mvc-ldap diff --git a/spring-security-custom-voter/pom.xml b/spring-security-custom-voter/pom.xml new file mode 100644 index 0000000000..727efa48ab --- /dev/null +++ b/spring-security-custom-voter/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + org.baeldung + spring-security-custom-voter + 0.0.1-SNAPSHOT + war + + spring-security-custom-voter + Custom AccessDecisionVoter with Spring Security + + + org.springframework.boot + spring-boot-starter-parent + 1.4.1.RELEASE + + + + + UTF-8 + UTF-8 + 3.0.1 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + junit + junit + test + + + + org.hamcrest + hamcrest-core + test + + + + org.hamcrest + hamcrest-library + test + + + + org.springframework + spring-test + 4.3.3.RELEASE + + + + org.springframework.security + spring-security-test + 4.1.3.RELEASE + test + + + + org.springframework.security + spring-security-web + 4.1.3.RELEASE + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/spring-security-custom-voter/src/main/java/org/baeldung/Application.java b/spring-security-custom-voter/src/main/java/org/baeldung/Application.java new file mode 100644 index 0000000000..a9d6f3b8b1 --- /dev/null +++ b/spring-security-custom-voter/src/main/java/org/baeldung/Application.java @@ -0,0 +1,12 @@ +package org.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/spring-security-custom-voter/src/main/java/org/baeldung/security/MinuteBasedVoter.java b/spring-security-custom-voter/src/main/java/org/baeldung/security/MinuteBasedVoter.java new file mode 100644 index 0000000000..8d22c52b0d --- /dev/null +++ b/spring-security-custom-voter/src/main/java/org/baeldung/security/MinuteBasedVoter.java @@ -0,0 +1,38 @@ +package org.baeldung.security; + +import org.springframework.security.access.AccessDecisionVoter; +import org.springframework.security.access.ConfigAttribute; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; + +import java.time.LocalDateTime; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class MinuteBasedVoter implements AccessDecisionVoter { + @Override + public boolean supports(ConfigAttribute attribute) { + return true; + } + + @Override + public boolean supports(Class clazz) { + return true; + } + + @Override + public int vote(Authentication authentication, Object object, Collection collection) { + List roles = authentication + .getAuthorities() + .stream().map(GrantedAuthority::getAuthority) + .collect(Collectors.toList()); + + for (String role: roles) { + if ("ROLE_USER".equals(role) && LocalDateTime.now().getMinute() % 2 != 0) { + return ACCESS_DENIED; + } + } + return ACCESS_ABSTAIN; + } +} diff --git a/spring-security-custom-voter/src/main/java/org/baeldung/security/WebSecurityConfig.java b/spring-security-custom-voter/src/main/java/org/baeldung/security/WebSecurityConfig.java new file mode 100644 index 0000000000..b3fb196424 --- /dev/null +++ b/spring-security-custom-voter/src/main/java/org/baeldung/security/WebSecurityConfig.java @@ -0,0 +1,69 @@ +package org.baeldung.security; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.access.AccessDecisionManager; +import org.springframework.security.access.AccessDecisionVoter; +import org.springframework.security.access.vote.AuthenticatedVoter; +import org.springframework.security.access.vote.RoleVoter; +import org.springframework.security.access.vote.UnanimousBased; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.access.expression.WebExpressionVoter; +import org.springframework.security.web.util.matcher.AntPathRequestMatcher; + +import java.util.Arrays; +import java.util.List; + +@Configuration +@EnableWebSecurity +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + @Autowired + public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { + // @formatter: off + auth.inMemoryAuthentication() + .withUser("user").password("pass").roles("USER") + .and() + .withUser("admin").password("pass").roles("ADMIN"); + // @formatter: on + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + // @formatter: off + http + // needed so our login could work + .csrf() + .disable() + .authorizeRequests() + .anyRequest() + .authenticated() + .accessDecisionManager(accessDecisionManager()) + .antMatchers("/").hasAnyRole("ROLE_ADMIN", "ROLE_USER") + .and() + .formLogin() + .permitAll() + .and() + .logout() + .permitAll() + .deleteCookies("JSESSIONID") + .logoutSuccessUrl("/login"); + // @formatter: on + } + + @Bean + public AccessDecisionManager accessDecisionManager() { + // @formatter: off + List> decisionVoters = + Arrays.asList( + new WebExpressionVoter(), + new RoleVoter(), + new AuthenticatedVoter(), + new MinuteBasedVoter()); + // @formatter: on + return new UnanimousBased(decisionVoters); + } +} diff --git a/spring-security-custom-voter/src/main/java/org/baeldung/security/XmlSecurityConfig.java b/spring-security-custom-voter/src/main/java/org/baeldung/security/XmlSecurityConfig.java new file mode 100644 index 0000000000..45e095c66e --- /dev/null +++ b/spring-security-custom-voter/src/main/java/org/baeldung/security/XmlSecurityConfig.java @@ -0,0 +1,15 @@ +package org.baeldung.security; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; + +/** + * Created by ambrusadrianz on 09/10/2016. + */ +@Configuration +//@ImportResource({"classpath:spring-security.xml"}) +public class XmlSecurityConfig { + public XmlSecurityConfig() { + super(); + } +} diff --git a/spring-security-custom-voter/src/main/java/org/baeldung/web/MvcConfig.java b/spring-security-custom-voter/src/main/java/org/baeldung/web/MvcConfig.java new file mode 100644 index 0000000000..5d38dca1ff --- /dev/null +++ b/spring-security-custom-voter/src/main/java/org/baeldung/web/MvcConfig.java @@ -0,0 +1,18 @@ +package org.baeldung.web; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +/** + * Created by ambrusadrianz on 30/09/2016. + */ + +@Configuration +public class MvcConfig extends WebMvcConfigurerAdapter { + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/").setViewName("private"); + } +} diff --git a/spring-security-custom-voter/src/main/resources/spring-security.xml b/spring-security-custom-voter/src/main/resources/spring-security.xml new file mode 100644 index 0000000000..117638289e --- /dev/null +++ b/spring-security-custom-voter/src/main/resources/spring-security.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-security-custom-voter/src/main/resources/templates/private.html b/spring-security-custom-voter/src/main/resources/templates/private.html new file mode 100644 index 0000000000..5af8c7a13e --- /dev/null +++ b/spring-security-custom-voter/src/main/resources/templates/private.html @@ -0,0 +1,10 @@ + + + + Private + + +

Congrats!

+ + \ No newline at end of file diff --git a/spring-security-custom-voter/src/main/webapp/WEB-INF/web.xml b/spring-security-custom-voter/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..d69bce35ae --- /dev/null +++ b/spring-security-custom-voter/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,47 @@ + + + + Spring Secured Application + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + org.baeldung.spring.web.config + + + + org.springframework.web.context.ContextLoaderListener + + + + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + + + \ No newline at end of file diff --git a/spring-security-custom-voter/src/test/java/org/baeldung/web/LiveTest.java b/spring-security-custom-voter/src/test/java/org/baeldung/web/LiveTest.java new file mode 100644 index 0000000000..3ddeab5920 --- /dev/null +++ b/spring-security-custom-voter/src/test/java/org/baeldung/web/LiveTest.java @@ -0,0 +1,42 @@ +package org.baeldung.web; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.formLogin; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.user; +import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.authenticated; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration @WebAppConfiguration @SpringBootTest public class LiveTest { + @Autowired private WebApplicationContext context; + + private MockMvc mvc; + + @Before public void setup() { + mvc = MockMvcBuilders.webAppContextSetup(context).apply(springSecurity()).build(); + } + + @Test public void givenUnauthenticatedUser_whenAccessingMainPage_thenRedirect() throws Exception { + mvc.perform(get("/")).andExpect(status().is3xxRedirection()); + } + + @Test public void givenValidUsernameAndPassword_whenLogin_thenOK() throws Exception { + mvc.perform(formLogin("/login").user("user").password("pass")).andExpect(authenticated()); + } + + @Test public void givenAuthenticatedAdmin_whenAccessingMainPage_thenOK() throws Exception { + mvc.perform(get("/").with(user("admin").password("pass").roles("ADMIN"))).andExpect(status().isOk()); + } +} From 18dfed06d0c68fe46eeffc0d7730a64d49d76f75 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 22 Oct 2016 15:08:10 +0200 Subject: [PATCH 31/52] add integration test profile --- jjwt/pom.xml | 49 +++++++++++++++++-- ...va => DemoApplicationIntegrationTest.java} | 2 +- 2 files changed, 47 insertions(+), 4 deletions(-) rename jjwt/src/test/java/io/jsonwebtoken/jjwtfun/{DemoApplicationTests.java => DemoApplicationIntegrationTest.java} (91%) diff --git a/jjwt/pom.xml b/jjwt/pom.xml index 24f1c5c5ab..d2a3f1cdd8 100644 --- a/jjwt/pom.xml +++ b/jjwt/pom.xml @@ -58,8 +58,51 @@ org.springframework.boot spring-boot-maven-plugin + + org.apache.maven.plugins + maven-surefire-plugin + + + **/*IntegrationTest.java + **/*LiveTest.java + + + - - - + + + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + diff --git a/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationTests.java b/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationIntegrationTest.java similarity index 91% rename from jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationTests.java rename to jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationIntegrationTest.java index 82138ea23e..df147232d9 100644 --- a/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationTests.java +++ b/jjwt/src/test/java/io/jsonwebtoken/jjwtfun/DemoApplicationIntegrationTest.java @@ -9,7 +9,7 @@ import org.springframework.test.context.web.WebAppConfiguration; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = JJWTFunApplication.class) @WebAppConfiguration -public class DemoApplicationTests { +public class DemoApplicationIntegrationTest { @Test public void contextLoads() { From d60874a90d873b334f46c7d08190fb3d941c0387 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 22 Oct 2016 17:01:45 +0200 Subject: [PATCH 32/52] add integration test profile --- java-cassandra/pom.xml | 49 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/java-cassandra/pom.xml b/java-cassandra/pom.xml index a91c3b9b62..92d3a8ede6 100644 --- a/java-cassandra/pom.xml +++ b/java-cassandra/pom.xml @@ -76,8 +76,54 @@ 1.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 + + + + + + + UTF-8 @@ -97,6 +143,7 @@ 3.5.1 + 2.19.1 3.1.0 From 5c7d521402e858d532255ce506b628f447705c13 Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 22 Oct 2016 17:07:54 +0200 Subject: [PATCH 33/52] add integration test profile --- hystrix/pom.xml | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/hystrix/pom.xml b/hystrix/pom.xml index 42828e1c97..54c17f1487 100644 --- a/hystrix/pom.xml +++ b/hystrix/pom.xml @@ -112,9 +112,54 @@ 1.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 + + + + + + + From c9b956e9b949561ee557b7a8b886b3411568f4da Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 22 Oct 2016 17:21:26 +0200 Subject: [PATCH 34/52] add integration test profile --- dependency-injection/pom.xml | 42 +++++++++++++++++-- ...ava => FieldAutowiredIntegrationTest.java} | 2 +- ...=> FieldAutowiredNameIntegrationTest.java} | 2 +- ...eldQualifierAutowiredIntegrationTest.java} | 2 +- ... => FieldByNameInjectIntegrationTest.java} | 2 +- ...t.java => FieldInjectIntegrationTest.java} | 2 +- ... FieldQualifierInjectIntegrationTest.java} | 2 +- ...ieldResourceInjectionIntegrationTest.java} | 2 +- ...odByQualifierResourceIntegrationTest.java} | 2 +- ... MethodByTypeResourceIntegrationTest.java} | 2 +- ...thodResourceInjectionIntegrationTest.java} | 2 +- ...java => NamedResourceIntegrationTest.java} | 2 +- ...fierResourceInjectionIntegrationTest.java} | 2 +- ...tterResourceInjectionIntegrationTest.java} | 2 +- 14 files changed, 52 insertions(+), 16 deletions(-) rename dependency-injection/src/test/java/com/baeldung/autowired/{FieldAutowiredTest.java => FieldAutowiredIntegrationTest.java} (95%) rename dependency-injection/src/test/java/com/baeldung/autowired/{FieldAutowiredNameTest.java => FieldAutowiredNameIntegrationTest.java} (95%) rename dependency-injection/src/test/java/com/baeldung/autowired/{FieldQualifierAutowiredTest.java => FieldQualifierAutowiredIntegrationTest.java} (96%) rename dependency-injection/src/test/java/com/baeldung/inject/{FieldByNameInjectTest.java => FieldByNameInjectIntegrationTest.java} (95%) rename dependency-injection/src/test/java/com/baeldung/inject/{FieldInjectTest.java => FieldInjectIntegrationTest.java} (95%) rename dependency-injection/src/test/java/com/baeldung/inject/{FieldQualifierInjectTest.java => FieldQualifierInjectIntegrationTest.java} (96%) rename dependency-injection/src/test/java/com/baeldung/resource/{FieldResourceInjectionTest.java => FieldResourceInjectionIntegrationTest.java} (94%) rename dependency-injection/src/test/java/com/baeldung/resource/{MethodByQualifierResourceTest.java => MethodByQualifierResourceIntegrationTest.java} (96%) rename dependency-injection/src/test/java/com/baeldung/resource/{MethodByTypeResourceTest.java => MethodByTypeResourceIntegrationTest.java} (95%) rename dependency-injection/src/test/java/com/baeldung/resource/{MethodResourceInjectionTest.java => MethodResourceInjectionIntegrationTest.java} (95%) rename dependency-injection/src/test/java/com/baeldung/resource/{NamedResourceTest.java => NamedResourceIntegrationTest.java} (95%) rename dependency-injection/src/test/java/com/baeldung/resource/{QualifierResourceInjectionTest.java => QualifierResourceInjectionIntegrationTest.java} (95%) rename dependency-injection/src/test/java/com/baeldung/resource/{SetterResourceInjectionTest.java => SetterResourceInjectionIntegrationTest.java} (95%) diff --git a/dependency-injection/pom.xml b/dependency-injection/pom.xml index 9e78a66ad6..9b94ba7b35 100644 --- a/dependency-injection/pom.xml +++ b/dependency-injection/pom.xml @@ -66,9 +66,10 @@ org.apache.maven.plugins maven-surefire-plugin - - **/*Test.java - + + **/*IntegrationTest.java + **/*LiveTest.java + @@ -85,6 +86,41 @@ + + + integration + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*LiveTest.java + + + **/*IntegrationTest.java + + + + + + + json + + + + + + + + 2.6 diff --git a/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredTest.java b/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredIntegrationTest.java similarity index 95% rename from dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredTest.java rename to dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredIntegrationTest.java index b736871f85..a78799f1d9 100644 --- a/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredTest.java +++ b/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredIntegrationTest.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestAutowiredType.class) -public class FieldAutowiredTest { +public class FieldAutowiredIntegrationTest { @Autowired private ArbitraryDependency fieldDependency; diff --git a/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredNameTest.java b/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredNameIntegrationTest.java similarity index 95% rename from dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredNameTest.java rename to dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredNameIntegrationTest.java index cbdac68543..8f09e73c33 100644 --- a/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredNameTest.java +++ b/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredNameIntegrationTest.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestAutowiredName.class) -public class FieldAutowiredNameTest { +public class FieldAutowiredNameIntegrationTest { @Autowired private ArbitraryDependency autowiredFieldDependency; diff --git a/dependency-injection/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredTest.java b/dependency-injection/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredIntegrationTest.java similarity index 96% rename from dependency-injection/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredTest.java rename to dependency-injection/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredIntegrationTest.java index cbc3d56f67..01317aef6f 100644 --- a/dependency-injection/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredTest.java +++ b/dependency-injection/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestAutowiredQualifier.class) -public class FieldQualifierAutowiredTest { +public class FieldQualifierAutowiredIntegrationTest { @Autowired @Qualifier("autowiredFieldDependency") diff --git a/dependency-injection/src/test/java/com/baeldung/inject/FieldByNameInjectTest.java b/dependency-injection/src/test/java/com/baeldung/inject/FieldByNameInjectIntegrationTest.java similarity index 95% rename from dependency-injection/src/test/java/com/baeldung/inject/FieldByNameInjectTest.java rename to dependency-injection/src/test/java/com/baeldung/inject/FieldByNameInjectIntegrationTest.java index 665c9f1ddc..f5897febab 100644 --- a/dependency-injection/src/test/java/com/baeldung/inject/FieldByNameInjectTest.java +++ b/dependency-injection/src/test/java/com/baeldung/inject/FieldByNameInjectIntegrationTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestInjectName.class) -public class FieldByNameInjectTest { +public class FieldByNameInjectIntegrationTest { @Inject @Named("yetAnotherFieldInjectDependency") diff --git a/dependency-injection/src/test/java/com/baeldung/inject/FieldInjectTest.java b/dependency-injection/src/test/java/com/baeldung/inject/FieldInjectIntegrationTest.java similarity index 95% rename from dependency-injection/src/test/java/com/baeldung/inject/FieldInjectTest.java rename to dependency-injection/src/test/java/com/baeldung/inject/FieldInjectIntegrationTest.java index 7561c39e76..45b7c8015c 100644 --- a/dependency-injection/src/test/java/com/baeldung/inject/FieldInjectTest.java +++ b/dependency-injection/src/test/java/com/baeldung/inject/FieldInjectIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestInjectType.class) -public class FieldInjectTest { +public class FieldInjectIntegrationTest { @Inject private ArbitraryDependency fieldInjectDependency; diff --git a/dependency-injection/src/test/java/com/baeldung/inject/FieldQualifierInjectTest.java b/dependency-injection/src/test/java/com/baeldung/inject/FieldQualifierInjectIntegrationTest.java similarity index 96% rename from dependency-injection/src/test/java/com/baeldung/inject/FieldQualifierInjectTest.java rename to dependency-injection/src/test/java/com/baeldung/inject/FieldQualifierInjectIntegrationTest.java index 7e5f7e7453..0fd6a0e4c1 100644 --- a/dependency-injection/src/test/java/com/baeldung/inject/FieldQualifierInjectTest.java +++ b/dependency-injection/src/test/java/com/baeldung/inject/FieldQualifierInjectIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestInjectQualifier.class) -public class FieldQualifierInjectTest { +public class FieldQualifierInjectIntegrationTest { @Inject @Qualifier("defaultFile") diff --git a/dependency-injection/src/test/java/com/baeldung/resource/FieldResourceInjectionTest.java b/dependency-injection/src/test/java/com/baeldung/resource/FieldResourceInjectionIntegrationTest.java similarity index 94% rename from dependency-injection/src/test/java/com/baeldung/resource/FieldResourceInjectionTest.java rename to dependency-injection/src/test/java/com/baeldung/resource/FieldResourceInjectionIntegrationTest.java index ef7e7b0aeb..63a25cb499 100644 --- a/dependency-injection/src/test/java/com/baeldung/resource/FieldResourceInjectionTest.java +++ b/dependency-injection/src/test/java/com/baeldung/resource/FieldResourceInjectionIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestResourceNameType.class) -public class FieldResourceInjectionTest { +public class FieldResourceInjectionIntegrationTest { @Resource(name = "namedFile") private File defaultFile; diff --git a/dependency-injection/src/test/java/com/baeldung/resource/MethodByQualifierResourceTest.java b/dependency-injection/src/test/java/com/baeldung/resource/MethodByQualifierResourceIntegrationTest.java similarity index 96% rename from dependency-injection/src/test/java/com/baeldung/resource/MethodByQualifierResourceTest.java rename to dependency-injection/src/test/java/com/baeldung/resource/MethodByQualifierResourceIntegrationTest.java index 95e9fc0bd5..f5bb9f10cf 100644 --- a/dependency-injection/src/test/java/com/baeldung/resource/MethodByQualifierResourceTest.java +++ b/dependency-injection/src/test/java/com/baeldung/resource/MethodByQualifierResourceIntegrationTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestResourceQualifier.class) -public class MethodByQualifierResourceTest { +public class MethodByQualifierResourceIntegrationTest { private File arbDependency; private File anotherArbDependency; diff --git a/dependency-injection/src/test/java/com/baeldung/resource/MethodByTypeResourceTest.java b/dependency-injection/src/test/java/com/baeldung/resource/MethodByTypeResourceIntegrationTest.java similarity index 95% rename from dependency-injection/src/test/java/com/baeldung/resource/MethodByTypeResourceTest.java rename to dependency-injection/src/test/java/com/baeldung/resource/MethodByTypeResourceIntegrationTest.java index ad9a9a4fb6..171cbfea47 100644 --- a/dependency-injection/src/test/java/com/baeldung/resource/MethodByTypeResourceTest.java +++ b/dependency-injection/src/test/java/com/baeldung/resource/MethodByTypeResourceIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestResourceNameType.class) -public class MethodByTypeResourceTest { +public class MethodByTypeResourceIntegrationTest { private File defaultFile; diff --git a/dependency-injection/src/test/java/com/baeldung/resource/MethodResourceInjectionTest.java b/dependency-injection/src/test/java/com/baeldung/resource/MethodResourceInjectionIntegrationTest.java similarity index 95% rename from dependency-injection/src/test/java/com/baeldung/resource/MethodResourceInjectionTest.java rename to dependency-injection/src/test/java/com/baeldung/resource/MethodResourceInjectionIntegrationTest.java index 1622d8896c..2e1c3c39a9 100644 --- a/dependency-injection/src/test/java/com/baeldung/resource/MethodResourceInjectionTest.java +++ b/dependency-injection/src/test/java/com/baeldung/resource/MethodResourceInjectionIntegrationTest.java @@ -17,7 +17,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestResourceNameType.class) -public class MethodResourceInjectionTest { +public class MethodResourceInjectionIntegrationTest { private File defaultFile; diff --git a/dependency-injection/src/test/java/com/baeldung/resource/NamedResourceTest.java b/dependency-injection/src/test/java/com/baeldung/resource/NamedResourceIntegrationTest.java similarity index 95% rename from dependency-injection/src/test/java/com/baeldung/resource/NamedResourceTest.java rename to dependency-injection/src/test/java/com/baeldung/resource/NamedResourceIntegrationTest.java index da104ecaae..d52660e9b8 100644 --- a/dependency-injection/src/test/java/com/baeldung/resource/NamedResourceTest.java +++ b/dependency-injection/src/test/java/com/baeldung/resource/NamedResourceIntegrationTest.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertNotNull; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestResourceNameType.class) -public class NamedResourceTest { +public class NamedResourceIntegrationTest { @Resource(name = "namedFile") private File testFile; diff --git a/dependency-injection/src/test/java/com/baeldung/resource/QualifierResourceInjectionTest.java b/dependency-injection/src/test/java/com/baeldung/resource/QualifierResourceInjectionIntegrationTest.java similarity index 95% rename from dependency-injection/src/test/java/com/baeldung/resource/QualifierResourceInjectionTest.java rename to dependency-injection/src/test/java/com/baeldung/resource/QualifierResourceInjectionIntegrationTest.java index 024c8e2bbe..3f812350c9 100644 --- a/dependency-injection/src/test/java/com/baeldung/resource/QualifierResourceInjectionTest.java +++ b/dependency-injection/src/test/java/com/baeldung/resource/QualifierResourceInjectionIntegrationTest.java @@ -18,7 +18,7 @@ import static org.junit.Assert.assertNotNull; @ContextConfiguration( loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestResourceQualifier.class) -public class QualifierResourceInjectionTest { +public class QualifierResourceInjectionIntegrationTest { @Resource @Qualifier("defaultFile") diff --git a/dependency-injection/src/test/java/com/baeldung/resource/SetterResourceInjectionTest.java b/dependency-injection/src/test/java/com/baeldung/resource/SetterResourceInjectionIntegrationTest.java similarity index 95% rename from dependency-injection/src/test/java/com/baeldung/resource/SetterResourceInjectionTest.java rename to dependency-injection/src/test/java/com/baeldung/resource/SetterResourceInjectionIntegrationTest.java index aa7cfda975..ae13b2336a 100644 --- a/dependency-injection/src/test/java/com/baeldung/resource/SetterResourceInjectionTest.java +++ b/dependency-injection/src/test/java/com/baeldung/resource/SetterResourceInjectionIntegrationTest.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertNotNull; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = ApplicationContextTestResourceNameType.class) -public class SetterResourceInjectionTest { +public class SetterResourceInjectionIntegrationTest { private File defaultFile; From d8c4b20e71201d04e03f3dd6600342f391d2ec7f Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 22 Oct 2016 19:27:31 +0200 Subject: [PATCH 35/52] add integration test profile --- cdi/pom.xml | 52 +++++++++++++++++++ ... => SpringInterceptorIntegrationTest.java} | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) rename cdi/src/test/java/com/baeldung/test/{TestSpringInterceptor.java => SpringInterceptorIntegrationTest.java} (95%) diff --git a/cdi/pom.xml b/cdi/pom.xml index b771857938..30dd167fa8 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -45,8 +45,60 @@
+ + + + + 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 + + + + + + + 4.3.1.RELEASE + 2.19.1 \ No newline at end of file diff --git a/cdi/src/test/java/com/baeldung/test/TestSpringInterceptor.java b/cdi/src/test/java/com/baeldung/test/SpringInterceptorIntegrationTest.java similarity index 95% rename from cdi/src/test/java/com/baeldung/test/TestSpringInterceptor.java rename to cdi/src/test/java/com/baeldung/test/SpringInterceptorIntegrationTest.java index 1f3a8d83e3..cffa2256ca 100644 --- a/cdi/src/test/java/com/baeldung/test/TestSpringInterceptor.java +++ b/cdi/src/test/java/com/baeldung/test/SpringInterceptorIntegrationTest.java @@ -16,7 +16,7 @@ import com.baeldung.spring.service.SpringSuperService; @RunWith(SpringRunner.class) @ContextConfiguration(classes = { AppConfig.class }) -public class TestSpringInterceptor { +public class SpringInterceptorIntegrationTest { @Autowired SpringSuperService springSuperService; From 366914a25ead8352c66290acd6047e6a6524b2d4 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sat, 22 Oct 2016 20:22:23 +0200 Subject: [PATCH 36/52] Fix Screenshot Test --- .../src/test/java/com/baeldung/printscreen/ScreenshotTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java b/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java index 895f514f4a..7e35fc3e30 100644 --- a/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java +++ b/core-java/src/test/java/com/baeldung/printscreen/ScreenshotTest.java @@ -10,7 +10,7 @@ import static org.junit.Assert.assertTrue; public class ScreenshotTest { - private Screenshot screenshot = new Screenshot("", "Screenshot", "jpg"); + private Screenshot screenshot = new Screenshot("Screenshot.jpg"); private File file = new File("Screenshot.jpg"); @Test From b018c6ca3b38994c7b01a4f362d0d634536ea620 Mon Sep 17 00:00:00 2001 From: Nancy Bosecker Date: Sat, 22 Oct 2016 22:47:44 -0700 Subject: [PATCH 37/52] Fixed http ssl apache 4.4 test, moved from Sandbox to Live class (#764) * Moved project to core-java from eclipse folder * Fixed http ssl test, moved from Sandbox to Live. --- .../httpclient/HttpsClientSslLiveTest.java | 31 ++++++++++++++++++- .../base/HttpClientSandboxLiveTest.java | 11 ------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java index 952ce3af25..34f99b9fb6 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java @@ -1,10 +1,12 @@ package org.baeldung.httpclient; -import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; import java.io.IOException; import java.security.GeneralSecurityException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; import java.security.cert.X509Certificate; import javax.net.ssl.SSLContext; @@ -16,6 +18,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContextBuilder; import org.apache.http.conn.ssl.SSLContexts; @@ -108,4 +111,30 @@ public class HttpsClientSslLiveTest { assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); } + @Test + public final void givenIgnoringCertificates_whenHttpsUrlIsConsumed_thenCorrect() throws ClientProtocolException, IOException { + + TrustStrategy acceptingTrustStrategy = new TrustStrategy() { + @Override + public boolean isTrusted(X509Certificate[] certificate, String authType) { + return true; + } + }; + + SSLContext sslContext = null; + try { + sslContext = new SSLContextBuilder().loadTrustMaterial(null, acceptingTrustStrategy).build(); + + } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException e) { + e.printStackTrace(); + } + + CloseableHttpClient client = HttpClients.custom().setSSLContext(sslContext).setSSLHostnameVerifier(new NoopHostnameVerifier()).build(); + final HttpGet httpGet = new HttpGet("https://sesar3.geoinfogeochem.org/sample/igsn/ODP000002"); + httpGet.setHeader("Accept", "application/xml"); + + final HttpResponse response = client.execute(httpGet); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + } + } diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java index 2333e2f8c9..ce4057aa6d 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java @@ -59,15 +59,4 @@ public class HttpClientSandboxLiveTest { System.out.println(response.getStatusLine()); } - - @Test - public final void givenIgnoringCertificates_whenHttpsUrlIsConsumed_thenCorrect() throws ClientProtocolException, IOException { - final CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build(); - - final HttpGet httpGet = new HttpGet("https://sesar3.geoinfogeochem.org/sample/igsn/ODP000002"); - httpGet.setHeader("Accept", "application/xml"); - - response = httpClient.execute(httpGet); - } - } From d0a376e6226b9658003d59ac0eb0872f7fdd457b Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 07:54:09 +0200 Subject: [PATCH 38/52] Refactor HttpClient test --- .../httpclient/HttpsClientSslLiveTest.java | 57 ++++++------------- .../httpclient/base/HttpClientLiveTest.java | 25 ++++---- .../base/HttpClientSandboxLiveTest.java | 11 ++-- 3 files changed, 33 insertions(+), 60 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java index 34f99b9fb6..66b4f5cff4 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/HttpsClientSslLiveTest.java @@ -1,30 +1,11 @@ package org.baeldung.httpclient; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.security.GeneralSecurityException; -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLException; - import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; import org.apache.http.conn.ClientConnectionManager; import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.conn.ssl.NoopHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.SSLContextBuilder; -import org.apache.http.conn.ssl.SSLContexts; -import org.apache.http.conn.ssl.SSLSocketFactory; -import org.apache.http.conn.ssl.TrustSelfSignedStrategy; -import org.apache.http.conn.ssl.TrustStrategy; +import org.apache.http.conn.ssl.*; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.HttpClientBuilder; @@ -32,6 +13,17 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.junit.Test; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLException; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + /** * This test requires a localhost server over HTTPS
* It should only be manually run, not part of the automated build @@ -45,7 +37,7 @@ public class HttpsClientSslLiveTest { // tests @Test(expected = SSLException.class) - public final void whenHttpsUrlIsConsumed_thenException() throws ClientProtocolException, IOException { + public final void whenHttpsUrlIsConsumed_thenException() throws IOException { final CloseableHttpClient httpClient = HttpClientBuilder.create().build(); final HttpGet getMethod = new HttpGet(HOST_WITH_SSL); @@ -56,12 +48,7 @@ public class HttpsClientSslLiveTest { @SuppressWarnings("deprecation") @Test public final void givenHttpClientPre4_3_whenAcceptingAllCertificates_thenCanConsumeHttpsUriWithSelfSignedCertificate() throws IOException, GeneralSecurityException { - final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { - @Override - public final boolean isTrusted(final X509Certificate[] certificate, final String authType) { - return true; - } - }; + final TrustStrategy acceptingTrustStrategy = (certificate, authType) -> true; final SSLSocketFactory sf = new SSLSocketFactory(acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); final SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("https", 443, sf)); @@ -78,12 +65,7 @@ public class HttpsClientSslLiveTest { @Test public final void givenHttpClientAfter4_3_whenAcceptingAllCertificates_thenCanConsumeHttpsUriWithSelfSignedCertificate() throws IOException, GeneralSecurityException { - final TrustStrategy acceptingTrustStrategy = new TrustStrategy() { - @Override - public final boolean isTrusted(final X509Certificate[] certificate, final String authType) { - return true; - } - }; + final TrustStrategy acceptingTrustStrategy = (certificate, authType) -> true; final SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build(); final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); @@ -112,14 +94,9 @@ public class HttpsClientSslLiveTest { } @Test - public final void givenIgnoringCertificates_whenHttpsUrlIsConsumed_thenCorrect() throws ClientProtocolException, IOException { + public final void givenIgnoringCertificates_whenHttpsUrlIsConsumed_thenCorrect() throws IOException { - TrustStrategy acceptingTrustStrategy = new TrustStrategy() { - @Override - public boolean isTrusted(X509Certificate[] certificate, String authType) { - return true; - } - }; + TrustStrategy acceptingTrustStrategy = (certificate, authType) -> true; SSLContext sslContext = null; try { diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java index 23c1fdf430..878d220f67 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientLiveTest.java @@ -1,16 +1,8 @@ package org.baeldung.httpclient.base; -import static org.hamcrest.Matchers.emptyArray; -import static org.hamcrest.Matchers.not; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.io.InputStream; - import org.apache.http.Header; import org.apache.http.HttpEntity; import org.apache.http.HttpHeaders; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; @@ -23,6 +15,13 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; +import java.io.IOException; +import java.io.InputStream; + +import static org.hamcrest.Matchers.emptyArray; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertThat; + public class HttpClientLiveTest { private static final String SAMPLE_URL = "http://www.github.com"; @@ -56,7 +55,7 @@ public class HttpClientLiveTest { // tests @Test(expected = ConnectTimeoutException.class) - public final void givenLowTimeout_whenExecutingRequestWithTimeout_thenException() throws ClientProtocolException, IOException { + public final void givenLowTimeout_whenExecutingRequestWithTimeout_thenException() throws IOException { final RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(50).setConnectTimeout(50).setSocketTimeout(20).build(); final HttpGet request = new HttpGet(SAMPLE_URL); request.setConfig(requestConfig); @@ -66,20 +65,20 @@ public class HttpClientLiveTest { // tests - configs @Test - public final void givenHttpClientIsConfiguredWithCustomConnectionManager_whenExecutingRequest_thenNoExceptions() throws ClientProtocolException, IOException { + public final void givenHttpClientIsConfiguredWithCustomConnectionManager_whenExecutingRequest_thenNoExceptions() throws IOException { instance = HttpClientBuilder.create().setConnectionManager(new BasicHttpClientConnectionManager()).build(); response = instance.execute(new HttpGet(SAMPLE_URL)); } @Test - public final void givenCustomHeaderIsSet_whenSendingRequest_thenNoExceptions() throws ClientProtocolException, IOException { + public final void givenCustomHeaderIsSet_whenSendingRequest_thenNoExceptions() throws IOException { final HttpGet request = new HttpGet(SAMPLE_URL); request.addHeader(HttpHeaders.ACCEPT, "application/xml"); response = instance.execute(request); } @Test - public final void givenRequestWasSet_whenAnalyzingTheHeadersOfTheResponse_thenCorrect() throws ClientProtocolException, IOException { + public final void givenRequestWasSet_whenAnalyzingTheHeadersOfTheResponse_thenCorrect() throws IOException { response = instance.execute(new HttpGet(SAMPLE_URL)); final Header[] headers = response.getHeaders(HttpHeaders.CONTENT_TYPE); @@ -89,7 +88,7 @@ public class HttpClientLiveTest { // tests - cancel request @Test - public final void whenRequestIsCanceled_thenCorrect() throws ClientProtocolException, IOException { + public final void whenRequestIsCanceled_thenCorrect() throws IOException { instance = HttpClients.custom().build(); final HttpGet request = new HttpGet(SAMPLE_URL); response = instance.execute(request); diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java index ce4057aa6d..c82022eb3f 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java @@ -1,23 +1,20 @@ package org.baeldung.httpclient.base; -import java.io.IOException; -import java.io.InputStream; - import org.apache.http.HttpEntity; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.CredentialsProvider; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; -import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.http.impl.client.HttpClients; import org.junit.After; import org.junit.Test; +import java.io.IOException; +import java.io.InputStream; + public class HttpClientSandboxLiveTest { private CloseableHttpClient client; @@ -47,7 +44,7 @@ public class HttpClientSandboxLiveTest { // simple request - response @Test - public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws ClientProtocolException, IOException { + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws IOException { final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); final AuthScope authscp = new AuthScope("localhost", 8080); credentialsProvider.setCredentials(authscp, new UsernamePasswordCredentials("user1", "user1Pass")); From bfddf3344d5f65342c2cbbc8871c925f678ca6f4 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 07:55:07 +0200 Subject: [PATCH 39/52] Refactor LiveTest --- .../base/HttpClientSandboxLiveTest.java | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java index c82022eb3f..22b32e7ef5 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/base/HttpClientSandboxLiveTest.java @@ -9,7 +9,6 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.After; import org.junit.Test; import java.io.IOException; @@ -17,15 +16,18 @@ import java.io.InputStream; public class HttpClientSandboxLiveTest { - private CloseableHttpClient client; + @Test + public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws IOException { + final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + final AuthScope authscp = new AuthScope("localhost", 8080); + credentialsProvider.setCredentials(authscp, new UsernamePasswordCredentials("user1", "user1Pass")); - private CloseableHttpResponse response; + CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build(); - @After - public final void after() throws IllegalStateException, IOException { - if (response == null) { - return; - } + final HttpGet httpGet = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/foos/1"); + CloseableHttpResponse response = client.execute(httpGet); + + System.out.println(response.getStatusLine()); try { final HttpEntity entity = response.getEntity(); @@ -38,22 +40,4 @@ public class HttpClientSandboxLiveTest { response.close(); } } - - // tests - - // simple request - response - - @Test - public final void givenGetRequestExecuted_whenAnalyzingTheResponse_thenCorrectStatusCode() throws IOException { - final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); - final AuthScope authscp = new AuthScope("localhost", 8080); - credentialsProvider.setCredentials(authscp, new UsernamePasswordCredentials("user1", "user1Pass")); - - client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentialsProvider).build(); - - final HttpGet httpGet = new HttpGet("http://localhost:8080/spring-security-rest-basic-auth/api/foos/1"); - response = client.execute(httpGet); - - System.out.println(response.getStatusLine()); - } } From 4670b8dbdabaf3dd0294c69f93d6399322e55509 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 11:25:09 +0200 Subject: [PATCH 40/52] Sockets moved to core-java --- core-java/README.md | 1 + .../java/com/baeldung/socket/EchoClient.java | 0 .../com/baeldung/socket/EchoMultiServer.java | 2 +- .../java/com/baeldung/socket/EchoServer.java | 2 +- .../java/com/baeldung/socket/GreetClient.java | 0 .../java/com/baeldung/socket/GreetServer.java | 0 .../com/baeldung/socket/EchoMultiTest.java | 6 ++-- .../java/com/baeldung/socket/EchoTest.java | 2 +- .../com/baeldung/socket/GreetServerTest.java | 0 sockets/README.md | 2 -- sockets/pom.xml | 30 ------------------- 11 files changed, 7 insertions(+), 38 deletions(-) rename {sockets => core-java}/src/main/java/com/baeldung/socket/EchoClient.java (100%) rename {sockets => core-java}/src/main/java/com/baeldung/socket/EchoMultiServer.java (97%) rename {sockets => core-java}/src/main/java/com/baeldung/socket/EchoServer.java (96%) rename {sockets => core-java}/src/main/java/com/baeldung/socket/GreetClient.java (100%) rename {sockets => core-java}/src/main/java/com/baeldung/socket/GreetServer.java (100%) rename {sockets => core-java}/src/test/java/com/baeldung/socket/EchoMultiTest.java (91%) rename {sockets => core-java}/src/test/java/com/baeldung/socket/EchoTest.java (95%) rename {sockets => core-java}/src/test/java/com/baeldung/socket/GreetServerTest.java (100%) delete mode 100644 sockets/README.md delete mode 100644 sockets/pom.xml diff --git a/core-java/README.md b/core-java/README.md index 440af67252..fbbfa65589 100644 --- a/core-java/README.md +++ b/core-java/README.md @@ -18,3 +18,4 @@ - [MD5 Hashing in Java](http://www.baeldung.com/java-md5) - [Guide to the Java ArrayList](http://www.baeldung.com/java-arraylist) - [Guide to Java Reflection](http://www.baeldung.com/java-reflection) +- [A Guide to Java Sockets](http://www.baeldung.com/a-guide-to-java-sockets) diff --git a/sockets/src/main/java/com/baeldung/socket/EchoClient.java b/core-java/src/main/java/com/baeldung/socket/EchoClient.java similarity index 100% rename from sockets/src/main/java/com/baeldung/socket/EchoClient.java rename to core-java/src/main/java/com/baeldung/socket/EchoClient.java diff --git a/sockets/src/main/java/com/baeldung/socket/EchoMultiServer.java b/core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java similarity index 97% rename from sockets/src/main/java/com/baeldung/socket/EchoMultiServer.java rename to core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java index 2ece1ceebe..1177b82c87 100644 --- a/sockets/src/main/java/com/baeldung/socket/EchoMultiServer.java +++ b/core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java @@ -46,7 +46,7 @@ public class EchoMultiServer { clientSocket.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { - if (".".equals(inputLine)) { + if ("".equals(inputLine)) { out.println("bye"); break; } diff --git a/sockets/src/main/java/com/baeldung/socket/EchoServer.java b/core-java/src/main/java/com/baeldung/socket/EchoServer.java similarity index 96% rename from sockets/src/main/java/com/baeldung/socket/EchoServer.java rename to core-java/src/main/java/com/baeldung/socket/EchoServer.java index 3607afa7f5..395624933c 100644 --- a/sockets/src/main/java/com/baeldung/socket/EchoServer.java +++ b/core-java/src/main/java/com/baeldung/socket/EchoServer.java @@ -18,7 +18,7 @@ public class EchoServer { clientSocket.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { - if (".".equals(inputLine)) { + if ("".equals(inputLine)) { out.println("good bye"); break; } diff --git a/sockets/src/main/java/com/baeldung/socket/GreetClient.java b/core-java/src/main/java/com/baeldung/socket/GreetClient.java similarity index 100% rename from sockets/src/main/java/com/baeldung/socket/GreetClient.java rename to core-java/src/main/java/com/baeldung/socket/GreetClient.java diff --git a/sockets/src/main/java/com/baeldung/socket/GreetServer.java b/core-java/src/main/java/com/baeldung/socket/GreetServer.java similarity index 100% rename from sockets/src/main/java/com/baeldung/socket/GreetServer.java rename to core-java/src/main/java/com/baeldung/socket/GreetServer.java diff --git a/sockets/src/test/java/com/baeldung/socket/EchoMultiTest.java b/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java similarity index 91% rename from sockets/src/test/java/com/baeldung/socket/EchoMultiTest.java rename to core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java index 19a59c211c..ef08385551 100644 --- a/sockets/src/test/java/com/baeldung/socket/EchoMultiTest.java +++ b/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java @@ -21,7 +21,7 @@ public class EchoMultiTest { client.startConnection("127.0.0.1", 5555); String msg1 = client.sendMessage("hello"); String msg2 = client.sendMessage("world"); - String terminate = client.sendMessage("."); + String terminate = client.sendMessage(""); assertEquals(msg1, "hello"); assertEquals(msg2, "world"); assertEquals(terminate, "bye"); @@ -34,7 +34,7 @@ public class EchoMultiTest { client.startConnection("127.0.0.1", 5555); String msg1 = client.sendMessage("hello"); String msg2 = client.sendMessage("world"); - String terminate = client.sendMessage("."); + String terminate = client.sendMessage(""); assertEquals(msg1, "hello"); assertEquals(msg2, "world"); assertEquals(terminate, "bye"); @@ -47,7 +47,7 @@ public class EchoMultiTest { client.startConnection("127.0.0.1", 5555); String msg1 = client.sendMessage("hello"); String msg2 = client.sendMessage("world"); - String terminate = client.sendMessage("."); + String terminate = client.sendMessage(""); assertEquals(msg1, "hello"); assertEquals(msg2, "world"); assertEquals(terminate, "bye"); diff --git a/sockets/src/test/java/com/baeldung/socket/EchoTest.java b/core-java/src/test/java/com/baeldung/socket/EchoTest.java similarity index 95% rename from sockets/src/test/java/com/baeldung/socket/EchoTest.java rename to core-java/src/test/java/com/baeldung/socket/EchoTest.java index 0f0c02e4d8..c12bd28a29 100644 --- a/sockets/src/test/java/com/baeldung/socket/EchoTest.java +++ b/core-java/src/test/java/com/baeldung/socket/EchoTest.java @@ -26,7 +26,7 @@ public class EchoTest { String resp1 = client.sendMessage("hello"); String resp2 = client.sendMessage("world"); String resp3 = client.sendMessage("!"); - String resp4 = client.sendMessage("."); + String resp4 = client.sendMessage(""); assertEquals("hello", resp1); assertEquals("world", resp2); assertEquals("!", resp3); diff --git a/sockets/src/test/java/com/baeldung/socket/GreetServerTest.java b/core-java/src/test/java/com/baeldung/socket/GreetServerTest.java similarity index 100% rename from sockets/src/test/java/com/baeldung/socket/GreetServerTest.java rename to core-java/src/test/java/com/baeldung/socket/GreetServerTest.java diff --git a/sockets/README.md b/sockets/README.md deleted file mode 100644 index ad8811ee80..0000000000 --- a/sockets/README.md +++ /dev/null @@ -1,2 +0,0 @@ -### Relevant Articles: -- [A Guide to Java Sockets](http://www.baeldung.com/a-guide-to-java-sockets) diff --git a/sockets/pom.xml b/sockets/pom.xml deleted file mode 100644 index 24e8e436f3..0000000000 --- a/sockets/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - 4.0.0 - com.baeldung - sockets - 1.0 - sockets - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.3 - - 8 - 8 - - - - - - - junit - junit - 4.3 - test - - - - From 803145826525fd88d3138d12fc9513f5cb16b8a5 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 11:53:43 +0200 Subject: [PATCH 41/52] Refactor Socket tests --- .../com/baeldung/socket/EchoMultiTest.java | 20 ++++++++++--------- .../java/com/baeldung/socket/EchoTest.java | 16 +++++++++------ .../com/baeldung/socket/GreetServerTest.java | 13 ++++++++---- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java b/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java index ef08385551..ccb5f48ddb 100644 --- a/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java +++ b/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java @@ -1,7 +1,6 @@ package com.baeldung.socket; -import org.junit.After; -import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import java.util.concurrent.Executors; @@ -10,18 +9,22 @@ import static org.junit.Assert.assertEquals; public class EchoMultiTest { - { - Executors.newSingleThreadExecutor().submit(() -> new EchoMultiServer().start(5555)); - } + private static final Integer PORT = 5555; + @BeforeClass + public static void start() throws InterruptedException { + Executors.newSingleThreadExecutor().submit(() -> new EchoMultiServer().start(PORT)); + Thread.sleep(500); + } @Test public void givenClient1_whenServerResponds_thenCorrect() { EchoClient client = new EchoClient(); - client.startConnection("127.0.0.1", 5555); + client.startConnection("127.0.0.1", PORT); String msg1 = client.sendMessage("hello"); String msg2 = client.sendMessage("world"); String terminate = client.sendMessage(""); + assertEquals(msg1, "hello"); assertEquals(msg2, "world"); assertEquals(terminate, "bye"); @@ -31,7 +34,7 @@ public class EchoMultiTest { @Test public void givenClient2_whenServerResponds_thenCorrect() { EchoClient client = new EchoClient(); - client.startConnection("127.0.0.1", 5555); + client.startConnection("127.0.0.1", PORT); String msg1 = client.sendMessage("hello"); String msg2 = client.sendMessage("world"); String terminate = client.sendMessage(""); @@ -44,7 +47,7 @@ public class EchoMultiTest { @Test public void givenClient3_whenServerResponds_thenCorrect() { EchoClient client = new EchoClient(); - client.startConnection("127.0.0.1", 5555); + client.startConnection("127.0.0.1", PORT); String msg1 = client.sendMessage("hello"); String msg2 = client.sendMessage("world"); String terminate = client.sendMessage(""); @@ -53,5 +56,4 @@ public class EchoMultiTest { assertEquals(terminate, "bye"); client.stopConnection(); } - } diff --git a/core-java/src/test/java/com/baeldung/socket/EchoTest.java b/core-java/src/test/java/com/baeldung/socket/EchoTest.java index c12bd28a29..76391f0f20 100644 --- a/core-java/src/test/java/com/baeldung/socket/EchoTest.java +++ b/core-java/src/test/java/com/baeldung/socket/EchoTest.java @@ -2,6 +2,7 @@ package com.baeldung.socket; import org.junit.After; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import java.util.concurrent.Executors; @@ -9,15 +10,19 @@ import java.util.concurrent.Executors; import static org.junit.Assert.assertEquals; public class EchoTest { - { - Executors.newSingleThreadExecutor().submit(() -> new EchoServer().start(4444)); - } + private static final Integer PORT = 4444; - EchoClient client = new EchoClient(); + @BeforeClass + public static void start() throws InterruptedException { + Executors.newSingleThreadExecutor().submit(() -> new EchoServer().start(PORT)); + Thread.sleep(500); + } + + private EchoClient client = new EchoClient(); @Before public void init() { - client.startConnection("127.0.0.1", 4444); + client.startConnection("127.0.0.1", PORT); } @Test @@ -37,5 +42,4 @@ public class EchoTest { public void tearDown() { client.stopConnection(); } - } diff --git a/core-java/src/test/java/com/baeldung/socket/GreetServerTest.java b/core-java/src/test/java/com/baeldung/socket/GreetServerTest.java index fedc32fb39..caf56a8c76 100644 --- a/core-java/src/test/java/com/baeldung/socket/GreetServerTest.java +++ b/core-java/src/test/java/com/baeldung/socket/GreetServerTest.java @@ -2,6 +2,7 @@ package com.baeldung.socket; import org.junit.After; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import java.util.concurrent.Executors; @@ -10,16 +11,20 @@ import static org.junit.Assert.assertEquals; public class GreetServerTest { - GreetClient client; + private GreetClient client; - { - Executors.newSingleThreadExecutor().submit(() -> new GreetServer().start(6666)); + private static final Integer PORT = 6666; + + @BeforeClass + public static void start() throws InterruptedException { + Executors.newSingleThreadExecutor().submit(() -> new GreetServer().start(PORT)); + Thread.sleep(500); } @Before public void init() { client = new GreetClient(); - client.startConnection("127.0.0.1", 6666); + client.startConnection("127.0.0.1", PORT); } From 65daa3aee2de7c813e852b1627be5fd288eac0eb Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 11:57:11 +0200 Subject: [PATCH 42/52] Refactor examples --- core-java/src/main/java/com/baeldung/socket/EchoClient.java | 3 +-- .../src/main/java/com/baeldung/socket/EchoMultiServer.java | 2 +- core-java/src/main/java/com/baeldung/socket/EchoServer.java | 2 +- .../src/main/java/com/baeldung/socket/GreetClient.java | 3 +-- .../src/test/java/com/baeldung/socket/EchoMultiTest.java | 6 +++--- core-java/src/test/java/com/baeldung/socket/EchoTest.java | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/socket/EchoClient.java b/core-java/src/main/java/com/baeldung/socket/EchoClient.java index e8ec97c80a..1ddf752a03 100644 --- a/core-java/src/main/java/com/baeldung/socket/EchoClient.java +++ b/core-java/src/main/java/com/baeldung/socket/EchoClient.java @@ -23,8 +23,7 @@ public class EchoClient { public String sendMessage(String msg) { try { out.println(msg); - String resp = in.readLine(); - return resp; + return in.readLine(); } catch (Exception e) { return null; } diff --git a/core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java b/core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java index 1177b82c87..2ece1ceebe 100644 --- a/core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java +++ b/core-java/src/main/java/com/baeldung/socket/EchoMultiServer.java @@ -46,7 +46,7 @@ public class EchoMultiServer { clientSocket.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { - if ("".equals(inputLine)) { + if (".".equals(inputLine)) { out.println("bye"); break; } diff --git a/core-java/src/main/java/com/baeldung/socket/EchoServer.java b/core-java/src/main/java/com/baeldung/socket/EchoServer.java index 395624933c..3607afa7f5 100644 --- a/core-java/src/main/java/com/baeldung/socket/EchoServer.java +++ b/core-java/src/main/java/com/baeldung/socket/EchoServer.java @@ -18,7 +18,7 @@ public class EchoServer { clientSocket.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { - if ("".equals(inputLine)) { + if (".".equals(inputLine)) { out.println("good bye"); break; } diff --git a/core-java/src/main/java/com/baeldung/socket/GreetClient.java b/core-java/src/main/java/com/baeldung/socket/GreetClient.java index 7252827c87..21959c7469 100644 --- a/core-java/src/main/java/com/baeldung/socket/GreetClient.java +++ b/core-java/src/main/java/com/baeldung/socket/GreetClient.java @@ -26,8 +26,7 @@ public class GreetClient { public String sendMessage(String msg) { try { out.println(msg); - String resp = in.readLine(); - return resp; + return in.readLine(); } catch (Exception e) { return null; } diff --git a/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java b/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java index ccb5f48ddb..fcf353281d 100644 --- a/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java +++ b/core-java/src/test/java/com/baeldung/socket/EchoMultiTest.java @@ -23,7 +23,7 @@ public class EchoMultiTest { client.startConnection("127.0.0.1", PORT); String msg1 = client.sendMessage("hello"); String msg2 = client.sendMessage("world"); - String terminate = client.sendMessage(""); + String terminate = client.sendMessage("."); assertEquals(msg1, "hello"); assertEquals(msg2, "world"); @@ -37,7 +37,7 @@ public class EchoMultiTest { client.startConnection("127.0.0.1", PORT); String msg1 = client.sendMessage("hello"); String msg2 = client.sendMessage("world"); - String terminate = client.sendMessage(""); + String terminate = client.sendMessage("."); assertEquals(msg1, "hello"); assertEquals(msg2, "world"); assertEquals(terminate, "bye"); @@ -50,7 +50,7 @@ public class EchoMultiTest { client.startConnection("127.0.0.1", PORT); String msg1 = client.sendMessage("hello"); String msg2 = client.sendMessage("world"); - String terminate = client.sendMessage(""); + String terminate = client.sendMessage("."); assertEquals(msg1, "hello"); assertEquals(msg2, "world"); assertEquals(terminate, "bye"); diff --git a/core-java/src/test/java/com/baeldung/socket/EchoTest.java b/core-java/src/test/java/com/baeldung/socket/EchoTest.java index 76391f0f20..cb09d42f79 100644 --- a/core-java/src/test/java/com/baeldung/socket/EchoTest.java +++ b/core-java/src/test/java/com/baeldung/socket/EchoTest.java @@ -31,7 +31,7 @@ public class EchoTest { String resp1 = client.sendMessage("hello"); String resp2 = client.sendMessage("world"); String resp3 = client.sendMessage("!"); - String resp4 = client.sendMessage(""); + String resp4 = client.sendMessage("."); assertEquals("hello", resp1); assertEquals("world", resp2); assertEquals("!", resp3); From 8cdc680e6f76174625e5eba32f18d3f521301e3a Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 12:11:23 +0200 Subject: [PATCH 43/52] Remove gson-jackson-performance --- gson-jackson-performance/README.md | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 gson-jackson-performance/README.md diff --git a/gson-jackson-performance/README.md b/gson-jackson-performance/README.md deleted file mode 100644 index e662219718..0000000000 --- a/gson-jackson-performance/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Performance of Gson and Jackson - -Standalone java programs to measure the performance of both JSON APIs based on file size and object graph complexity. - -###Relevant Articles: -- [Jackson vs Gson: A Quick Look At Performance](http://www.baeldung.com/jackson-gson-performance) From bc9b170e89c1fa927eabc83fe268f35ddc88021e Mon Sep 17 00:00:00 2001 From: DOHA Date: Sun, 23 Oct 2016 12:19:55 +0200 Subject: [PATCH 44/52] configure test profiles --- apache-cxf/cxf-introduction/pom.xml | 65 ++++++++++- ...{StudentTest.java => StudentLiveTest.java} | 30 +++-- apache-cxf/cxf-jaxrs-implementation/pom.xml | 65 ++++++++++- ...{ServiceTest.java => ServiceLiveTest.java} | 107 +++++++++--------- apache-cxf/cxf-spring/pom.xml | 4 +- ...{StudentTest.java => StudentLiveTest.java} | 2 +- 6 files changed, 198 insertions(+), 75 deletions(-) rename apache-cxf/cxf-introduction/src/test/java/com/baeldung/cxf/introduction/{StudentTest.java => StudentLiveTest.java} (65%) rename apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/{ServiceTest.java => ServiceLiveTest.java} (63%) rename apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/{StudentTest.java => StudentLiveTest.java} (97%) diff --git a/apache-cxf/cxf-introduction/pom.xml b/apache-cxf/cxf-introduction/pom.xml index 232a4f0089..9629dfda1b 100644 --- a/apache-cxf/cxf-introduction/pom.xml +++ b/apache-cxf/cxf-introduction/pom.xml @@ -11,6 +11,7 @@ 3.1.6 + 2.19.1 @@ -26,7 +27,7 @@ 2.19.1 - **/StudentTest.java + **/*LiveTest.java @@ -44,4 +45,66 @@ ${cxf.version}
+ + + + live + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.19 + + + tomcat8x + embedded + + + + localhost + 8082 + + + + + + start-server + pre-integration-test + + start + + + + stop-server + post-integration-test + + stop + + + + + + + maven-surefire-plugin + ${surefire.version} + + + integration-test + + test + + + + none + + + + + + + + + + diff --git a/apache-cxf/cxf-introduction/src/test/java/com/baeldung/cxf/introduction/StudentTest.java b/apache-cxf/cxf-introduction/src/test/java/com/baeldung/cxf/introduction/StudentLiveTest.java similarity index 65% rename from apache-cxf/cxf-introduction/src/test/java/com/baeldung/cxf/introduction/StudentTest.java rename to apache-cxf/cxf-introduction/src/test/java/com/baeldung/cxf/introduction/StudentLiveTest.java index e1e5b60ec3..1c50fcb9b6 100644 --- a/apache-cxf/cxf-introduction/src/test/java/com/baeldung/cxf/introduction/StudentTest.java +++ b/apache-cxf/cxf-introduction/src/test/java/com/baeldung/cxf/introduction/StudentLiveTest.java @@ -2,20 +2,16 @@ package com.baeldung.cxf.introduction; import static org.junit.Assert.assertEquals; -import org.junit.Before; -import org.junit.Test; - import java.util.Map; import javax.xml.namespace.QName; import javax.xml.ws.Service; import javax.xml.ws.soap.SOAPBinding; -import com.baeldung.cxf.introduction.Baeldung; -import com.baeldung.cxf.introduction.Student; -import com.baeldung.cxf.introduction.StudentImpl; +import org.junit.Before; +import org.junit.Test; -public class StudentTest { +public class StudentLiveTest { private static QName SERVICE_NAME = new QName("http://introduction.cxf.baeldung.com/", "Baeldung"); private static QName PORT_NAME = new QName("http://introduction.cxf.baeldung.com/", "BaeldungPort"); @@ -25,7 +21,7 @@ public class StudentTest { { service = Service.create(SERVICE_NAME); - String endpointAddress = "http://localhost:8080/baeldung"; + final String endpointAddress = "http://localhost:8082/cxf-introduction/baeldung"; service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); } @@ -37,28 +33,28 @@ public class StudentTest { @Test public void whenUsingHelloMethod_thenCorrect() { - String endpointResponse = baeldungProxy.hello("Baeldung"); - String localResponse = baeldungImpl.hello("Baeldung"); + final String endpointResponse = baeldungProxy.hello("Baeldung"); + final String localResponse = baeldungImpl.hello("Baeldung"); assertEquals(localResponse, endpointResponse); } @Test public void whenUsingHelloStudentMethod_thenCorrect() { - Student student = new StudentImpl("John Doe"); - String endpointResponse = baeldungProxy.helloStudent(student); - String localResponse = baeldungImpl.helloStudent(student); + final Student student = new StudentImpl("John Doe"); + final String endpointResponse = baeldungProxy.helloStudent(student); + final String localResponse = baeldungImpl.helloStudent(student); assertEquals(localResponse, endpointResponse); } @Test public void usingGetStudentsMethod_thenCorrect() { - Student student1 = new StudentImpl("Adam"); + final Student student1 = new StudentImpl("Adam"); baeldungProxy.helloStudent(student1); - Student student2 = new StudentImpl("Eve"); + final Student student2 = new StudentImpl("Eve"); baeldungProxy.helloStudent(student2); - - Map students = baeldungProxy.getStudents(); + + final Map students = baeldungProxy.getStudents(); assertEquals("Adam", students.get(1).getName()); assertEquals("Eve", students.get(2).getName()); } diff --git a/apache-cxf/cxf-jaxrs-implementation/pom.xml b/apache-cxf/cxf-jaxrs-implementation/pom.xml index 1f83ecf934..24dad05a0f 100644 --- a/apache-cxf/cxf-jaxrs-implementation/pom.xml +++ b/apache-cxf/cxf-jaxrs-implementation/pom.xml @@ -13,6 +13,7 @@ UTF-8 3.1.7 4.5.2 + 2.19.1 @@ -28,7 +29,7 @@ 2.19.1 - **/ServiceTest + **/*LiveTest.java @@ -51,4 +52,66 @@ ${httpclient.version} + + + + live + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.4.19 + + + tomcat8x + embedded + + + + localhost + 8082 + + + + + + start-server + pre-integration-test + + start + + + + stop-server + post-integration-test + + stop + + + + + + + maven-surefire-plugin + ${surefire.version} + + + integration-test + + test + + + + none + + + + + + + + + + diff --git a/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java b/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceLiveTest.java similarity index 63% rename from apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java rename to apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceLiveTest.java index b8fc833194..692def81f5 100644 --- a/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceTest.java +++ b/apache-cxf/cxf-jaxrs-implementation/src/test/java/com/baeldung/cxf/jaxrs/implementation/ServiceLiveTest.java @@ -1,5 +1,14 @@ package com.baeldung.cxf.jaxrs.implementation; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; + +import javax.xml.bind.JAXB; + import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpPost; @@ -11,119 +20,111 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import javax.xml.bind.JAXB; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; - -import static org.junit.Assert.assertEquals; - -public class ServiceTest { - private static final String BASE_URL = "http://localhost:8080/baeldung/courses/"; +public class ServiceLiveTest { + private static final String BASE_URL = "http://localhost:8082/baeldung/courses/"; private static CloseableHttpClient client; - + @BeforeClass public static void createClient() { client = HttpClients.createDefault(); } - + @AfterClass public static void closeClient() throws IOException { client.close(); } - + @Test public void whenUpdateNonExistentCourse_thenReceiveNotFoundResponse() throws IOException { - HttpPut httpPut = new HttpPut(BASE_URL + "3"); - InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("non_existent_course.xml"); + final HttpPut httpPut = new HttpPut(BASE_URL + "3"); + final InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("non_existent_course.xml"); httpPut.setEntity(new InputStreamEntity(resourceStream)); httpPut.setHeader("Content-Type", "text/xml"); - - HttpResponse response = client.execute(httpPut); + + final HttpResponse response = client.execute(httpPut); assertEquals(404, response.getStatusLine().getStatusCode()); } - + @Test public void whenUpdateUnchangedCourse_thenReceiveNotModifiedResponse() throws IOException { - HttpPut httpPut = new HttpPut(BASE_URL + "1"); - InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("unchanged_course.xml"); + final HttpPut httpPut = new HttpPut(BASE_URL + "1"); + final InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("unchanged_course.xml"); httpPut.setEntity(new InputStreamEntity(resourceStream)); httpPut.setHeader("Content-Type", "text/xml"); - - HttpResponse response = client.execute(httpPut); + + final HttpResponse response = client.execute(httpPut); assertEquals(304, response.getStatusLine().getStatusCode()); } - + @Test public void whenUpdateValidCourse_thenReceiveOKResponse() throws IOException { - HttpPut httpPut = new HttpPut(BASE_URL + "2"); - InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("changed_course.xml"); + final HttpPut httpPut = new HttpPut(BASE_URL + "2"); + final InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("changed_course.xml"); httpPut.setEntity(new InputStreamEntity(resourceStream)); httpPut.setHeader("Content-Type", "text/xml"); - - HttpResponse response = client.execute(httpPut); + + final HttpResponse response = client.execute(httpPut); assertEquals(200, response.getStatusLine().getStatusCode()); - - Course course = getCourse(2); + + final Course course = getCourse(2); assertEquals(2, course.getId()); assertEquals("Apache CXF Support for RESTful", course.getName()); } - + @Test public void whenCreateConflictStudent_thenReceiveConflictResponse() throws IOException { - HttpPost httpPost = new HttpPost(BASE_URL + "1/students"); - InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("conflict_student.xml"); + final HttpPost httpPost = new HttpPost(BASE_URL + "1/students"); + final InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("conflict_student.xml"); httpPost.setEntity(new InputStreamEntity(resourceStream)); httpPost.setHeader("Content-Type", "text/xml"); - - HttpResponse response = client.execute(httpPost); + + final HttpResponse response = client.execute(httpPost); assertEquals(409, response.getStatusLine().getStatusCode()); } @Test public void whenCreateValidStudent_thenReceiveOKResponse() throws IOException { - HttpPost httpPost = new HttpPost(BASE_URL + "2/students"); - InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("created_student.xml"); + final HttpPost httpPost = new HttpPost(BASE_URL + "2/students"); + final InputStream resourceStream = this.getClass().getClassLoader().getResourceAsStream("created_student.xml"); httpPost.setEntity(new InputStreamEntity(resourceStream)); httpPost.setHeader("Content-Type", "text/xml"); - - HttpResponse response = client.execute(httpPost); + + final HttpResponse response = client.execute(httpPost); assertEquals(200, response.getStatusLine().getStatusCode()); - - Student student = getStudent(2, 3); + + final Student student = getStudent(2, 3); assertEquals(3, student.getId()); assertEquals("Student C", student.getName()); } - + @Test public void whenDeleteInvalidStudent_thenReceiveNotFoundResponse() throws IOException { - HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/3"); - HttpResponse response = client.execute(httpDelete); + final HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/3"); + final HttpResponse response = client.execute(httpDelete); assertEquals(404, response.getStatusLine().getStatusCode()); - } - + } + @Test public void whenDeleteValidStudent_thenReceiveOKResponse() throws IOException { - HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/1"); - HttpResponse response = client.execute(httpDelete); + final HttpDelete httpDelete = new HttpDelete(BASE_URL + "1/students/1"); + final HttpResponse response = client.execute(httpDelete); assertEquals(200, response.getStatusLine().getStatusCode()); - - Course course = getCourse(1); + + final Course course = getCourse(1); assertEquals(1, course.getStudents().size()); assertEquals(2, course.getStudents().get(0).getId()); assertEquals("Student B", course.getStudents().get(0).getName()); } private Course getCourse(int courseOrder) throws IOException { - URL url = new URL(BASE_URL + courseOrder); - InputStream input = url.openStream(); + final URL url = new URL(BASE_URL + courseOrder); + final InputStream input = url.openStream(); return JAXB.unmarshal(new InputStreamReader(input), Course.class); } private Student getStudent(int courseOrder, int studentOrder) throws IOException { - URL url = new URL(BASE_URL + courseOrder + "/students/" + studentOrder); - InputStream input = url.openStream(); + final URL url = new URL(BASE_URL + courseOrder + "/students/" + studentOrder); + final InputStream input = url.openStream(); return JAXB.unmarshal(new InputStreamReader(input), Student.class); } } \ No newline at end of file diff --git a/apache-cxf/cxf-spring/pom.xml b/apache-cxf/cxf-spring/pom.xml index 85e68300f0..8f1dee965a 100644 --- a/apache-cxf/cxf-spring/pom.xml +++ b/apache-cxf/cxf-spring/pom.xml @@ -51,7 +51,7 @@ ${surefire.version} - StudentTest.java + **/*LiveTest.java @@ -60,7 +60,7 @@ - integration + live diff --git a/apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentTest.java b/apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentLiveTest.java similarity index 97% rename from apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentTest.java rename to apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentLiveTest.java index 7466944e04..80a8f6c3b8 100644 --- a/apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentTest.java +++ b/apache-cxf/cxf-spring/src/test/java/com/baeldung/cxf/spring/StudentLiveTest.java @@ -6,7 +6,7 @@ import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; -public class StudentTest { +public class StudentLiveTest { private ApplicationContext context = new AnnotationConfigApplicationContext(ClientConfiguration.class); private Baeldung baeldungProxy = (Baeldung) context.getBean("client"); From 951552c7428c2aab1f531ffda16f74a070481d92 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 12:27:49 +0200 Subject: [PATCH 45/52] Rename autovalue-tutorial -> autovalue --- {autovalue-tutorial => autovalue}/README.md | 0 {autovalue-tutorial => autovalue}/pom.xml | 0 .../src/main/java/com/baeldung/autovalue/AutoValueMoney.java | 0 .../java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java | 0 .../src/main/java/com/baeldung/autovalue/Foo.java | 0 .../src/main/java/com/baeldung/autovalue/ImmutableMoney.java | 0 .../src/main/java/com/baeldung/autovalue/MutableMoney.java | 0 .../src/test/java/com/baeldung/autovalue/MoneyTest.java | 0 pom.xml | 2 +- 9 files changed, 1 insertion(+), 1 deletion(-) rename {autovalue-tutorial => autovalue}/README.md (100%) rename {autovalue-tutorial => autovalue}/pom.xml (100%) rename {autovalue-tutorial => autovalue}/src/main/java/com/baeldung/autovalue/AutoValueMoney.java (100%) rename {autovalue-tutorial => autovalue}/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java (100%) rename {autovalue-tutorial => autovalue}/src/main/java/com/baeldung/autovalue/Foo.java (100%) rename {autovalue-tutorial => autovalue}/src/main/java/com/baeldung/autovalue/ImmutableMoney.java (100%) rename {autovalue-tutorial => autovalue}/src/main/java/com/baeldung/autovalue/MutableMoney.java (100%) rename {autovalue-tutorial => autovalue}/src/test/java/com/baeldung/autovalue/MoneyTest.java (100%) diff --git a/autovalue-tutorial/README.md b/autovalue/README.md similarity index 100% rename from autovalue-tutorial/README.md rename to autovalue/README.md diff --git a/autovalue-tutorial/pom.xml b/autovalue/pom.xml similarity index 100% rename from autovalue-tutorial/pom.xml rename to autovalue/pom.xml diff --git a/autovalue-tutorial/src/main/java/com/baeldung/autovalue/AutoValueMoney.java b/autovalue/src/main/java/com/baeldung/autovalue/AutoValueMoney.java similarity index 100% rename from autovalue-tutorial/src/main/java/com/baeldung/autovalue/AutoValueMoney.java rename to autovalue/src/main/java/com/baeldung/autovalue/AutoValueMoney.java diff --git a/autovalue-tutorial/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java b/autovalue/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java similarity index 100% rename from autovalue-tutorial/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java rename to autovalue/src/main/java/com/baeldung/autovalue/AutoValueMoneyWithBuilder.java diff --git a/autovalue-tutorial/src/main/java/com/baeldung/autovalue/Foo.java b/autovalue/src/main/java/com/baeldung/autovalue/Foo.java similarity index 100% rename from autovalue-tutorial/src/main/java/com/baeldung/autovalue/Foo.java rename to autovalue/src/main/java/com/baeldung/autovalue/Foo.java diff --git a/autovalue-tutorial/src/main/java/com/baeldung/autovalue/ImmutableMoney.java b/autovalue/src/main/java/com/baeldung/autovalue/ImmutableMoney.java similarity index 100% rename from autovalue-tutorial/src/main/java/com/baeldung/autovalue/ImmutableMoney.java rename to autovalue/src/main/java/com/baeldung/autovalue/ImmutableMoney.java diff --git a/autovalue-tutorial/src/main/java/com/baeldung/autovalue/MutableMoney.java b/autovalue/src/main/java/com/baeldung/autovalue/MutableMoney.java similarity index 100% rename from autovalue-tutorial/src/main/java/com/baeldung/autovalue/MutableMoney.java rename to autovalue/src/main/java/com/baeldung/autovalue/MutableMoney.java diff --git a/autovalue-tutorial/src/test/java/com/baeldung/autovalue/MoneyTest.java b/autovalue/src/test/java/com/baeldung/autovalue/MoneyTest.java similarity index 100% rename from autovalue-tutorial/src/test/java/com/baeldung/autovalue/MoneyTest.java rename to autovalue/src/test/java/com/baeldung/autovalue/MoneyTest.java diff --git a/pom.xml b/pom.xml index 9979ff95a5..0a8b39b14f 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ assertj apache-cxf - autovalue-tutorial + autovalue cdi core-java From fc1aaef4717cf0734263e1268070accc68e6c189 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 14:19:10 +0200 Subject: [PATCH 46/52] Rename dependency-injection -> spring-core --- {dependency-injection => spring-core}/.gitignore | 0 {dependency-injection => spring-core}/README.md | 0 {dependency-injection => spring-core}/pom.xml | 0 .../ApplicationContextTestAutowiredName.java | 0 .../ApplicationContextTestAutowiredQualifier.java | 0 .../ApplicationContextTestAutowiredType.java | 0 .../ApplicationContextTestInjectName.java | 0 .../ApplicationContextTestInjectQualifier.java | 0 .../ApplicationContextTestInjectType.java | 0 .../ApplicationContextTestResourceNameType.java | 0 .../ApplicationContextTestResourceQualifier.java | 0 .../dependency/AnotherArbitraryDependency.java | 0 .../com/baeldung/dependency/ArbitraryDependency.java | 0 .../dependency/YetAnotherArbitraryDependency.java | 0 .../autowired/FieldAutowiredIntegrationTest.java | 0 .../autowired/FieldAutowiredNameIntegrationTest.java | 0 .../FieldQualifierAutowiredIntegrationTest.java | 0 .../inject/FieldByNameInjectIntegrationTest.java | 0 .../baeldung/inject/FieldInjectIntegrationTest.java | 0 .../inject/FieldQualifierInjectIntegrationTest.java | 0 .../FieldResourceInjectionIntegrationTest.java | 0 .../MethodByQualifierResourceIntegrationTest.java | 0 .../MethodByTypeResourceIntegrationTest.java | 0 .../MethodResourceInjectionIntegrationTest.java | 0 .../resource/NamedResourceIntegrationTest.java | 0 .../QualifierResourceInjectionIntegrationTest.java | 0 .../SetterResourceInjectionIntegrationTest.java | 0 .../spring/web/config/MainWebAppInitializer.java | 12 +++++------- 28 files changed, 5 insertions(+), 7 deletions(-) rename {dependency-injection => spring-core}/.gitignore (100%) rename {dependency-injection => spring-core}/README.md (100%) rename {dependency-injection => spring-core}/pom.xml (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredName.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredQualifier.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredType.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectName.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectQualifier.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectType.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceNameType.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceQualifier.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/dependency/AnotherArbitraryDependency.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/dependency/ArbitraryDependency.java (100%) rename {dependency-injection => spring-core}/src/main/java/com/baeldung/dependency/YetAnotherArbitraryDependency.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/autowired/FieldAutowiredIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/autowired/FieldAutowiredNameIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/inject/FieldByNameInjectIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/inject/FieldInjectIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/inject/FieldQualifierInjectIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/resource/FieldResourceInjectionIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/resource/MethodByQualifierResourceIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/resource/MethodByTypeResourceIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/resource/MethodResourceInjectionIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/resource/NamedResourceIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/resource/QualifierResourceInjectionIntegrationTest.java (100%) rename {dependency-injection => spring-core}/src/test/java/com/baeldung/resource/SetterResourceInjectionIntegrationTest.java (100%) diff --git a/dependency-injection/.gitignore b/spring-core/.gitignore similarity index 100% rename from dependency-injection/.gitignore rename to spring-core/.gitignore diff --git a/dependency-injection/README.md b/spring-core/README.md similarity index 100% rename from dependency-injection/README.md rename to spring-core/README.md diff --git a/dependency-injection/pom.xml b/spring-core/pom.xml similarity index 100% rename from dependency-injection/pom.xml rename to spring-core/pom.xml diff --git a/dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredName.java b/spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredName.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredName.java rename to spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredName.java diff --git a/dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredQualifier.java b/spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredQualifier.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredQualifier.java rename to spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredQualifier.java diff --git a/dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredType.java b/spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredType.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredType.java rename to spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredType.java diff --git a/dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectName.java b/spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectName.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectName.java rename to spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectName.java diff --git a/dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectQualifier.java b/spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectQualifier.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectQualifier.java rename to spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectQualifier.java diff --git a/dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectType.java b/spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectType.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectType.java rename to spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectType.java diff --git a/dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceNameType.java b/spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceNameType.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceNameType.java rename to spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceNameType.java diff --git a/dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceQualifier.java b/spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceQualifier.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceQualifier.java rename to spring-core/src/main/java/com/baeldung/configuration/ApplicationContextTestResourceQualifier.java diff --git a/dependency-injection/src/main/java/com/baeldung/dependency/AnotherArbitraryDependency.java b/spring-core/src/main/java/com/baeldung/dependency/AnotherArbitraryDependency.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/dependency/AnotherArbitraryDependency.java rename to spring-core/src/main/java/com/baeldung/dependency/AnotherArbitraryDependency.java diff --git a/dependency-injection/src/main/java/com/baeldung/dependency/ArbitraryDependency.java b/spring-core/src/main/java/com/baeldung/dependency/ArbitraryDependency.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/dependency/ArbitraryDependency.java rename to spring-core/src/main/java/com/baeldung/dependency/ArbitraryDependency.java diff --git a/dependency-injection/src/main/java/com/baeldung/dependency/YetAnotherArbitraryDependency.java b/spring-core/src/main/java/com/baeldung/dependency/YetAnotherArbitraryDependency.java similarity index 100% rename from dependency-injection/src/main/java/com/baeldung/dependency/YetAnotherArbitraryDependency.java rename to spring-core/src/main/java/com/baeldung/dependency/YetAnotherArbitraryDependency.java diff --git a/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredIntegrationTest.java b/spring-core/src/test/java/com/baeldung/autowired/FieldAutowiredIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/autowired/FieldAutowiredIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredNameIntegrationTest.java b/spring-core/src/test/java/com/baeldung/autowired/FieldAutowiredNameIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/autowired/FieldAutowiredNameIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/autowired/FieldAutowiredNameIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredIntegrationTest.java b/spring-core/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/autowired/FieldQualifierAutowiredIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/inject/FieldByNameInjectIntegrationTest.java b/spring-core/src/test/java/com/baeldung/inject/FieldByNameInjectIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/inject/FieldByNameInjectIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/inject/FieldByNameInjectIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/inject/FieldInjectIntegrationTest.java b/spring-core/src/test/java/com/baeldung/inject/FieldInjectIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/inject/FieldInjectIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/inject/FieldInjectIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/inject/FieldQualifierInjectIntegrationTest.java b/spring-core/src/test/java/com/baeldung/inject/FieldQualifierInjectIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/inject/FieldQualifierInjectIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/inject/FieldQualifierInjectIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/resource/FieldResourceInjectionIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/FieldResourceInjectionIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/resource/FieldResourceInjectionIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/resource/FieldResourceInjectionIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/resource/MethodByQualifierResourceIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/MethodByQualifierResourceIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/resource/MethodByQualifierResourceIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/resource/MethodByQualifierResourceIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/resource/MethodByTypeResourceIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/MethodByTypeResourceIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/resource/MethodByTypeResourceIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/resource/MethodByTypeResourceIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/resource/MethodResourceInjectionIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/MethodResourceInjectionIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/resource/MethodResourceInjectionIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/resource/MethodResourceInjectionIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/resource/NamedResourceIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/NamedResourceIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/resource/NamedResourceIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/resource/NamedResourceIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/resource/QualifierResourceInjectionIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/QualifierResourceInjectionIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/resource/QualifierResourceInjectionIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/resource/QualifierResourceInjectionIntegrationTest.java diff --git a/dependency-injection/src/test/java/com/baeldung/resource/SetterResourceInjectionIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/SetterResourceInjectionIntegrationTest.java similarity index 100% rename from dependency-injection/src/test/java/com/baeldung/resource/SetterResourceInjectionIntegrationTest.java rename to spring-core/src/test/java/com/baeldung/resource/SetterResourceInjectionIntegrationTest.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java index f428fc3223..80ce22edd6 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java +++ b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java @@ -1,17 +1,16 @@ package com.baeldung.spring.web.config; -import java.util.Set; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; - import org.springframework.web.WebApplicationInitializer; import org.springframework.web.context.ContextLoaderListener; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; import org.springframework.web.context.support.GenericWebApplicationContext; import org.springframework.web.servlet.DispatcherServlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; +import java.util.Set; + public class MainWebAppInitializer implements WebApplicationInitializer { private static final String TMP_FOLDER = "/tmp"; @@ -28,7 +27,6 @@ public class MainWebAppInitializer implements WebApplicationInitializer { root.scan("com.baeldung.spring.web.config"); // root.getEnvironment().setDefaultProfiles("embedded"); - // Manages the lifecycle of the root application context sc.addListener(new ContextLoaderListener(root)); // Handles requests into the application From 26fbeb98da706708749575a9497254243c0c247f Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 14:23:56 +0200 Subject: [PATCH 47/52] Rename module --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0a8b39b14f..b38fe174c9 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,6 @@ dozer - dependency-injection deltaspike patterns @@ -75,6 +74,7 @@ spring-autowire spring-batch spring-boot + spring-core spring-cucumber spring-data-cassandra spring-data-couchbase-2 From b1b4d4ff7fa9c70316352de43cbc44cce6574610 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 18:57:21 +0200 Subject: [PATCH 48/52] Rename jooq-spring -> spring-jooq --- pom.xml | 5 +++-- {jooq-spring => spring-jooq}/.gitignore | 0 {jooq-spring => spring-jooq}/README.md | 0 {jooq-spring => spring-jooq}/pom.xml | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/intro_config.properties | 0 .../src/main/resources/intro_schema.sql | 0 .../com/baeldung/jooq/introduction/ExceptionTranslator.java | 0 .../jooq/introduction/PersistenceContextIntegrationTest.java | 0 .../com/baeldung/jooq/introduction/QueryIntegrationTest.java | 0 .../test/java/com/baeldung/jooq/springboot/Application.java | 0 .../com/baeldung/jooq/springboot/InitialConfiguration.java | 0 .../baeldung/jooq/springboot/SpringBootIntegrationTest.java | 0 13 files changed, 3 insertions(+), 2 deletions(-) rename {jooq-spring => spring-jooq}/.gitignore (100%) rename {jooq-spring => spring-jooq}/README.md (100%) rename {jooq-spring => spring-jooq}/pom.xml (100%) rename {jooq-spring => spring-jooq}/src/main/resources/application.properties (100%) rename {jooq-spring => spring-jooq}/src/main/resources/intro_config.properties (100%) rename {jooq-spring => spring-jooq}/src/main/resources/intro_schema.sql (100%) rename {jooq-spring => spring-jooq}/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java (100%) rename {jooq-spring => spring-jooq}/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java (100%) rename {jooq-spring => spring-jooq}/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java (100%) rename {jooq-spring => spring-jooq}/src/test/java/com/baeldung/jooq/springboot/Application.java (100%) rename {jooq-spring => spring-jooq}/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java (100%) rename {jooq-spring => spring-jooq}/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java (100%) diff --git a/pom.xml b/pom.xml index b38fe174c9..71d12fddcf 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ jackson javaxval jjwt - jooq-spring + jpa-storedprocedure json json-path @@ -87,8 +87,9 @@ spring-freemarker spring-hibernate3 spring-hibernate4 - spring-jpa spring-jms + spring-jooq + spring-jpa spring-katharsis spring-mockito spring-mvc-java diff --git a/jooq-spring/.gitignore b/spring-jooq/.gitignore similarity index 100% rename from jooq-spring/.gitignore rename to spring-jooq/.gitignore diff --git a/jooq-spring/README.md b/spring-jooq/README.md similarity index 100% rename from jooq-spring/README.md rename to spring-jooq/README.md diff --git a/jooq-spring/pom.xml b/spring-jooq/pom.xml similarity index 100% rename from jooq-spring/pom.xml rename to spring-jooq/pom.xml diff --git a/jooq-spring/src/main/resources/application.properties b/spring-jooq/src/main/resources/application.properties similarity index 100% rename from jooq-spring/src/main/resources/application.properties rename to spring-jooq/src/main/resources/application.properties diff --git a/jooq-spring/src/main/resources/intro_config.properties b/spring-jooq/src/main/resources/intro_config.properties similarity index 100% rename from jooq-spring/src/main/resources/intro_config.properties rename to spring-jooq/src/main/resources/intro_config.properties diff --git a/jooq-spring/src/main/resources/intro_schema.sql b/spring-jooq/src/main/resources/intro_schema.sql similarity index 100% rename from jooq-spring/src/main/resources/intro_schema.sql rename to spring-jooq/src/main/resources/intro_schema.sql diff --git a/jooq-spring/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java b/spring-jooq/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java similarity index 100% rename from jooq-spring/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java rename to spring-jooq/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java diff --git a/jooq-spring/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java b/spring-jooq/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java similarity index 100% rename from jooq-spring/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java rename to spring-jooq/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java diff --git a/jooq-spring/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java b/spring-jooq/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java similarity index 100% rename from jooq-spring/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java rename to spring-jooq/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java diff --git a/jooq-spring/src/test/java/com/baeldung/jooq/springboot/Application.java b/spring-jooq/src/test/java/com/baeldung/jooq/springboot/Application.java similarity index 100% rename from jooq-spring/src/test/java/com/baeldung/jooq/springboot/Application.java rename to spring-jooq/src/test/java/com/baeldung/jooq/springboot/Application.java diff --git a/jooq-spring/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java b/spring-jooq/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java similarity index 100% rename from jooq-spring/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java rename to spring-jooq/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java diff --git a/jooq-spring/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java b/spring-jooq/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java similarity index 100% rename from jooq-spring/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java rename to spring-jooq/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java From a757c7e301012dac6c2615bef93dc0d7b2a28cb0 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 19:07:13 +0200 Subject: [PATCH 49/52] Rename flyway-migration -> flyway --- {flyway-migration => flyway}/.gitignore | 6 +- {flyway-migration => flyway}/README.MD | 0 .../V1_0__create_employee_schema.sql | 14 ++-- .../V2_0__create_department_schema.sql | 14 ++-- .../myFlywayConfig.properties | 8 +-- {flyway-migration => flyway}/pom.xml | 66 +++++++++---------- pom.xml | 2 + 7 files changed, 56 insertions(+), 54 deletions(-) rename {flyway-migration => flyway}/.gitignore (75%) rename {flyway-migration => flyway}/README.MD (100%) rename {flyway-migration => flyway}/db/migration/V1_0__create_employee_schema.sql (77%) rename {flyway-migration => flyway}/db/migration/V2_0__create_department_schema.sql (70%) rename {flyway-migration => flyway}/myFlywayConfig.properties (69%) rename {flyway-migration => flyway}/pom.xml (90%) diff --git a/flyway-migration/.gitignore b/flyway/.gitignore similarity index 75% rename from flyway-migration/.gitignore rename to flyway/.gitignore index abffe04ed2..9cdd5b9542 100644 --- a/flyway-migration/.gitignore +++ b/flyway/.gitignore @@ -1,4 +1,4 @@ -.classpath -.project -.settings +.classpath +.project +.settings target/ \ No newline at end of file diff --git a/flyway-migration/README.MD b/flyway/README.MD similarity index 100% rename from flyway-migration/README.MD rename to flyway/README.MD diff --git a/flyway-migration/db/migration/V1_0__create_employee_schema.sql b/flyway/db/migration/V1_0__create_employee_schema.sql similarity index 77% rename from flyway-migration/db/migration/V1_0__create_employee_schema.sql rename to flyway/db/migration/V1_0__create_employee_schema.sql index 09408faecb..b6167bfacc 100644 --- a/flyway-migration/db/migration/V1_0__create_employee_schema.sql +++ b/flyway/db/migration/V1_0__create_employee_schema.sql @@ -1,8 +1,8 @@ -CREATE TABLE IF NOT EXISTS `employee` ( - -`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, -`name` varchar(20), -`email` varchar(50), -`date_of_birth` timestamp - +CREATE TABLE IF NOT EXISTS `employee` ( + +`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, +`name` varchar(20), +`email` varchar(50), +`date_of_birth` timestamp + )ENGINE=InnoDB DEFAULT CHARSET=UTF8; \ No newline at end of file diff --git a/flyway-migration/db/migration/V2_0__create_department_schema.sql b/flyway/db/migration/V2_0__create_department_schema.sql similarity index 70% rename from flyway-migration/db/migration/V2_0__create_department_schema.sql rename to flyway/db/migration/V2_0__create_department_schema.sql index 2b9d3364a5..c85cc81353 100644 --- a/flyway-migration/db/migration/V2_0__create_department_schema.sql +++ b/flyway/db/migration/V2_0__create_department_schema.sql @@ -1,8 +1,8 @@ -CREATE TABLE IF NOT EXISTS `department` ( - -`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, -`name` varchar(20) - -)ENGINE=InnoDB DEFAULT CHARSET=UTF8; - +CREATE TABLE IF NOT EXISTS `department` ( + +`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY, +`name` varchar(20) + +)ENGINE=InnoDB DEFAULT CHARSET=UTF8; + ALTER TABLE `employee` ADD `dept_id` int AFTER `email`; \ No newline at end of file diff --git a/flyway-migration/myFlywayConfig.properties b/flyway/myFlywayConfig.properties similarity index 69% rename from flyway-migration/myFlywayConfig.properties rename to flyway/myFlywayConfig.properties index 22f3afefd3..8bb102930a 100644 --- a/flyway-migration/myFlywayConfig.properties +++ b/flyway/myFlywayConfig.properties @@ -1,5 +1,5 @@ -flyway.user=root -flyway.password=mysql -flyway.schemas=app-db -flyway.url=jdbc:mysql://localhost:3306/ +flyway.user=root +flyway.password=mysql +flyway.schemas=app-db +flyway.url=jdbc:mysql://localhost:3306/ flyway.locations=filesystem:db/migration \ No newline at end of file diff --git a/flyway-migration/pom.xml b/flyway/pom.xml similarity index 90% rename from flyway-migration/pom.xml rename to flyway/pom.xml index 6e9d683a0e..d53bc7dc41 100644 --- a/flyway-migration/pom.xml +++ b/flyway/pom.xml @@ -1,34 +1,34 @@ - - 4.0.0 - com.baeldung - flyway-migration - 1.0 - flyway-migration - A sample project to demonstrate Flyway migrations - - - mysql - mysql-connector-java - 6.0.3 - - - - - - org.flywaydb - flyway-maven-plugin - 4.0.3 - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - 1.8 - 1.8 - - - - + + 4.0.0 + com.baeldung + flyway + 1.0 + flyway + A sample project to demonstrate Flyway migrations + + + mysql + mysql-connector-java + 6.0.3 + + + + + + org.flywaydb + flyway-maven-plugin + 4.0.3 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 71d12fddcf..bec40024b7 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,8 @@ feign-client + flyway + gson guava guava18 From 9055ecbc6fc56e563eead2fc1ae615621e304af3 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 19:10:16 +0200 Subject: [PATCH 50/52] Rename xmlunit2-tutorial -> xmlunit2 --- pom.xml | 1 + {xmlunit2-tutorial => xmlunit2}/README.md | 0 {xmlunit2-tutorial => xmlunit2}/pom.xml | 2 +- .../baeldung/xmlunit/IgnoreAttributeDifferenceEvaluator.java | 0 .../src/test/java/com/baeldung/xmlunit/XMLUnitTest.java | 0 {xmlunit2-tutorial => xmlunit2}/src/test/resources/control.xml | 0 {xmlunit2-tutorial => xmlunit2}/src/test/resources/students.xml | 0 {xmlunit2-tutorial => xmlunit2}/src/test/resources/students.xsd | 0 .../src/test/resources/students_with_error.xml | 0 {xmlunit2-tutorial => xmlunit2}/src/test/resources/teachers.xml | 0 {xmlunit2-tutorial => xmlunit2}/src/test/resources/test.xml | 0 11 files changed, 2 insertions(+), 1 deletion(-) rename {xmlunit2-tutorial => xmlunit2}/README.md (100%) rename {xmlunit2-tutorial => xmlunit2}/pom.xml (96%) rename {xmlunit2-tutorial => xmlunit2}/src/main/java/com/baeldung/xmlunit/IgnoreAttributeDifferenceEvaluator.java (100%) rename {xmlunit2-tutorial => xmlunit2}/src/test/java/com/baeldung/xmlunit/XMLUnitTest.java (100%) rename {xmlunit2-tutorial => xmlunit2}/src/test/resources/control.xml (100%) rename {xmlunit2-tutorial => xmlunit2}/src/test/resources/students.xml (100%) rename {xmlunit2-tutorial => xmlunit2}/src/test/resources/students.xsd (100%) rename {xmlunit2-tutorial => xmlunit2}/src/test/resources/students_with_error.xml (100%) rename {xmlunit2-tutorial => xmlunit2}/src/test/resources/teachers.xml (100%) rename {xmlunit2-tutorial => xmlunit2}/src/test/resources/test.xml (100%) diff --git a/pom.xml b/pom.xml index bec40024b7..f1c23bfb55 100644 --- a/pom.xml +++ b/pom.xml @@ -129,6 +129,7 @@ jsf xml + xmlunit2 lombok redis diff --git a/xmlunit2-tutorial/README.md b/xmlunit2/README.md similarity index 100% rename from xmlunit2-tutorial/README.md rename to xmlunit2/README.md diff --git a/xmlunit2-tutorial/pom.xml b/xmlunit2/pom.xml similarity index 96% rename from xmlunit2-tutorial/pom.xml rename to xmlunit2/pom.xml index b4cb684f65..c80e3f37b2 100644 --- a/xmlunit2-tutorial/pom.xml +++ b/xmlunit2/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 com.baeldung - xmlunit2-tutorial + xmlunit2 1.0 XMLUnit-2 diff --git a/xmlunit2-tutorial/src/main/java/com/baeldung/xmlunit/IgnoreAttributeDifferenceEvaluator.java b/xmlunit2/src/main/java/com/baeldung/xmlunit/IgnoreAttributeDifferenceEvaluator.java similarity index 100% rename from xmlunit2-tutorial/src/main/java/com/baeldung/xmlunit/IgnoreAttributeDifferenceEvaluator.java rename to xmlunit2/src/main/java/com/baeldung/xmlunit/IgnoreAttributeDifferenceEvaluator.java diff --git a/xmlunit2-tutorial/src/test/java/com/baeldung/xmlunit/XMLUnitTest.java b/xmlunit2/src/test/java/com/baeldung/xmlunit/XMLUnitTest.java similarity index 100% rename from xmlunit2-tutorial/src/test/java/com/baeldung/xmlunit/XMLUnitTest.java rename to xmlunit2/src/test/java/com/baeldung/xmlunit/XMLUnitTest.java diff --git a/xmlunit2-tutorial/src/test/resources/control.xml b/xmlunit2/src/test/resources/control.xml similarity index 100% rename from xmlunit2-tutorial/src/test/resources/control.xml rename to xmlunit2/src/test/resources/control.xml diff --git a/xmlunit2-tutorial/src/test/resources/students.xml b/xmlunit2/src/test/resources/students.xml similarity index 100% rename from xmlunit2-tutorial/src/test/resources/students.xml rename to xmlunit2/src/test/resources/students.xml diff --git a/xmlunit2-tutorial/src/test/resources/students.xsd b/xmlunit2/src/test/resources/students.xsd similarity index 100% rename from xmlunit2-tutorial/src/test/resources/students.xsd rename to xmlunit2/src/test/resources/students.xsd diff --git a/xmlunit2-tutorial/src/test/resources/students_with_error.xml b/xmlunit2/src/test/resources/students_with_error.xml similarity index 100% rename from xmlunit2-tutorial/src/test/resources/students_with_error.xml rename to xmlunit2/src/test/resources/students_with_error.xml diff --git a/xmlunit2-tutorial/src/test/resources/teachers.xml b/xmlunit2/src/test/resources/teachers.xml similarity index 100% rename from xmlunit2-tutorial/src/test/resources/teachers.xml rename to xmlunit2/src/test/resources/teachers.xml diff --git a/xmlunit2-tutorial/src/test/resources/test.xml b/xmlunit2/src/test/resources/test.xml similarity index 100% rename from xmlunit2-tutorial/src/test/resources/test.xml rename to xmlunit2/src/test/resources/test.xml From 90ca6097627098d2203675524f56e3e51b1ce380 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 19:13:21 +0200 Subject: [PATCH 51/52] Rename jee7schedule -> jee7 --- {jee7schedule => jee7}/README.md | 0 {jee7schedule => jee7}/pom.xml | 0 .../baeldung/timer/AutomaticTimerBean.java | 0 .../baeldung/timer/FixedDelayTimerBean.java | 0 .../ProgrammaticAtFixedRateTimerBean.java | 0 .../baeldung/timer/ProgrammaticTimerBean.java | 0 ...ammaticWithInitialFixedDelayTimerBean.java | 0 .../com/baeldung/timer/ScheduleTimerBean.java | 0 .../java/com/baeldung/timer/TimerEvent.java | 0 .../baeldung/timer/TimerEventListener.java | 0 .../java/com/baeldung/timer/WorkerBean.java | 0 .../src/main/webapp/WEB-INF/beans.xml | 0 .../timer/AutomaticTimerBeanTest.java | 0 .../ProgrammaticAtFixedRateTimerBeanTest.java | 0 .../timer/ProgrammaticTimerBeanTest.java | 0 ...ogrammaticWithFixedDelayTimerBeanTest.java | 0 .../baeldung/timer/ScheduleTimerBeanTest.java | 0 .../baeldung/timer/WithinWindowMatcher.java | 0 pom.xml | 2 +- .../com/baeldung/xmlunit/XMLUnitTest.java | 33 ++++++++----------- 20 files changed, 14 insertions(+), 21 deletions(-) rename {jee7schedule => jee7}/README.md (100%) rename {jee7schedule => jee7}/pom.xml (100%) rename {jee7schedule => jee7}/src/main/java/com/baeldung/timer/AutomaticTimerBean.java (100%) rename {jee7schedule => jee7}/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java (100%) rename {jee7schedule => jee7}/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java (100%) rename {jee7schedule => jee7}/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java (100%) rename {jee7schedule => jee7}/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java (100%) rename {jee7schedule => jee7}/src/main/java/com/baeldung/timer/ScheduleTimerBean.java (100%) rename {jee7schedule => jee7}/src/main/java/com/baeldung/timer/TimerEvent.java (100%) rename {jee7schedule => jee7}/src/main/java/com/baeldung/timer/TimerEventListener.java (100%) rename {jee7schedule => jee7}/src/main/java/com/baeldung/timer/WorkerBean.java (100%) rename {jee7schedule => jee7}/src/main/webapp/WEB-INF/beans.xml (100%) rename {jee7schedule => jee7}/src/test/java/com/baeldung/timer/AutomaticTimerBeanTest.java (100%) rename {jee7schedule => jee7}/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanTest.java (100%) rename {jee7schedule => jee7}/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanTest.java (100%) rename {jee7schedule => jee7}/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanTest.java (100%) rename {jee7schedule => jee7}/src/test/java/com/baeldung/timer/ScheduleTimerBeanTest.java (100%) rename {jee7schedule => jee7}/src/test/java/com/baeldung/timer/WithinWindowMatcher.java (100%) diff --git a/jee7schedule/README.md b/jee7/README.md similarity index 100% rename from jee7schedule/README.md rename to jee7/README.md diff --git a/jee7schedule/pom.xml b/jee7/pom.xml similarity index 100% rename from jee7schedule/pom.xml rename to jee7/pom.xml diff --git a/jee7schedule/src/main/java/com/baeldung/timer/AutomaticTimerBean.java b/jee7/src/main/java/com/baeldung/timer/AutomaticTimerBean.java similarity index 100% rename from jee7schedule/src/main/java/com/baeldung/timer/AutomaticTimerBean.java rename to jee7/src/main/java/com/baeldung/timer/AutomaticTimerBean.java diff --git a/jee7schedule/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java b/jee7/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java similarity index 100% rename from jee7schedule/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java rename to jee7/src/main/java/com/baeldung/timer/FixedDelayTimerBean.java diff --git a/jee7schedule/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java b/jee7/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java similarity index 100% rename from jee7schedule/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java rename to jee7/src/main/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBean.java diff --git a/jee7schedule/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java b/jee7/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java similarity index 100% rename from jee7schedule/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java rename to jee7/src/main/java/com/baeldung/timer/ProgrammaticTimerBean.java diff --git a/jee7schedule/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java b/jee7/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java similarity index 100% rename from jee7schedule/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java rename to jee7/src/main/java/com/baeldung/timer/ProgrammaticWithInitialFixedDelayTimerBean.java diff --git a/jee7schedule/src/main/java/com/baeldung/timer/ScheduleTimerBean.java b/jee7/src/main/java/com/baeldung/timer/ScheduleTimerBean.java similarity index 100% rename from jee7schedule/src/main/java/com/baeldung/timer/ScheduleTimerBean.java rename to jee7/src/main/java/com/baeldung/timer/ScheduleTimerBean.java diff --git a/jee7schedule/src/main/java/com/baeldung/timer/TimerEvent.java b/jee7/src/main/java/com/baeldung/timer/TimerEvent.java similarity index 100% rename from jee7schedule/src/main/java/com/baeldung/timer/TimerEvent.java rename to jee7/src/main/java/com/baeldung/timer/TimerEvent.java diff --git a/jee7schedule/src/main/java/com/baeldung/timer/TimerEventListener.java b/jee7/src/main/java/com/baeldung/timer/TimerEventListener.java similarity index 100% rename from jee7schedule/src/main/java/com/baeldung/timer/TimerEventListener.java rename to jee7/src/main/java/com/baeldung/timer/TimerEventListener.java diff --git a/jee7schedule/src/main/java/com/baeldung/timer/WorkerBean.java b/jee7/src/main/java/com/baeldung/timer/WorkerBean.java similarity index 100% rename from jee7schedule/src/main/java/com/baeldung/timer/WorkerBean.java rename to jee7/src/main/java/com/baeldung/timer/WorkerBean.java diff --git a/jee7schedule/src/main/webapp/WEB-INF/beans.xml b/jee7/src/main/webapp/WEB-INF/beans.xml similarity index 100% rename from jee7schedule/src/main/webapp/WEB-INF/beans.xml rename to jee7/src/main/webapp/WEB-INF/beans.xml diff --git a/jee7schedule/src/test/java/com/baeldung/timer/AutomaticTimerBeanTest.java b/jee7/src/test/java/com/baeldung/timer/AutomaticTimerBeanTest.java similarity index 100% rename from jee7schedule/src/test/java/com/baeldung/timer/AutomaticTimerBeanTest.java rename to jee7/src/test/java/com/baeldung/timer/AutomaticTimerBeanTest.java diff --git a/jee7schedule/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanTest.java b/jee7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanTest.java similarity index 100% rename from jee7schedule/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanTest.java rename to jee7/src/test/java/com/baeldung/timer/ProgrammaticAtFixedRateTimerBeanTest.java diff --git a/jee7schedule/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanTest.java b/jee7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanTest.java similarity index 100% rename from jee7schedule/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanTest.java rename to jee7/src/test/java/com/baeldung/timer/ProgrammaticTimerBeanTest.java diff --git a/jee7schedule/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanTest.java b/jee7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanTest.java similarity index 100% rename from jee7schedule/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanTest.java rename to jee7/src/test/java/com/baeldung/timer/ProgrammaticWithFixedDelayTimerBeanTest.java diff --git a/jee7schedule/src/test/java/com/baeldung/timer/ScheduleTimerBeanTest.java b/jee7/src/test/java/com/baeldung/timer/ScheduleTimerBeanTest.java similarity index 100% rename from jee7schedule/src/test/java/com/baeldung/timer/ScheduleTimerBeanTest.java rename to jee7/src/test/java/com/baeldung/timer/ScheduleTimerBeanTest.java diff --git a/jee7schedule/src/test/java/com/baeldung/timer/WithinWindowMatcher.java b/jee7/src/test/java/com/baeldung/timer/WithinWindowMatcher.java similarity index 100% rename from jee7schedule/src/test/java/com/baeldung/timer/WithinWindowMatcher.java rename to jee7/src/test/java/com/baeldung/timer/WithinWindowMatcher.java diff --git a/pom.xml b/pom.xml index f1c23bfb55..4e8b54446d 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,7 @@ json json-path junit5 - jee7schedule + jee7 log4j diff --git a/xmlunit2/src/test/java/com/baeldung/xmlunit/XMLUnitTest.java b/xmlunit2/src/test/java/com/baeldung/xmlunit/XMLUnitTest.java index 175250f47b..5af3d48433 100644 --- a/xmlunit2/src/test/java/com/baeldung/xmlunit/XMLUnitTest.java +++ b/xmlunit2/src/test/java/com/baeldung/xmlunit/XMLUnitTest.java @@ -1,37 +1,30 @@ package com.baeldung.xmlunit; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.core.IsNot.not; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.xmlunit.matchers.CompareMatcher.isIdenticalTo; -import static org.xmlunit.matchers.CompareMatcher.isSimilarTo; -import static org.xmlunit.matchers.HasXPathMatcher.hasXPath; - -import java.io.File; -import java.util.Iterator; - import org.junit.Ignore; import org.junit.Test; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.xmlunit.builder.DiffBuilder; import org.xmlunit.builder.Input; -import org.xmlunit.diff.ComparisonControllers; -import org.xmlunit.diff.DefaultNodeMatcher; -import org.xmlunit.diff.Diff; -import org.xmlunit.diff.Difference; -import org.xmlunit.diff.ElementSelectors; +import org.xmlunit.diff.*; import org.xmlunit.validation.Languages; import org.xmlunit.validation.ValidationProblem; import org.xmlunit.validation.ValidationResult; import org.xmlunit.validation.Validator; import org.xmlunit.xpath.JAXPXPathEngine; +import java.io.File; +import java.util.Iterator; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.core.IsNot.not; +import static org.junit.Assert.*; +import static org.xmlunit.matchers.CompareMatcher.isIdenticalTo; +import static org.xmlunit.matchers.CompareMatcher.isSimilarTo; +import static org.xmlunit.matchers.HasXPathMatcher.hasXPath; + public class XMLUnitTest { @Test public void givenWrongXml_whenValidateFailsAgainstXsd_thenCorrect() { From 7df435bb6fa0e59aa3835d6fb845a7667b191607 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Sun, 23 Oct 2016 19:15:31 +0200 Subject: [PATCH 52/52] Rename feign-client -> feign --- {feign-client => feign}/README.md | 0 {feign-client => feign}/pom.xml | 0 .../com/baeldung/feign/BookControllerFeignClientBuilder.java | 0 .../src/main/java/com/baeldung/feign/clients/BookClient.java | 0 .../src/main/java/com/baeldung/feign/models/Book.java | 0 .../src/main/java/com/baeldung/feign/models/BookResource.java | 0 {feign-client => feign}/src/main/resources/log4j2.xml | 0 .../test/java/com/baeldung/feign/clients/BookClientTest.java | 0 pom.xml | 2 +- 9 files changed, 1 insertion(+), 1 deletion(-) rename {feign-client => feign}/README.md (100%) rename {feign-client => feign}/pom.xml (100%) rename {feign-client => feign}/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java (100%) rename {feign-client => feign}/src/main/java/com/baeldung/feign/clients/BookClient.java (100%) rename {feign-client => feign}/src/main/java/com/baeldung/feign/models/Book.java (100%) rename {feign-client => feign}/src/main/java/com/baeldung/feign/models/BookResource.java (100%) rename {feign-client => feign}/src/main/resources/log4j2.xml (100%) rename {feign-client => feign}/src/test/java/com/baeldung/feign/clients/BookClientTest.java (100%) diff --git a/feign-client/README.md b/feign/README.md similarity index 100% rename from feign-client/README.md rename to feign/README.md diff --git a/feign-client/pom.xml b/feign/pom.xml similarity index 100% rename from feign-client/pom.xml rename to feign/pom.xml diff --git a/feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java b/feign/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java similarity index 100% rename from feign-client/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java rename to feign/src/main/java/com/baeldung/feign/BookControllerFeignClientBuilder.java diff --git a/feign-client/src/main/java/com/baeldung/feign/clients/BookClient.java b/feign/src/main/java/com/baeldung/feign/clients/BookClient.java similarity index 100% rename from feign-client/src/main/java/com/baeldung/feign/clients/BookClient.java rename to feign/src/main/java/com/baeldung/feign/clients/BookClient.java diff --git a/feign-client/src/main/java/com/baeldung/feign/models/Book.java b/feign/src/main/java/com/baeldung/feign/models/Book.java similarity index 100% rename from feign-client/src/main/java/com/baeldung/feign/models/Book.java rename to feign/src/main/java/com/baeldung/feign/models/Book.java diff --git a/feign-client/src/main/java/com/baeldung/feign/models/BookResource.java b/feign/src/main/java/com/baeldung/feign/models/BookResource.java similarity index 100% rename from feign-client/src/main/java/com/baeldung/feign/models/BookResource.java rename to feign/src/main/java/com/baeldung/feign/models/BookResource.java diff --git a/feign-client/src/main/resources/log4j2.xml b/feign/src/main/resources/log4j2.xml similarity index 100% rename from feign-client/src/main/resources/log4j2.xml rename to feign/src/main/resources/log4j2.xml diff --git a/feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java b/feign/src/test/java/com/baeldung/feign/clients/BookClientTest.java similarity index 100% rename from feign-client/src/test/java/com/baeldung/feign/clients/BookClientTest.java rename to feign/src/test/java/com/baeldung/feign/clients/BookClientTest.java diff --git a/pom.xml b/pom.xml index 4e8b54446d..0de16500d6 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ deltaspike patterns - feign-client + feign flyway