|
16 | 16 |
|
17 | 17 | package com.google.cloud.testing; |
18 | 18 |
|
19 | | -import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; |
20 | 19 |
|
21 | 20 | import com.google.api.client.util.Charsets; |
22 | 21 | import com.google.cloud.ServiceOptions; |
@@ -75,7 +74,8 @@ public void start() throws IOException, InterruptedException { |
75 | 74 | @Override |
76 | 75 | public void stop(org.threeten.bp.Duration timeout) |
77 | 76 | throws IOException, InterruptedException, TimeoutException { |
78 | | - stopDuration(toJavaTimeDuration(timeout)); |
| 77 | + // we call the threeten method directly to confirm behavior |
| 78 | + waitForProcess(timeout); |
79 | 79 | } |
80 | 80 |
|
81 | 81 | @Override |
@@ -110,6 +110,26 @@ void testEmulatorHelper() throws IOException, InterruptedException, TimeoutExcep |
110 | 110 | EasyMock.verify(); |
111 | 111 | } |
112 | 112 |
|
| 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 | + |
113 | 133 | @Test |
114 | 134 | void testEmulatorHelperDownloadWithRetries() |
115 | 135 | throws IOException, InterruptedException, TimeoutException { |
|
0 commit comments