Skip to content

Commit b9b4aff

Browse files
authored
fix logging unit tests (#3630)
(#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.
1 parent ff2ed5e commit b9b4aff

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

google-cloud-clients/google-cloud-logging/src/test/java/com/google/cloud/logging/LoggingHandlerTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void testPublishLevels() {
250250
logging.write(ImmutableList.of(EMERGENCY_ENTRY), DEFAULT_OPTIONS);
251251
expectLastCall().once();
252252
replay(options, logging);
253-
Handler handler = new LoggingHandler(LOG_NAME, options);
253+
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
254254
handler.setLevel(Level.ALL);
255255
handler.setFormatter(new TestFormatter());
256256
// default levels
@@ -362,7 +362,7 @@ public void testReportWriteError() {
362362
errorManager.error(null, ex, ErrorManager.WRITE_FAILURE);
363363
expectLastCall().once();
364364
replay(errorManager);
365-
Handler handler = new LoggingHandler(LOG_NAME, options);
365+
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
366366
handler.setLevel(Level.ALL);
367367
handler.setErrorManager(errorManager);
368368
handler.setFormatter(new TestFormatter());
@@ -388,7 +388,7 @@ public void testReportFlushError() {
388388
expectLastCall().once();
389389
replay(options, logging, errorManager);
390390
LogRecord record = newLogRecord(Level.FINEST, MESSAGE);
391-
Handler handler = new LoggingHandler(LOG_NAME, options);
391+
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
392392
handler.setLevel(Level.ALL);
393393
handler.setErrorManager(errorManager);
394394
handler.setFormatter(new TestFormatter());
@@ -414,7 +414,7 @@ public void testReportFormatError() {
414414
LogRecord record = newLogRecord(Level.FINEST, MESSAGE);
415415
expect(formatter.format(record)).andThrow(ex);
416416
replay(errorManager, formatter);
417-
Handler handler = new LoggingHandler(LOG_NAME, options);
417+
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
418418
handler.setLevel(Level.ALL);
419419
handler.setErrorManager(errorManager);
420420
handler.setFormatter(formatter);
@@ -439,7 +439,7 @@ public void testFlushLevel() {
439439
DEFAULT_OPTIONS);
440440
expectLastCall().once();
441441
replay(options, logging);
442-
LoggingHandler handler = new LoggingHandler(LOG_NAME, options);
442+
LoggingHandler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
443443
handler.setLevel(Level.ALL);
444444
handler.setFlushLevel(Level.WARNING);
445445
handler.setFormatter(new TestFormatter());
@@ -473,7 +473,7 @@ public void testSyncWrite() {
473473
expectLastCall().once();
474474
replay(options, logging);
475475

476-
LoggingHandler handler = new LoggingHandler(LOG_NAME, options);
476+
LoggingHandler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
477477
handler.setLevel(Level.ALL);
478478
handler.setSynchronicity(Synchronicity.SYNC);
479479
handler.setFormatter(new TestFormatter());
@@ -493,7 +493,7 @@ public void testAddHandler() {
493493
logging.write(ImmutableList.of(FINEST_ENTRY), DEFAULT_OPTIONS);
494494
expectLastCall().once();
495495
replay(options, logging);
496-
LoggingHandler handler = new LoggingHandler(LOG_NAME, options) {
496+
LoggingHandler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE) {
497497
@Override
498498
public void close() {
499499
// Make close NOOP to avoid mock close exception
@@ -520,7 +520,7 @@ public void testClose() throws Exception {
520520
logging.close();
521521
expectLastCall().once();
522522
replay(options, logging);
523-
Handler handler = new LoggingHandler(LOG_NAME, options);
523+
Handler handler = new LoggingHandler(LOG_NAME, options, DEFAULT_RESOURCE);
524524
handler.setLevel(Level.ALL);
525525
handler.setFormatter(new TestFormatter());
526526
handler.publish(newLogRecord(Level.FINEST, MESSAGE));

0 commit comments

Comments
 (0)