Package org.jmock.core.matcher

Examples of org.jmock.core.matcher.InvokeOnceMatcher


        Process process = createMockProcess( 0 );

        Mock commandLineMock = createMockCommandLine( workingDirectory, process );
        String arguments = "-DperformRelease=true -Dmaven.test.skip=true";
        commandLineMock.expects( new InvokeOnceMatcher() ).method( "createArgument" ).will(
            new ReturnStub( createArgumentLineMock( arguments ) ) );

        expectDefaultArguments( commandLineMock );

        Mock mock = new Mock( CommandLineFactory.class );

        mock.expects( new InvokeOnceMatcher() ).method( "createCommandLine" ).with( new IsEqual( "mvn" ) ).will(
            new ReturnStub( commandLineMock.proxy() ) );

        executor.setCommandLineFactory( (CommandLineFactory) mock.proxy() );

        executor.executeGoals( workingDirectory, "clean integration-test", false, arguments, null );
View Full Code Here


        expectDefaultArguments( commandLineMock );

        Mock mock = new Mock( CommandLineFactory.class );

        mock.expects( new InvokeOnceMatcher() ).method( "createCommandLine" ).with( new IsEqual( "mvn" ) ).will(
            new ReturnStub( commandLineMock.proxy() ) );

        executor.setCommandLineFactory( (CommandLineFactory) mock.proxy() );

        try
View Full Code Here

        throws MavenExecutorException
    {
        File workingDirectory = getTestFile( "target/working-directory" );

        Mock commandLineMock = new Mock( Commandline.class );
        commandLineMock.expects( new InvokeOnceMatcher() ).method( "setWorkingDirectory" ).with(
            new IsEqual( workingDirectory.getAbsolutePath() ) );
        commandLineMock.expects( new InvokeOnceMatcher() ).method( "addEnvironment" ).with(
            new IsEqual( "MAVEN_TERMINATE_CMD" ), new IsEqual( "on" ) );
        commandLineMock.expects( new InvokeOnceMatcher() ).method( "execute" ).will(
            new ThrowStub( new CommandLineException( "..." ) ) );

        expectDefaultArguments( commandLineMock );

        Mock mock = new Mock( CommandLineFactory.class );

        mock.expects( new InvokeOnceMatcher() ).method( "createCommandLine" ).with( new IsEqual( "mvn" ) ).will(
            new ReturnStub( commandLineMock.proxy() ) );

        executor.setCommandLineFactory( (CommandLineFactory) mock.proxy() );

        try
View Full Code Here

    private static void expectDefaultArguments( Mock commandLineMock )
    {
        String[] args = new String[]{"clean", "integration-test", "--no-plugin-updates", "--batch-mode"};
        for ( int i = args.length - 1; i >= 0; i-- )
        {
            commandLineMock.expects( new InvokeOnceMatcher() ).method( "createArgument" ).will(
                new ReturnStub( createArgumentValueMock( args[i] ) ) );
        }
    }
View Full Code Here

    }

    private static Mock createMockCommandLine( File workingDirectory, Process process )
    {
        Mock commandLineMock = new Mock( Commandline.class );
        commandLineMock.expects( new InvokeOnceMatcher() ).method( "setWorkingDirectory" ).with(
            new IsEqual( workingDirectory.getAbsolutePath() ) );
        commandLineMock.expects( new InvokeOnceMatcher() ).method( "addEnvironment" ).with(
            new IsEqual( "MAVEN_TERMINATE_CMD" ), new IsEqual( "on" ) );
        commandLineMock.expects( new InvokeOnceMatcher() ).method( "execute" ).will( new ReturnStub( process ) );

        return commandLineMock;
    }
View Full Code Here

    }

    private static Commandline.Argument createArgumentValueMock( String value )
    {
        Mock mock = new Mock( Commandline.Argument.class );
        mock.expects( new InvokeOnceMatcher() ).method( "setValue" ).with( new IsEqual( value ) );
        return (Commandline.Argument) mock.proxy();
    }
View Full Code Here

    }

    private static Commandline.Argument createArgumentLineMock( String value )
    {
        Mock mock = new Mock( Commandline.Argument.class );
        mock.expects( new InvokeOnceMatcher() ).method( "setLine" ).with( new IsEqual( value ) );
        return (Commandline.Argument) mock.proxy();
    }
View Full Code Here

    }

    private static Process createMockProcess( int exitCode )
    {
        Mock mockProcess = new Mock( Process.class );
        mockProcess.expects( new InvokeOnceMatcher() ).method( "getInputStream" ).will(
            new ReturnStub( new StringInputStream( "" ) ) );
        mockProcess.expects( new InvokeOnceMatcher() ).method( "getErrorStream" ).will(
            new ReturnStub( new StringInputStream( "" ) ) );
        mockProcess.expects( new InvokeOnceMatcher() ).method( "waitFor" ).will(
            new ReturnStub( new Integer( exitCode ) ) );
        if ( exitCode != 0 )
        {
            mockProcess.expects( new InvokeOnceMatcher() ).method( "exitValue" ).will(
                new ReturnStub( new Integer( exitCode ) ) );
        }
        return (Process) mockProcess.proxy();
    }
View Full Code Here

        releaseDescriptor.setCheckoutDirectory( checkoutDirectory.getAbsolutePath() );

        Mock mock = new Mock( MavenExecutor.class );
        Constraint[] constraints = new Constraint[]{new IsSame( checkoutDirectory ), new IsEqual( "goal1 goal2" ),
            new IsEqual( Boolean.TRUE ), new IsEqual( "-Dmaven.test.skip=true" ), new IsNull(), new IsAnything()};
        mock.expects( new InvokeOnceMatcher() ).method( "executeGoals" ).with( constraints );
        RunPerformGoalsPhase phase = (RunPerformGoalsPhase) lookup( ReleasePhase.ROLE, "run-perform-goals" );
        phase.setMavenExecutor( (MavenExecutor) mock.proxy() );

        Mock scmProviderMock = new Mock( ScmProvider.class );
        constraints = new Constraint[]{new IsAnything(), new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ),
            new IsInstanceOf( ScmTag.class )};
        scmProviderMock.expects( new InvokeOnceMatcher() ).method( "checkOut" ).with( constraints ).will(
            new ReturnStub( new CheckOutScmResult( "...", Collections.<ScmFile>emptyList() ) ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( (ScmProvider) scmProviderMock.proxy() );
View Full Code Here

        releaseDescriptor.setCheckoutDirectory( checkoutDirectory.getAbsolutePath() );

        Mock mock = new Mock( MavenExecutor.class );
        Constraint[] constraints = new Constraint[]{new IsSame( checkoutDirectory ), new IsEqual( "goal1 goal2" ),
            new IsEqual( Boolean.TRUE ), new IsEqual( "-DperformRelease=true" ), new IsNull(), new IsAnything()};
        mock.expects( new InvokeOnceMatcher() ).method( "executeGoals" ).with( constraints );
        RunPerformGoalsPhase phase = (RunPerformGoalsPhase) lookup( ReleasePhase.ROLE, "run-perform-goals" );
        phase.setMavenExecutor( (MavenExecutor) mock.proxy() );

        Mock scmProviderMock = new Mock( ScmProvider.class );
        constraints = new Constraint[]{new IsAnything(), new IsScmFileSetEquals( new ScmFileSet( checkoutDirectory ) ),
            new IsInstanceOf( ScmTag.class )};
        scmProviderMock.expects( new InvokeOnceMatcher() ).method( "checkOut" ).with( constraints ).will(
            new ReturnStub( new CheckOutScmResult( "...", Collections.<ScmFile>emptyList() ) ) );

        ScmManagerStub stub = (ScmManagerStub) lookup( ScmManager.ROLE );
        stub.setScmProvider( (ScmProvider) scmProviderMock.proxy() );
View Full Code Here

TOP

Related Classes of org.jmock.core.matcher.InvokeOnceMatcher

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.