Forgot to notifyAll()! Thanks abadea.
1.1 --- a/openide.util/test/unit/src/org/openide/util/test/MockChangeListener.java Wed Apr 25 02:14:40 2007 +0000
1.2 +++ b/openide.util/test/unit/src/org/openide/util/test/MockChangeListener.java Wed Apr 25 16:15:44 2007 +0000
1.3 @@ -41,6 +41,7 @@
1.4
1.5 public synchronized void stateChanged(ChangeEvent ev) {
1.6 events.add(ev);
1.7 + notifyAll();
1.8 }
1.9
1.10 /**
2.1 --- a/openide.util/test/unit/src/org/openide/util/test/MockChangeListenerTest.java Wed Apr 25 02:14:40 2007 +0000
2.2 +++ b/openide.util/test/unit/src/org/openide/util/test/MockChangeListenerTest.java Wed Apr 25 16:15:44 2007 +0000
2.3 @@ -42,8 +42,6 @@
2.4 cs.addChangeListener(l);
2.5 }
2.6
2.7 - // XXX test expect
2.8 -
2.9 public void testBasicUsage() throws Exception {
2.10 l.assertNoEvents();
2.11 l.assertEventCount(0);
2.12 @@ -93,4 +91,28 @@
2.13 }
2.14 }
2.15
2.16 + public void testExpect() throws Exception {
2.17 + l.expectNoEvents(1000);
2.18 + cs.fireChange();
2.19 + l.expectEvent(1000);
2.20 + l.assertNoEvents();
2.21 + new Thread() {
2.22 + @Override public void run() {
2.23 + try {
2.24 + Thread.sleep(2000);
2.25 + } catch (InterruptedException x) {
2.26 + assert false;
2.27 + }
2.28 + cs.fireChange();
2.29 + }
2.30 + }.start();
2.31 + try {
2.32 + l.expectEvent(1000);
2.33 + assert false;
2.34 + } catch (AssertionFailedError e) {}
2.35 + l.expectEvent(2000);
2.36 + l.assertNoEvents();
2.37 + l.expectNoEvents(1000);
2.38 + }
2.39 +
2.40 }