16
16
17
17
package com .google .cloud .logging ;
18
18
19
+ import static java .time .ZoneOffset .UTC ;
20
+
19
21
import com .google .api .gax .paging .Page ;
20
22
import com .google .cloud .MonitoredResource ;
21
23
import com .google .cloud .logging .testing .RemoteLoggingHelper ;
22
- import com .google .common .collect .Iterators ;
24
+ import com .google .common .collect .Iterables ;
23
25
import com .google .logging .v2 .LogName ;
24
- import java .text .DateFormat ;
25
- import java .text .SimpleDateFormat ;
26
+ import java .time .format .DateTimeFormatter ;
26
27
import java .util .Calendar ;
27
28
import java .util .Iterator ;
28
29
import org .junit .AfterClass ;
@@ -38,7 +39,8 @@ public class BaseSystemTest {
38
39
39
40
@ Rule public Timeout globalTimeout = Timeout .seconds (600 );
40
41
41
- private static DateFormat RFC_3339 = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
42
+ private static final DateTimeFormatter RFC_3339 =
43
+ DateTimeFormatter .ofPattern ("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" );
42
44
43
45
protected static Logging logging ;
44
46
@@ -60,7 +62,7 @@ public static void afterClass() throws Exception {
60
62
* Filters Documentation</a>
61
63
*/
62
64
protected static <V > String createEqualityFilter (String name , V value ) {
63
- return name + "=" + "\" " + value . toString () + "\" " ;
65
+ return name + "=" + "\" " + value + "\" " ;
64
66
}
65
67
66
68
protected static boolean cleanupLog (String logName ) throws InterruptedException {
@@ -84,7 +86,9 @@ protected static boolean cleanupLog(String logName) throws InterruptedException
84
86
protected static String createTimestampFilter (int hoursAgo ) {
85
87
Calendar calendar = Calendar .getInstance ();
86
88
calendar .add (Calendar .HOUR , -1 * hoursAgo );
87
- return "timestamp>=\" " + RFC_3339 .format (calendar .getTime ()) + "\" " ;
89
+ return "timestamp>=\" "
90
+ + calendar .getTime ().toInstant ().atZone (UTC ).toLocalDate ().format (RFC_3339 )
91
+ + "\" " ;
88
92
}
89
93
90
94
protected static String appendResourceTypeFilter (
@@ -133,7 +137,7 @@ protected static Iterator<LogEntry> waitForLogs(LogName logName) throws Interrup
133
137
protected static Iterator <LogEntry > waitForLogs (Logging .EntryListOption [] options , int minLogs )
134
138
throws InterruptedException {
135
139
Page <LogEntry > page = logging .listLogEntries (options );
136
- while (Iterators .size (page .iterateAll (). iterator ()) < minLogs ) {
140
+ while (Iterables .size (page .iterateAll ()) < minLogs ) {
137
141
Thread .sleep (500 );
138
142
page = logging .listLogEntries (options );
139
143
}
0 commit comments