1 package org.apidesign.deadlock;
3 import java.awt.Dimension;
4 import java.util.logging.Level;
5 import java.util.logging.Logger;
6 import javax.swing.JFrame;
7 import javax.swing.JLabel;
8 import javax.swing.JPanel;
9 import javax.swing.SwingUtilities;
10 import org.junit.Test;
11 import org.netbeans.junit.Log;
12 import org.netbeans.junit.NbTestCase;
13 import static org.junit.Assert.*;
15 // BEGIN: deadlock.test
16 public class DeadlockTest extends NbTestCase {
17 static final Logger LOG = Logger.getLogger(DeadlockTest.class.getName());
19 public DeadlockTest(String n) {
24 protected int timeOut() {
29 public static class StrangePanel extends LabelProvider {
31 public Dimension getPreferredSize () {
34 JLabel sampleLabel = createLabel();
35 return sampleLabel.getPreferredSize();
36 } catch (InterruptedException ex) {
37 Logger.getLogger(DeadlockTest.class.getName()).log(Level.SEVERE, null, ex);
38 return super.getPreferredSize();
46 public void testCreateLabel() throws Exception {
47 final LabelProvider instance = new StrangePanel();
49 class R implements Runnable {
51 JFrame f = new JFrame();
58 R showFrame = new R();
59 SwingUtilities.invokeLater(showFrame);
62 JLabel result = instance.createLabel();
63 assertNotNull("Creates the result", result);