Search in sources :

Example 6 with Sequence

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);
}
Also used : Expectations(org.jmock.Expectations) Sequence(org.jmock.Sequence) Test(org.junit.Test)

Example 7 with Sequence

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);
}
Also used : Expectations(org.jmock.Expectations) List(java.util.List) Rule(org.gradle.api.Rule) Sequence(org.jmock.Sequence) Test(org.junit.Test)

Example 8 with Sequence

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();
}
Also used : Expectations(org.jmock.Expectations) OutputStream(java.io.OutputStream) Sequence(org.jmock.Sequence) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 9 with Sequence

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();
}
Also used : Expectations(org.jmock.Expectations) OutputStream(java.io.OutputStream) Sequence(org.jmock.Sequence) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Example 10 with Sequence

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();
}
Also used : Expectations(org.jmock.Expectations) OutputStream(java.io.OutputStream) Sequence(org.jmock.Sequence) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Aggregations

Expectations (org.jmock.Expectations)19 Sequence (org.jmock.Sequence)19 Test (org.junit.Test)19 OutputStream (java.io.OutputStream)7 UnitTest (org.apache.geode.test.junit.categories.UnitTest)7 BuildClientMetaData (org.gradle.initialization.BuildClientMetaData)3 List (java.util.List)2 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)2 Script (org.gradle.groovy.scripts.Script)2 StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)2 File (java.io.File)1 GradleScriptException (org.gradle.api.GradleScriptException)1 Project (org.gradle.api.Project)1 Rule (org.gradle.api.Rule)1 Task (org.gradle.api.Task)1 TestUtil.createChildProject (org.gradle.util.TestUtil.createChildProject)1 Description (org.hamcrest.Description)1 Action (org.jmock.api.Action)1 Invocation (org.jmock.api.Invocation)1 Bundle (org.osgi.framework.Bundle)1