use of org.jmock.Expectations in project gradle by gradle.
the class LineBufferingOutputStreamTest method logsEachLineAsASeparateLogMessage.
@Test
public void logsEachLineAsASeparateLogMessage() throws IOException {
LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
context.checking(new Expectations() {
{
one(action).text(TextUtil.toPlatformLineSeparators("line 1\n"));
one(action).text(TextUtil.toPlatformLineSeparators("line 2\n"));
}
});
outputStream.write(TextUtil.toPlatformLineSeparators("line 1\nline 2\n").getBytes());
}
use of org.jmock.Expectations in project gradle by gradle.
the class LineBufferingOutputStreamTest method cannotWriteAfterClose.
@Test(expected = IOException.class)
public void cannotWriteAfterClose() throws IOException {
LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
context.checking(new Expectations() {
{
one(action).endOfStream(null);
}
});
outputStream.close();
outputStream.write("ignore me".getBytes());
}
use of org.jmock.Expectations in project gradle by gradle.
the class LineBufferingOutputStreamTest method buffersTextUntilEndOfLineReached.
@Test
public void buffersTextUntilEndOfLineReached() throws IOException {
System.setProperty("line.separator", "-");
LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
context.checking(new Expectations() {
{
one(action).text("line 1-");
}
});
outputStream.write("line ".getBytes());
outputStream.write("1-line 2".getBytes());
context.checking(new Expectations() {
{
one(action).text("line 2-");
}
});
outputStream.write("-".getBytes());
}
use of org.jmock.Expectations in project gradle by gradle.
the class LineBufferingOutputStreamTest method handlesSingleCharacterLineSeparator.
@Test
public void handlesSingleCharacterLineSeparator() throws IOException {
System.setProperty("line.separator", "-");
LineBufferingOutputStream outputStream = new LineBufferingOutputStream(action, 8);
context.checking(new Expectations() {
{
one(action).text("line 1-");
one(action).text("line 2-");
}
});
outputStream.write(String.format("line 1-line 2-").getBytes());
}
use of org.jmock.Expectations in project jewelcli by lexicalscope.
the class TestArgumentCollectionBuilder method noOptionsProducesUnparsed.
@Test
public void noOptionsProducesUnparsed() throws ArgumentValidationException {
argumentCollectionBuilder.addValue("1");
argumentCollectionBuilder.addValue("2");
argumentCollectionBuilder.addValue("3");
context.checking(new Expectations() {
{
oneOf(argumentProcessor).processUnparsed(asList("1", "2", "3"));
oneOf(argumentProcessor).finishedProcessing();
}
});
argumentCollectionBuilder.processArguments(argumentProcessor);
}
Aggregations