|
21 | 21 | import static org.easymock.EasyMock.replay; |
22 | 22 | import static org.easymock.EasyMock.verify; |
23 | 23 |
|
24 | | -import static org.junit.Assert.assertEquals; |
25 | | -import static org.junit.Assert.assertNotNull; |
26 | | - |
27 | 24 | import com.google.cloud.MonitoredResource; |
28 | 25 | import com.google.cloud.logging.LogEntry.Builder; |
29 | 26 | import com.google.cloud.logging.Logging.WriteOption; |
30 | 27 | import com.google.cloud.logging.Payload.StringPayload; |
31 | 28 | import com.google.common.collect.ImmutableList; |
32 | 29 | import com.google.common.collect.ImmutableMap; |
33 | | -import java.io.ByteArrayInputStream; |
34 | | -import java.io.IOException; |
35 | 30 | import java.util.Collections; |
36 | 31 | import java.util.Map; |
37 | 32 | import java.util.logging.ErrorManager; |
38 | 33 | import java.util.logging.Filter; |
39 | 34 | import java.util.logging.Formatter; |
40 | 35 | import java.util.logging.Handler; |
41 | 36 | import java.util.logging.Level; |
42 | | -import java.util.logging.LogManager; |
43 | 37 | import java.util.logging.LogRecord; |
44 | 38 | import java.util.logging.Logger; |
45 | 39 | import org.easymock.EasyMock; |
@@ -199,7 +193,7 @@ public void enhanceLogEntry(LogEntry.Builder builder) { |
199 | 193 |
|
200 | 194 | @Before |
201 | 195 | public void setUp() { |
202 | | - logging = EasyMock.createStrictMock(Logging.class); |
| 196 | + logging = EasyMock.createMock(Logging.class); |
203 | 197 | options = EasyMock.createStrictMock(LoggingOptions.class); |
204 | 198 | } |
205 | 199 |
|
@@ -481,58 +475,6 @@ public void close() { |
481 | 475 | logger.log(newLogRecord(Level.FINEST, MESSAGE)); |
482 | 476 | } |
483 | 477 |
|
484 | | - @Test |
485 | | - public void testPropertiesFile() throws IOException, InterruptedException { |
486 | | - expect(options.getProjectId()).andReturn(PROJECT).anyTimes(); |
487 | | - expect(options.getService()).andReturn(logging); |
488 | | - MonitoredResource monitoredResource = MonitoredResource.of( |
489 | | - "testResourceType", ImmutableMap.of("project_id", PROJECT, "enhanced", "true")); |
490 | | - LogEntry entry = |
491 | | - LogEntry.newBuilder(Payload.StringPayload.of(MESSAGE)) |
492 | | - .setSeverity(Severity.DEBUG) |
493 | | - .addLabel("enhanced", "true") |
494 | | - .setTimestamp(123456789L) |
495 | | - .build(); |
496 | | - |
497 | | - logging.setFlushSeverity(Severity.CRITICAL); |
498 | | - expectLastCall().once(); |
499 | | - logging.setWriteSynchronicity(Synchronicity.SYNC); |
500 | | - expectLastCall().once(); |
501 | | - logging.write( |
502 | | - ImmutableList.of(entry), |
503 | | - WriteOption.logName("testLogName"), |
504 | | - WriteOption.resource(monitoredResource), |
505 | | - WriteOption.labels( |
506 | | - ImmutableMap.of( |
507 | | - "levelName", |
508 | | - Level.FINEST.getName(), |
509 | | - "levelValue", |
510 | | - String.valueOf(Level.FINEST.intValue())))); |
511 | | - logging.getWriteSynchronicity(); |
512 | | - expectLastCall().andReturn(Synchronicity.SYNC).once(); |
513 | | - replay(options, logging); |
514 | | - LogManager.getLogManager() |
515 | | - .readConfiguration(new ByteArrayInputStream(renderConfig(CONFIG_MAP))); |
516 | | - LoggingHandler handler = new LoggingHandler(null, options, monitoredResource); |
517 | | - LogRecord record = new LogRecord(Level.FINEST, MESSAGE); |
518 | | - record.setMillis(123456789L); |
519 | | - handler.publish(record); |
520 | | - assertEquals(Level.ALL, handler.getLevel()); |
521 | | - assertNotNull(handler.getFilter()); |
522 | | - |
523 | | - assertEquals( |
524 | | - "com.google.cloud.logging.LoggingHandlerTest$TestFilter", |
525 | | - handler.getFilter().getClass().getName()); |
526 | | - assertNotNull(handler.getFormatter()); |
527 | | - assertEquals( |
528 | | - "com.google.cloud.logging.LoggingHandlerTest$TestFormatter", |
529 | | - handler.getFormatter().getClass().getName()); |
530 | | - assertEquals(LoggingLevel.CRITICAL, handler.getFlushLevel()); |
531 | | - assertEquals(Synchronicity.SYNC, handler.getSynchronicity()); |
532 | | - |
533 | | - LogManager.getLogManager().reset(); |
534 | | - } |
535 | | - |
536 | 478 | @Test |
537 | 479 | public void testClose() throws Exception { |
538 | 480 | expect(options.getProjectId()).andReturn(PROJECT).anyTimes(); |
|
0 commit comments