You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Martin Gainty <mg...@hotmail.com> on 2011/03/08 15:51:42 UTC

org.apache.maven.surefire.booter.output.ForkingStreamConsumer doesnt compile..has been refactored to compile (and work)

package org.apache.maven.surefire.booter.output;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import org.apache.maven.surefire.report.ForkingConsoleReporter;
import org.apache.maven.surefire.report.ReportEntry;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
import org.jmock.core.Constraint;
import org.jmock.builder.MatchBuilder;

/**
 * Test for {@link ForkingStreamConsumer}
 *
 * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
 *
 * caution the original ForkingStreamConsumer class doesnt compile
 * added public class matcher_impl implements org.jmock.core.InvocationMatcher MCG
 * added public org.jmock.core.InvocationMatcher once() { return new matcher_impl(); } MCG
 */
public class ForkingStreamConsumerTest
    extends MockObjectTestCase
{

    private ForkingStreamConsumer streamConsumer;

    private Mock outputConsumerMock;

    private String message;

    private ReportEntry reportEntry;
    public class matcher_impl implements org.jmock.core.InvocationMatcher
    {
        public org.jmock.core.Invocation invocation=null;
        public matcher_impl() { ; }
        public boolean hasDescription() { return true; }
        public void invoked(org.jmock.core.Invocation invocation) { this.invocation=invocation; }
        public boolean matches(org.jmock.core.Invocation invocation)
        {
            if (this.invocation==invocation)
            {
                return true;
            }
            else return false;
        }
        public boolean verify_bool=true;
        public void verify() { ; }
        public StringBuffer describeTo(StringBuffer buffer)
        {
            StringBuffer result=new StringBuffer();
            result.append(buffer.toString());
            return result;
        }
    }
    public org.jmock.core.InvocationMatcher once() { return new matcher_impl(); }
    protected void setUp()
        throws Exception
    {
        super.setUp();
        outputConsumerMock = new Mock( OutputConsumer.class );
        streamConsumer = new ForkingStreamConsumer( (OutputConsumer) outputConsumerMock.proxy() );
        message = "message";
        reportEntry = new ReportEntry();
        reportEntry.setGroup( "group" );
        reportEntry.setName( "name" );
    }
    public MatchBuilder match_builder;
    public Constraint constraint;

    public MatchBuilder with(Constraint arg1)
    {
        if(arg1.eval(match_builder)==true) return match_builder;
        else return null;
    }
    public Constraint eq(String test)
    {
        org.jmock.core.constraint.IsEqual is_equal=new org.jmock.core.constraint.IsEqual((java.lang.Object)test);
        if(is_equal!=null) return (Constraint)is_equal;
        return null;
    }
    public void testConsumeHeaderLine()
    {
        String message = "message";
        String line = ForkingConsoleReporter.FORKING_PREFIX_HEADING + message;
        outputConsumerMock.expects( once() ).method( "consumeHeaderLine" ).with( eq( message ) );
        streamConsumer.consumeLine( line );
    }

    public void testConsumeMessageLine()
    {
        String message = "message";
        String line = ForkingConsoleReporter.FORKING_PREFIX_STANDARD + message;
        outputConsumerMock.expects( once() ).method( "consumeMessageLine" ).with( eq( message ) );
        streamConsumer.consumeLine( line );
    }

    public void testConsumeFooterLine()
    {
        String message = "message";
        String line = ForkingConsoleReporter.FORKING_PREFIX_FOOTER + message;
        outputConsumerMock.expects( once() ).method( "consumeFooterLine" ).with( eq( message ) );
        streamConsumer.consumeLine( line );
    }

    public void testConsumeOutputLine()
    {
        String line = message;
        outputConsumerMock.expects( once() ).method( "consumeOutputLine" ).with( eq( message ) );
        streamConsumer.consumeLine( line );
    }

    public void testTestSetStarting()
    {
        message = ForkingConsoleReporter.getTestSetStartingMessage( reportEntry );
        String line = ForkingConsoleReporter.FORKING_PREFIX_STANDARD + message;
        outputConsumerMock.expects( once() ).method( "testSetStarting" ).with( eq( reportEntry ) );
        outputConsumerMock.expects( once() ).method( "consumeMessageLine" ).with( eq( message ) );
        streamConsumer.consumeLine( line );
    }

    public void testTestSetCompleted()
    {
        message = "Tests run: xxxx";
        String line = ForkingConsoleReporter.FORKING_PREFIX_STANDARD + message;
        outputConsumerMock.expects( once() ).method( "testSetCompleted" );
        outputConsumerMock.expects( once() ).method( "consumeMessageLine" ).with( eq( message ) );
        streamConsumer.consumeLine( line );
    }

}

?
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.


 		 	   		  

Re: org.apache.maven.surefire.booter.output.ForkingStreamConsumer doesnt compile..has been refactored to compile (and work)

Posted by Kristian Rosenvold <kr...@gmail.com>.
What kind of platform is this ? We have 2 CI's that says it compiles, 
as well as both jdk 1.5 and 1.6 on my local linux box.

Kristian


ti., 08.03.2011 kl. 09.51 -0500, skrev Martin Gainty:
> package org.apache.maven.surefire.booter.output;
> 
> /*
>  * Licensed to the Apache Software Foundation (ASF) under one
>  * or more contributor license agreements.  See the NOTICE file
>  * distributed with this work for additional information
>  * regarding copyright ownership.  The ASF licenses this file
>  * to you under the Apache License, Version 2.0 (the
>  * "License"); you may not use this file except in compliance
>  * with the License.  You may obtain a copy of the License at
>  *
>  *     http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing,
>  * software distributed under the License is distributed on an
>  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
>  * KIND, either express or implied.  See the License for the
>  * specific language governing permissions and limitations
>  * under the License.
>  */
> 
> import org.apache.maven.surefire.report.ForkingConsoleReporter;
> import org.apache.maven.surefire.report.ReportEntry;
> import org.jmock.Mock;
> import org.jmock.MockObjectTestCase;
> import org.jmock.core.Constraint;
> import org.jmock.builder.MatchBuilder;
> 
> /**
>  * Test for {@link ForkingStreamConsumer}
>  *
>  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
>  *
>  * caution the original ForkingStreamConsumer class doesnt compile
>  * added public class matcher_impl implements org.jmock.core.InvocationMatcher MCG
>  * added public org.jmock.core.InvocationMatcher once() { return new matcher_impl(); } MCG
>  */
> public class ForkingStreamConsumerTest
>     extends MockObjectTestCase
> {
> 
>     private ForkingStreamConsumer streamConsumer;
> 
>     private Mock outputConsumerMock;
> 
>     private String message;
> 
>     private ReportEntry reportEntry;
>     public class matcher_impl implements org.jmock.core.InvocationMatcher
>     {
>         public org.jmock.core.Invocation invocation=null;
>         public matcher_impl() { ; }
>         public boolean hasDescription() { return true; }
>         public void invoked(org.jmock.core.Invocation invocation) { this.invocation=invocation; }
>         public boolean matches(org.jmock.core.Invocation invocation)
>         {
>             if (this.invocation==invocation)
>             {
>                 return true;
>             }
>             else return false;
>         }
>         public boolean verify_bool=true;
>         public void verify() { ; }
>         public StringBuffer describeTo(StringBuffer buffer)
>         {
>             StringBuffer result=new StringBuffer();
>             result.append(buffer.toString());
>             return result;
>         }
>     }
>     public org.jmock.core.InvocationMatcher once() { return new matcher_impl(); }
>     protected void setUp()
>         throws Exception
>     {
>         super.setUp();
>         outputConsumerMock = new Mock( OutputConsumer.class );
>         streamConsumer = new ForkingStreamConsumer( (OutputConsumer) outputConsumerMock.proxy() );
>         message = "message";
>         reportEntry = new ReportEntry();
>         reportEntry.setGroup( "group" );
>         reportEntry.setName( "name" );
>     }
>     public MatchBuilder match_builder;
>     public Constraint constraint;
> 
>     public MatchBuilder with(Constraint arg1)
>     {
>         if(arg1.eval(match_builder)==true) return match_builder;
>         else return null;
>     }
>     public Constraint eq(String test)
>     {
>         org.jmock.core.constraint.IsEqual is_equal=new org.jmock.core.constraint.IsEqual((java.lang.Object)test);
>         if(is_equal!=null) return (Constraint)is_equal;
>         return null;
>     }
>     public void testConsumeHeaderLine()
>     {
>         String message = "message";
>         String line = ForkingConsoleReporter.FORKING_PREFIX_HEADING + message;
>         outputConsumerMock.expects( once() ).method( "consumeHeaderLine" ).with( eq( message ) );
>         streamConsumer.consumeLine( line );
>     }
> 
>     public void testConsumeMessageLine()
>     {
>         String message = "message";
>         String line = ForkingConsoleReporter.FORKING_PREFIX_STANDARD + message;
>         outputConsumerMock.expects( once() ).method( "consumeMessageLine" ).with( eq( message ) );
>         streamConsumer.consumeLine( line );
>     }
> 
>     public void testConsumeFooterLine()
>     {
>         String message = "message";
>         String line = ForkingConsoleReporter.FORKING_PREFIX_FOOTER + message;
>         outputConsumerMock.expects( once() ).method( "consumeFooterLine" ).with( eq( message ) );
>         streamConsumer.consumeLine( line );
>     }
> 
>     public void testConsumeOutputLine()
>     {
>         String line = message;
>         outputConsumerMock.expects( once() ).method( "consumeOutputLine" ).with( eq( message ) );
>         streamConsumer.consumeLine( line );
>     }
> 
>     public void testTestSetStarting()
>     {
>         message = ForkingConsoleReporter.getTestSetStartingMessage( reportEntry );
>         String line = ForkingConsoleReporter.FORKING_PREFIX_STANDARD + message;
>         outputConsumerMock.expects( once() ).method( "testSetStarting" ).with( eq( reportEntry ) );
>         outputConsumerMock.expects( once() ).method( "consumeMessageLine" ).with( eq( message ) );
>         streamConsumer.consumeLine( line );
>     }
> 
>     public void testTestSetCompleted()
>     {
>         message = "Tests run: xxxx";
>         String line = ForkingConsoleReporter.FORKING_PREFIX_STANDARD + message;
>         outputConsumerMock.expects( once() ).method( "testSetCompleted" );
>         outputConsumerMock.expects( once() ).method( "consumeMessageLine" ).with( eq( message ) );
>         streamConsumer.consumeLine( line );
>     }
> 
> }
> 
> ?
> Martin Gainty 
> ______________________________________________ 
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>  
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> 
> 
>  		 	   		  



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org