1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.jxpath.ri.model;
18
19 import java.util.Collections;
20
21 import org.apache.commons.jxpath.JXPathContext;
22 import org.apache.commons.jxpath.JXPathTestCase;
23
24
25
26
27
28
29 public class EmptyCollectionTest extends JXPathTestCase {
30 public static class HasChild {
31 private Object child;
32
33
34
35
36 public HasChild(Object child) {
37 this.child = child;
38 }
39
40 public Object getChild() {
41 return child;
42 }
43 }
44
45 public void testEmptyList() {
46 assertXPathPointerIterator(JXPathContext.newContext(Collections.EMPTY_LIST), "/*",
47 Collections.EMPTY_LIST);
48 }
49
50 public void testEmptyArray() {
51 assertXPathPointerIterator(JXPathContext.newContext(new Object[0]), "/*", list());
52 }
53
54 public void testEmptySet() {
55 assertXPathPointerIterator(JXPathContext.newContext(Collections.EMPTY_SET), "/*",
56 Collections.EMPTY_SET);
57 }
58
59 public void testEmptyChildList() {
60 assertXPathPointerIterator(JXPathContext.newContext(new HasChild(Collections.EMPTY_LIST)),
61 "/child/*", Collections.EMPTY_LIST);
62 }
63
64 public void testEmptyChildArray() {
65 assertXPathPointerIterator(JXPathContext.newContext(new HasChild(new Object[0])),
66 "/child/*", list());
67 }
68
69 public void testEmptyChildSet() {
70 assertXPathPointerIterator(JXPathContext.newContext(new HasChild(Collections.EMPTY_SET)),
71 "/child/*", Collections.EMPTY_SET);
72 }
73 }