test.ca.odell.glazedlists.swing.SwingTestCase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glazedlists_java15 Show documentation
Show all versions of glazedlists_java15 Show documentation
Event-driven lists for dynamically filtered and sorted tables
/* 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