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!
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 = {
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());
}
}
}
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);
* 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
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);