|
62 | 62 | public class LoggingAppenderTest { |
63 | 63 | private static final String PROJECT_ID = "test-project"; |
64 | 64 | private static final String CRED_FILE_PROJECT_ID = "project-12345"; |
65 | | - private static final String OVERRIDED_PROJECT_ID = "some-project-id"; |
| 65 | + private static final String OVERRIDDEN_PROJECT_ID = "some-project-id"; |
66 | 66 | private static final String DUMMY_CRED_FILE_PATH = |
67 | 67 | "src/test/java/com/google/cloud/logging/logback/dummy-credentials.json"; |
68 | 68 | private static final Payload.JsonPayload JSON_PAYLOAD = |
@@ -295,6 +295,9 @@ public void testMdcValuesAreConvertedToLabels() { |
295 | 295 | public void testCreateLoggingOptionsWithValidCredentials() { |
296 | 296 | LoggingAppender appender = new LoggingAppender(); |
297 | 297 | appender.setCredentials(GoogleCredentials.newBuilder().build()); |
| 298 | + // ServiceOptions requires a projectId to be set. Normally this is determined by the |
| 299 | + // GoogleCredentials (Credential set above is a dummy value with no ProjectId). |
| 300 | + appender.setLogDestinationProjectId(PROJECT_ID); |
298 | 301 | appender.getLoggingOptions(); |
299 | 302 | } |
300 | 303 |
|
@@ -325,8 +328,8 @@ public void testCreateLoggingOptionsWithDestination() { |
325 | 328 | // Try to build LoggingOptions with file based credentials. |
326 | 329 | LoggingAppender appender = new LoggingAppender(); |
327 | 330 | appender.setCredentialsFile(DUMMY_CRED_FILE_PATH); |
328 | | - appender.setLogDestinationProjectId(OVERRIDED_PROJECT_ID); |
329 | | - assertThat(appender.getLoggingOptions().getProjectId()).isEqualTo(OVERRIDED_PROJECT_ID); |
| 331 | + appender.setLogDestinationProjectId(OVERRIDDEN_PROJECT_ID); |
| 332 | + assertThat(appender.getLoggingOptions().getProjectId()).isEqualTo(OVERRIDDEN_PROJECT_ID); |
330 | 333 | } |
331 | 334 |
|
332 | 335 | private LoggingEvent createLoggingEvent(Level level, long timestamp) { |
|
0 commit comments