You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2017/01/05 08:32:07 UTC
svn commit: r1777435 - in /poi/trunk/src:
ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java
Author: onealj
Date: Thu Jan 5 08:32:07 2017
New Revision: 1777435
URL: http://svn.apache.org/viewvc?rev=1777435&view=rev
Log:
junit3 -> junit4
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java?rev=1777435&r1=1777434&r2=1777435&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java Thu Jan 5 08:32:07 2017
@@ -256,7 +256,8 @@ public class ColumnHelper {
if(fromCol.isSetCollapsed()) toCol.setCollapsed(fromCol.getCollapsed());
if(fromCol.isSetPhonetic()) toCol.setPhonetic(fromCol.getPhonetic());
if(fromCol.isSetOutlineLevel()) toCol.setOutlineLevel(fromCol.getOutlineLevel());
- toCol.setCollapsed(fromCol.isSetCollapsed());
+ // this is probably wrong.
+ //toCol.setCollapsed(fromCol.isSetCollapsed());
}
public void setColBestFit(long index, boolean bestFit) {
Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1777435&r1=1777434&r2=1777435&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Thu Jan 5 08:32:07 2017
@@ -442,6 +442,17 @@ public final class TestXSSFSheet extends
* completely clear in all cases what it's supposed to
* be doing... Someone who understands the goals a little
* better should really review this!
+ *
+ * Graphically, this is what we're creating:
+ *
+ * Column
+ *
+ * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ *
+ * After groupColumn(4,7)
+ * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ * +--------+ +-----------+
+ *
*/
@Test
public void setColumnGroupCollapsed() throws IOException {
@@ -451,17 +462,29 @@ public final class TestXSSFSheet extends
CTCols cols = sheet1.getCTWorksheet().getColsArray(0);
assertEquals(0, cols.sizeOfColArray());
+ // Column
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ // ++++++++++
+ //
sheet1.groupColumn( 4, 7 );
assertEquals(1, cols.sizeOfColArray());
checkColumnGroup(cols.getColArray(0), 4, 7); // false, true
+ // Column
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ // ++++++++++ +++++++++++++
+ //
sheet1.groupColumn( 9, 12 );
assertEquals(2, cols.sizeOfColArray());
checkColumnGroup(cols.getColArray(0), 4, 7); // false, true
checkColumnGroup(cols.getColArray(1), 9, 12); // false, true
+ // Column
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ // ++++++++++ +++++++++++++
+ // ++++++
sheet1.groupColumn( 10, 11 );
assertEquals(4, cols.sizeOfColArray());
@@ -471,8 +494,12 @@ public final class TestXSSFSheet extends
checkColumnGroup(cols.getColArray(3), 12, 12); // false, true
// collapse columns - 1
+ // Column
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ // ---------- +++++++++++++
+ // ++++++
sheet1.setColumnGroupCollapsed( 5, true );
-
+
// FIXME: we grew a column?
assertEquals(5, cols.sizeOfColArray());
checkColumnGroupIsCollapsed(cols.getColArray(0), 4, 7); // true, true
@@ -483,6 +510,10 @@ public final class TestXSSFSheet extends
// expand columns - 1
+ // Column
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ // ++++++++++ +++++++++++++
+ // ++++++
sheet1.setColumnGroupCollapsed( 5, false );
assertEquals(5, cols.sizeOfColArray());
@@ -494,8 +525,13 @@ public final class TestXSSFSheet extends
//collapse - 2
+ // Column
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ // ++++++++++ -------------
+ // -----
+ // can lower-level outlines be expanded if their parents are collapsed?
sheet1.setColumnGroupCollapsed( 9, true );
- // it grew again?
+ // FIXME: it grew again?
assertEquals(6, cols.sizeOfColArray());
checkColumnGroup(cols.getColArray(0), 4, 7); // false, true
checkColumnGroup(cols.getColArray(1), 8, 8, false, false);
@@ -507,11 +543,19 @@ public final class TestXSSFSheet extends
//expand - 2
+ // Column
+ // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
+ // ++++++++++ +++++++++++++
+ // ++++++
+ // do collapsed lower-level outlines get expanded if their parents are expanded?
+ // how much of this is Excel GUI behavior convenience and what is allowed
+ // per the OOXML format?
sheet1.setColumnGroupCollapsed( 9, false );
assertEquals(6, cols.sizeOfColArray());
//outline level 2: the line under ==> collapsed==True
assertEquals(2, cols.getColArray(3).getOutlineLevel());
+ assertTrue(cols.getColArray(3).getCollapsed());
assertTrue(cols.getColArray(4).isSetCollapsed());
checkColumnGroup(cols.getColArray(0), 4, 7);
@@ -546,7 +590,7 @@ public final class TestXSSFSheet extends
wb1.close();
sheet1 = wb2.getSheetAt(0);
// FIXME: forgot to reassign!
- //cols = sheet1.getCTWorksheet().getColsArray(0);
+ cols = sheet1.getCTWorksheet().getColsArray(0);
assertEquals(6, cols.sizeOfColArray());
checkColumnGroup(cols.getColArray(0), 4, 7); // false, true
@@ -590,8 +634,9 @@ public final class TestXSSFSheet extends
) {
assertEquals("from column index", fromColumnIndex, col.getMin() - 1); // 1 based
assertEquals("to column index", toColumnIndex, col.getMax() - 1); // 1 based
- assertFalse("isSetHidden", col.isSetHidden());
- assertTrue("isSetCollapsed", col.isSetCollapsed()); //not necessarily set
+ //assertFalse("isSetHidden", col.isSetHidden());
+ // group collapse state is either unset or not collapsed
+ assertFalse("collapsed", col.isSetCollapsed() && col.getCollapsed());
}
/**
* Verify that column groups were created correctly after Sheet.groupColumn
@@ -606,9 +651,8 @@ public final class TestXSSFSheet extends
) {
assertEquals("from column index", fromColumnIndex, col.getMin() - 1); // 1 based
assertEquals("to column index", toColumnIndex, col.getMax() - 1); // 1 based
- assertTrue("isSetHidden", col.isSetHidden());
- assertTrue("isSetCollapsed", col.isSetCollapsed());
- //assertTrue("getCollapsed", col.getCollapsed());
+ // assertTrue("isSetHidden", col.isSetHidden());
+ assertTrue("collapsed", col.isSetCollapsed() && col.getCollapsed());
}
/**
* Verify that column groups were created correctly after Sheet.groupColumn
@@ -623,10 +667,9 @@ public final class TestXSSFSheet extends
) {
assertEquals("from column index", fromColumnIndex, col.getMin() - 1); // 1 based
assertEquals("to column index", toColumnIndex, col.getMax() - 1); // 1 based
- assertFalse("isSetHidden", col.isSetHidden());
- assertTrue("isSetCollapsed", col.isSetCollapsed());
- //assertTrue("isSetCollapsed", !col.isSetCollapsed() || !col.getCollapsed());
- //assertFalse("getCollapsed", col.getCollapsed());
+ // assertFalse("isSetHidden", col.isSetHidden());
+ // group collapse state is either unset or not collapsed
+ assertFalse("collapsed", col.isSetCollapsed() && col.getCollapsed());
}
/**
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java?rev=1777435&r1=1777434&r2=1777435&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/TestFileWithAttachmentsRead.java Thu Jan 5 08:32:07 2017
@@ -17,9 +17,16 @@
package org.apache.poi.hsmf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
-import junit.framework.TestCase;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.apache.poi.POIDataSamples;
import org.apache.poi.hsmf.datatypes.AttachmentChunks;
@@ -28,21 +35,29 @@ import org.apache.poi.hsmf.exceptions.Ch
/**
* Tests to verify that we can read attachments from msg file
*/
-public class TestFileWithAttachmentsRead extends TestCase {
- private final MAPIMessage twoSimpleAttachments;
- private final MAPIMessage pdfMsgAttachments;
- private final MAPIMessage inlineImgMsgAttachments;
+public class TestFileWithAttachmentsRead {
+ private static MAPIMessage twoSimpleAttachments;
+ private static MAPIMessage pdfMsgAttachments;
+ private static MAPIMessage inlineImgMsgAttachments;
/**
* Initialize this test, load up the attachment_test_msg.msg mapi message.
*
* @throws Exception
*/
- public TestFileWithAttachmentsRead() throws IOException {
+ @BeforeClass
+ public static void setUp() throws IOException {
POIDataSamples samples = POIDataSamples.getHSMFInstance();
- this.twoSimpleAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_test_msg.msg"));
- this.pdfMsgAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_msg_pdf.msg"));
- this.inlineImgMsgAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_msg_inlineImg.msg"));
+ twoSimpleAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_test_msg.msg"));
+ pdfMsgAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_msg_pdf.msg"));
+ inlineImgMsgAttachments = new MAPIMessage(samples.openResourceAsStream("attachment_msg_inlineImg.msg"));
+ }
+
+ @AfterClass
+ public static void tearDown() throws IOException {
+ twoSimpleAttachments.close();
+ pdfMsgAttachments.close();
+ inlineImgMsgAttachments.close();
}
/**
@@ -51,6 +66,7 @@ public class TestFileWithAttachmentsRead
* @throws ChunkNotFoundException
*
*/
+ @Test
public void testRetrieveAttachments() {
// Simple file
AttachmentChunks[] attachments = twoSimpleAttachments.getAttachmentFiles();
@@ -64,6 +80,7 @@ public class TestFileWithAttachmentsRead
/**
* Bug 60550: Test to see if we get the correct Content-IDs of inline images`.
*/
+ @Test
public void testReadContentIDField() throws IOException {
AttachmentChunks[] attachments = inlineImgMsgAttachments.getAttachmentFiles();
@@ -95,6 +112,7 @@ public class TestFileWithAttachmentsRead
/**
* Test to see if attachments are not empty.
*/
+ @Test
public void testReadAttachments() throws IOException {
AttachmentChunks[] attachments = twoSimpleAttachments.getAttachmentFiles();
@@ -129,6 +147,7 @@ public class TestFileWithAttachmentsRead
/**
* Test that we can handle both PDF and MSG attachments
*/
+ @Test
public void testReadMsgAttachments() throws Exception {
AttachmentChunks[] attachments = pdfMsgAttachments.getAttachmentFiles();
assertEquals(2, attachments.length);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org