blob: b65ceed1ef24b8f4b227f37643fad596a25e8150 (
plain)
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
|
package com.orbekk.util;
import static org.junit.Assert.*;
import org.junit.Test;
public class DelayedOperationTest {
@Test public void initialOperationStatus() {
DelayedOperation operation = new DelayedOperation();
assertFalse(operation.isDone());
}
@Test public void completedOperationReturns() {
DelayedOperation operation = new DelayedOperation();
operation.complete(DelayedOperation.Status.createOk());
assertTrue(operation.isDone());
assertEquals(DelayedOperation.Status.createOk(), operation.getStatus());
}
@Test public void concurrentTest() throws Exception {
final DelayedOperation operation = new DelayedOperation();
Thread t = new Thread(new Runnable() {
@Override
public void run() {
operation.waitFor();
}
});
t.start();
operation.complete(DelayedOperation.Status.createError("Fail."));
t.join();
assertTrue(operation.isDone());
}
}
|