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

Commit

Permalink
More unit tests for MongoDBAccessEventAppender.
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Trutz <christian.trutz@belaso.de>
  • Loading branch information
Christian Trutz committed Jun 22, 2012
1 parent 78eae25 commit a3d0ffd
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,62 @@ public void testServerName() {
assertEquals("servername", dbObject.get("serverName"));
}

@Test
public void testRemote() {
// given
new NonStrictExpectations() {
{
event.getRemoteHost();
result = "host";
event.getRemoteUser();
result = "user";
event.getRemoteAddr();
result = "addr";
}
};
// when
final BasicDBObject dbObject = appender.toMongoDocument(event);
// then
BasicDBObject remoteDBObject = (BasicDBObject) dbObject.get("remote");
assertEquals("host", remoteDBObject.getString("host"));
assertEquals("user", remoteDBObject.getString("user"));
assertEquals("addr", remoteDBObject.getString("addr"));
}

@Test
public void testRequest() {
// given
new NonStrictExpectations() {
{
event.getRequestURI();
result = "uri";
event.getProtocol();
result = "protocol";
event.getMethod();
result = "method";
event.getRequestContent();
result = "postContent";
event.getCookie("JSESSIONID");
result = "sessionId";
event.getRequestHeader("User-Agent");
result = "userAgent";
event.getRequestHeader("Referer");
result = "referer";
}
};
// when
final BasicDBObject dbObject = appender.toMongoDocument(event);
// then
BasicDBObject requestDBObject = (BasicDBObject) dbObject.get("request");
assertEquals("uri", requestDBObject.getString("uri"));
assertEquals("protocol", requestDBObject.getString("protocol"));
assertEquals("method", requestDBObject.getString("method"));
assertEquals("postContent", requestDBObject.getString("postContent"));
assertEquals("sessionId", requestDBObject.getString("sessionId"));
assertEquals("userAgent", requestDBObject.getString("userAgent"));
assertEquals("referer", requestDBObject.getString("referer"));
}

//
//
// MOCKING
Expand Down

0 comments on commit a3d0ffd

Please sign in to comment.