Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
johngmyers committed Sep 9, 2014
1 parent e5e971e commit 42168f6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 44 deletions.
49 changes: 17 additions & 32 deletions src/test/java/com/proofpoint/event/collector/TestServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.net.URI;
import java.util.concurrent.ExecutionException;

import static com.proofpoint.http.client.JsonBodyGenerator.jsonBodyGenerator;
import static com.proofpoint.http.client.Request.Builder.prepareDelete;
import static com.proofpoint.http.client.Request.Builder.prepareGet;
import static com.proofpoint.http.client.Request.Builder.preparePost;
Expand All @@ -68,6 +69,18 @@ public class TestServer
{
private static final JsonCodec<Object> OBJECT_CODEC = JsonCodec.jsonCodec(Object.class);
private static final ObjectMapper MAPPER = new ObjectMapper(new SmileFactory()).disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
private static final Object TESTING_SINGLE_EVENT_STRUCTURE = ImmutableList.of(
ImmutableMap.of(
"type", "Test",
"uuid", "DCD36293-3072-4AFD-B6E3-A9EB9CE1F219",
"host", "test.local",
"timestamp", "2011-03-30T16:10:16.000Z",
"data", ImmutableMap.of(
"foo", "bar",
"hello", "world"
)
)
);
private HttpClient client;
private TestingHttpServer server;
private File tempStageDir;
Expand Down Expand Up @@ -141,11 +154,10 @@ public void teardown()
public void testPostSingle()
throws IOException, ExecutionException, InterruptedException
{
String json = Resources.toString(Resources.getResource("single.json"), Charsets.UTF_8);
StatusResponse response = client.execute(preparePost()
.setUri(urlFor("/v2/event"))
.setHeader("Content-Type", APPLICATION_JSON)
.setBodyGenerator(createStaticBodyGenerator(json, Charsets.UTF_8))
.setBodyGenerator(jsonBodyGenerator(OBJECT_CODEC, TESTING_SINGLE_EVENT_STRUCTURE))
.build(),
createStatusResponseHandler());

Expand All @@ -165,20 +177,7 @@ public void testPostSmile()
public void write(OutputStream outputStream)
throws Exception
{
MAPPER.writeValue(outputStream, ImmutableList.of(
ImmutableMap.of(
"type", "Test",
"uuid", "DCD36293-3072-4AFD-B6E3-A9EB9CE1F219",
"host", "test.local",
"timestamp", "2011-03-30T16:10:16.000Z",
"data", ImmutableMap.of(
"foo", "bar",
"hello", "world"
)
)

)
);
MAPPER.writeValue(outputStream, TESTING_SINGLE_EVENT_STRUCTURE);
}
})
.build(),
Expand Down Expand Up @@ -232,11 +231,10 @@ public void testClearSpoolCounts()
public void testDistributeSingle()
throws IOException, ExecutionException, InterruptedException
{
String json = Resources.toString(Resources.getResource("single.json"), Charsets.UTF_8);
StatusResponse response = client.execute(preparePost()
.setUri(urlFor("/v2/event/distribute"))
.setHeader("Content-Type", APPLICATION_JSON)
.setBodyGenerator(createStaticBodyGenerator(json, Charsets.UTF_8))
.setBodyGenerator(jsonBodyGenerator(OBJECT_CODEC, TESTING_SINGLE_EVENT_STRUCTURE))
.build(),
createStatusResponseHandler());

Expand All @@ -256,20 +254,7 @@ public void testDistributeSmile()
public void write(OutputStream outputStream)
throws Exception
{
MAPPER.writeValue(outputStream, ImmutableList.of(
ImmutableMap.of(
"type", "Test",
"uuid", "DCD36293-3072-4AFD-B6E3-A9EB9CE1F219",
"host", "test.local",
"timestamp", "2011-03-30T16:10:16.000Z",
"data", ImmutableMap.of(
"foo", "bar",
"hello", "world"
)
)

)
);
MAPPER.writeValue(outputStream, TESTING_SINGLE_EVENT_STRUCTURE);
}
})
.build(),
Expand Down
12 changes: 0 additions & 12 deletions src/test/resources/single.json

This file was deleted.

0 comments on commit 42168f6

Please sign in to comment.