configure test profiles
This commit is contained in:
parent
bf887e71d9
commit
66c5db02a3
@ -339,7 +339,7 @@
|
|||||||
</container>
|
</container>
|
||||||
<configuration>
|
<configuration>
|
||||||
<properties>
|
<properties>
|
||||||
<cargo.servlet.port>8080</cargo.servlet.port>
|
<cargo.servlet.port>8082</cargo.servlet.port>
|
||||||
</properties>
|
</properties>
|
||||||
</configuration>
|
</configuration>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -386,10 +386,45 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>none</exclude>
|
<exclude>**/*LiveTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*IntegrationTest.java</include>
|
<include>**/*IntegrationTest.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<systemPropertyVariables>
|
||||||
|
<test.mime>json</test.mime>
|
||||||
|
</systemPropertyVariables>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<profile>
|
||||||
|
<id>live</id>
|
||||||
|
<build>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>integration-test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*IntegrationTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
<includes>
|
||||||
<include>**/*LiveTest.java</include>
|
<include>**/*LiveTest.java</include>
|
||||||
</includes>
|
</includes>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -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
|
* 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
|
@EnableScheduling
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
server.port=8082
|
||||||
|
server.context-path=/spring-security-rest-full
|
@ -1,5 +1,5 @@
|
|||||||
package org.baeldung;
|
package org.baeldung;
|
||||||
|
|
||||||
public interface Consts {
|
public interface Consts {
|
||||||
int APPLICATION_PORT = 8080;
|
int APPLICATION_PORT = 8082;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ import com.google.common.base.Charsets;
|
|||||||
public class RestTemplateLiveTest {
|
public class RestTemplateLiveTest {
|
||||||
|
|
||||||
private RestTemplate restTemplate;
|
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
|
@Before
|
||||||
public void beforeTest() {
|
public void beforeTest() {
|
||||||
|
@ -57,7 +57,7 @@ public abstract class AbstractLiveTest<T extends Serializable> {
|
|||||||
//
|
//
|
||||||
|
|
||||||
protected String getURL() {
|
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() {
|
protected final RequestSpecification givenAuth() {
|
||||||
|
@ -24,7 +24,7 @@ public class JPASpecificationLiveTest {
|
|||||||
|
|
||||||
private User userTom;
|
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
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
|
@ -14,17 +14,17 @@ import com.jayway.restassured.specification.RequestSpecification;
|
|||||||
public class MyUserLiveTest {
|
public class MyUserLiveTest {
|
||||||
|
|
||||||
private final MyUser userJohn = new MyUser("john", "doe", "john@doe.com", 11);
|
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
|
@Test
|
||||||
public void whenGettingListOfUsers_thenCorrect() {
|
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);
|
final MyUser[] result = response.as(MyUser[].class);
|
||||||
assertEquals(result.length, 2);
|
assertEquals(result.length, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenFirstName_whenGettingListOfUsers_thenCorrect() {
|
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);
|
final MyUser[] result = response.as(MyUser[].class);
|
||||||
assertEquals(result.length, 1);
|
assertEquals(result.length, 1);
|
||||||
assertEquals(result[0].getEmail(), userJohn.getEmail());
|
assertEquals(result[0].getEmail(), userJohn.getEmail());
|
||||||
@ -32,14 +32,14 @@ public class MyUserLiveTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenPartialLastName_whenGettingListOfUsers_thenCorrect() {
|
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);
|
final MyUser[] result = response.as(MyUser[].class);
|
||||||
assertEquals(result.length, 2);
|
assertEquals(result.length, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenEmail_whenGettingListOfUsers_thenIgnored() {
|
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);
|
final MyUser[] result = response.as(MyUser[].class);
|
||||||
assertEquals(result.length, 2);
|
assertEquals(result.length, 2);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user