Skip to content

Commit e1ac29b

Browse files
authored
---
yaml --- r: 7891 b: refs/heads/tswast-patch-1 c: 3919d63 h: refs/heads/master i: 7889: cec7f37 7887: daaa5be
1 parent d9716a1 commit e1ac29b

2 files changed

Lines changed: 29 additions & 26 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 6d844c9465c62f78c6414314ca408f0e2aa06bf5
60+
refs/heads/tswast-patch-1: 3919d63a5ff030a522ad07d5a46c3251998795e6
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/google-cloud-logging/src/test/java/com/google/cloud/logging/LoggingHandlerTest.java

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.ByteArrayInputStream;
3131
import java.io.IOException;
3232
import java.util.Collections;
33+
import java.util.Map;
3334
import java.util.logging.ErrorManager;
3435
import java.util.logging.Filter;
3536
import java.util.logging.Formatter;
@@ -135,33 +136,35 @@ public class LoggingHandlerTest {
135136
.addLabel("levelValue", String.valueOf(LoggingLevel.EMERGENCY.intValue()))
136137
.setTimestamp(123456789L)
137138
.build();
138-
private static final String CONFIG_FILE_STRING =
139-
(new StringBuilder())
140-
.append("com.google.cloud.logging.LoggingHandler.log=testLogName")
141-
.append(System.lineSeparator())
142-
.append("com.google.cloud.logging.LoggingHandler.level=ALL")
143-
.append(System.lineSeparator())
144-
.append(
145-
"com.google.cloud.logging.LoggingHandler.filter=com.google.cloud.logging.LoggingHandlerTest$TestFilter")
146-
.append(System.lineSeparator())
147-
.append(
148-
"com.google.cloud.logging.LoggingHandler.formatter=com.google.cloud.logging.LoggingHandlerTest$TestFormatter")
149-
.append(System.lineSeparator())
150-
.append("com.google.cloud.logging.LoggingHandler.flushSize=2")
151-
.append(System.lineSeparator())
152-
.append("com.google.cloud.logging.LoggingHandler.flushLevel=CRITICAL")
153-
.append(System.lineSeparator())
154-
.append(
155-
"com.google.cloud.logging.LoggingHandler.enhancers=com.google.cloud.logging.LoggingHandlerTest$TestEnhancer")
156-
.append(System.lineSeparator())
157-
.append("com.google.cloud.logging.LoggingHandler.resourceType=testResourceType")
158-
.append(System.lineSeparator())
159-
.append("com.google.cloud.logging.LoggingHandler.synchronicity=SYNC")
160-
.append(System.lineSeparator())
161-
.toString();
139+
private static final String CONFIG_NAMESPACE = "com.google.cloud.logging.LoggingHandler";
140+
private static final ImmutableMap<String, String> CONFIG_MAP =
141+
ImmutableMap.<String, String>builder()
142+
.put("log", "testLogName")
143+
.put("level", "ALL")
144+
.put("filter", "com.google.cloud.logging.LoggingHandlerTest$TestFilter")
145+
.put("formatter", "com.google.cloud.logging.LoggingHandlerTest$TestFormatter")
146+
.put("flushSize", "2")
147+
.put("flushLevel", "CRITICAL")
148+
.put("enhancers", "com.google.cloud.logging.LoggingHandlerTest$TestEnhancer")
149+
.put("resourceType", "testResourceType")
150+
.put("synchronicity", "SYNC")
151+
.build();
162152
private static final WriteOption[] DEFAULT_OPTIONS =
163153
new WriteOption[] {WriteOption.logName(LOG_NAME), WriteOption.resource(DEFAULT_RESOURCE)};
164154

155+
private static byte[] renderConfig(Map<String, String> config) {
156+
StringBuilder str = new StringBuilder();
157+
for (Map.Entry<String, String> entry : config.entrySet()) {
158+
str.append(CONFIG_NAMESPACE)
159+
.append('.')
160+
.append(entry.getKey())
161+
.append('=')
162+
.append(entry.getValue())
163+
.append(System.lineSeparator());
164+
}
165+
return str.toString().getBytes();
166+
}
167+
165168
private Logging logging;
166169
private LoggingOptions options;
167170

@@ -454,7 +457,7 @@ public void testPropertiesFile() throws IOException, InterruptedException {
454457
"testResourceType", ImmutableMap.of("project_id", PROJECT, "enhanced", "true"))));
455458
EasyMock.replay(options, logging);
456459
LogManager.getLogManager()
457-
.readConfiguration(new ByteArrayInputStream(CONFIG_FILE_STRING.getBytes()));
460+
.readConfiguration(new ByteArrayInputStream(renderConfig(CONFIG_MAP)));
458461
LoggingHandler handler = new LoggingHandler(null, options);
459462
LogRecord record = new LogRecord(Level.FINEST, MESSAGE);
460463
record.setMillis(123456789L);

0 commit comments

Comments
 (0)