Package org.jmock

Examples of org.jmock.Expectations


    @Test
    public void execute() throws Exception {
        final String[] expectedArgs = { "arg1", "arg2" };
        final int expectedExitValue = 5;
        final String expectedGradleHome = "somepath";
        context.checking(new Expectations() {{
          one(installMock).createDist(
                  "test" + Wrapper.URL_ROOT_PROPERTY,
                  "test" + Wrapper.DISTRIBUTION_BASE_PROPERTY,
                  "test" + Wrapper.DISTRIBUTION_PATH_PROPERTY,
                  "test" + Wrapper.DISTRIBUTION_NAME_PROPERTY,
View Full Code Here


                LoggingEvent event = (LoggingEvent) o;
                return event.getLevel().equals(level) && event.getMessage().equals(text) && event.getMarker() == marker;
            }
        };

        context.checking(new Expectations() {{
            one(appender).doAppend(with(matcher));
        }});
    }
View Full Code Here

        expectedScriptRunner = context.mock(ScriptRunner.class);
        scriptProcessor = new DefaultScriptCompilerFactory(scriptCompilationHandlerMock, scriptRunnerFactoryMock, cacheRepositoryMock);
        source = context.mock(ScriptSource.class);
        cacheBuilder = context.mock(CacheBuilder.class);

        context.checking(new Expectations() {{
            Resource resource = context.mock(Resource.class);

            allowing(source).getDisplayName();
            will(returnValue("[script source]"));
            allowing(source).getClassName();
View Full Code Here

    @Test
    public void testWithSourceFileNotCached() {
        final Collector<TestScript> collector = collector();

        context.checking(new Expectations() {{
            one(cacheRepositoryMock).cache("scripts/class-name");
            will(returnValue(cacheBuilder));

            one(cacheBuilder).withProperties(expectedCacheProperties);
            will(returnValue(cacheBuilder));
View Full Code Here

    @Test
    public void testWithCachedSourceFile() {
        final Collector<TestScript> collector = collector();

        context.checking(new Expectations() {{
            one(cacheRepositoryMock).cache("scripts/class-name");
            will(returnValue(cacheBuilder));

            one(cacheBuilder).withProperties(expectedCacheProperties);
            will(returnValue(cacheBuilder));
View Full Code Here

    public void testUsesSuppliedClassLoaderToLoadScript() {
        final Collector<TestScript> collector = collector();
        final ClassLoader classLoader = new ClassLoader() {
        };

        context.checking(new Expectations(){{
            one(cacheRepositoryMock).cache("scripts/class-name");
            will(returnValue(cacheBuilder));

            one(cacheBuilder).withProperties(expectedCacheProperties);
            will(returnValue(cacheBuilder));
View Full Code Here

    @Test
    public void testUsesSuppliedTransformerToDetermineCacheDirName() {
        final Transformer transformer = context.mock(Transformer.class);
        final File expectedCacheDir = new TestFile(expectedScriptCacheDir.getParentFile(), "transformer_Script").createDir();

        context.checking(new Expectations(){{
            allowing(transformer).getId();
            will(returnValue("transformer"));

            one(cacheRepositoryMock).cache("scripts/class-name");
            will(returnValue(cacheBuilder));
View Full Code Here

    private final ScriptExecutionListener scriptExecutionListenerMock = context.mock(ScriptExecutionListener.class);
    private final DefaultScriptRunnerFactory factory = new DefaultScriptRunnerFactory(scriptExecutionListenerMock);

    @Before
    public void setUp() {
        context.checking(new Expectations() {{
            allowing(scriptMock).getStandardOutputCapture();
            will(returnValue(standardOutputCaptureMock));
            allowing(scriptMock).getScriptSource();
            will(returnValue(scriptSourceDummy));
            allowing(scriptMock).getContextClassloader();
View Full Code Here

    @Test
    public void redirectsStandardOutputAndSetsContextClassLoaderWhenScriptIsRun() {
        ScriptRunner<Script> scriptRunner = factory.create(scriptMock);

        context.checking(new Expectations() {{
            Sequence sequence = context.sequence("seq");

            one(scriptExecutionListenerMock).beforeScript(scriptMock);
            inSequence(sequence);
View Full Code Here

    public void wrapsExecutionExceptionAndRestoresStateWhenScriptFails() {
        final RuntimeException failure = new RuntimeException();

        ScriptRunner<Script> scriptRunner = factory.create(scriptMock);

        context.checking(new Expectations() {{
            Sequence sequence = context.sequence("seq");

            one(scriptExecutionListenerMock).beforeScript(scriptMock);
            inSequence(sequence);
View Full Code Here

TOP

Related Classes of org.jmock.Expectations

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.