Skip to content

Commit b33497b

Browse files
committed
increase coverage in java-core units
1 parent b67db50 commit b33497b

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

java-core/google-cloud-core/src/test/java/com/google/cloud/TimestampTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,14 @@ void comparable() {
335335
void serialization() {
336336
reserializeAndAssert(Timestamp.parseTimestamp("9999-12-31T23:59:59.999999999Z"));
337337
}
338+
339+
@Test
340+
void parseInvalidTimestampThreetenThrowsThreetenException() {
341+
assertThrows(
342+
org.threeten.bp.format.DateTimeParseException.class,
343+
() -> Timestamp.parseTimestamp("00x1-01-01T00:00:00"));
344+
assertThrows(
345+
java.time.format.DateTimeParseException.class,
346+
() -> Timestamp.parseTimestampDuration("00x1-01-01T00:00:00"));
347+
}
338348
}

java-core/google-cloud-core/src/test/java/com/google/cloud/testing/BaseEmulatorHelperTest.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package com.google.cloud.testing;
1818

19-
import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
2019

2120
import com.google.api.client.util.Charsets;
2221
import com.google.cloud.ServiceOptions;
@@ -75,7 +74,8 @@ public void start() throws IOException, InterruptedException {
7574
@Override
7675
public void stop(org.threeten.bp.Duration timeout)
7776
throws IOException, InterruptedException, TimeoutException {
78-
stopDuration(toJavaTimeDuration(timeout));
77+
// we call the threeten method directly to confirm behavior
78+
waitForProcess(timeout);
7979
}
8080

8181
@Override
@@ -110,6 +110,26 @@ void testEmulatorHelper() throws IOException, InterruptedException, TimeoutExcep
110110
EasyMock.verify();
111111
}
112112

113+
@Test
114+
void testEmulatorHelperThreeten() throws IOException, InterruptedException, TimeoutException {
115+
Process process = EasyMock.createStrictMock(Process.class);
116+
InputStream stream = new ByteArrayInputStream(BLOCK_UNTIL.getBytes(Charsets.UTF_8));
117+
EmulatorRunner emulatorRunner = EasyMock.createStrictMock(EmulatorRunner.class);
118+
EasyMock.expect(process.getInputStream()).andReturn(stream);
119+
EasyMock.expect(emulatorRunner.isAvailable()).andReturn(true);
120+
emulatorRunner.start();
121+
EasyMock.expectLastCall();
122+
EasyMock.expect(emulatorRunner.getProcess()).andReturn(process);
123+
emulatorRunner.waitForDuration(java.time.Duration.ofMinutes(1));
124+
EasyMock.expectLastCall().andReturn(0);
125+
EasyMock.replay(process, emulatorRunner);
126+
TestEmulatorHelper helper =
127+
new TestEmulatorHelper(ImmutableList.of(emulatorRunner), BLOCK_UNTIL);
128+
helper.start();
129+
helper.stop(org.threeten.bp.Duration.ofMinutes(1));
130+
EasyMock.verify();
131+
}
132+
113133
@Test
114134
void testEmulatorHelperDownloadWithRetries()
115135
throws IOException, InterruptedException, TimeoutException {

0 commit comments

Comments
 (0)