testing cleanup

This commit is contained in:
eugenp 2017-03-11 23:31:41 +02:00
parent 84c71b3dbf
commit e8faa73d74
6 changed files with 16 additions and 37 deletions

Binary file not shown.

View File

@ -10,12 +10,12 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class JedisTest {
public class JedisIntegrationTest {
private Jedis jedis;
private static RedisServer redisServer;
public JedisTest() {
public JedisIntegrationTest() {
jedis = new Jedis();
}

View File

@ -14,7 +14,7 @@ import java.io.IOException;
/**
* Created by johnson on 3/9/17.
*/
public class RedissonConfigurationTest {
public class RedissonConfigurationIntegrationTest {
private static RedisServer redisServer;
private static RedissonClient client;

View File

@ -22,7 +22,7 @@ import java.util.stream.StreamSupport;
import static org.junit.Assert.assertEquals;
public class RedissonTest {
public class RedissonIntegrationTest {
private static RedisServer redisServer;
private static RedissonClient client;

View File

@ -1,68 +1,45 @@
package com.baeldung.cachecontrol;
import com.jayway.restassured.http.ContentType;
import static com.jayway.restassured.RestAssured.given;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.context.embedded.LocalServerPort;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import static com.jayway.restassured.RestAssured.given;
import com.jayway.restassured.http.ContentType;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = AppRunner.class)
public class ResourceEndpointTest {
public class ResourceEndpointIntegrationTest {
@LocalServerPort
private int serverPort;
@Test
public void whenGetRequestForUser_shouldRespondWithDefaultCacheHeaders() {
given()
.when()
.get(getBaseUrl() + "/default/users/Michael")
.then()
.headers("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate")
.header("Pragma", "no-cache");
given().when().get(getBaseUrl() + "/default/users/Michael").then().headers("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate").header("Pragma", "no-cache");
}
@Test
public void whenGetRequestForUser_shouldRespondMaxAgeCacheControl() {
given()
.when()
.get(getBaseUrl() + "/users/Michael")
.then()
.header("Cache-Control", "max-age=60");
given().when().get(getBaseUrl() + "/users/Michael").then().header("Cache-Control", "max-age=60");
}
@Test
public void givenServiceEndpoint_whenGetRequestForUser_shouldResponseWithCacheControlMaxAge() {
given()
.when()
.get(getBaseUrl() + "/users/Michael")
.then()
.contentType(ContentType.JSON).and().statusCode(200).and()
.header("Cache-Control", "max-age=60");
given().when().get(getBaseUrl() + "/users/Michael").then().contentType(ContentType.JSON).and().statusCode(200).and().header("Cache-Control", "max-age=60");
}
@Test
public void givenServiceEndpoint_whenGetRequestForNotCacheableContent_shouldResponseWithCacheControlNoCache() {
given()
.when()
.get(getBaseUrl() + "/timestamp")
.then()
.contentType(ContentType.JSON).and().statusCode(200).and()
.header("Cache-Control", "no-store");
given().when().get(getBaseUrl() + "/timestamp").then().contentType(ContentType.JSON).and().statusCode(200).and().header("Cache-Control", "no-store");
}
@Test
public void givenServiceEndpoint_whenGetRequestForPrivateUser_shouldResponseWithSecurityDefaultCacheControl() {
given()
.when()
.get(getBaseUrl() + "/private/users/Michael")
.then()
.contentType(ContentType.JSON).and().statusCode(200).and()
.header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
given().when().get(getBaseUrl() + "/private/users/Michael").then().contentType(ContentType.JSON).and().statusCode(200).and().header("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
}
private String getBaseUrl() {

View File

@ -2,10 +2,11 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>MyStrutsApp</artifactId>
<artifactId>struts</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>struts</name>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
@ -13,6 +14,7 @@
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>