Skip to content

Commit

Permalink
yegor256#575 added tests for implemention of close and skip method on…
Browse files Browse the repository at this point in the history
… CapinputStream
  • Loading branch information
original-brownbear committed Mar 1, 2016
1 parent 3b35a7f commit 4d3c59a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/test/java/org/takes/rq/CapInputStreamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.mockito.Mockito;

/**
* Test case for {@link CapInputStream}.
Expand All @@ -54,4 +56,35 @@ public void putsCapOnStream() throws IOException {
);
}

/**
* CapInputStream can close a stream.
* @throws IOException If some problem inside
*/
@Test
public void closesStream() throws IOException {
final InputStream stream = Mockito.mock(InputStream.class);
final CapInputStream wrapper = new CapInputStream(
stream,
0L
);
wrapper.close();
Mockito.verify(stream, Mockito.times(1)).close();
}

/**
* CapInputStream can skip on a stream.
* @throws IOException If some problem inside
*/
@Test
public void skipsOnStream() throws IOException {
final long skip = 25L;
final InputStream stream = Mockito.mock(InputStream.class);
final CapInputStream wrapper = new CapInputStream(
stream,
50L
);
wrapper.skip(skip);
Mockito.verify(stream, Mockito.times(1)).skip(skip);
}

}

0 comments on commit 4d3c59a

Please sign in to comment.