Skip to content

Commit 9c03345

Browse files
Latest updates
1 parent 3044191 commit 9c03345

File tree

7 files changed

+661
-0
lines changed

7 files changed

+661
-0
lines changed

UNLICENSE

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* This is free and unencumbered software released into the public domain.
2+
*
3+
* Anyone is free to copy, modify, publish, use, compile, sell, or
4+
* distribute this software, either in source code form or as a compiled
5+
* binary, for any purpose, commercial or non-commercial, and by any
6+
* means.
7+
*
8+
* In jurisdictions that recognize copyright laws, the author or authors
9+
* of this software dedicate any and all copyright interest in the
10+
* software to the public domain. We make this dedication for the benefit
11+
* of the public at large and to the detriment of our heirs and
12+
* successors. We intend this dedication to be an overt act of
13+
* relinquishment in perpetuity of all present and future rights to this
14+
* software under copyright law.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
* OTHER DEALINGS IN THE SOFTWARE.
23+
*
24+
* For more information, please refer to <http://unlicense.org/>
25+
*/

src/main/site/apt/index.apt

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
------
2+
Overview
3+
------
4+
Jeff Rodriguez
5+
------
6+
------
7+
8+
XML Wrapper for Java
9+
10+
The XML Wrapper library is a set of lightweight wrapper classes to make
11+
working with XML and the DOM in Java easier.
12+
13+
14+
Maven 2
15+
16+
+-------------------------------------------------------------------------------
17+
<dependencies>
18+
...
19+
<dependency>
20+
<groupId>com.jeffrodriguez</groupId>
21+
<artifactId>xmlwrapper</artifactId>
22+
<version>...</version>
23+
</dependency>
24+
...
25+
</dependencies>
26+
+-------------------------------------------------------------------------------

src/main/site/site.xml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
<project xmlns="http://maven.apache.org/DECORATION/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="
5+
http://maven.apache.org/DECORATION/1.0.0
6+
http://maven.apache.org/xsd/decoration-1.0.0.xsd"
7+
name="JavaScript Object Graph">
8+
<bannerLeft>
9+
<name>XML Wrapper for Java</name>
10+
</bannerLeft>
11+
<body>
12+
13+
<menu ref="reports"/>
14+
</body>
15+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* This is free and unencumbered software released into the public domain.
3+
*
4+
* Anyone is free to copy, modify, publish, use, compile, sell, or
5+
* distribute this software, either in source code form or as a compiled
6+
* binary, for any purpose, commercial or non-commercial, and by any
7+
* means.
8+
*
9+
* In jurisdictions that recognize copyright laws, the author or authors
10+
* of this software dedicate any and all copyright interest in the
11+
* software to the public domain. We make this dedication for the benefit
12+
* of the public at large and to the detriment of our heirs and
13+
* successors. We intend this dedication to be an overt act of
14+
* relinquishment in perpetuity of all present and future rights to this
15+
* software under copyright law.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
* OTHER DEALINGS IN THE SOFTWARE.
24+
*
25+
* For more information, please refer to <http://unlicense.org/>
26+
*/
27+
package com.jeffrodriguez.xmlwrapper;
28+
29+
import org.w3c.dom.Element;
30+
import org.junit.Before;
31+
import org.junit.Test;
32+
import static org.junit.Assert.*;
33+
34+
/**
35+
* @author <a href="mailto:[email protected]">Jeff Rodriguez</a>
36+
*/
37+
public class NodeListIteratorTest {
38+
39+
private XML xml;
40+
41+
private NodeListIterator<Element> instance;
42+
43+
@Before
44+
public void setUp() {
45+
xml = XML.create("foo");
46+
47+
xml.getRoot()
48+
.addChild("baz")
49+
.setAttribute("qux", "true");
50+
51+
xml.getRoot()
52+
.addChild("baz")
53+
.setAttribute("qux", "false");
54+
55+
instance = new NodeListIterator<Element>(xml.getDocument().getElementsByTagName("baz"));
56+
}
57+
58+
/**
59+
* Test of hasNext method, of class NodeListIterator.
60+
*/
61+
@Test
62+
public void testHasNext() {
63+
System.out.println("hasNext");
64+
65+
assertTrue(instance.hasNext());
66+
instance.next();
67+
instance.next();
68+
assertFalse(instance.hasNext());
69+
70+
}
71+
72+
/**
73+
* Test of next method, of class NodeListIterator.
74+
*/
75+
@Test
76+
public void testNext() {
77+
System.out.println("next");
78+
79+
assertEquals(xml.getDocument().getElementsByTagName("baz").item(0), instance.next());
80+
assertEquals(xml.getDocument().getElementsByTagName("baz").item(1), instance.next());
81+
}
82+
83+
/**
84+
* Test of remove method, of class NodeListIterator.
85+
*/
86+
@Test(expected=UnsupportedOperationException.class)
87+
public void testRemove() {
88+
System.out.println("remove");
89+
instance.remove();
90+
}
91+
92+
/**
93+
* Test of toIterable method, of class NodeListIterator.
94+
*/
95+
@Test
96+
public void testToIterable() {
97+
System.out.println("toIterable");
98+
99+
Iterable<Element> iterable = instance.toIterable();
100+
assertNotNull(iterable);
101+
assertEquals(instance, iterable.iterator());
102+
}
103+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* This is free and unencumbered software released into the public domain.
3+
*
4+
* Anyone is free to copy, modify, publish, use, compile, sell, or
5+
* distribute this software, either in source code form or as a compiled
6+
* binary, for any purpose, commercial or non-commercial, and by any
7+
* means.
8+
*
9+
* In jurisdictions that recognize copyright laws, the author or authors
10+
* of this software dedicate any and all copyright interest in the
11+
* software to the public domain. We make this dedication for the benefit
12+
* of the public at large and to the detriment of our heirs and
13+
* successors. We intend this dedication to be an overt act of
14+
* relinquishment in perpetuity of all present and future rights to this
15+
* software under copyright law.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
* OTHER DEALINGS IN THE SOFTWARE.
24+
*
25+
* For more information, please refer to <http://unlicense.org/>
26+
*/
27+
package com.jeffrodriguez.xmlwrapper;
28+
29+
import org.junit.Before;
30+
import org.junit.Test;
31+
import static org.junit.Assert.*;
32+
33+
/**
34+
* @author <a href="mailto:[email protected]">Jeff Rodriguez</a>
35+
*/
36+
public class XMLElementIteratorTest {
37+
38+
private XML xml;
39+
40+
private XMLElementIterator instance;
41+
42+
@Before
43+
public void setUp() {
44+
xml = XML.create("foo");
45+
46+
xml.getRoot()
47+
.addChild("baz")
48+
.setAttribute("qux", "true");
49+
50+
xml.getRoot()
51+
.addChild("baz")
52+
.setAttribute("qux", "false");
53+
54+
instance = (XMLElementIterator) xml.getRoot().getChildren("baz").iterator();
55+
}
56+
57+
/**
58+
* Test of hasNext method, of class XMLElementIterator.
59+
*/
60+
@Test
61+
public void testHasNext() {
62+
System.out.println("hasNext");
63+
64+
assertTrue(instance.hasNext());
65+
instance.next();
66+
assertTrue(instance.hasNext());
67+
instance.next();
68+
assertFalse(instance.hasNext());
69+
}
70+
71+
/**
72+
* Test of next method, of class XMLElementIterator.
73+
*/
74+
@Test
75+
public void testNext() {
76+
assertEquals(xml.getDocument().getElementsByTagName("baz").item(0), instance.next().getElement());
77+
assertEquals(xml.getDocument().getElementsByTagName("baz").item(1), instance.next().getElement());
78+
}
79+
80+
/**
81+
* Test of remove method, of class XMLElementIterator.
82+
*/
83+
@Test(expected=UnsupportedOperationException.class)
84+
public void testRemove() {
85+
System.out.println("remove");
86+
instance.remove();
87+
}
88+
89+
/**
90+
* Test of toIterable method, of class XMLElementIterator.
91+
*/
92+
@Test
93+
public void testToIterable() {
94+
System.out.println("toIterable");
95+
96+
Iterable<XMLElement> iterable = instance.toIterable();
97+
assertNotNull(iterable);
98+
assertEquals(instance, iterable.iterator());
99+
}
100+
}

0 commit comments

Comments
 (0)