package groovy.util;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class GroovySwingTestCase extends GroovyTestCase {
    private static boolean headless;

    public static boolean isHeadless() {
        return headless;
    }

    static {
        try {
            final Class jframe = Class.forName("javax.swing.JFrame");
            final Constructor constructor = jframe.getConstructor(new Class[]{String.class});
            constructor.newInstance(new String[]{"testing"});
            headless = false;
        } catch (java.awt.HeadlessException e) {
            headless = true;
        } catch (UnsatisfiedLinkError e) {
            headless = true;
        } catch (ClassNotFoundException e) {
            headless = true;
        } catch (IllegalAccessException e) {
            headless = true;
        } catch (InstantiationException e) {
            headless = true;
        } catch (NoSuchMethodException e) {
            headless = true;
        } catch (InvocationTargetException e) {
            headless = true;
        }
    }

}

@@ -210,68 +210,524 @@
     
-public static boolean isHeadless() %7B%0A        return headless
+/**%0A     * A boolean indicating if we are running in headless mode.%0A     * Check this flag if you believe your test may make use of AWT/Swing%0A     * features, then simply return rather than running your test.%0A     *%0A     * @return true if running in headless mode%0A     */%0A    public static boolean isHeadless() %7B%0A        return headless;%0A    %7D%0A%0A    /**%0A     * Alias for isHeadless().%0A     *%0A     * @return true if running in headless mode%0A     */%0A    public static boolean getHeadless() %7B%0A        return isHeadless()
 ;%0A  

tweak for headless build on bamboo