Skip to content

Commit

Permalink
jcabi#120 Brought constants into test, identify two existing constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Evans committed May 17, 2016
1 parent d32478c commit 8885cd8
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/test/java/com/jcabi/http/wire/LastModifiedCachingWireTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,16 @@ public final class LastModifiedCachingWireTest {

/**
* Test body.
* @todo: #120 inline constant to test(s)
* */
private static final String BODY = "Test body";

/**
* Test body updated.
* @todo: #120 inline constant to test(s)
* */
private static final String BODY_UPDATED = "Test body updated";

/**
* Test body updated 2.
* */
private static final String BODY_UPDATED_2 = "Test body updated 2";

/**
* LastModifiedCachingWire can handle requests without headers.
* @throws Exception If fails
Expand Down Expand Up @@ -147,6 +144,9 @@ public void cachesGetRequest() throws Exception {
@Test
public void doesNotCacheGetRequestIfTheLastModifiedHeaderIsMissing()
throws Exception {
final String firstresponse = "Body 1";
final String secondresponse = "Body 2";
final String thirdreponse = "Body 3";
final Map<String, String> headers = Collections.singletonMap(
HttpHeaders.LAST_MODIFIED,
"Wed, 15 Nov 1995 05:58:08 GMT"
Expand All @@ -157,23 +157,23 @@ public void doesNotCacheGetRequestIfTheLastModifiedHeaderIsMissing()
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
headers.entrySet(),
LastModifiedCachingWireTest.BODY.getBytes()
firstresponse.getBytes()
),
Matchers.not(queryContainsIfModifiedSinceHeader())
)
.next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
noHeaders.entrySet(),
LastModifiedCachingWireTest.BODY_UPDATED.getBytes()
secondresponse.getBytes()
),
queryContainsIfModifiedSinceHeader()
)
.next(
new MkAnswer.Simple(
HttpURLConnection.HTTP_OK,
noHeaders.entrySet(),
LastModifiedCachingWireTest.BODY_UPDATED_2.getBytes()
thirdreponse.getBytes()
),
Matchers.not(queryContainsIfModifiedSinceHeader())
).start();
Expand All @@ -183,17 +183,17 @@ public void doesNotCacheGetRequestIfTheLastModifiedHeaderIsMissing()
req.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(
Matchers.equalTo(LastModifiedCachingWireTest.BODY)
Matchers.equalTo(firstresponse)
);
req.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(
Matchers.equalTo(LastModifiedCachingWireTest.BODY_UPDATED)
Matchers.equalTo(secondresponse)
);
req.fetch().as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_OK)
.assertBody(
Matchers.equalTo(LastModifiedCachingWireTest.BODY_UPDATED_2)
Matchers.equalTo(thirdreponse)
);
} finally {
container.stop();
Expand Down

0 comments on commit 8885cd8

Please sign in to comment.