title: Testng using org.fest.swing hangs randomly when click on button
body: <p>I have a testng gui test, where I am using org.fest.swing APIs. It has 3 testcases where at the end of each it tries to close a dialog. When executing, it randomly hangs at a dialog box where it should click on one of the button and later fails at an assert condition.</p>
  
  <p>Example: </p>
  
  <pre><code>DialogFixture saveChangesDialog = WindowFinder.findDialog(SAVE).using(robot);
  
  String buttonText = saveChanges ? "Yes" : "No";
  saveChangesDialog.button(JButtonMatcher.withText(buttonText)).click();
  </code></pre>
  
  <p>and assert condition is:</p>
  
  <pre><code>assertThat(ComponentVisibleQuery.isVisible(target)).isFalse();
  </code></pre>
  
  <p>It fails many of the times (not always). When executing single test it passes always. Unable to identify the reason for failure.</p>
  
  <p>Found a similar reference, but it didn't work.
  <a href="https://github.com/joel-costigliola/assertj-swing/issues/30" rel="nofollow noreferrer">https://github.com/joel-costigliola/assertj-swing/issues/30</a></p>
  
  <p>---------- EDIT 1 ----------</p>
  
  <p>On more analysis found that in same method, a thread is started to close Frame. It has single line in run() :-
  org.fest.swing.fixture.JInternalFrameFixture.close();</p>
  
  <p>After initiating this thread, main thread calls the above mentioned Dialog (given in above example).
  Later main thread calls t.join(5000)  ... to check if the thread task is completed.
  And later checks that the Frame visibility is false.</p>
  
  <pre><code>assertThat(ComponentVisibleQuery.isVisible(target)).isFalse();
  </code></pre>
  
  <p>In all fail scenarios, the thread state is WAITING and on printing stackTrace :-</p>
  
  <p>10:19:32    [testng] Thread State: WAITING
  10:19:32    [testng] StackTrace1 [sun.misc.Unsafe.park(Native Method), java.util.concurrent.locks.LockSupport.park(LockSupport.java:175), java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836), java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997), java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304), java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231), org.fest.swing.edt.GuiActionRunner.run(GuiActionRunner.java:117), org.fest.swing.edt.GuiActionRunner.execute(GuiActionRunner.java:96), org.fest.swing.driver.JInternalFrameCloseTask.close(JInternalFrameCloseTask.java:33), org.fest.swing.driver.JInternalFrameDriver.close(JInternalFrameDriver.java:339), org.fest.swing.fixture.JInternalFrameFixture.close(JInternalFrameFixture.java:150), </p>
  
  <p>So this means, that because thread is in WAITING state and stuck at some lock condition, its not able to close Frame, and so the assert condition fails.</p>
  
  <p>Updated time to 500 seconds, still its in WAITING state for failure scenarios. Unable to find why the thread is stuck in waiting state.</p>