@@ -0,0 +1,2145 @@
+/*%0A  This file is licensed to You under the Apache License, Version 2.0%0A  (the %22License%22); you may not use this file except in compliance with%0A  the License.  You may obtain a copy of the License at%0A%0A  http://www.apache.org/licenses/LICENSE-2.0%0A%0A  Unless required by applicable law or agreed to in writing, software%0A  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A  See the License for the specific language governing permissions and%0A  limitations under the License.%0A*/%0Apackage org.xmlunit.util;%0A%0Aimport java.util.Arrays;%0Aimport org.w3c.dom.Node;%0Aimport org.w3c.dom.NodeList;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0Aimport org.mockito.MockitoAnnotations;%0A%0Aimport static org.mockito.Mockito.when;%0A%0Apublic class IterableNodeListTest %7B%0A%0A    @Mock%0A    private NodeList list;%0A%0A    @Mock%0A    private Node node1;%0A%0A    @Mock%0A    private Node node2;%0A%0A    private IterableNodeList il;%0A%0A    @Before%0A    public void setupMocks() %7B%0A        MockitoAnnotations.initMocks(this);%0A        when(list.getLength()).thenReturn(2);%0A        when(list.item(0)).thenReturn(node1);%0A        when(list.item(1)).thenReturn(node2);%0A        il = new IterableNodeList(list);%0A    %7D%0A%0A    @Test(expected=UnsupportedOperationException.class)%0A    public void cantRemoveFromIterator() %7B%0A        il.iterator().remove();%0A    %7D%0A%0A    @Test%0A    public void iteratesOverNodes() %7B%0A        int i = 0;%0A        for (Node n : il) %7B%0A            switch (i) %7B%0A            case 0:%0A                Assert.assertSame(node1, n);%0A                break;%0A            case 1:%0A                Assert.assertSame(node2, n);%0A                break;%0A            default:%0A                Assert.fail(%22there shouldn't be more than 2 nodes%22);%0A                break;%0A            %7D%0A            i++;%0A        %7D%0A        Assert.assertEquals(2, i);%0A    %7D%0A%0A    @Test%0A    public void asListCreatesExpectedList() %7B%0A        Assert.assertArrayEquals(new Node%5B%5D %7B node1, node2 %7D,%0A                                 IterableNodeList.asList(list).toArray(new Node%5B2%5D));%0A    %7D%0A%7D%0A

test for IterableNodeList