Skip to content

Commit

Permalink
fix logging unit tests (googleapis#3630)
Browse files Browse the repository at this point in the history
(googleapis#3615) is happening when running on GCE. GCE would override the DEFAULT_RESOURCE and that's causing the tests to fail. This commit fixes the bug.
  • Loading branch information
yihanzhen authored Aug 31, 2018
1 parent ff2ed5e commit b9b4aff
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void testPublishLevels() {
logging.write(ImmutableList.of(EMERGENCY_ENTRY), DEFAULT_OPTIONS);
expectLastCall().once();
replay(options, logging);
Handler handler = new LoggingHandler(LOG_NAME, options);
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
handler.setLevel(Level.ALL);
handler.setFormatter(new TestFormatter());
// default levels
Expand Down Expand Up @@ -362,7 +362,7 @@ public void testReportWriteError() {
errorManager.error(null, ex, ErrorManager.WRITE_FAILURE);
expectLastCall().once();
replay(errorManager);
Handler handler = new LoggingHandler(LOG_NAME, options);
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
handler.setLevel(Level.ALL);
handler.setErrorManager(errorManager);
handler.setFormatter(new TestFormatter());
Expand All @@ -388,7 +388,7 @@ public void testReportFlushError() {
expectLastCall().once();
replay(options, logging, errorManager);
LogRecord record = newLogRecord(Level.FINEST, MESSAGE);
Handler handler = new LoggingHandler(LOG_NAME, options);
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
handler.setLevel(Level.ALL);
handler.setErrorManager(errorManager);
handler.setFormatter(new TestFormatter());
Expand All @@ -414,7 +414,7 @@ public void testReportFormatError() {
LogRecord record = newLogRecord(Level.FINEST, MESSAGE);
expect(formatter.format(record)).andThrow(ex);
replay(errorManager, formatter);
Handler handler = new LoggingHandler(LOG_NAME, options);
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
handler.setLevel(Level.ALL);
handler.setErrorManager(errorManager);
handler.setFormatter(formatter);
Expand All @@ -439,7 +439,7 @@ public void testFlushLevel() {
DEFAULT_OPTIONS);
expectLastCall().once();
replay(options, logging);
LoggingHandler handler = new LoggingHandler(LOG_NAME, options);
LoggingHandler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
handler.setLevel(Level.ALL);
handler.setFlushLevel(Level.WARNING);
handler.setFormatter(new TestFormatter());
Expand Down Expand Up @@ -473,7 +473,7 @@ public void testSyncWrite() {
expectLastCall().once();
replay(options, logging);

LoggingHandler handler = new LoggingHandler(LOG_NAME, options);
LoggingHandler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
handler.setLevel(Level.ALL);
handler.setSynchronicity(Synchronicity.SYNC);
handler.setFormatter(new TestFormatter());
Expand All @@ -493,7 +493,7 @@ public void testAddHandler() {
logging.write(ImmutableList.of(FINEST_ENTRY), DEFAULT_OPTIONS);
expectLastCall().once();
replay(options, logging);
LoggingHandler handler = new LoggingHandler(LOG_NAME, options) {
LoggingHandler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE) {
@Override
public void close() {
// Make close NOOP to avoid mock close exception
Expand All @@ -520,7 +520,7 @@ public void testClose() throws Exception {
logging.close();
expectLastCall().once();
replay(options, logging);
Handler handler = new LoggingHandler(LOG_NAME, options);
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
handler.setLevel(Level.ALL);
handler.setFormatter(new TestFormatter());
handler.publish(newLogRecord(Level.FINEST, MESSAGE));
Expand Down

0 comments on commit b9b4aff

Please sign in to comment.