Package org.jmock.cglib

Examples of org.jmock.cglib.Mock


        return createMockObject(name, null);
    }

    public static <T> T createMockObject(Class<T> name, MockInitializer initializer) {
        String shortName = getShortName(name);
        Mock mock = new Mock(name, shortName);
        log.info("created a Mock for " + shortName);

        if (initializer != null) {
            initializer.init(mock);
        }

        return name.cast(mock.proxy());
    }
View Full Code Here


    public static Object createMockObject(Class<?> name, MockInitializer initializer,
                                          Class<?>[] clsArgs, Object[] args) {
        String shortName = getShortName(name);
        CGLibCoreMockExt cglibMock = new CGLibCoreMockExt(name, shortName);
        Mock mock = new Mock(cglibMock);
        log.info("created a Mock for " + shortName);

        if (initializer != null) {
            initializer.init(mock);
        }
View Full Code Here

        stubActivationSpec.setClientId("foo");
        stubActivationSpec.setSubscriptionName("bar");
    }

    private void setupMocks() {
        mockResourceAdapter = new Mock(ActiveMQResourceAdapter.class);
        mockActivationKey = new Mock(ActiveMQEndpointActivationKey.class);
        mockEndpointFactory = new Mock(MessageEndpointFactory.class);
        mockBootstrapContext = new Mock(BootstrapContext.class);
        mockConnection = new Mock(Connection.class);
       
        mockActivationKey.expects(atLeastOnce())
                            .method("getMessageEndpointFactory")
                                .will(returnValue((MessageEndpointFactory) mockEndpointFactory.proxy()));
       
View Full Code Here

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

        Process process = createMockProcess( 0 );

        Mock commandLineMock = createMockCommandLine( workingDirectory, process );
        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, null, new ReleaseResult() );

        assertTrue( true );
    }
View Full Code Here

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

        Process process = createMockProcess( 0 );

        Mock commandLineMock = createMockCommandLine( workingDirectory, process );
        expectDefaultArguments( commandLineMock );

        String arguments = "-f my-pom.xml";
        commandLineMock.expects( new InvokeOnceMatcher() ).method( "createArgument" ).will(
            new ReturnStub( createArgumentLineMock( arguments ) ) );

        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, null, "my-pom.xml",
                               new ReleaseResult() );

        assertTrue( true );
View Full Code Here

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

        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 );

        assertTrue( true );
    }
View Full Code Here

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

        Process process = createMockProcess( 1 );

        Mock commandLineMock = createMockCommandLine( workingDirectory, process );

        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
        {
            executor.executeGoals( workingDirectory, "clean integration-test", false, null, new ReleaseResult() );
View Full Code Here

    public void testExecutionWithCommandLineException()
        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
        {
            executor.executeGoals( workingDirectory, "clean integration-test", false, null, new ReleaseResult() );
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

        return commandLineMock;
    }

    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

TOP

Related Classes of org.jmock.cglib.Mock

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.