|
16 | 16 |
|
17 | 17 | package com.example.logging;
|
18 | 18 |
|
| 19 | +import static com.google.cloud.logging.testing.RemoteLoggingHelper.formatForTest; |
19 | 20 | import static com.google.common.truth.Truth.assertThat;
|
20 | 21 |
|
21 | 22 | import com.google.cloud.MonitoredResource;
|
|
24 | 25 | import com.google.cloud.logging.Logging;
|
25 | 26 | import com.google.cloud.logging.LoggingOptions;
|
26 | 27 | import com.google.cloud.logging.Payload.StringPayload;
|
| 28 | +import com.google.cloud.logging.Synchronicity; |
27 | 29 | import java.io.ByteArrayOutputStream;
|
28 | 30 | import java.io.PrintStream;
|
29 | 31 | import java.util.Collections;
|
|
38 | 40 | @SuppressWarnings("checkstyle:abbreviationaswordinname")
|
39 | 41 | public class LoggingIT {
|
40 | 42 |
|
41 |
| - private static final String TEST_LOG = "test-log"; |
| 43 | + private static final String TEST_LOG = formatForTest("test-log"); |
42 | 44 | private static final String GOOGLEAPIS_AUDIT_LOGNAME = "cloudaudit.googleapis.com%2Factivity";
|
43 | 45 | private static final String STRING_PAYLOAD = "Hello, world!";
|
44 | 46 | private static final String STRING_PAYLOAD2 = "Hello world again";
|
@@ -74,13 +76,14 @@ public void testQuickstart() throws Exception {
|
74 | 76 | }
|
75 | 77 |
|
76 | 78 | @Test(timeout = 60000)
|
77 |
| - public void testWriteAndListLogs() throws Exception { |
| 79 | + public void testListLogEntries() throws Exception { |
78 | 80 | // write a log entry
|
79 | 81 | LogEntry entry =
|
80 | 82 | LogEntry.newBuilder(StringPayload.of(STRING_PAYLOAD2))
|
81 | 83 | .setLogName(TEST_LOG)
|
82 | 84 | .setResource(MonitoredResource.newBuilder("global").build())
|
83 | 85 | .build();
|
| 86 | + logging.setWriteSynchronicity(Synchronicity.SYNC); |
84 | 87 | logging.write(Collections.singleton(entry));
|
85 | 88 | // flush out log immediately
|
86 | 89 | logging.flush();
|
|
0 commit comments