My favorites
▼
|
Sign in
jconch
Java Concurrency Handling: Safe Concurrency Tools
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
eg
/
eg
/
jconch
/
testing
/
TestCoordinatorExamples.groovy
r139
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import java.util.ArrayList
import java.util.List
import java.util.concurrent.TimeUnit
import javax.swing.SwingUtilities
/**
* Examples of how to use the TestCoordinator object.
*/
import jconch.testing.TestCoordinator
TestCoordinator coord = new TestCoordinator()
MyComponent component = new MyComponent()
component.addActionListener({ ActionEvent e ->
assert e.source != null
assert "click" == e.actionCommand
coord.finishTest()
} as ActionListener)
component.click()
coord.delayTestFinish()
component.click()
coord.delayTestFinish(1000)
component.click()
coord.delayTestFinish(1, TimeUnit.SECONDS)
println 'Success'
/**
* Mock component to spawn off click events on a 2nd thread.
*/
class MyComponent {
private def listeners = []
public void addActionListener(ActionListener listener) {
listeners << listener
}
public void click() {
SwingUtilities.invokeLater {
listeners.each { listener ->
def event = new ActionEvent(new Object(), 24987234, "click");
listener.actionPerformed(event);
}
}
}
}
Show details
Hide details
Change log
r134
by HamletDRC on Dec 18, 2009
Diff
Added TestCoordinator for GWT style asynchronous test creation
Go to:
...g/TestCoordinatorExamples.groovy
...nch/testing/TestCoordinator.java
...testing/TestCoordinatorTest.java
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 1276 bytes, 55 lines
View raw file
Powered by
Google Project Hosting