final SQLException exception2 = new SQLException("This is the result.", exception1);
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").addParents(MarkerManager.getMarker("Parent1").addParents(MarkerManager.getMarker("GrandParent1")),
MarkerManager.getMarker("Parent2")));
expect(event.getThreadName()).andReturn("AnotherThread-B");
expect(event.getTimeMillis()).andReturn(987654321564L).times(2);
expect(event.getThrown()).andReturn(exception2);
expect(event.getContextMap()).andReturn(context);
expect(event.getContextStack()).andReturn(stack);
this.connection.insertObject(capture(capture));
expectLastCall();
replay(this.provider, this.connection, event, message);
manager.writeInternal(event);