<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: JUnit 3.x and the Event Dispatch Thread</title>
	<atom:link href="http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/feed/" rel="self" type="application/rss+xml" />
	<link>http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/</link>
	<description>Technology and Geek Stuff by Eric Burke</description>
	<lastBuildDate>Thu, 04 Nov 2010 22:37:00 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Laird Nelson</title>
		<link>http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/comment-page-1/#comment-795</link>
		<dc:creator>Laird Nelson</dc:creator>
		<pubDate>Thu, 01 Nov 2007 20:49:45 +0000</pubDate>
		<guid isPermaLink="false">http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/#comment-795</guid>
		<description>Hey there; I like this entry and the JUnit4 specific bit in the comments section.

To either of you: have you had any luck using this construct in something like a Maven test runner?  No matter what wizardry I try to bring to bear on the problem, the net result is that my properly-EDTized tests pop their frames (or dialogs or whatever) up for the briefest of seconds and exit immediately.  While sometimes this is valuable, and I&#039;m glad to understand how to make it happen, what should I do in the guts of EDTRunner to make it so that any visual artifacts produced by my tests--frames and windows and whatnot--&quot;stick around&quot;?  Normally, in an application, I wouldn&#039;t have to do anything--the mere presence of a frame&#039;s being visible on the EDT causes the application to stick around until that frame is disposed, and until all non-daemon threads exit.  But for some reason when I run my JUnit4 tests under, in this case, Maven&#039;s surefire plugin, there is nothing I can figure out to do to cause my frames to stick around.

Any ideas heartily welcomed.

THanks,
Laird</description>
		<content:encoded><![CDATA[<p>Hey there; I like this entry and the JUnit4 specific bit in the comments section.</p>
<p>To either of you: have you had any luck using this construct in something like a Maven test runner?  No matter what wizardry I try to bring to bear on the problem, the net result is that my properly-EDTized tests pop their frames (or dialogs or whatever) up for the briefest of seconds and exit immediately.  While sometimes this is valuable, and I&#8217;m glad to understand how to make it happen, what should I do in the guts of EDTRunner to make it so that any visual artifacts produced by my tests&#8211;frames and windows and whatnot&#8211;&#8221;stick around&#8221;?  Normally, in an application, I wouldn&#8217;t have to do anything&#8211;the mere presence of a frame&#8217;s being visible on the EDT causes the application to stick around until that frame is disposed, and until all non-daemon threads exit.  But for some reason when I run my JUnit4 tests under, in this case, Maven&#8217;s surefire plugin, there is nothing I can figure out to do to cause my frames to stick around.</p>
<p>Any ideas heartily welcomed.</p>
<p>THanks,<br />
Laird</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carey</title>
		<link>http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/comment-page-1/#comment-38</link>
		<dc:creator>Carey</dc:creator>
		<pubDate>Sun, 16 Sep 2007 22:56:34 +0000</pubDate>
		<guid isPermaLink="false">http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/#comment-38</guid>
		<description>No problem. It was wrapped in &lt;code&gt;pre&lt;/code&gt; tags and indented before I clicked submit; thank you, Wordpress.</description>
		<content:encoded><![CDATA[<p>No problem. It was wrapped in <code>pre</code> tags and indented before I clicked submit; thank you, Wordpress.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Burke</title>
		<link>http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/comment-page-1/#comment-37</link>
		<dc:creator>Eric Burke</dc:creator>
		<pubDate>Sun, 16 Sep 2007 14:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/#comment-37</guid>
		<description>Carey, I hope you don&#039;t mind me editing your comment...I wrapped the code in a &lt;pre class=&quot;prettyprint&quot;&gt; element and changed the indentation.</description>
		<content:encoded><![CDATA[<p>Carey, I hope you don&#8217;t mind me editing your comment&#8230;I wrapped the code in a &lt;pre class=&#8221;prettyprint&#8221;> element and changed the indentation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carey</title>
		<link>http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/comment-page-1/#comment-36</link>
		<dc:creator>Carey</dc:creator>
		<pubDate>Sun, 16 Sep 2007 09:56:31 +0000</pubDate>
		<guid isPermaLink="false">http://stuffthathappens.com/blog/2007/09/14/junit-3x-and-the-event-dispatch-thread/#comment-36</guid>
		<description>Unlike JUnit 3, in JUnit 4 it looks like you write a &lt;code&gt;Runner&lt;/code&gt; that switches to the EDT for you, then add &lt;code&gt;@RunWith(EDTRunner.class)&lt;/code&gt; to the test. Something like:

&lt;pre class=&quot;prettyprint&quot;&gt;public class EDTRunner extends 
    org.junit.internal.runners.TestClassRunner {
  public EDTRunner(Class klass) 
        throws org.junit.internal.runners.InitializationError {
    super(klass);
  }

  @Override
  public void run(final org.junit.runner.notification.RunNotifier notifier) {
    if (javax.swing.SwingUtilities.isEventDispatchThread()) {
      super.run(notifier);
      return;
    }
    try {
      javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
          EDTRunner.super.run(notifier);
        }
      });
    } catch (InterruptedException e) {
      notifier.fireTestFailure(new org.junit.runner.notification.Failure(
        getDescription(), e));
    } catch (java.lang.reflect.InvocationTargetException e) {
      notifier.fireTestFailure(new org.junit.runner.notification.Failure(
        getDescription(), e.getCause()));
    }
  }
}&lt;/pre&gt;

I will probably regret extending an internal class.</description>
		<content:encoded><![CDATA[<p>Unlike JUnit 3, in JUnit 4 it looks like you write a <code>Runner</code> that switches to the EDT for you, then add <code>@RunWith(EDTRunner.class)</code> to the test. Something like:</p>
<pre class="prettyprint">public class EDTRunner extends
    org.junit.internal.runners.TestClassRunner {
  public EDTRunner(Class klass)
        throws org.junit.internal.runners.InitializationError {
    super(klass);
  }

  @Override
  public void run(final org.junit.runner.notification.RunNotifier notifier) {
    if (javax.swing.SwingUtilities.isEventDispatchThread()) {
      super.run(notifier);
      return;
    }
    try {
      javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
          EDTRunner.super.run(notifier);
        }
      });
    } catch (InterruptedException e) {
      notifier.fireTestFailure(new org.junit.runner.notification.Failure(
        getDescription(), e));
    } catch (java.lang.reflect.InvocationTargetException e) {
      notifier.fireTestFailure(new org.junit.runner.notification.Failure(
        getDescription(), e.getCause()));
    }
  }
}</pre>
<p>I will probably regret extending an internal class.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.243 seconds -->

