From 66c5db02a3602c3d9c571f8d12938398e061e6eb Mon Sep 17 00:00:00 2001 From: DOHA Date: Sat, 15 Oct 2016 17:34:11 +0200 Subject: [PATCH] configure test profiles --- spring-security-rest-full/pom.xml | 39 ++++++++++++++++++- .../java/org/baeldung/spring/Application.java | 2 +- .../src/main/resources/application.properties | 2 + .../src/test/java/org/baeldung/Consts.java | 2 +- .../baeldung/client/RestTemplateLiveTest.java | 2 +- .../baeldung/common/web/AbstractLiveTest.java | 2 +- .../query/JPASpecificationLiveTest.java | 2 +- .../java/org/baeldung/web/MyUserLiveTest.java | 10 ++--- 8 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 spring-security-rest-full/src/main/resources/application.properties diff --git a/spring-security-rest-full/pom.xml b/spring-security-rest-full/pom.xml index b354e61b35..5cd0ed51f3 100644 --- a/spring-security-rest-full/pom.xml +++ b/spring-security-rest-full/pom.xml @@ -339,7 +339,7 @@ - 8080 + 8082 @@ -386,10 +386,45 @@ - none + **/*LiveTest.java **/*IntegrationTest.java + + + + + + + json + + + + + + + + + + live + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + integration-test + + test + + + + **/*IntegrationTest.java + + **/*LiveTest.java diff --git a/spring-security-rest-full/src/main/java/org/baeldung/spring/Application.java b/spring-security-rest-full/src/main/java/org/baeldung/spring/Application.java index c44e37fee8..f8bc6c0160 100644 --- a/spring-security-rest-full/src/main/java/org/baeldung/spring/Application.java +++ b/spring-security-rest-full/src/main/java/org/baeldung/spring/Application.java @@ -10,7 +10,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter /** * Main Application Class - uses Spring Boot. Just run this as a normal Java - * class to run up a Jetty Server (on http://localhost:8080) + * class to run up a Jetty Server (on http://localhost:8082/spring-security-rest-full) * */ @EnableScheduling diff --git a/spring-security-rest-full/src/main/resources/application.properties b/spring-security-rest-full/src/main/resources/application.properties new file mode 100644 index 0000000000..58c6f8eec7 --- /dev/null +++ b/spring-security-rest-full/src/main/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8082 +server.context-path=/spring-security-rest-full \ No newline at end of file diff --git a/spring-security-rest-full/src/test/java/org/baeldung/Consts.java b/spring-security-rest-full/src/test/java/org/baeldung/Consts.java index 9c44d63c4d..e5f0be160f 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/Consts.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/Consts.java @@ -1,5 +1,5 @@ package org.baeldung; public interface Consts { - int APPLICATION_PORT = 8080; + int APPLICATION_PORT = 8082; } diff --git a/spring-security-rest-full/src/test/java/org/baeldung/client/RestTemplateLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/client/RestTemplateLiveTest.java index 0f0a73b536..a1cd9fcfe1 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/client/RestTemplateLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/client/RestTemplateLiveTest.java @@ -51,7 +51,7 @@ import com.google.common.base.Charsets; public class RestTemplateLiveTest { private RestTemplate restTemplate; - private static final String fooResourceUrl = "http://localhost:" + APPLICATION_PORT + "/auth/foos"; + private static final String fooResourceUrl = "http://localhost:" + APPLICATION_PORT + "/spring-security-rest-full/auth/foos"; @Before public void beforeTest() { diff --git a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java index a3e6c8858d..a2890d8643 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/common/web/AbstractLiveTest.java @@ -57,7 +57,7 @@ public abstract class AbstractLiveTest { // protected String getURL() { - return "http://localhost:" + APPLICATION_PORT + "/auth/foos"; + return "http://localhost:" + APPLICATION_PORT + "/spring-security-rest-full/auth/foos"; } protected final RequestSpecification givenAuth() { diff --git a/spring-security-rest-full/src/test/java/org/baeldung/persistence/query/JPASpecificationLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/persistence/query/JPASpecificationLiveTest.java index 4fa15d536a..3b85cfb487 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/persistence/query/JPASpecificationLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/persistence/query/JPASpecificationLiveTest.java @@ -24,7 +24,7 @@ public class JPASpecificationLiveTest { private User userTom; - private final String URL_PREFIX = "http://localhost:8080/auth/users/spec?search="; + private final String URL_PREFIX = "http://localhost:8082/spring-security-rest-full/auth/users/spec?search="; @Before public void init() { diff --git a/spring-security-rest-full/src/test/java/org/baeldung/web/MyUserLiveTest.java b/spring-security-rest-full/src/test/java/org/baeldung/web/MyUserLiveTest.java index 4a3bd50f90..16ed9db253 100644 --- a/spring-security-rest-full/src/test/java/org/baeldung/web/MyUserLiveTest.java +++ b/spring-security-rest-full/src/test/java/org/baeldung/web/MyUserLiveTest.java @@ -14,17 +14,17 @@ import com.jayway.restassured.specification.RequestSpecification; public class MyUserLiveTest { private final MyUser userJohn = new MyUser("john", "doe", "john@doe.com", 11); - + private String URL_PREFIX = "http://localhost:8082/spring-security-rest-full/auth/api/myusers"; @Test public void whenGettingListOfUsers_thenCorrect() { - final Response response = givenAuth().get("http://localhost:8080/auth/api/myusers"); + final Response response = givenAuth().get(URL_PREFIX); final MyUser[] result = response.as(MyUser[].class); assertEquals(result.length, 2); } @Test public void givenFirstName_whenGettingListOfUsers_thenCorrect() { - final Response response = givenAuth().get("http://localhost:8080/auth/api/myusers?firstName=john"); + final Response response = givenAuth().get(URL_PREFIX + "?firstName=john"); final MyUser[] result = response.as(MyUser[].class); assertEquals(result.length, 1); assertEquals(result[0].getEmail(), userJohn.getEmail()); @@ -32,14 +32,14 @@ public class MyUserLiveTest { @Test public void givenPartialLastName_whenGettingListOfUsers_thenCorrect() { - final Response response = givenAuth().get("http://localhost:8080/auth/api/myusers?lastName=do"); + final Response response = givenAuth().get(URL_PREFIX + "?lastName=do"); final MyUser[] result = response.as(MyUser[].class); assertEquals(result.length, 2); } @Test public void givenEmail_whenGettingListOfUsers_thenIgnored() { - final Response response = givenAuth().get("http://localhost:8080/auth/api/myusers?email=john"); + final Response response = givenAuth().get(URL_PREFIX + "?email=john"); final MyUser[] result = response.as(MyUser[].class); assertEquals(result.length, 2); }