|
2 | 2 |
|
3 | 3 | import com.google.common.base.Charsets; |
4 | 4 | import io.fabric8.maven.docker.access.UrlBuilder; |
| 5 | +import io.fabric8.maven.docker.access.log.LogCallback.DoneException; |
5 | 6 | import io.fabric8.maven.docker.access.util.RequestUtil; |
6 | 7 | import mockit.Expectations; |
7 | 8 | import mockit.Mocked; |
|
29 | 30 | import static org.hamcrest.CoreMatchers.equalTo; |
30 | 31 | import static org.hamcrest.MatcherAssert.assertThat; |
31 | 32 | import static org.junit.Assert.assertEquals; |
| 33 | +import static org.junit.Assert.assertNotNull; |
| 34 | +import static org.junit.Assert.assertThrows; |
32 | 35 | import static org.junit.Assert.assertTrue; |
33 | 36 | import java.time.ZonedDateTime; |
34 | 37 |
|
@@ -298,6 +301,27 @@ public void runCanHandleIOException() throws Exception { |
298 | 301 | new LogRequestor(client, urlBuilder, containerId, callback).run(); |
299 | 302 | } |
300 | 303 |
|
| 304 | + @Test |
| 305 | + public void testcallLogCallbackDoneException() throws DoneException |
| 306 | + { |
| 307 | + final LogRequestor requestor = new LogRequestor(client,urlBuilder, "containerId",callback); |
| 308 | + assertNotNull(requestor); |
| 309 | + |
| 310 | + assertThrows(DoneException.class, ()-> requestor.callLogCallback(-1, "txt")); |
| 311 | + } |
| 312 | + |
| 313 | + /* |
| 314 | + * Should roll-over and use default timestamp |
| 315 | + */ |
| 316 | + @Test |
| 317 | + public void testcallLogCallbackInvalidTimestamp() throws DoneException |
| 318 | + { |
| 319 | + final LogRequestor requestor = new LogRequestor(client,urlBuilder, "containerId",callback); |
| 320 | + assertNotNull(requestor); |
| 321 | + |
| 322 | + requestor.callLogCallback(-1, "<timestamp> <entry> </timestamp>"); |
| 323 | + } |
| 324 | + |
301 | 325 | private void setupMocks(final InputStream inputStream) throws Exception { |
302 | 326 | new Expectations() {{ |
303 | 327 | RequestUtil.newGet(anyString); |
|
0 commit comments