All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.ca.odell.glazedlists.swing.SwingTestCase Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
/* Glazed Lists                                                 (c) 2003-2006 */
/* http://publicobject.com/glazedlists/                      publicobject.com,*/
/*                                                     O'Dell Engineering Ltd.*/
package ca.odell.glazedlists.swing;

import ca.odell.glazedlists.GuiTestCase;

import javax.swing.*;
import java.lang.reflect.InvocationTargetException;

/**
 * Utility class for running JUnit tests with Swing code.
 *
 * 

This class has the following behaviour: * *

    *
  • Extending classes must not define any other testXXX() * methods. The should define only guiTestXXX() methods.
  • * *
  • If one test fails, they all fail.
  • *
* * @author James Lemieux * @author Jesse Wilson */ public abstract class SwingTestCase extends GuiTestCase { protected final void executeOnGUIThread(Runnable runnable) { try { SwingUtilities.invokeAndWait(runnable); } catch (InterruptedException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { Throwable rootCause = e; // unwrap all wrapper layers down to the root problem while (rootCause.getCause() != null) rootCause = rootCause.getCause(); if (rootCause instanceof RuntimeException) throw (RuntimeException) rootCause; if (rootCause instanceof Error) throw (Error) rootCause; // embed anything else as a RuntimeException throw new RuntimeException(rootCause); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy