Package net.sourceforge.clownfish.mojo.glassfish

Examples of net.sourceforge.clownfish.mojo.glassfish.ListMojo


     * Test execute success.
     */
    public void testExecuteSuccess() {
        try {
            final String artifactTypes = " this, is, a,test ";
            ListMojo listMojo = new ListMojo();
            listMojo.setArtifactTypes(artifactTypes);
       
            Command command = new Command(null);
            command.setVerbose(true);

            EasyMock.expect(log.isInfoEnabled()).andReturn(false).times(2);
           
            EasyMock.expect(clownfishHelper.parseString(artifactTypes))
                    .andReturn(new ArrayList<String>());
           
            EasyMock.expect(clownfishFactory.createClownfish(
                    command, clownfishHelper, progressListenerFactory,
                    maven2WrapperLog))
                    .andReturn(clownfish);
           
            EasyMock.expect(clownfish.list()).andReturn(true);
           

            clownfish.destroy();


            EasyMock.replay(log);
            EasyMock.replay(clownfish);
            EasyMock.replay(clownfishFactory);
            EasyMock.replay(clownfishHelper);


            listMojo.setClownfishFactory(clownfishFactory);
            listMojo.setClownfishHelper(clownfishHelper);
            listMojo.setProgressListenerFactory(progressListenerFactory);
            listMojo.setCommand(command);
            listMojo.setMaven2WrapperLog(maven2WrapperLog);
            listMojo.setLog(log);

            listMojo.execute();
           
            EasyMock.verify(log);
            EasyMock.verify(clownfish);
            EasyMock.verify(clownfishFactory);
            EasyMock.verify(clownfishHelper);
           
            assertEquals(" this, is, a,test ", listMojo.getArtifactTypes());
           
        } catch (MojoExecutionException e) {
            fail(e.getMessage());
        }
    }
View Full Code Here


    /**
     * Test execute fail.
     */
    public void testExecuteFail() {

        ListMojo listMojo = new ListMojo();

        Command command = new Command(null);
        command.setVerbose(true);
       
        Exception exception = new RuntimeException("test mock exception");

        EasyMock.expect(log.isInfoEnabled()).andReturn(false).times(1);

        EasyMock.expect(clownfishHelper.parseString(null))
                .andReturn(new ArrayList<String>());
       
        EasyMock.expect(clownfishFactory.createClownfish(
                    command, clownfishHelper, progressListenerFactory,
                    maven2WrapperLog))
                    .andReturn(clownfish);
           
        EasyMock.expect(clownfish.list()).andThrow(exception);

        log.error("Exception thrown while listing", exception);
       

        clownfish.destroy();


        EasyMock.replay(log);
        EasyMock.replay(clownfish);
        EasyMock.replay(clownfishFactory);
        EasyMock.replay(clownfishHelper);


        listMojo.setClownfishFactory(clownfishFactory);
        listMojo.setClownfishHelper(clownfishHelper);
        listMojo.setProgressListenerFactory(progressListenerFactory);
        listMojo.setCommand(command);
        listMojo.setMaven2WrapperLog(maven2WrapperLog);
        listMojo.setLog(log);

        try {
            listMojo.execute();
            fail("execute should fail "
                    + "- should throw MojoExecutionException");
        } catch (MojoExecutionException e) {
            // do-nothing
        }
View Full Code Here

TOP

Related Classes of net.sourceforge.clownfish.mojo.glassfish.ListMojo

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.