com.greenpepper.runner.CompositeSpecificationRunnerMonitor Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2007 Pyxis Technologies inc.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA,
* or see the FSF site: http://www.fsf.org.
*/
package com.greenpepper.runner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* CompositeSpecificationRunnerMonitor class.
*
* @author oaouattara
* @version $Id: $Id
*/
public class CompositeSpecificationRunnerMonitor implements SpecificationRunnerMonitor
{
private final List monitors;
/**
* Constructor for CompositeSpecificationRunnerMonitor.
*
* @param monitors a {@link com.greenpepper.runner.SpecificationRunnerMonitor} object.
*/
public CompositeSpecificationRunnerMonitor( SpecificationRunnerMonitor... monitors )
{
this( Arrays.asList( monitors ) );
}
/**
* Constructor for CompositeSpecificationRunnerMonitor.
*
* @param monitors a {@link java.util.List} object.
*/
public CompositeSpecificationRunnerMonitor( List monitors )
{
this.monitors = new ArrayList();
this.monitors.addAll( monitors );
}
/**
* Constructor for CompositeSpecificationRunnerMonitor.
*/
public CompositeSpecificationRunnerMonitor()
{
this( Collections.emptyList() );
}
/**
* add.
*
* @param monitor a {@link com.greenpepper.runner.SpecificationRunnerMonitor} object.
*/
public void add( SpecificationRunnerMonitor monitor )
{
monitors.add( monitor );
}
/** {@inheritDoc} */
public void testRunning( String location )
{
for (SpecificationRunnerMonitor monitor : monitors)
{
monitor.testRunning( location );
}
}
/** {@inheritDoc} */
public void testDone( int rightCount, int wrongCount, int exceptionCount, int ignoreCount ) {
// reverse the order in which the monitors are notified
Collections.reverse(monitors);
for (SpecificationRunnerMonitor monitor : monitors) {
monitor.testDone( rightCount, wrongCount, exceptionCount, ignoreCount );
}
Collections.reverse(monitors);
}
/** {@inheritDoc} */
public void exceptionOccured( Throwable t )
{
for (SpecificationRunnerMonitor monitor : monitors)
{
monitor.exceptionOccured( t );
}
}
}