use of com.amazonaws.services.logs.AWSLogsClient in project cloudwatch-logback-appender by j256.
the class SystemEnvironConverterTest method testNoEnvNameSpecified.
@Test(timeout = 5000)
public void testNoEnvNameSpecified() throws InterruptedException {
AWSLogsClient awsLogClient = createMock(AWSLogsClient.class);
appender.setAwsLogsClient(awsLogClient);
String prefix = "logstream-";
appender.setLogStream(prefix + "%systemEnviron");
final String expectedLogStream = prefix + null;
PatternLayout layout = new PatternLayout();
layout.setPattern("%msg");
layout.setContext(LOGGER_CONTEXT);
layout.start();
appender.setLayout(layout);
LoggingEvent event = new LoggingEvent();
event.setTimeStamp(System.currentTimeMillis());
event.setLoggerName("name");
event.setLevel(Level.DEBUG);
event.setMessage("message");
final PutLogEventsResult result = new PutLogEventsResult();
result.setNextSequenceToken("ewopjfewfj");
expect(awsLogClient.putLogEvents(isA(PutLogEventsRequest.class))).andAnswer(new IAnswer<PutLogEventsResult>() {
@Override
public PutLogEventsResult answer() {
PutLogEventsRequest request = (PutLogEventsRequest) getCurrentArguments()[0];
assertEquals(LOG_GROUP, request.getLogGroupName());
assertEquals(expectedLogStream, request.getLogStreamName());
return result;
}
});
awsLogClient.shutdown();
// =====================================
replay(awsLogClient);
appender.start();
appender.append(event);
while (appender.getEventsWrittenCount() < 1) {
Thread.sleep(10);
}
appender.stop();
verify(awsLogClient);
}
Aggregations