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
56
57
58
|
package net.java.sip.communicator.impl.protocol.irc;
import junit.framework.*;
public class ResultTest
extends TestCase
{
public void testConstruction()
{
Result<Object, Exception> result = new Result<Object, Exception>();
Assert.assertNotNull(result);
Assert.assertFalse(result.isDone());
Assert.assertNull(result.getValue());
Assert.assertNull(result.getException());
}
public void testSetDone()
{
Result<Object, Exception> result = new Result<Object, Exception>();
result.setDone();
Assert.assertTrue(result.isDone());
Assert.assertNull(result.getValue());
Assert.assertNull(result.getException());
}
public void testSetDoneWithValue()
{
Object v = new Object();
Result<Object, Exception> result = new Result<Object, Exception>();
result.setDone(v);
Assert.assertTrue(result.isDone());
Assert.assertSame(v, result.getValue());
Assert.assertNull(result.getException());
}
public void testSetDoneWithException()
{
Exception e =
new IllegalStateException("the world is going to explode");
Result<Object, Exception> result = new Result<Object, Exception>();
result.setDone(e);
Assert.assertTrue(result.isDone());
Assert.assertNull(result.getValue());
Assert.assertSame(e, result.getException());
}
public void testSetDoneWithBoth()
{
Object v = new Object();
Exception e =
new IllegalStateException("the world is going to explode");
Result<Object, Exception> result = new Result<Object, Exception>();
result.setDone(v, e);
Assert.assertTrue(result.isDone());
Assert.assertSame(v, result.getValue());
Assert.assertSame(e, result.getException());
}
}
|