1
2
3
4
5
6 package org.springframework.richclient.util;
7
8 import junit.framework.TestCase;
9
10
11
12
13
14
15
16
17
18 public class AssertTests extends TestCase {
19
20
21
22
23 public final void testRequired() {
24
25 Assert.required(new Object(), "object");
26 Assert.required(new Object(), null);
27
28 try {
29 Assert.required(null, "bogus");
30 fail("Should have thrown an IllegalArgumentException");
31 }
32 catch(IllegalArgumentException e) {
33
34 }
35
36 }
37
38
39
40
41 public final void testNoElementsNull() {
42
43 Object[] array = new Object[0];
44
45 Assert.noElementsNull(array, null);
46 Assert.noElementsNull(array, "bogusArray");
47
48 try {
49 Assert.noElementsNull(null, "bogusArray");
50 fail("Should have thrown an IllegalArgumentException");
51 }
52 catch (IllegalArgumentException e) {
53
54 }
55
56 array = new Object[1];
57
58 try {
59 Assert.noElementsNull(null, "bogusArray");
60 fail("Should have thrown an IllegalArgumentException for a non-null array with a null element");
61 }
62 catch (IllegalArgumentException e) {
63
64 }
65
66 array = new Object[] {"bogus", null};
67
68 try {
69 Assert.noElementsNull(null, "bogusArray");
70 fail("Should have thrown an IllegalArgumentException for a non-null array with a null element");
71 }
72 catch (IllegalArgumentException e) {
73
74 }
75
76 }
77
78 }