Skip to content

Commit 7ecf1cc

Browse files
author
Jeffrey Bennett
committed
coverage tests
1 parent a05f40d commit 7ecf1cc

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

src/main/java/io/fabric8/maven/docker/access/log/LogRequestor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private void parseResponse(HttpResponse response) throws LogCallback.DoneExcepti
190190
}
191191
}
192192

193-
private void callLogCallback(int type, String txt) throws LogCallback.DoneException {
193+
protected void callLogCallback(int type, String txt) throws LogCallback.DoneException {
194194
Matcher matcher = LOG_LINE.matcher(txt);
195195
if (!matcher.matches()) {
196196
callback.error(String.format("Invalid log format for '%s' (expected: \"<timestamp> <txt>\") [%04x %04x]",

src/test/java/io/fabric8/maven/docker/access/log/LogRequestorTest.java

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

33
import com.google.common.base.Charsets;
44
import io.fabric8.maven.docker.access.UrlBuilder;
5+
import io.fabric8.maven.docker.access.log.LogCallback.DoneException;
56
import io.fabric8.maven.docker.access.util.RequestUtil;
67
import mockit.Expectations;
78
import mockit.Mocked;
@@ -29,6 +30,8 @@
2930
import static org.hamcrest.CoreMatchers.equalTo;
3031
import static org.hamcrest.MatcherAssert.assertThat;
3132
import static org.junit.Assert.assertEquals;
33+
import static org.junit.Assert.assertNotNull;
34+
import static org.junit.Assert.assertThrows;
3235
import static org.junit.Assert.assertTrue;
3336
import java.time.ZonedDateTime;
3437

@@ -298,6 +301,27 @@ public void runCanHandleIOException() throws Exception {
298301
new LogRequestor(client, urlBuilder, containerId, callback).run();
299302
}
300303

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+
301325
private void setupMocks(final InputStream inputStream) throws Exception {
302326
new Expectations() {{
303327
RequestUtil.newGet(anyString);

0 commit comments

Comments
 (0)