package com.gargoylesoftware.htmlunit;

import java.io.File;

import junit.framework.Test;
import junit.framework.TestSuite;

import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.XMLOutput;


/**
* run all the jelly tests
*
* @version  $Revision: 1.7 $
* @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
*/
public class JellyTest extends WebTestCase {

    
/**
     *  Create an instance
     *
     * @param  name The name of the test
     */
    
public JellyTest( final String name ) {
        
super( name );
    }

    
/**
     * Return a suite of jelly tests.
     *
     * @return A suite of jelly tests
     * @throws Exception When bad things happen
     */
    
public static Test suite() throws Exception {
        
final XMLOutput output = XMLOutput.createXMLOutput(System.out);
        
final File file = getFileObject("src/test/jelly/com/gargoylesoftware/htmlunit/WebClient.jelly");
        
final JellyContext context = new JellyContext().runScript(file, output);
        
final TestSuite answer = (TestSuite) context.getVariable("org.apache.commons.jelly.junit.suite");
        if (
answer == null ) {
            
System.out.println( "Could not find a TestSuite created by Jelly for the script:" + file );
            
// return an empty test suite
            
return new TestSuite();
        }
        return
answer;
    }
    
/**
     * Empty test method to stop warnings
     */
    
public void testNothing() {
    }
}