Changed CRLF to LF in ooxml/testcases. Minor fixes for compiler warnings and formatting
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@776905 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7b5b57423f
commit
5fb78707f7
@ -27,7 +27,7 @@ import org.apache.poi.openxml4j.opc.internal.ContentType;
|
|||||||
*
|
*
|
||||||
* @author Julien Chable
|
* @author Julien Chable
|
||||||
*/
|
*/
|
||||||
public class TestContentType extends TestCase {
|
public final class TestContentType extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check rule M1.13: Package implementers shall only create and only
|
* Check rule M1.13: Package implementers shall only create and only
|
||||||
|
@ -29,27 +29,28 @@ import junit.framework.TestCase;
|
|||||||
*
|
*
|
||||||
* @author Julien Chable
|
* @author Julien Chable
|
||||||
*/
|
*/
|
||||||
public class TestFileHelper extends TestCase {
|
public final class TestFileHelper extends TestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO - use simple JDK methods on {@link File} instead:<br/>
|
||||||
|
* {@link File#getParentFile()} instead of {@link FileHelper#getDirectory(File)
|
||||||
|
* {@link File#getName()} instead of {@link FileHelper#getFilename(File)
|
||||||
|
*/
|
||||||
public void testGetDirectory() {
|
public void testGetDirectory() {
|
||||||
TreeMap<String, String> expectedValue = new TreeMap<String, String>();
|
TreeMap<String, String> expectedValue = new TreeMap<String, String>();
|
||||||
expectedValue.put("/dir1/test.doc", "/dir1");
|
expectedValue.put("/dir1/test.doc", "/dir1");
|
||||||
expectedValue.put("/dir1/dir2/test.doc.xml", "/dir1/dir2");
|
expectedValue.put("/dir1/dir2/test.doc.xml", "/dir1/dir2");
|
||||||
|
|
||||||
for (String filename : expectedValue.keySet()) {
|
for (String filename : expectedValue.keySet()) {
|
||||||
File f1 = new File(expectedValue.get(filename));
|
File f1 = new File(expectedValue.get(filename));
|
||||||
File f2 = FileHelper.getDirectory(new File(filename));
|
File f2 = FileHelper.getDirectory(new File(filename));
|
||||||
|
|
||||||
/*
|
if (false) {
|
||||||
* YK: The original version asserted expected values against File#getAbsolutePath():
|
// YK: The original version asserted expected values against File#getAbsolutePath():
|
||||||
* assertTrue(expectedValue.get(filename).equalsIgnoreCase(
|
assertTrue(expectedValue.get(filename).equalsIgnoreCase(f2.getAbsolutePath()));
|
||||||
* FileHelper.getDirectory(new File(filename))
|
// This comparison is platform dependent. A better approach is below
|
||||||
* .getAbsolutePath()));
|
}
|
||||||
*
|
assertTrue(f1.equals(f2));
|
||||||
* This comparison is platform dependent and resulted in build errors in Gump since 21/02/2009.
|
|
||||||
* Assertion via File#equals(File otherFile) is a better approach.
|
|
||||||
*/
|
|
||||||
assertTrue(f1.equals(f2));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.openxml4j.opc;
|
package org.apache.poi.openxml4j.opc;
|
||||||
|
|
||||||
import org.apache.poi.openxml4j.opc.PackagePartName;
|
import org.apache.poi.openxml4j.opc.PackagePartName;
|
||||||
@ -21,7 +22,7 @@ import org.apache.poi.openxml4j.opc.PackagingURIHelper;
|
|||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
public class TestPackagePartName extends TestCase {
|
public final class TestPackagePartName extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test method getExtension().
|
* Test method getExtension().
|
||||||
|
@ -20,7 +20,7 @@ package org.apache.poi.openxml4j.opc.compliance;
|
|||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
public class AllOpenXML4JComplianceTests {
|
public final class AllOpenXML4JComplianceTests {
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite(AllOpenXML4JComplianceTests.class.getName());
|
TestSuite suite = new TestSuite(AllOpenXML4JComplianceTests.class.getName());
|
||||||
|
@ -20,7 +20,7 @@ package org.apache.poi.openxml4j.opc.internal;
|
|||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
public class AllOpenXML4JInternalTests {
|
public final class AllOpenXML4JInternalTests {
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite(AllOpenXML4JInternalTests.class.getName());
|
TestSuite suite = new TestSuite(AllOpenXML4JInternalTests.class.getName());
|
||||||
|
@ -22,7 +22,7 @@ import junit.framework.TestCase;
|
|||||||
import org.apache.poi.openxml4j.opc.PackagePartName;
|
import org.apache.poi.openxml4j.opc.PackagePartName;
|
||||||
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
|
import org.apache.poi.openxml4j.opc.PackagingURIHelper;
|
||||||
|
|
||||||
public class TestContentTypeManager extends TestCase {
|
public final class TestContentTypeManager extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the properties part content parsing.
|
* Test the properties part content parsing.
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.xssf;
|
package org.apache.poi.xssf;
|
||||||
|
|
||||||
import org.apache.poi.ss.ITestDataProvider;
|
import org.apache.poi.ss.ITestDataProvider;
|
||||||
@ -28,16 +29,16 @@ import org.apache.poi.hssf.HSSFTestDataSamples;
|
|||||||
public final class XSSFITestDataProvider implements ITestDataProvider {
|
public final class XSSFITestDataProvider implements ITestDataProvider {
|
||||||
|
|
||||||
public XSSFWorkbook openSampleWorkbook(String sampleFileName) {
|
public XSSFWorkbook openSampleWorkbook(String sampleFileName) {
|
||||||
return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);
|
return XSSFTestDataSamples.openSampleWorkbook(sampleFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public XSSFWorkbook writeOutAndReadBack(Workbook original) {
|
public XSSFWorkbook writeOutAndReadBack(Workbook original) {
|
||||||
if(!(original instanceof XSSFWorkbook)) {
|
if(!(original instanceof XSSFWorkbook)) {
|
||||||
throw new IllegalArgumentException("Expected an instance of XSSFWorkbook");
|
throw new IllegalArgumentException("Expected an instance of XSSFWorkbook");
|
||||||
}
|
}
|
||||||
|
|
||||||
return XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)original);
|
return XSSFTestDataSamples.writeOutAndReadBack((XSSFWorkbook)original);
|
||||||
}
|
}
|
||||||
|
|
||||||
public XSSFWorkbook createWorkbook(){
|
public XSSFWorkbook createWorkbook(){
|
||||||
return new XSSFWorkbook();
|
return new XSSFWorkbook();
|
||||||
@ -51,7 +52,9 @@ public final class XSSFITestDataProvider implements ITestDataProvider {
|
|||||||
return SpreadsheetVersion.EXCEL2007;
|
return SpreadsheetVersion.EXCEL2007;
|
||||||
}
|
}
|
||||||
|
|
||||||
private XSSFITestDataProvider(){}
|
private XSSFITestDataProvider() {
|
||||||
|
// enforce singleton
|
||||||
|
}
|
||||||
private static XSSFITestDataProvider inst = new XSSFITestDataProvider();
|
private static XSSFITestDataProvider inst = new XSSFITestDataProvider();
|
||||||
public static XSSFITestDataProvider getInstance(){
|
public static XSSFITestDataProvider getInstance(){
|
||||||
return inst;
|
return inst;
|
||||||
|
@ -17,9 +17,6 @@
|
|||||||
|
|
||||||
package org.apache.poi.xssf.model;
|
package org.apache.poi.xssf.model;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@ -38,15 +35,15 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
|
|||||||
*/
|
*/
|
||||||
public final class TestSharedStringsTable extends TestCase {
|
public final class TestSharedStringsTable extends TestCase {
|
||||||
|
|
||||||
public void testCreateNew() {
|
public void testCreateNew() {
|
||||||
SharedStringsTable sst = new SharedStringsTable();
|
SharedStringsTable sst = new SharedStringsTable();
|
||||||
|
|
||||||
CTRst st;
|
CTRst st;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
// Check defaults
|
// Check defaults
|
||||||
assertNotNull(sst.getItems());
|
assertNotNull(sst.getItems());
|
||||||
assertEquals(0, sst.getItems().size());
|
assertEquals(0, sst.getItems().size());
|
||||||
assertEquals(0, sst.getCount());
|
assertEquals(0, sst.getCount());
|
||||||
assertEquals(0, sst.getUniqueCount());
|
assertEquals(0, sst.getUniqueCount());
|
||||||
|
|
||||||
@ -58,13 +55,13 @@ public final class TestSharedStringsTable extends TestCase {
|
|||||||
assertEquals(1, sst.getCount());
|
assertEquals(1, sst.getCount());
|
||||||
assertEquals(1, sst.getUniqueCount());
|
assertEquals(1, sst.getUniqueCount());
|
||||||
|
|
||||||
//add the same entry egain
|
//add the same entry again
|
||||||
idx = sst.addEntry(st);
|
idx = sst.addEntry(st);
|
||||||
assertEquals(0, idx);
|
assertEquals(0, idx);
|
||||||
assertEquals(2, sst.getCount());
|
assertEquals(2, sst.getCount());
|
||||||
assertEquals(1, sst.getUniqueCount());
|
assertEquals(1, sst.getUniqueCount());
|
||||||
|
|
||||||
//and egain
|
//and again
|
||||||
idx = sst.addEntry(st);
|
idx = sst.addEntry(st);
|
||||||
assertEquals(0, idx);
|
assertEquals(0, idx);
|
||||||
assertEquals(3, sst.getCount());
|
assertEquals(3, sst.getCount());
|
||||||
@ -78,7 +75,7 @@ public final class TestSharedStringsTable extends TestCase {
|
|||||||
assertEquals(4, sst.getCount());
|
assertEquals(4, sst.getCount());
|
||||||
assertEquals(2, sst.getUniqueCount());
|
assertEquals(2, sst.getUniqueCount());
|
||||||
|
|
||||||
//add the same entry egain
|
//add the same entry again
|
||||||
idx = sst.addEntry(st);
|
idx = sst.addEntry(st);
|
||||||
assertEquals(1, idx);
|
assertEquals(1, idx);
|
||||||
assertEquals(5, sst.getCount());
|
assertEquals(5, sst.getCount());
|
||||||
@ -102,19 +99,19 @@ public final class TestSharedStringsTable extends TestCase {
|
|||||||
assertEquals(7, sst.getCount());
|
assertEquals(7, sst.getCount());
|
||||||
assertEquals(3, sst.getUniqueCount());
|
assertEquals(3, sst.getUniqueCount());
|
||||||
|
|
||||||
//ok. the sst table is filled, check the contents
|
//OK. the sst table is filled, check the contents
|
||||||
assertEquals(3, sst.getItems().size());
|
assertEquals(3, sst.getItems().size());
|
||||||
assertEquals("Hello, World!", new XSSFRichTextString(sst.getEntryAt(0)).toString());
|
assertEquals("Hello, World!", new XSSFRichTextString(sst.getEntryAt(0)).toString());
|
||||||
assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(1)).toString());
|
assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(1)).toString());
|
||||||
assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(2)).toString());
|
assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(2)).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testReadWrite() {
|
public void testReadWrite() {
|
||||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx");
|
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx");
|
||||||
SharedStringsTable sst1 = wb.getSharedStringSource();
|
SharedStringsTable sst1 = wb.getSharedStringSource();
|
||||||
|
|
||||||
//serialize, read back and compare with the original
|
//serialize, read back and compare with the original
|
||||||
SharedStringsTable sst2 = XSSFTestDataSamples.writeOutAndReadBack(wb).getSharedStringSource();
|
SharedStringsTable sst2 = XSSFTestDataSamples.writeOutAndReadBack(wb).getSharedStringSource();
|
||||||
|
|
||||||
assertEquals(sst1.getCount(), sst2.getCount());
|
assertEquals(sst1.getCount(), sst2.getCount());
|
||||||
assertEquals(sst1.getUniqueCount(), sst2.getUniqueCount());
|
assertEquals(sst1.getUniqueCount(), sst2.getUniqueCount());
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.xssf.usermodel;
|
package org.apache.poi.xssf.usermodel;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@ -22,7 +23,7 @@ import org.apache.poi.xssf.XSSFTestDataSamples;
|
|||||||
/**
|
/**
|
||||||
* @author Yegor Kozlov
|
* @author Yegor Kozlov
|
||||||
*/
|
*/
|
||||||
public class TestSheetHiding extends TestCase {
|
public final class TestSheetHiding extends TestCase {
|
||||||
private XSSFWorkbook wbH;
|
private XSSFWorkbook wbH;
|
||||||
private XSSFWorkbook wbU;
|
private XSSFWorkbook wbU;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.xssf.usermodel;
|
package org.apache.poi.xssf.usermodel;
|
||||||
|
|
||||||
import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
|
import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
|
||||||
@ -23,7 +24,7 @@ import org.apache.poi.xssf.XSSFITestDataProvider;
|
|||||||
/**
|
/**
|
||||||
* @author Yegor Kozlov
|
* @author Yegor Kozlov
|
||||||
*/
|
*/
|
||||||
public class TestSheetShiftRows extends BaseTestSheetShiftRows {
|
public final class TestSheetShiftRows extends BaseTestSheetShiftRows {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ITestDataProvider getTestDataProvider(){
|
protected ITestDataProvider getTestDataProvider(){
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.xssf.usermodel;
|
package org.apache.poi.xssf.usermodel;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@ -24,7 +25,7 @@ import org.apache.poi.ss.usermodel.BaseTestNamedRange;
|
|||||||
/**
|
/**
|
||||||
* @author Yegor Kozlov
|
* @author Yegor Kozlov
|
||||||
*/
|
*/
|
||||||
public class TestXSSFName extends BaseTestNamedRange {
|
public final class TestXSSFName extends BaseTestNamedRange {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected XSSFITestDataProvider getTestDataProvider(){
|
protected XSSFITestDataProvider getTestDataProvider(){
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.xssf.usermodel;
|
package org.apache.poi.xssf.usermodel;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@ -29,7 +30,7 @@ import java.util.Arrays;
|
|||||||
/**
|
/**
|
||||||
* @author Yegor Kozlov
|
* @author Yegor Kozlov
|
||||||
*/
|
*/
|
||||||
public class TestXSSFPicture extends BaseTestPicture {
|
public final class TestXSSFPicture extends BaseTestPicture {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected XSSFITestDataProvider getTestDataProvider(){
|
protected XSSFITestDataProvider getTestDataProvider(){
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
==================================================================== */
|
==================================================================== */
|
||||||
|
|
||||||
package org.apache.poi.xssf.usermodel;
|
package org.apache.poi.xssf.usermodel;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
@ -28,7 +29,7 @@ import java.io.IOException;
|
|||||||
/**
|
/**
|
||||||
* @author Yegor Kozlov
|
* @author Yegor Kozlov
|
||||||
*/
|
*/
|
||||||
public class TestXSSFPictureData extends TestCase {
|
public final class TestXSSFPictureData extends TestCase {
|
||||||
public void testRead(){
|
public void testRead(){
|
||||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithDrawing.xlsx");
|
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithDrawing.xlsx");
|
||||||
List<XSSFPictureData> pictures = wb.getAllPictures();
|
List<XSSFPictureData> pictures = wb.getAllPictures();
|
||||||
|
@ -40,7 +40,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
|
|||||||
*
|
*
|
||||||
* @author Yegor Kozlov
|
* @author Yegor Kozlov
|
||||||
*/
|
*/
|
||||||
public class TestXSSFRichTextString extends TestCase {
|
public final class TestXSSFRichTextString extends TestCase {
|
||||||
|
|
||||||
public void testCreate() throws Exception {
|
public void testCreate() throws Exception {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user