eclipse warnings - raw list access

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1773905 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2016-12-13 00:30:24 +00:00
parent fae46faf29
commit 128001186b
2 changed files with 23 additions and 25 deletions

View File

@ -17,22 +17,25 @@
package org.apache.poi.poifs.property; 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.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import junit.framework.TestCase;
import org.apache.poi.poifs.storage.RawDataBlock; import org.apache.poi.poifs.storage.RawDataBlock;
import org.apache.poi.poifs.storage.RawDataUtil; import org.apache.poi.poifs.storage.RawDataUtil;
import org.junit.Test;
/** /**
* Class to test PropertyFactory functionality * Class to test PropertyFactory functionality
*
* @author Marc Johnson
*/ */
public final class TestPropertyFactory extends TestCase { public final class TestPropertyFactory {
@Test
public void testConvertToProperties() throws IOException { public void testConvertToProperties() throws IOException {
// real data from a real file! // 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++) { for (int j = 0; j < raw_data.length; j++) {
raw_data[j] = new RawDataBlock(stream); raw_data[j] = new RawDataBlock(stream);
} }
List properties = PropertyFactory.convertToProperties(raw_data); List<Property> properties = PropertyFactory.convertToProperties(raw_data);
assertEquals(64, properties.size()); assertEquals(64, properties.size());
String[] names = { String[] names = {
@ -388,8 +391,7 @@ public final class TestPropertyFactory extends TestCase {
assertTrue("Checking property " + j, assertTrue("Checking property " + j,
properties.get(j) instanceof DocumentProperty); properties.get(j) instanceof DocumentProperty);
} }
assertEquals("Checking property " + j, names[j], ((Property) properties.get(j)) assertEquals("Checking property " + j, names[j], properties.get(j).getName());
.getName());
} }
} }
} }

View File

@ -17,26 +17,25 @@
package org.apache.poi.poifs.property; 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.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; 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.common.POIFSConstants;
import org.apache.poi.poifs.storage.BlockAllocationTableReader; import org.apache.poi.poifs.storage.BlockAllocationTableReader;
import org.apache.poi.poifs.storage.HeaderBlock; import org.apache.poi.poifs.storage.HeaderBlock;
import org.apache.poi.poifs.storage.RawDataBlockList; import org.apache.poi.poifs.storage.RawDataBlockList;
import org.apache.poi.poifs.storage.RawDataUtil; import org.apache.poi.poifs.storage.RawDataUtil;
import org.junit.Test;
/** /**
* Class to test PropertyTable functionality * 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) { private static void confirmBlockEncoding(String[] expectedDataHexDumpLines, PropertyTable table) {
byte[] expectedData = RawDataUtil.decode(expectedDataHexDumpLines); 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 * the preWrite phase first), and comparing it against a real property table
* extracted from a file known to be acceptable to Excel. * extracted from a file known to be acceptable to Excel.
*/ */
@Test
public void testWriterPropertyTable() throws IOException { public void testWriterPropertyTable() throws IOException {
// create the PropertyTable // create the PropertyTable
@ -450,21 +450,17 @@ public final class TestPropertyTable extends TestCase {
assertEquals(30 * 64, table.getRoot().getSize()); assertEquals(30 * 64, table.getRoot().getSize());
int count = 0; int count = 0;
Property child = null; Property child = null;
Iterator iter = table.getRoot().getChildren(); for (Property p : table.getRoot()) {
child = p;
while (iter.hasNext()) {
child = (Property) iter.next();
++count; ++count;
} }
if (child == null) {
throw new AssertionFailedError("no children found"); assertNotNull("no children found", child);
}
assertEquals(1, count); assertEquals(1, count);
assertTrue(child.isDirectory()); assertTrue(child.isDirectory());
iter = ((DirectoryProperty) child).getChildren();
count = 0; count = 0;
while (iter.hasNext()) { for (Property p : (DirectoryProperty) child) {
iter.next(); child = p;
++count; ++count;
} }
assertEquals(35, count); assertEquals(35, count);