]> source.dussan.org Git - poi.git/commitdiff
eclipse warnings - raw list access
authorAndreas Beeker <kiwiwings@apache.org>
Tue, 13 Dec 2016 00:30:24 +0000 (00:30 +0000)
committerAndreas Beeker <kiwiwings@apache.org>
Tue, 13 Dec 2016 00:30:24 +0000 (00:30 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1773905 13f79535-47bb-0310-9956-ffa450edef68

src/testcases/org/apache/poi/poifs/property/TestPropertyFactory.java
src/testcases/org/apache/poi/poifs/property/TestPropertyTable.java

index e6d2c656a6c5307d9a67d536f3199717842a90ba..36287129843f77f69f396bbe0ed499b54c00c2f8 100644 (file)
 
 package org.apache.poi.poifs.property;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.apache.poi.poifs.storage.RawDataBlock;
 import org.apache.poi.poifs.storage.RawDataUtil;
+import org.junit.Test;
 
 /**
  * Class to test PropertyFactory functionality
- *
- * @author Marc Johnson
  */
-public final class TestPropertyFactory extends TestCase {
+public final class TestPropertyFactory {
 
+    @Test
     public void testConvertToProperties() throws IOException {
 
                // real data from a real file!
@@ -302,7 +305,7 @@ public final class TestPropertyFactory extends TestCase {
                for (int j = 0; j < raw_data.length; j++) {
                        raw_data[j] = new RawDataBlock(stream);
                }
-               List properties = PropertyFactory.convertToProperties(raw_data);
+               List<Property> properties = PropertyFactory.convertToProperties(raw_data);
 
                assertEquals(64, properties.size());
                String[] names = {
@@ -388,8 +391,7 @@ public final class TestPropertyFactory extends TestCase {
                                        assertTrue("Checking property " + j,
                                                        properties.get(j) instanceof DocumentProperty);
                                }
-                               assertEquals("Checking property " + j, names[j], ((Property) properties.get(j))
-                                               .getName());
+                               assertEquals("Checking property " + j, names[j], properties.get(j).getName());
                        }
                }
        }
index 52e4aafc198c1e1854b48fc95d5afc2265d4f9bb..3950ce07e2cf83243089610b9728c1f6b6406812 100644 (file)
 
 package org.apache.poi.poifs.property;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.util.Iterator;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
 
 import org.apache.poi.poifs.common.POIFSConstants;
 import org.apache.poi.poifs.storage.BlockAllocationTableReader;
 import org.apache.poi.poifs.storage.HeaderBlock;
 import org.apache.poi.poifs.storage.RawDataBlockList;
 import org.apache.poi.poifs.storage.RawDataUtil;
+import org.junit.Test;
 
 /**
  * Class to test PropertyTable functionality
- *
- * @author Marc Johnson
  */
-public final class TestPropertyTable extends TestCase {
+public final class TestPropertyTable {
 
        private static void confirmBlockEncoding(String[] expectedDataHexDumpLines, PropertyTable table) {
                byte[] expectedData = RawDataUtil.decode(expectedDataHexDumpLines);
@@ -68,6 +67,7 @@ public final class TestPropertyTable extends TestCase {
         * the preWrite phase first), and comparing it against a real property table
         * extracted from a file known to be acceptable to Excel.
         */
+       @Test
        public void testWriterPropertyTable() throws IOException {
 
                // create the PropertyTable
@@ -450,21 +450,17 @@ public final class TestPropertyTable extends TestCase {
                assertEquals(30 * 64, table.getRoot().getSize());
                int count = 0;
                Property child = null;
-               Iterator iter = table.getRoot().getChildren();
-
-               while (iter.hasNext()) {
-                       child = (Property) iter.next();
+               for (Property p : table.getRoot()) {
+                       child = p;
                        ++count;
                }
-               if (child == null) {
-                       throw new AssertionFailedError("no children found");
-               }
+               
+               assertNotNull("no children found", child);
                assertEquals(1, count);
                assertTrue(child.isDirectory());
-               iter = ((DirectoryProperty) child).getChildren();
                count = 0;
-               while (iter.hasNext()) {
-                       iter.next();
+               for (Property p : (DirectoryProperty) child) {
+                   child = p;
                        ++count;
                }
                assertEquals(35, count);