Cleaned up test code
git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@699991 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0c602f354f
commit
0d50343293
@ -1,11 +1,5 @@
|
||||
package org.apache.poi.xssf.usermodel;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
@ -13,8 +7,8 @@ import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
import org.apache.poi.xssf.usermodel.extensions.XSSFColor;
|
||||
import org.openxml4j.opc.Package;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
|
||||
@ -28,15 +22,13 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STFontScheme;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STUnderlineValues;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignRun;
|
||||
|
||||
public class TestXSSFFont extends TestCase{
|
||||
public final class TestXSSFFont extends TestCase{
|
||||
|
||||
public void testConstructor() {
|
||||
XSSFFont xssfFont=new XSSFFont();
|
||||
assertNotNull(xssfFont);
|
||||
assertNotNull(xssfFont.getCTFont());
|
||||
}
|
||||
|
||||
|
||||
public void testBoldweight() {
|
||||
CTFont ctFont=CTFont.Factory.newInstance();
|
||||
CTBooleanProperty bool=ctFont.addNewB();
|
||||
@ -64,7 +56,6 @@ public class TestXSSFFont extends TestCase{
|
||||
assertEquals(FontCharset.DEFAULT.getValue(),ctFont.getCharsetArray(0).getVal());
|
||||
}
|
||||
|
||||
|
||||
public void testFontName() {
|
||||
CTFont ctFont=CTFont.Factory.newInstance();
|
||||
CTFontName fname=ctFont.addNewName();
|
||||
@ -78,7 +69,6 @@ public class TestXSSFFont extends TestCase{
|
||||
assertEquals("Courier",ctFont.getNameArray(0).getVal());
|
||||
}
|
||||
|
||||
|
||||
public void testItalic() {
|
||||
CTFont ctFont=CTFont.Factory.newInstance();
|
||||
CTBooleanProperty bool=ctFont.addNewI();
|
||||
@ -94,7 +84,6 @@ public class TestXSSFFont extends TestCase{
|
||||
assertEquals(true,ctFont.getIArray(0).getVal());
|
||||
}
|
||||
|
||||
|
||||
public void testStrikeout() {
|
||||
CTFont ctFont=CTFont.Factory.newInstance();
|
||||
CTBooleanProperty bool=ctFont.addNewStrike();
|
||||
@ -110,7 +99,6 @@ public class TestXSSFFont extends TestCase{
|
||||
assertEquals(true,ctFont.getStrikeArray(0).getVal());
|
||||
}
|
||||
|
||||
|
||||
public void testFontHeight() {
|
||||
CTFont ctFont=CTFont.Factory.newInstance();
|
||||
CTFontSize size=ctFont.addNewSz();
|
||||
@ -124,7 +112,6 @@ public class TestXSSFFont extends TestCase{
|
||||
assertEquals(new Double(20).doubleValue(),ctFont.getSzArray(0).getVal());
|
||||
}
|
||||
|
||||
|
||||
public void testFontHeightInPoint() {
|
||||
CTFont ctFont=CTFont.Factory.newInstance();
|
||||
CTFontSize size=ctFont.addNewSz();
|
||||
@ -138,7 +125,6 @@ public class TestXSSFFont extends TestCase{
|
||||
assertEquals(new Double(20).doubleValue(),ctFont.getSzArray(0).getVal());
|
||||
}
|
||||
|
||||
|
||||
public void testUnderline() {
|
||||
CTFont ctFont=CTFont.Factory.newInstance();
|
||||
CTUnderlineProperty underlinePropr=ctFont.addNewU();
|
||||
@ -192,7 +178,7 @@ public class TestXSSFFont extends TestCase{
|
||||
public void testThemeColor() {
|
||||
CTFont ctFont=CTFont.Factory.newInstance();
|
||||
CTColor color=ctFont.addNewColor();
|
||||
color.setTheme((long)1);
|
||||
color.setTheme(1);
|
||||
ctFont.setColorArray(0,color);
|
||||
|
||||
XSSFFont xssfFont=new XSSFFont(ctFont);
|
||||
@ -212,7 +198,6 @@ public class TestXSSFFont extends TestCase{
|
||||
assertEquals(FontFamily.MODERN.getValue(),xssfFont.getFamily());
|
||||
}
|
||||
|
||||
|
||||
public void testScheme() {
|
||||
CTFont ctFont=CTFont.Factory.newInstance();
|
||||
CTFontScheme scheme=ctFont.addNewScheme();
|
||||
@ -244,9 +229,9 @@ public class TestXSSFFont extends TestCase{
|
||||
* file, save, load, and still see them
|
||||
* @throws Exception
|
||||
*/
|
||||
public void testCreateSave() throws Exception {
|
||||
public void testCreateSave() {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
XSSFSheet s1 = (XSSFSheet)wb.createSheet();
|
||||
XSSFSheet s1 = wb.createSheet();
|
||||
Row r1 = s1.createRow(0);
|
||||
Cell r1c1 = r1.createCell(0);
|
||||
r1c1.setCellValue(2.2);
|
||||
@ -266,12 +251,8 @@ public class TestXSSFFont extends TestCase{
|
||||
r1c1.setCellStyle(cellStyleTitle);
|
||||
|
||||
// Save and re-load
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
wb.write(baos);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
|
||||
wb = new XSSFWorkbook(Package.open(bais));
|
||||
s1 = (XSSFSheet)wb.getSheetAt(0);
|
||||
wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
s1 = wb.getSheetAt(0);
|
||||
|
||||
assertEquals(2, wb.getNumberOfFonts());
|
||||
assertNotNull(s1.getRow(0).getCell(0).getCellStyle().getFont(wb));
|
||||
@ -286,12 +267,8 @@ public class TestXSSFFont extends TestCase{
|
||||
assertEquals(3, wb.getNumberOfFonts());
|
||||
|
||||
// Save and re-load
|
||||
baos = new ByteArrayOutputStream();
|
||||
wb.write(baos);
|
||||
bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
|
||||
wb = new XSSFWorkbook(Package.open(bais));
|
||||
s1 = (XSSFSheet)wb.getSheetAt(0);
|
||||
wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||
s1 = wb.getSheetAt(0);
|
||||
|
||||
assertEquals(3, wb.getNumberOfFonts());
|
||||
assertNotNull(wb.getFontAt((short)1));
|
||||
@ -301,8 +278,7 @@ public class TestXSSFFont extends TestCase{
|
||||
assertEquals(true, wb.getFontAt((short)2).getItalic());
|
||||
}
|
||||
|
||||
|
||||
public void testXSSFFont() throws IOException{
|
||||
public void testXSSFFont() {
|
||||
XSSFWorkbook workbook=new XSSFWorkbook();
|
||||
//Font font1=workbook.createFont();
|
||||
|
||||
@ -364,11 +340,6 @@ public class TestXSSFFont extends TestCase{
|
||||
cell1.setCellValue(new XSSFRichTextString("pink italic Times 9pt strikeout!!!"));
|
||||
cell1.setCellStyle(cellStyle3);
|
||||
|
||||
File tmpFile = new File("test-ooxml-font.xlsx");
|
||||
if(tmpFile.exists()) tmpFile.delete();
|
||||
FileOutputStream out = new FileOutputStream(tmpFile);
|
||||
workbook.write(out);
|
||||
out.close();
|
||||
XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user