junit3 -> junit4

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1777435 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2017-01-05 08:32:07 +00:00
parent fd47334832
commit 4b99fb8ec1
3 changed files with 85 additions and 22 deletions

View File

@ -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) {

View File

@ -442,6 +442,17 @@ public final class TestXSSFSheet extends BaseTestXSheet {
* 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 BaseTestXSheet {
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,6 +494,10 @@ public final class TestXSSFSheet extends BaseTestXSheet {
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?
@ -483,6 +510,10 @@ public final class TestXSSFSheet extends BaseTestXSheet {
// 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 BaseTestXSheet {
//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 BaseTestXSheet {
//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 BaseTestXSheet {
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 BaseTestXSheet {
) {
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 BaseTestXSheet {
) {
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 BaseTestXSheet {
) {
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());
}
/**

View File

@ -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.ChunkNotFoundException;
/**
* 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 extends TestCase {
* @throws ChunkNotFoundException
*
*/
@Test
public void testRetrieveAttachments() {
// Simple file
AttachmentChunks[] attachments = twoSimpleAttachments.getAttachmentFiles();
@ -64,6 +80,7 @@ public class TestFileWithAttachmentsRead extends TestCase {
/**
* 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 extends TestCase {
/**
* 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 extends TestCase {
/**
* Test that we can handle both PDF and MSG attachments
*/
@Test
public void testReadMsgAttachments() throws Exception {
AttachmentChunks[] attachments = pdfMsgAttachments.getAttachmentFiles();
assertEquals(2, attachments.length);