* under the License.
*/
-import org.dom4j.Element;
-
import java.io.File;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
+import org.dom4j.Element;
+
/**
* XMLReaderTest
*
public class XMLReaderTest
extends AbstractArchivaXmlTestCase
{
- private void assertElementTexts( List elementList, String[] expectedTexts )
+ private void assertElementTexts( List<Element> elementList, String[] expectedTexts )
{
assertEquals( "Element List Size", expectedTexts.length, elementList.size() );
- List texts = new ArrayList();
- for ( Iterator iter = elementList.iterator(); iter.hasNext(); )
+ List<String> texts = new ArrayList<String>();
+ for ( Element element : elementList )
{
- Element element = (Element) iter.next();
texts.add( element.getTextTrim() );
}
File xmlFile = getExampleXml( "no-prolog-basic.xml" );
XMLReader reader = new XMLReader( "basic", xmlFile );
- List fruits = reader.getElementList( "//basic/fruits/fruit" );
+ List<Element> fruits = reader.getElementList( "//basic/fruits/fruit" );
assertElementTexts( fruits, new String[] { "apple", "cherry", "pear", "peach" } );
}
File xmlFile = getExampleXml( "no-prolog-with-entities.xml" );
XMLReader reader = new XMLReader( "basic", xmlFile );
- List names = reader.getElementList( "//basic/names/name" );
+ List<Element> names = reader.getElementList( "//basic/names/name" );
assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
}
File xmlFile = getExampleXml( "no-prolog-with-utf8.xml" );
XMLReader reader = new XMLReader( "basic", xmlFile );
- List names = reader.getElementList( "//basic/names/name" );
+ List<Element> names = reader.getElementList( "//basic/names/name" );
assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
}
File xmlFile = getExampleXml( "prolog-with-utf8.xml" );
XMLReader reader = new XMLReader( "basic", xmlFile );
- List names = reader.getElementList( "//basic/names/name" );
+ List<Element> names = reader.getElementList( "//basic/names/name" );
assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
}