com.greenpepper.runner.SuiteRunner Maven / Gradle / Ivy
/*
* 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 com.greenpepper.document.InterpreterSelector;
import com.greenpepper.report.ReportGenerator;
import com.greenpepper.repository.DocumentRepository;
import com.greenpepper.systemunderdevelopment.SystemUnderDevelopment;
import static com.greenpepper.util.URIUtil.flatten;
import java.util.ArrayList;
import java.util.List;
/**
* SuiteRunner class.
*
* @author oaouattara
* @version $Id: $Id
*/
public class SuiteRunner implements SpecificationRunner
{
private SpecificationRunnerMonitor monitor;
private DocumentRepository documentRepository;
private DocumentRunner runner;
/**
* Constructor for SuiteRunner.
*/
public SuiteRunner()
{
runner = new DocumentRunner();
}
/**
* setSystemUnderDevelopment.
*
* @param systemUnderDevelopment a {@link com.greenpepper.systemunderdevelopment.SystemUnderDevelopment} object.
*/
public void setSystemUnderDevelopment( SystemUnderDevelopment systemUnderDevelopment )
{
runner.setSystemUnderDevelopment( systemUnderDevelopment );
}
/**
* setRepository.
*
* @param documentRepository a {@link com.greenpepper.repository.DocumentRepository} object.
*/
public void setRepository( DocumentRepository documentRepository )
{
this.documentRepository = documentRepository;
runner.setRepository( documentRepository );
}
/**
* Setter for the field monitor
.
*
* @param monitor a {@link com.greenpepper.runner.SpecificationRunnerMonitor} object.
*/
public void setMonitor( SpecificationRunnerMonitor monitor )
{
this.monitor = monitor;
runner.setMonitor( monitor );
}
/**
* setSections.
*
* @param sections a {@link java.lang.String} object.
*/
public void setSections( String... sections )
{
runner.setSections( sections );
}
/**
* setReportGenerator.
*
* @param generator a {@link com.greenpepper.report.ReportGenerator} object.
*/
public void setReportGenerator( ReportGenerator generator )
{
runner.setReportGenerator( generator );
}
/** {@inheritDoc} */
public void run( String source, String destination )
{
List names = listDocumentsAt( source );
if (names.isEmpty())
{
monitor.testRunning(source);
monitor.testDone( 0, 0, 0, 0 );
return;
}
for (String name : names)
{
runner.run( name, flatten( name ) );
}
}
private List listDocumentsAt( String source )
{
List names = new ArrayList();
try
{
names = documentRepository.listDocuments( source );
}
catch (Exception e)
{
monitor.exceptionOccured( e );
}
return names;
}
/**
* setLazy.
*
* @param lazy a boolean.
*/
public void setLazy(boolean lazy)
{
runner.setLazy(lazy);
}
/**
* setInterpreterSelector.
*
* @param interpreterSelectorClass a {@link java.lang.Class} object.
*/
public void setInterpreterSelector(Class extends InterpreterSelector> interpreterSelectorClass)
{
runner.setInterpreterSelector(interpreterSelectorClass);
}
}