mirror of https://github.com/apache/poi.git
Fix some IntelliJ and JavaDoc warnings and avoid code-duplication and duplicated test-methods
Adjust tests slighlty, close resources git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1814289 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3e1ee0afeb
commit
b7f7ff71b4
|
@ -536,7 +536,7 @@ public final class NameRecord extends ContinuableRecord {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append("[NAME]\n");
|
sb.append("[NAME]\n");
|
||||||
sb.append(" .option flags = ").append(HexDump.shortToHex(field_1_option_flag)).append("\n");
|
sb.append(" .option flags = ").append(HexDump.shortToHex(field_1_option_flag)).append("\n");
|
||||||
|
@ -553,7 +553,7 @@ public final class NameRecord extends ContinuableRecord {
|
||||||
Ptg[] ptgs = field_13_name_definition.getTokens();
|
Ptg[] ptgs = field_13_name_definition.getTokens();
|
||||||
sb.append(" .Formula (nTokens=").append(ptgs.length).append("):") .append("\n");
|
sb.append(" .Formula (nTokens=").append(ptgs.length).append("):") .append("\n");
|
||||||
for (Ptg ptg : ptgs) {
|
for (Ptg ptg : ptgs) {
|
||||||
sb.append(" " + ptg).append(ptg.getRVAType()).append("\n");
|
sb.append(" ").append(ptg).append(ptg.getRVAType()).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(" .Menu text = ").append(field_14_custom_menu_text).append("\n");
|
sb.append(" .Menu text = ").append(field_14_custom_menu_text).append("\n");
|
||||||
|
|
|
@ -29,7 +29,6 @@ import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.poi.POIXMLDocumentPart;
|
import org.apache.poi.POIXMLDocumentPart;
|
||||||
import org.apache.poi.POIXMLDocumentPart.RelationPart;
|
|
||||||
import org.apache.poi.openxml4j.opc.PackagePart;
|
import org.apache.poi.openxml4j.opc.PackagePart;
|
||||||
import org.apache.poi.ss.SpreadsheetVersion;
|
import org.apache.poi.ss.SpreadsheetVersion;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
@ -80,8 +79,8 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param part
|
* @param part The part used to initialize the table
|
||||||
* @throws IOException
|
* @throws IOException If reading data from the part fails.
|
||||||
* @since POI 3.14-Beta1
|
* @since POI 3.14-Beta1
|
||||||
*/
|
*/
|
||||||
public XSSFTable(PackagePart part) throws IOException {
|
public XSSFTable(PackagePart part) throws IOException {
|
||||||
|
@ -90,9 +89,9 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read table XML
|
* Read table XML from an {@link InputStream}
|
||||||
* @param is
|
* @param is The stream which provides the XML data for the table.
|
||||||
* @throws IOException
|
* @throws IOException If reading from the stream fails
|
||||||
*/
|
*/
|
||||||
public void readFrom(InputStream is) throws IOException {
|
public void readFrom(InputStream is) throws IOException {
|
||||||
try {
|
try {
|
||||||
|
@ -111,9 +110,9 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* write table XML to stream
|
* write table XML to an {@link OutputStream}
|
||||||
* @param out
|
* @param out The stream to write the XML data to
|
||||||
* @throws IOException
|
* @throws IOException If writing to the stream fails.
|
||||||
*/
|
*/
|
||||||
public void writeTo(OutputStream out) throws IOException {
|
public void writeTo(OutputStream out) throws IOException {
|
||||||
updateHeaders();
|
updateHeaders();
|
||||||
|
@ -265,7 +264,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the name of the Table
|
* Changes the name of the Table
|
||||||
* @param newName
|
* @param newName The name of the table.
|
||||||
*/
|
*/
|
||||||
public void setName(String newName) {
|
public void setName(String newName) {
|
||||||
if (newName == null) {
|
if (newName == null) {
|
||||||
|
@ -290,7 +289,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the name of the Table
|
* Changes the name of the Table
|
||||||
* @param newStyleName
|
* @param newStyleName The name of the style.
|
||||||
* @since 3.17 beta 1
|
* @since 3.17 beta 1
|
||||||
*/
|
*/
|
||||||
public void setStyleName(String newStyleName) {
|
public void setStyleName(String newStyleName) {
|
||||||
|
@ -431,7 +430,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
* The next call to {@link #getStartCellReference()} and
|
* The next call to {@link #getStartCellReference()} and
|
||||||
* {@link #getEndCellReference()} will synchronize the
|
* {@link #getEndCellReference()} will synchronize the
|
||||||
* cell references with the underlying <code>CTTable</code>.
|
* cell references with the underlying <code>CTTable</code>.
|
||||||
* Thus, {@link #updateReferences()} is inexpensive.
|
* Thus this method is inexpensive.
|
||||||
*
|
*
|
||||||
* @since POI 3.15 beta 3
|
* @since POI 3.15 beta 3
|
||||||
*/
|
*/
|
||||||
|
@ -466,7 +465,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
* "Found unreadable content" message on startup.
|
* "Found unreadable content" message on startup.
|
||||||
*
|
*
|
||||||
* If calling both {@link #updateReferences()} and
|
* If calling both {@link #updateReferences()} and
|
||||||
* {@link #updateHeaders()}, {@link #updateReferences()}
|
* this method, {@link #updateReferences()}
|
||||||
* should be called first.
|
* should be called first.
|
||||||
*
|
*
|
||||||
* Note that a Table <em>must</em> have a header. To reproduce
|
* Note that a Table <em>must</em> have a header. To reproduce
|
||||||
|
@ -545,7 +544,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
/**
|
/**
|
||||||
* Note: This is misleading. The Spec indicates this is true if the totals row
|
* Note: This is misleading. The Spec indicates this is true if the totals row
|
||||||
* has <b><i>ever</i></b> been shown, not whether or not it is currently displayed.
|
* has <b><i>ever</i></b> been shown, not whether or not it is currently displayed.
|
||||||
* Use {@link #getTotalsRowCount()} > 0 to decide whether or not the totals row is visible.
|
* Use {@link #getTotalsRowCount()} > 0 to decide whether or not the totals row is visible.
|
||||||
* @since 3.15 beta 2
|
* @since 3.15 beta 2
|
||||||
* @see #getTotalsRowCount()
|
* @see #getTotalsRowCount()
|
||||||
*/
|
*/
|
||||||
|
@ -555,7 +554,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 0 for no totals rows, 1 for totals row shown.
|
* @return 0 for no totals rows, 1 for totals row shown.
|
||||||
* Values > 1 are not currently used by Excel up through 2016, and the OOXML spec
|
* Values > 1 are not currently used by Excel up through 2016, and the OOXML spec
|
||||||
* doesn't define how they would be implemented.
|
* doesn't define how they would be implemented.
|
||||||
* @since 3.17 beta 1
|
* @since 3.17 beta 1
|
||||||
*/
|
*/
|
||||||
|
@ -565,7 +564,7 @@ public class XSSFTable extends POIXMLDocumentPart implements Table {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 0 for no header rows, 1 for table headers shown.
|
* @return 0 for no header rows, 1 for table headers shown.
|
||||||
* Values > 1 might be used by Excel for pivot tables?
|
* Values > 1 might be used by Excel for pivot tables?
|
||||||
* @since 3.17 beta 1
|
* @since 3.17 beta 1
|
||||||
*/
|
*/
|
||||||
public int getHeaderRowCount() {
|
public int getHeaderRowCount() {
|
||||||
|
|
|
@ -285,8 +285,8 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
||||||
* Returns the bullet size that is to be used within a paragraph.
|
* Returns the bullet size that is to be used within a paragraph.
|
||||||
* This may be specified in two different ways, percentage spacing and font point spacing:
|
* This may be specified in two different ways, percentage spacing and font point spacing:
|
||||||
* <p>
|
* <p>
|
||||||
* If bulletSize >= 0, then bulletSize is a percentage of the font size.
|
* If bulletSize >= 0, then bulletSize is a percentage of the font size.
|
||||||
* If bulletSize < 0, then it specifies the size in points
|
* If bulletSize < 0, then it specifies the size in points
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return the bullet size
|
* @return the bullet size
|
||||||
|
@ -313,8 +313,8 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
||||||
* Sets the bullet size that is to be used within a paragraph.
|
* Sets the bullet size that is to be used within a paragraph.
|
||||||
* This may be specified in two different ways, percentage spacing and font point spacing:
|
* This may be specified in two different ways, percentage spacing and font point spacing:
|
||||||
* <p>
|
* <p>
|
||||||
* If bulletSize >= 0, then bulletSize is a percentage of the font size.
|
* If bulletSize >= 0, then bulletSize is a percentage of the font size.
|
||||||
* If bulletSize < 0, then it specifies the size in points
|
* If bulletSize < 0, then it specifies the size in points
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public void setBulletFontSize(double bulletSize){
|
public void setBulletFontSize(double bulletSize){
|
||||||
|
@ -497,8 +497,8 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
||||||
* This element specifies the vertical line spacing that is to be used within a paragraph.
|
* This element specifies the vertical line spacing that is to be used within a paragraph.
|
||||||
* This may be specified in two different ways, percentage spacing and font point spacing:
|
* This may be specified in two different ways, percentage spacing and font point spacing:
|
||||||
* <p>
|
* <p>
|
||||||
* If linespacing >= 0, then linespacing is a percentage of normal line height
|
* If linespacing >= 0, then linespacing is a percentage of normal line height
|
||||||
* If linespacing < 0, the absolute value of linespacing is the spacing in points
|
* If linespacing < 0, the absolute value of linespacing is the spacing in points
|
||||||
* </p>
|
* </p>
|
||||||
* Examples:
|
* Examples:
|
||||||
* <pre><code>
|
* <pre><code>
|
||||||
|
@ -526,8 +526,8 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
||||||
* Returns the vertical line spacing that is to be used within a paragraph.
|
* Returns the vertical line spacing that is to be used within a paragraph.
|
||||||
* This may be specified in two different ways, percentage spacing and font point spacing:
|
* This may be specified in two different ways, percentage spacing and font point spacing:
|
||||||
* <p>
|
* <p>
|
||||||
* If linespacing >= 0, then linespacing is a percentage of normal line height.
|
* If linespacing >= 0, then linespacing is a percentage of normal line height.
|
||||||
* If linespacing < 0, the absolute value of linespacing is the spacing in points
|
* If linespacing < 0, the absolute value of linespacing is the spacing in points
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return the vertical line spacing.
|
* @return the vertical line spacing.
|
||||||
|
@ -564,8 +564,8 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
||||||
* Set the amount of vertical white space that will be present before the paragraph.
|
* Set the amount of vertical white space that will be present before the paragraph.
|
||||||
* This space is specified in either percentage or points:
|
* This space is specified in either percentage or points:
|
||||||
* <p>
|
* <p>
|
||||||
* If spaceBefore >= 0, then space is a percentage of normal line height.
|
* If spaceBefore >= 0, then space is a percentage of normal line height.
|
||||||
* If spaceBefore < 0, the absolute value of linespacing is the spacing in points
|
* If spaceBefore < 0, the absolute value of linespacing is the spacing in points
|
||||||
* </p>
|
* </p>
|
||||||
* Examples:
|
* Examples:
|
||||||
* <pre><code>
|
* <pre><code>
|
||||||
|
@ -591,8 +591,8 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
||||||
* The amount of vertical white space before the paragraph
|
* The amount of vertical white space before the paragraph
|
||||||
* This may be specified in two different ways, percentage spacing and font point spacing:
|
* This may be specified in two different ways, percentage spacing and font point spacing:
|
||||||
* <p>
|
* <p>
|
||||||
* If spaceBefore >= 0, then space is a percentage of normal line height.
|
* If spaceBefore >= 0, then space is a percentage of normal line height.
|
||||||
* If spaceBefore < 0, the absolute value of linespacing is the spacing in points
|
* If spaceBefore < 0, the absolute value of linespacing is the spacing in points
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return the vertical white space before the paragraph
|
* @return the vertical white space before the paragraph
|
||||||
|
@ -619,8 +619,8 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
||||||
* Set the amount of vertical white space that will be present after the paragraph.
|
* Set the amount of vertical white space that will be present after the paragraph.
|
||||||
* This space is specified in either percentage or points:
|
* This space is specified in either percentage or points:
|
||||||
* <p>
|
* <p>
|
||||||
* If spaceAfter >= 0, then space is a percentage of normal line height.
|
* If spaceAfter >= 0, then space is a percentage of normal line height.
|
||||||
* If spaceAfter < 0, the absolute value of linespacing is the spacing in points
|
* If spaceAfter < 0, the absolute value of linespacing is the spacing in points
|
||||||
* </p>
|
* </p>
|
||||||
* Examples:
|
* Examples:
|
||||||
* <pre><code>
|
* <pre><code>
|
||||||
|
@ -646,8 +646,8 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
||||||
* The amount of vertical white space after the paragraph
|
* The amount of vertical white space after the paragraph
|
||||||
* This may be specified in two different ways, percentage spacing and font point spacing:
|
* This may be specified in two different ways, percentage spacing and font point spacing:
|
||||||
* <p>
|
* <p>
|
||||||
* If spaceBefore >= 0, then space is a percentage of normal line height.
|
* If spaceBefore >= 0, then space is a percentage of normal line height.
|
||||||
* If spaceBefore < 0, the absolute value of linespacing is the spacing in points
|
* If spaceBefore < 0, the absolute value of linespacing is the spacing in points
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @return the vertical white space after the paragraph
|
* @return the vertical white space after the paragraph
|
||||||
|
@ -715,11 +715,11 @@ public class XSSFTextParagraph implements Iterable<XSSFTextRun>{
|
||||||
if (props.isSetBuChar() || props.isSetBuAutoNum()) {
|
if (props.isSetBuChar() || props.isSetBuAutoNum()) {
|
||||||
setValue(true);
|
setValue(true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} /*else {
|
||||||
// Excel treats text with buFont but no char/autonum
|
// Excel treats text with buFont but no char/autonum
|
||||||
// as not bulleted
|
// as not bulleted
|
||||||
// Possibly the font is just used if bullets turned on again?
|
// Possibly the font is just used if bullets turned on again?
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,16 +24,17 @@ import org.apache.poi.POIDataSamples;
|
||||||
import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
|
import org.apache.poi.hsmf.exceptions.ChunkNotFoundException;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests to verify that we can read a simple msg file, that is in plain/text
|
* Tests to verify that we can read a simple msg file, that is in plain/text
|
||||||
* format with no attachments or extra recipents.
|
* format with no attachments or extra recipents.
|
||||||
*/
|
*/
|
||||||
public final class TestSimpleFileRead extends TestCase {
|
public final class TestSimpleFileRead {
|
||||||
private final MAPIMessage mapiMessage;
|
private final MAPIMessage mapiMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize this test, load up the blank.msg mapi message.
|
* Initialize this test, load up the blank.msg mapi message.
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public TestSimpleFileRead() throws IOException {
|
public TestSimpleFileRead() throws IOException {
|
||||||
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
POIDataSamples samples = POIDataSamples.getHSMFInstance();
|
||||||
|
@ -42,9 +43,9 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
* @throws ChunkNotFoundException
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReadDisplayCC() throws ChunkNotFoundException {
|
public void testReadDisplayCC() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayCC();
|
String obtained = mapiMessage.getDisplayCC();
|
||||||
String expected = "";
|
String expected = "";
|
||||||
|
@ -54,9 +55,8 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
* @throws ChunkNotFoundException
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReadDisplayTo() throws ChunkNotFoundException {
|
public void testReadDisplayTo() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayTo();
|
String obtained = mapiMessage.getDisplayTo();
|
||||||
String expected = "travis@overwrittenstack.com";
|
String expected = "travis@overwrittenstack.com";
|
||||||
|
@ -66,9 +66,8 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the From Chunk.
|
* Test to see if we can read the From Chunk.
|
||||||
* @throws ChunkNotFoundException
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReadDisplayFrom() throws ChunkNotFoundException {
|
public void testReadDisplayFrom() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayFrom();
|
String obtained = mapiMessage.getDisplayFrom();
|
||||||
String expected = "Travis Ferguson";
|
String expected = "Travis Ferguson";
|
||||||
|
@ -78,9 +77,8 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test to see if we can read the CC Chunk.
|
* Test to see if we can read the CC Chunk.
|
||||||
* @throws ChunkNotFoundException
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReadDisplayBCC() throws ChunkNotFoundException {
|
public void testReadDisplayBCC() throws ChunkNotFoundException {
|
||||||
String obtained = mapiMessage.getDisplayBCC();
|
String obtained = mapiMessage.getDisplayBCC();
|
||||||
String expected = "";
|
String expected = "";
|
||||||
|
@ -91,9 +89,8 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the body of the blank message, we expect "".
|
* Check if we can read the body of the blank message, we expect "".
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReadBody() throws Exception {
|
public void testReadBody() throws Exception {
|
||||||
String obtained = mapiMessage.getTextBody();
|
String obtained = mapiMessage.getTextBody();
|
||||||
String expected = "This is a test message.";
|
String expected = "This is a test message.";
|
||||||
|
@ -103,9 +100,8 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the subject line of the blank message, we expect ""
|
* Check if we can read the subject line of the blank message, we expect ""
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReadSubject() throws Exception {
|
public void testReadSubject() throws Exception {
|
||||||
String obtained = mapiMessage.getSubject();
|
String obtained = mapiMessage.getSubject();
|
||||||
String expected = "test message";
|
String expected = "test message";
|
||||||
|
@ -115,9 +111,8 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the subject line of the blank message, we expect ""
|
* Check if we can read the subject line of the blank message, we expect ""
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReadConversationTopic() throws Exception {
|
public void testReadConversationTopic() throws Exception {
|
||||||
String obtained = mapiMessage.getConversationTopic();
|
String obtained = mapiMessage.getConversationTopic();
|
||||||
TestCase.assertEquals("test message", obtained);
|
TestCase.assertEquals("test message", obtained);
|
||||||
|
@ -126,9 +121,8 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we can read the subject line of the blank message, we expect ""
|
* Check if we can read the subject line of the blank message, we expect ""
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
|
@Test
|
||||||
public void testReadMessageClass() throws Exception {
|
public void testReadMessageClass() throws Exception {
|
||||||
MAPIMessage.MESSAGE_CLASS obtained = mapiMessage.getMessageClassEnum();
|
MAPIMessage.MESSAGE_CLASS obtained = mapiMessage.getMessageClassEnum();
|
||||||
TestCase.assertEquals(MAPIMessage.MESSAGE_CLASS.NOTE, obtained);
|
TestCase.assertEquals(MAPIMessage.MESSAGE_CLASS.NOTE, obtained);
|
||||||
|
@ -136,8 +130,6 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the various message classes
|
* Check the various message classes
|
||||||
*
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testReadMessageClass2() throws Exception {
|
public void testReadMessageClass2() throws Exception {
|
||||||
|
@ -147,11 +139,12 @@ public final class TestSimpleFileRead extends TestCase {
|
||||||
for (String messageClass : new String[]{
|
for (String messageClass : new String[]{
|
||||||
"Appointment", "Contact", "Post", "StickyNote", "Task"
|
"Appointment", "Contact", "Post", "StickyNote", "Task"
|
||||||
}) {
|
}) {
|
||||||
MAPIMessage.MESSAGE_CLASS mc = new MAPIMessage(
|
try (MAPIMessage mapiMessage = new MAPIMessage(
|
||||||
POIDataSamples.getHSMFInstance().getFile("msgClass"+messageClass+".msg")
|
POIDataSamples.getHSMFInstance().getFile("msgClass" + messageClass + ".msg"))) {
|
||||||
).getMessageClassEnum();
|
MAPIMessage.MESSAGE_CLASS mc = mapiMessage.getMessageClassEnum();
|
||||||
assertTrue(mc + " but expected " + messageClass,
|
assertTrue(mc + " but expected " + messageClass,
|
||||||
messageClass.equalsIgnoreCase(mc.toString().replaceAll("_", "")));
|
messageClass.equalsIgnoreCase(mc.toString().replaceAll("_", "")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -98,7 +98,6 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSetMargin() throws IOException {
|
public void getSetMargin() throws IOException {
|
||||||
baseTestGetSetMargin(new double[]{0.75, 0.75, 1.0, 1.0, 0.3, 0.3});
|
baseTestGetSetMargin(new double[]{0.75, 0.75, 1.0, 1.0, 0.3, 0.3});
|
||||||
|
@ -156,7 +155,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test WSBboolRecord fields get set in the user model.
|
* Test WSBoolRecord fields get set in the user model.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void wsBool() throws IOException {
|
public void wsBool() throws IOException {
|
||||||
|
@ -166,6 +165,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||||
(WSBoolRecord) s.getSheet().findFirstRecordBySid(WSBoolRecord.sid);
|
(WSBoolRecord) s.getSheet().findFirstRecordBySid(WSBoolRecord.sid);
|
||||||
|
|
||||||
// Check defaults
|
// Check defaults
|
||||||
|
assertNotNull(record);
|
||||||
assertTrue(record.getAlternateExpression());
|
assertTrue(record.getAlternateExpression());
|
||||||
assertTrue(record.getAlternateFormula());
|
assertTrue(record.getAlternateFormula());
|
||||||
assertFalse(record.getAutobreaks());
|
assertFalse(record.getAutobreaks());
|
||||||
|
@ -518,7 +518,9 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||||
sheet.setZoom(75);
|
sheet.setZoom(75);
|
||||||
assertTrue(sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid) > 0);
|
assertTrue(sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid) > 0);
|
||||||
SCLRecord sclRecord = (SCLRecord) sheet.getSheet().findFirstRecordBySid(SCLRecord.sid);
|
SCLRecord sclRecord = (SCLRecord) sheet.getSheet().findFirstRecordBySid(SCLRecord.sid);
|
||||||
assertEquals(75, 100*sclRecord.getNumerator()/sclRecord.getDenominator());
|
assertNotNull(sclRecord);
|
||||||
|
short numerator = sclRecord.getNumerator();
|
||||||
|
assertEquals(75, 100* numerator /sclRecord.getDenominator());
|
||||||
|
|
||||||
int sclLoc = sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid);
|
int sclLoc = sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid);
|
||||||
int window2Loc = sheet.getSheet().findFirstRecordLocBySid(WindowTwoRecord.sid);
|
int window2Loc = sheet.getSheet().findFirstRecordLocBySid(WindowTwoRecord.sid);
|
||||||
|
@ -942,6 +944,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||||
|
|
||||||
// Details checks
|
// Details checks
|
||||||
HSSFCellStyle bs = wbSimple.getSheetAt(0).getColumnStyle(1);
|
HSSFCellStyle bs = wbSimple.getSheetAt(0).getColumnStyle(1);
|
||||||
|
assertNotNull(bs);
|
||||||
assertEquals(62, bs.getIndex());
|
assertEquals(62, bs.getIndex());
|
||||||
assertEquals("#,##0.0_ ;\\-#,##0.0\\ ", bs.getDataFormatString());
|
assertEquals("#,##0.0_ ;\\-#,##0.0\\ ", bs.getDataFormatString());
|
||||||
assertEquals("Calibri", bs.getFont(wbSimple).getFontName());
|
assertEquals("Calibri", bs.getFont(wbSimple).getFontName());
|
||||||
|
@ -952,6 +955,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||||
|
|
||||||
|
|
||||||
HSSFCellStyle cs = wbComplex.getSheetAt(0).getColumnStyle(1);
|
HSSFCellStyle cs = wbComplex.getSheetAt(0).getColumnStyle(1);
|
||||||
|
assertNotNull(cs);
|
||||||
assertEquals(62, cs.getIndex());
|
assertEquals(62, cs.getIndex());
|
||||||
assertEquals("#,##0.0_ ;\\-#,##0.0\\ ", cs.getDataFormatString());
|
assertEquals("#,##0.0_ ;\\-#,##0.0\\ ", cs.getDataFormatString());
|
||||||
assertEquals("Arial", cs.getFont(wbComplex).getFontName());
|
assertEquals("Arial", cs.getFont(wbComplex).getFontName());
|
||||||
|
@ -1023,6 +1027,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||||
sh = wb2.getSheetAt(0);
|
sh = wb2.getSheetAt(0);
|
||||||
ish = sh.getSheet();
|
ish = sh.getSheet();
|
||||||
ObjRecord objRecord = (ObjRecord)ish.findFirstRecordBySid(ObjRecord.sid);
|
ObjRecord objRecord = (ObjRecord)ish.findFirstRecordBySid(ObjRecord.sid);
|
||||||
|
assertNotNull(objRecord);
|
||||||
List<SubRecord> subRecords = objRecord.getSubRecords();
|
List<SubRecord> subRecords = objRecord.getSubRecords();
|
||||||
assertEquals(3, subRecords.size());
|
assertEquals(3, subRecords.size());
|
||||||
assertTrue(subRecords.get(0) instanceof CommonObjectDataSubRecord );
|
assertTrue(subRecords.get(0) instanceof CommonObjectDataSubRecord );
|
||||||
|
|
|
@ -17,11 +17,6 @@
|
||||||
|
|
||||||
package org.apache.poi.hssf.usermodel;
|
package org.apache.poi.hssf.usermodel;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||||
|
@ -30,13 +25,12 @@ import org.apache.poi.hssf.record.BackupRecord;
|
||||||
import org.apache.poi.hssf.record.LabelSSTRecord;
|
import org.apache.poi.hssf.record.LabelSSTRecord;
|
||||||
import org.apache.poi.hssf.record.Record;
|
import org.apache.poi.hssf.record.Record;
|
||||||
import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
|
import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
import org.apache.poi.ss.usermodel.Name;
|
|
||||||
import org.apache.poi.ss.usermodel.Sheet;
|
|
||||||
import org.apache.poi.ss.usermodel.Workbook;
|
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to test Workbook functionality
|
* Class to test Workbook functionality
|
||||||
*/
|
*/
|
||||||
|
@ -71,18 +65,7 @@ public final class TestWorkbook {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
|
|
||||||
for (int rownum = 0; rownum < 100; rownum++) {
|
populateSheet(s);
|
||||||
HSSFRow r = s.createRow(rownum);
|
|
||||||
|
|
||||||
for (int cellnum = 0; cellnum < 50; cellnum += 2) {
|
|
||||||
HSSFCell c = r.createCell(cellnum);
|
|
||||||
c.setCellValue(rownum * 10000 + cellnum
|
|
||||||
+ ((( double ) rownum / 1000)
|
|
||||||
+ (( double ) cellnum / 10000)));
|
|
||||||
c = r.createCell(cellnum + 1);
|
|
||||||
c.setCellValue(new HSSFRichTextString("TEST"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
|
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
|
||||||
|
|
||||||
|
@ -112,18 +95,8 @@ public final class TestWorkbook {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
|
|
||||||
for (int rownum = 0; rownum < 100; rownum++) {
|
populateSheet(s);
|
||||||
HSSFRow r = s.createRow(rownum);
|
|
||||||
|
|
||||||
for (int cellnum = 0; cellnum < 50; cellnum += 2) {
|
|
||||||
HSSFCell c = r.createCell(cellnum);
|
|
||||||
c.setCellValue(rownum * 10000 + cellnum
|
|
||||||
+ ((( double ) rownum / 1000)
|
|
||||||
+ (( double ) cellnum / 10000)));
|
|
||||||
c = r.createCell(cellnum + 1);
|
|
||||||
c.setCellValue(new HSSFRichTextString("TEST"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int rownum = 0; rownum < 25; rownum++) {
|
for (int rownum = 0; rownum < 25; rownum++) {
|
||||||
HSSFRow r = s.getRow(rownum);
|
HSSFRow r = s.getRow(rownum);
|
||||||
s.removeRow(r);
|
s.removeRow(r);
|
||||||
|
@ -411,18 +384,8 @@ public final class TestWorkbook {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
HSSFSheet s = wb1.createSheet();
|
HSSFSheet s = wb1.createSheet();
|
||||||
|
|
||||||
for (int rownum = 0; rownum < 100; rownum++) {
|
populateSheet(s);
|
||||||
HSSFRow r = s.createRow(rownum);
|
|
||||||
|
|
||||||
for (int cellnum = 0; cellnum < 50; cellnum += 2) {
|
|
||||||
HSSFCell c = r.createCell(cellnum);
|
|
||||||
c.setCellValue(rownum * 10000 + cellnum
|
|
||||||
+ ((( double ) rownum / 1000)
|
|
||||||
+ (( double ) cellnum / 10000)));
|
|
||||||
c = r.createCell(cellnum + 1);
|
|
||||||
c.setCellValue(new HSSFRichTextString("TEST"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.addMergedRegion(new CellRangeAddress(0, 10, 0, 10));
|
s.addMergedRegion(new CellRangeAddress(0, 10, 0, 10));
|
||||||
s.addMergedRegion(new CellRangeAddress(30, 40, 5, 15));
|
s.addMergedRegion(new CellRangeAddress(30, 40, 5, 15));
|
||||||
sanityChecker.checkHSSFWorkbook(wb1);
|
sanityChecker.checkHSSFWorkbook(wb1);
|
||||||
|
@ -439,6 +402,21 @@ public final class TestWorkbook {
|
||||||
wb1.close();
|
wb1.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void populateSheet(Sheet s) {
|
||||||
|
for (int rownum = 0; rownum < 100; rownum++) {
|
||||||
|
Row r = s.createRow(rownum);
|
||||||
|
|
||||||
|
for (int cellnum = 0; cellnum < 50; cellnum += 2) {
|
||||||
|
Cell c = r.createCell(cellnum);
|
||||||
|
c.setCellValue(rownum * 10000 + cellnum
|
||||||
|
+ ((( double ) rownum / 1000)
|
||||||
|
+ (( double ) cellnum / 10000)));
|
||||||
|
c = r.createCell(cellnum + 1);
|
||||||
|
c.setCellValue(new HSSFRichTextString("TEST"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void confirmRegion(CellRangeAddress ra, CellRangeAddress rb) {
|
private static void confirmRegion(CellRangeAddress ra, CellRangeAddress rb) {
|
||||||
assertEquals(ra.getFirstRow(), rb.getFirstRow());
|
assertEquals(ra.getFirstRow(), rb.getFirstRow());
|
||||||
assertEquals(ra.getLastRow(), rb.getLastRow());
|
assertEquals(ra.getLastRow(), rb.getLastRow());
|
||||||
|
@ -448,7 +426,6 @@ public final class TestWorkbook {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the backup field gets set as expected.
|
* Test the backup field gets set as expected.
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testBackupRecord() throws IOException {
|
public void testBackupRecord() throws IOException {
|
||||||
|
@ -490,7 +467,6 @@ public final class TestWorkbook {
|
||||||
* This tests is for bug [ #506658 ] Repeating output.
|
* This tests is for bug [ #506658 ] Repeating output.
|
||||||
*
|
*
|
||||||
* We need to make sure only one LabelSSTRecord is produced.
|
* We need to make sure only one LabelSSTRecord is produced.
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testRepeatingBug() throws IOException {
|
public void testRepeatingBug() throws IOException {
|
||||||
|
@ -501,6 +477,7 @@ public final class TestWorkbook {
|
||||||
|
|
||||||
cell.setCellValue(new HSSFRichTextString("Class"));
|
cell.setCellValue(new HSSFRichTextString("Class"));
|
||||||
cell = row.createCell(2);
|
cell = row.createCell(2);
|
||||||
|
assertNotNull(cell);
|
||||||
|
|
||||||
RecordCounter rc = new RecordCounter();
|
RecordCounter rc = new RecordCounter();
|
||||||
sheet.getSheet().visitContainedRecords(rc, 0);
|
sheet.getSheet().visitContainedRecords(rc, 0);
|
||||||
|
@ -584,12 +561,16 @@ public final class TestWorkbook {
|
||||||
try {
|
try {
|
||||||
sheet.setRepeatingColumns(cra);
|
sheet.setRepeatingColumns(cra);
|
||||||
fail("invalid start index is ignored");
|
fail("invalid start index is ignored");
|
||||||
} catch (IllegalArgumentException e) {}
|
} catch (IllegalArgumentException e) {
|
||||||
|
// expected here
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sheet.setRepeatingRows(cra);
|
sheet.setRepeatingRows(cra);
|
||||||
fail("invalid start index is ignored");
|
fail("invalid start index is ignored");
|
||||||
} catch (IllegalArgumentException e) {}
|
} catch (IllegalArgumentException e) {
|
||||||
|
// expected here
|
||||||
|
}
|
||||||
|
|
||||||
sheet.setRepeatingColumns(null);
|
sheet.setRepeatingColumns(null);
|
||||||
sheet.setRepeatingRows(null);
|
sheet.setRepeatingRows(null);
|
||||||
|
@ -599,39 +580,6 @@ public final class TestWorkbook {
|
||||||
workbook.close();
|
workbook.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddMergedRegionWithRegion() throws IOException {
|
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
|
||||||
HSSFSheet s = wb1.createSheet();
|
|
||||||
|
|
||||||
for (int rownum = 0; rownum < 100; rownum++) {
|
|
||||||
HSSFRow r = s.createRow(rownum);
|
|
||||||
|
|
||||||
for (int cellnum = 0; cellnum < 50; cellnum += 2) {
|
|
||||||
HSSFCell c = r.createCell(cellnum);
|
|
||||||
c.setCellValue(rownum * 10000 + cellnum
|
|
||||||
+ ((( double ) rownum / 1000)
|
|
||||||
+ (( double ) cellnum / 10000)));
|
|
||||||
c = r.createCell(cellnum + 1);
|
|
||||||
c.setCellValue(new HSSFRichTextString("TEST"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.addMergedRegion(new CellRangeAddress(0, 10, 0, 10));
|
|
||||||
s.addMergedRegion(new CellRangeAddress(30, 40, 5, 15));
|
|
||||||
sanityChecker.checkHSSFWorkbook(wb1);
|
|
||||||
HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb1);
|
|
||||||
|
|
||||||
s = wb2.getSheetAt(0);
|
|
||||||
CellRangeAddress r1 = s.getMergedRegion(0);
|
|
||||||
CellRangeAddress r2 = s.getMergedRegion(1);
|
|
||||||
|
|
||||||
confirmRegion(new CellRangeAddress(0, 10, 0, 10), r1);
|
|
||||||
confirmRegion(new CellRangeAddress(30, 40,5, 15), r2);
|
|
||||||
|
|
||||||
wb2.close();
|
|
||||||
wb1.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBug58085RemoveSheetWithNames() throws Exception {
|
public void testBug58085RemoveSheetWithNames() throws Exception {
|
||||||
HSSFWorkbook wb1 = new HSSFWorkbook();
|
HSSFWorkbook wb1 = new HSSFWorkbook();
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
package org.apache.poi.ss.usermodel;
|
package org.apache.poi.ss.usermodel;
|
||||||
|
|
||||||
import org.apache.poi.common.usermodel.HyperlinkType;
|
import org.apache.poi.common.usermodel.HyperlinkType;
|
||||||
import org.apache.poi.hssf.usermodel.*;
|
|
||||||
import org.apache.poi.ss.ITestDataProvider;
|
import org.apache.poi.ss.ITestDataProvider;
|
||||||
import org.apache.poi.ss.SpreadsheetVersion;
|
import org.apache.poi.ss.SpreadsheetVersion;
|
||||||
import org.apache.poi.ss.util.CellAddress;
|
import org.apache.poi.ss.util.CellAddress;
|
||||||
|
@ -37,8 +36,9 @@ import static org.junit.Assert.*;
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common superclass for testing {@link HSSFCell}, org.apache.poi.xssf.usermodel.XSSFCell and
|
* Common superclass for testing {@link org.apache.poi.hssf.usermodel.HSSFCell},
|
||||||
* org.apache.poi.xssf.streaming.SXSSFCell
|
* {@link org.apache.poi.xssf.usermodel.XSSFCell} and
|
||||||
|
* {@link org.apache.poi.xssf.streaming.SXSSFCell}
|
||||||
*/
|
*/
|
||||||
public abstract class BaseTestSheet {
|
public abstract class BaseTestSheet {
|
||||||
private static final int ROW_COUNT = 40000;
|
private static final int ROW_COUNT = 40000;
|
||||||
|
|
Loading…
Reference in New Issue