appendFormat(StringBuilder out, String rawSheetName)
instead
*/
public static void appendFormat(StringBuffer out, String rawSheetName) {
boolean needsQuotes = needsDelimiting(rawSheetName);
@@ -67,6 +69,10 @@ public final class SheetNameFormatter {
out.append(rawSheetName);
}
}
+
+ /**
+ * @deprecated use appendFormat(StringBuilder out, String workbookName, String rawSheetName)
instead
+ */
public static void appendFormat(StringBuffer out, String workbookName, String rawSheetName) {
boolean needsQuotes = needsDelimiting(workbookName) || needsDelimiting(rawSheetName);
if(needsQuotes) {
@@ -84,17 +90,54 @@ public final class SheetNameFormatter {
}
}
- private static void appendAndEscape(StringBuffer sb, String rawSheetName) {
- int len = rawSheetName.length();
- for(int i=0; i
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java
index 575b01c99..e56af69d9 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java
@@ -283,7 +283,7 @@ public final class XSSFName implements Name {
* Get the sheets name which this named range is referenced to
*
* @return sheet name, which this named range referred to.
- * Empty string if the referenced sheet name weas not found.
+ * Empty string if the referenced sheet name was not found.
*/
public String getSheetName() {
if (_ctName.isSetLocalSheetId()) {
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
index 67a82510d..1916ef50b 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
@@ -1490,13 +1490,13 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook {
//short externSheetIndex = getWorkbook().checkExternSheet(sheetIndex);
//name.setExternSheetNumber(externSheetIndex);
String[] parts = COMMA_PATTERN.split(reference);
- StringBuffer sb = new StringBuffer(32);
+ StringBuilder sb = new StringBuilder(32);
for (int i = 0; i < parts.length; i++) {
if(i>0) {
- sb.append(",");
+ sb.append(',');
}
SheetNameFormatter.appendFormat(sb, getSheetName(sheetIndex));
- sb.append("!");
+ sb.append('!');
sb.append(parts[i]);
}
name.setRefersToFormula(sb.toString());
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java b/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java
index c6e2f7eca..93f35aac4 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java
@@ -18,7 +18,6 @@
package org.apache.poi.xssf;
import org.apache.poi.ss.format.TestCellFormatPart;
-import org.apache.poi.xssf.eventusermodel.TestXSSFReader;
import org.apache.poi.xssf.extractor.TestXSSFExcelExtractor;
import org.apache.poi.xssf.io.TestLoadSaveXSSF;
import org.apache.poi.xssf.model.TestCommentsTable;
@@ -29,14 +28,13 @@ import org.apache.poi.xssf.util.TestNumericRanges;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
-
/**
* Collects all tests for org.apache.poi.xssf and sub-packages.
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
AllXSSFUsermodelTests.class,
- TestXSSFReader.class,
+ //TestXSSFReader.class, //converted to junit4
TestXSSFExcelExtractor.class,
TestLoadSaveXSSF.class,
TestCommentsTable.class,
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
index c70a24ceb..5e27ad61c 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/eventusermodel/TestXSSFReader.java
@@ -19,6 +19,7 @@ package org.apache.poi.xssf.eventusermodel;
import static org.apache.poi.POITestCase.assertContains;
import static org.apache.poi.POITestCase.assertNotContained;
+import static org.junit.Assert.*;
import java.io.InputStream;
import java.util.Iterator;
@@ -29,6 +30,8 @@ import java.util.HashSet;
import org.apache.poi.POIDataSamples;
import org.apache.poi.POIXMLException;
import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.ss.usermodel.Name;
+import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.model.CommentsTable;
@@ -36,21 +39,23 @@ import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFShape;
import org.apache.poi.xssf.usermodel.XSSFSimpleShape;
-
-import junit.framework.TestCase;
+import org.junit.Ignore;
+import org.junit.Test;
/**
* Tests for {@link XSSFReader}
*/
-public final class TestXSSFReader extends TestCase {
+public final class TestXSSFReader {
+
private static POIDataSamples _ssTests = POIDataSamples.getSpreadSheetInstance();
+ @Test
public void testGetBits() throws Exception {
OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream("SampleSS.xlsx"));
XSSFReader r = new XSSFReader(pkg);
- assertNotNull(r.getWorkbookData());
+ assertNotNull(r.getWorkbookData());
assertNotNull(r.getSharedStringsData());
assertNotNull(r.getStylesData());
@@ -58,6 +63,7 @@ public final class TestXSSFReader extends TestCase {
assertNotNull(r.getStylesTable());
}
+ @Test
public void testStyles() throws Exception {
OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream("SampleSS.xlsx"));
@@ -74,6 +80,7 @@ public final class TestXSSFReader extends TestCase {
assertNotNull(r.getThemesData());
}
+ @Test
public void testStrings() throws Exception {
OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream("SampleSS.xlsx"));
@@ -83,6 +90,7 @@ public final class TestXSSFReader extends TestCase {
assertEquals("Test spreadsheet", new XSSFRichTextString(r.getSharedStringsTable().getEntryAt(0)).toString());
}
+ @Test
public void testSheets() throws Exception {
OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream("SampleSS.xlsx"));
@@ -115,6 +123,7 @@ public final class TestXSSFReader extends TestCase {
* Check that the sheet iterator returns sheets in the logical order
* (as they are defined in the workbook.xml)
*/
+ @Test
public void testOrderOfSheets() throws Exception {
OPCPackage pkg = OPCPackage.open(_ssTests.openResourceAsStream("reordered_sheets.xlsx"));
@@ -134,7 +143,8 @@ public final class TestXSSFReader extends TestCase {
}
assertEquals(4, count);
}
-
+
+ @Test
public void testComments() throws Exception {
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("comments.xlsx");
XSSFReader r = new XSSFReader(pkg);
@@ -163,6 +173,7 @@ public final class TestXSSFReader extends TestCase {
* XSSFReader method
* @throws Exception
*/
+ @Test
public void test50119() throws Exception {
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("WithChartSheet.xlsx");
XSSFReader r = new XSSFReader(pkg);
@@ -180,6 +191,7 @@ public final class TestXSSFReader extends TestCase {
*
* @throws Exception
*/
+ @Test
public void testShapes() throws Exception {
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("WithTextBox.xlsx");
XSSFReader r = new XSSFReader(pkg);
@@ -208,6 +220,7 @@ public final class TestXSSFReader extends TestCase {
return sb.toString();
}
+ @Test
public void testBug57914() throws Exception {
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("57914.xlsx");
final XSSFReader r;
@@ -234,6 +247,7 @@ public final class TestXSSFReader extends TestCase {
* NPE from XSSFReader$SheetIterator.