Search in sources :

Example 56 with Expectations

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

Example 57 with Expectations

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

Example 58 with Expectations

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

Example 59 with Expectations

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

Example 60 with Expectations

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

Aggregations

Expectations (org.jmock.Expectations)651 Test (org.junit.Test)443 UnitTest (org.apache.geode.test.junit.categories.UnitTest)109 File (java.io.File)41 ConfigurationServiceImpl (org.nhindirect.config.service.impl.ConfigurationServiceImpl)41 InternalCache (org.apache.geode.internal.cache.InternalCache)35 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)33 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)32 Resource (org.apache.sling.api.resource.Resource)31 RewriterResponse (org.apache.sling.security.impl.ContentDispositionFilter.RewriterResponse)31 ArrayList (java.util.ArrayList)27 DiskStore (org.apache.geode.cache.DiskStore)23 ValueMap (org.apache.sling.api.resource.ValueMap)21 Before (org.junit.Before)20 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)20 Sequence (org.jmock.Sequence)19 Cache (org.apache.geode.cache.Cache)18 Region (org.apache.geode.cache.Region)18 DistributedMember (org.apache.geode.distributed.DistributedMember)18 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)17