use of org.jmock.Sequence in project gradle by gradle.
the class PropertyReportTaskTest method doesNotShowContentsOfThePropertiesProperty.
@Test
public void doesNotShowContentsOfThePropertiesProperty() throws IOException {
context.checking(new Expectations() {
{
oneOf(project).getProperties();
will(returnValue(GUtil.map("prop", "value", "properties", "prop")));
Sequence sequence = context.sequence("seq");
oneOf(renderer).addProperty("prop", "value");
inSequence(sequence);
oneOf(renderer).addProperty("properties", "{...}");
inSequence(sequence);
}
});
task.generate(project);
}
use of org.jmock.Sequence in project gradle by gradle.
the class TaskReportTaskTest method passesEachRuleToRenderer.
@Test
public void passesEachRuleToRenderer() throws IOException {
context.checking(new Expectations() {
{
Rule rule1 = context.mock(Rule.class);
Rule rule2 = context.mock(Rule.class);
List<String> defaultTasks = toList();
allowing(project).getDefaultTasks();
will(returnValue(defaultTasks));
allowing(taskContainer).realize();
allowing(taskContainer).size();
will(returnValue(0));
allowing(taskContainer).iterator();
will(returnIterator(toLinkedSet()));
allowing(implicitTasks).iterator();
will(returnIterator(toLinkedSet()));
one(taskContainer).getRules();
will(returnValue(toList(rule1, rule2)));
Sequence sequence = context.sequence("seq");
one(renderer).showDetail(false);
inSequence(sequence);
one(renderer).addDefaultTasks(defaultTasks);
inSequence(sequence);
one(renderer).completeTasks();
inSequence(sequence);
one(renderer).addRule(rule1);
inSequence(sequence);
one(renderer).addRule(rule2);
inSequence(sequence);
}
});
task.generate(project);
}
use of org.jmock.Sequence in project geode by apache.
the class CompositeOutputStreamJUnitTest method testAddOutputStreamWithOneStream.
@Test
public void testAddOutputStreamWithOneStream() throws IOException {
final Sequence seqStreamOne = mockContext.sequence("seqStreamOne");
final OutputStream streamOne = mockContext.mock(OutputStream.class, "streamOne");
mockContext.checking(new Expectations() {
{
oneOf(streamOne).write(2);
inSequence(seqStreamOne);
oneOf(streamOne).write(3);
inSequence(seqStreamOne);
oneOf(streamOne).write(4);
inSequence(seqStreamOne);
oneOf(streamOne).write(0);
inSequence(seqStreamOne);
oneOf(streamOne).write(1);
inSequence(seqStreamOne);
oneOf(streamOne).write(9);
inSequence(seqStreamOne);
oneOf(streamOne).flush();
inSequence(seqStreamOne);
oneOf(streamOne).flush();
inSequence(seqStreamOne);
oneOf(streamOne).close();
inSequence(seqStreamOne);
}
});
final Sequence seqStreamTwo = mockContext.sequence("seqStreamTwo");
final OutputStream streamTwo = mockContext.mock(OutputStream.class, "streamTwo");
mockContext.checking(new Expectations() {
{
oneOf(streamTwo).write(2);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(3);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(4);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(0);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(1);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(9);
inSequence(seqStreamTwo);
oneOf(streamTwo).flush();
inSequence(seqStreamTwo);
oneOf(streamTwo).flush();
inSequence(seqStreamTwo);
oneOf(streamTwo).close();
inSequence(seqStreamTwo);
}
});
final CompositeOutputStream cos = new CompositeOutputStream(streamOne);
assertFalse(cos.isEmpty());
assertEquals(1, cos.size());
cos.addOutputStream(streamTwo);
assertEquals(2, cos.size());
cos.write(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 2, 3);
cos.write(new byte[] { 0, 1 });
cos.write(9);
cos.flush();
cos.close();
}
use of org.jmock.Sequence in project geode by apache.
the class CompositeOutputStreamJUnitTest method testRemoveOutputStreamWithTwoStreams.
@Test
public void testRemoveOutputStreamWithTwoStreams() throws IOException {
final Sequence seqStreamOne = mockContext.sequence("seqStreamOne");
final OutputStream streamOne = mockContext.mock(OutputStream.class, "streamOne");
mockContext.checking(new Expectations() {
{
oneOf(streamOne).write(2);
inSequence(seqStreamOne);
oneOf(streamOne).write(3);
inSequence(seqStreamOne);
oneOf(streamOne).write(4);
inSequence(seqStreamOne);
oneOf(streamOne).write(0);
inSequence(seqStreamOne);
oneOf(streamOne).write(1);
inSequence(seqStreamOne);
oneOf(streamOne).write(9);
inSequence(seqStreamOne);
oneOf(streamOne).flush();
inSequence(seqStreamOne);
oneOf(streamOne).flush();
inSequence(seqStreamOne);
oneOf(streamOne).close();
inSequence(seqStreamOne);
}
});
final OutputStream streamTwo = mockContext.mock(OutputStream.class, "streamTwo");
mockContext.checking(new Expectations() {
{
never(streamTwo).write(2);
never(streamTwo).write(3);
never(streamTwo).write(4);
never(streamTwo).write(0);
never(streamTwo).write(1);
never(streamTwo).write(9);
never(streamTwo).flush();
never(streamTwo).flush();
never(streamTwo).close();
}
});
final CompositeOutputStream cos = new CompositeOutputStream(streamOne, streamTwo);
assertFalse(cos.isEmpty());
assertEquals(2, cos.size());
cos.removeOutputStream(streamTwo);
assertFalse(cos.isEmpty());
assertEquals(1, cos.size());
cos.write(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 2, 3);
cos.write(new byte[] { 0, 1 });
cos.write(9);
cos.flush();
cos.close();
}
use of org.jmock.Sequence in project geode by apache.
the class CompositeOutputStreamJUnitTest method testAddOutputStreamWithTwoStreams.
@Test
public void testAddOutputStreamWithTwoStreams() throws IOException {
final Sequence seqStreamOne = mockContext.sequence("seqStreamOne");
final OutputStream streamOne = mockContext.mock(OutputStream.class, "streamOne");
mockContext.checking(new Expectations() {
{
oneOf(streamOne).write(2);
inSequence(seqStreamOne);
oneOf(streamOne).write(3);
inSequence(seqStreamOne);
oneOf(streamOne).write(4);
inSequence(seqStreamOne);
oneOf(streamOne).write(0);
inSequence(seqStreamOne);
oneOf(streamOne).write(1);
inSequence(seqStreamOne);
oneOf(streamOne).write(9);
inSequence(seqStreamOne);
oneOf(streamOne).flush();
inSequence(seqStreamOne);
oneOf(streamOne).flush();
inSequence(seqStreamOne);
oneOf(streamOne).close();
inSequence(seqStreamOne);
}
});
final Sequence seqStreamTwo = mockContext.sequence("seqStreamTwo");
final OutputStream streamTwo = mockContext.mock(OutputStream.class, "streamTwo");
mockContext.checking(new Expectations() {
{
oneOf(streamTwo).write(2);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(3);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(4);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(0);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(1);
inSequence(seqStreamTwo);
oneOf(streamTwo).write(9);
inSequence(seqStreamTwo);
oneOf(streamTwo).flush();
inSequence(seqStreamTwo);
oneOf(streamTwo).flush();
inSequence(seqStreamTwo);
oneOf(streamTwo).close();
inSequence(seqStreamTwo);
}
});
final Sequence seqStreamThree = mockContext.sequence("seqStreamThree");
final OutputStream streamThree = mockContext.mock(OutputStream.class, "streamThree");
mockContext.checking(new Expectations() {
{
oneOf(streamThree).write(2);
inSequence(seqStreamThree);
oneOf(streamThree).write(3);
inSequence(seqStreamThree);
oneOf(streamThree).write(4);
inSequence(seqStreamThree);
oneOf(streamThree).write(0);
inSequence(seqStreamThree);
oneOf(streamThree).write(1);
inSequence(seqStreamThree);
oneOf(streamThree).write(9);
inSequence(seqStreamThree);
oneOf(streamThree).flush();
inSequence(seqStreamThree);
oneOf(streamThree).flush();
inSequence(seqStreamThree);
oneOf(streamThree).close();
inSequence(seqStreamThree);
}
});
final CompositeOutputStream cos = new CompositeOutputStream(streamOne, streamTwo);
assertFalse(cos.isEmpty());
assertEquals(2, cos.size());
cos.addOutputStream(streamThree);
assertEquals(3, cos.size());
cos.write(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, 2, 3);
cos.write(new byte[] { 0, 1 });
cos.write(9);
cos.flush();
cos.close();
}
Aggregations