use of com.google.cloud.logging.Logging.WriteOption in project google-cloud-java by GoogleCloudPlatform.
the class LoggingAppenderTest method testDefaultWriteOptionsHasExpectedDefaults.
@Test
public void testDefaultWriteOptionsHasExpectedDefaults() {
logging.setFlushSeverity(Severity.ERROR);
Capture<WriteOption> logNameArg = Capture.newInstance();
Capture<WriteOption> resourceArg = Capture.newInstance();
logging.write((Iterable<LogEntry>) anyObject(), capture(logNameArg), capture(resourceArg));
expectLastCall().once();
replay(logging);
loggingAppender.start();
Timestamp timestamp = Timestamp.ofTimeSecondsAndNanos(100000, 0);
LoggingEvent loggingEvent = createLoggingEvent(Level.ERROR, timestamp.getSeconds());
loggingAppender.doAppend(loggingEvent);
Assert.assertTrue(logNameArg.getValue().equals(defaultWriteOptions[0]));
Assert.assertTrue(resourceArg.getValue().equals(defaultWriteOptions[1]));
}
use of com.google.cloud.logging.Logging.WriteOption in project google-cloud-java by GoogleCloudPlatform.
the class LoggingTest method testWriteOption.
@Test
public void testWriteOption() {
WriteOption writeOption = WriteOption.labels(LABELS);
assertEquals(LABELS, writeOption.getValue());
assertEquals(WriteOption.OptionType.LABELS, writeOption.getOptionType());
writeOption = WriteOption.logName(LOG_NAME);
assertEquals(LOG_NAME, writeOption.getValue());
assertEquals(WriteOption.OptionType.LOG_NAME, writeOption.getOptionType());
writeOption = WriteOption.resource(RESOURCE);
assertEquals(RESOURCE, writeOption.getValue());
assertEquals(WriteOption.OptionType.RESOURCE, writeOption.getOptionType());
}
Aggregations