final Map<String, String> context = new HashMap<String, String>();
context.put("hello", "world");
context.put("user", "pass");
final LogEvent event = createStrictMock(LogEvent.class);
final Message message = createStrictMock(Message.class);
ThreadContext.push("message1");
ThreadContext.push("stack2");
final ThreadContext.ContextStack stack = ThreadContext.getImmutableStack();
ThreadContext.clearStack();
expect(this.connection.isClosed()).andReturn(false);
expect(this.connection.createObject()).andAnswer(new IAnswer<CouchDBObject>() {
@Override
public CouchDBObject answer() throws Throwable {
return new CouchDBObject();
}
}).atLeastOnce();
expect(this.connection.createList(anyInt())).andAnswer(new IAnswer<CouchDBObject[]>() {
@Override
public CouchDBObject[] answer() throws Throwable {
return new CouchDBObject[(Integer) getCurrentArguments()[0]];
}
});
expect(this.connection.createObject()).andAnswer(new IAnswer<CouchDBObject>() {
@Override
public CouchDBObject answer() throws Throwable {
return new CouchDBObject();
}
}).atLeastOnce();
expect(this.connection.createList(anyInt())).andAnswer(new IAnswer<CouchDBObject[]>() {
@Override
public CouchDBObject[] answer() throws Throwable {
return new CouchDBObject[(Integer) getCurrentArguments()[0]];
}
});
expect(this.connection.createObject()).andAnswer(new IAnswer<CouchDBObject>() {
@Override
public CouchDBObject answer() throws Throwable {
return new CouchDBObject();
}
}).atLeastOnce();
expect(event.getLevel()).andReturn(Level.DEBUG);
expect(event.getLoggerName()).andReturn("com.foo.NoSQLDbTest.testWriteInternal02");
expect(event.getMessage()).andReturn(message).times(2);
expect(message.getFormattedMessage()).andReturn("Another cool message 02.");
expect(event.getSource()).andReturn(new StackTraceElement("com.bar.Foo", "anotherMethod03", "Foo.java", 9));
expect(event.getMarker()).andReturn(
MarkerManager.getMarker("AnotherMarker",
MarkerManager.getMarker("Parent1", MarkerManager.getMarker("Grandparent2"))));
expect(event.getThreadName()).andReturn("AnotherThread-B");