-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCallbackTest.java
More file actions
42 lines (34 loc) · 1.15 KB
/
CallbackTest.java
File metadata and controls
42 lines (34 loc) · 1.15 KB
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
package callback;
import org.junit.Test;
/**
* @Title: CallbackTest.java
*
* @Package callback
*
* @Description: Add a field as a counter of people go to bathroom. Add Unit
* * test checks that the field is being incremented.
*
* @author Jiajie
*
* @date 2020/11/28
*/
public class CallbackTest {
private Long callingCount = Long.valueOf(0);
/**
* @Description: Test the callback
*
*/
@Test
public void test() {
Callback callback = () -> callingCount++;
goToTheBathroom task = new goToTheBathroom();
System.out.println("Initial calling count of 0");
System.out.println("CallbackTest:getInstance:("+this.hashCode()+"): calling count = " + callingCount.toString());
System.out.println("\nCallback called once");
task.executeWith(callback);
System.out.println("CallbackTest:getInstance:("+this.hashCode()+"): calling count = " + callingCount.toString());
System.out.println("\nCallback called twice");
task.executeWith(callback);
System.out.println("CallbackTest:getInstance:("+this.hashCode()+"): calling count = " + callingCount.toString());
}
}