You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2015/10/12 22:43:42 UTC

svn commit: r1708236 [2/3] - in /poi: site/src/documentation/content/xdocs/ trunk/src/examples/src/org/apache/poi/ss/examples/html/ trunk/src/java/org/apache/poi/hssf/usermodel/ trunk/src/java/org/apache/poi/ss/usermodel/ trunk/src/ooxml/java/org/apach...

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1708236&r1=1708235&r2=1708236&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Mon Oct 12 20:43:42 2015
@@ -50,7 +50,9 @@ import org.apache.poi.POIXMLProperties;
 import org.apache.poi.hssf.HSSFTestDataSamples;
 import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
+import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.openxml4j.opc.PackageAccess;
 import org.apache.poi.openxml4j.opc.PackagePart;
@@ -62,7 +64,29 @@ import org.apache.poi.ss.formula.eval.Er
 import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.functions.Function;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellValue;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Comment;
+import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.FormulaError;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
+import org.apache.poi.ss.usermodel.Hyperlink;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Name;
+import org.apache.poi.ss.usermodel.PrintSetup;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
 import org.apache.poi.ss.util.AreaReference;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellReference;
@@ -74,6 +98,7 @@ import org.apache.poi.xssf.XSSFTestDataS
 import org.apache.poi.xssf.model.CalculationChain;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
+import org.apache.xmlbeans.XmlException;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcCell;
@@ -93,7 +118,7 @@ public final class TestXSSFBugs extends
      * open resulting file in Excel to check results!
      */
     @Test
-    public void bug15375_2() throws Exception {
+    public void bug15375_2() throws IOException {
         bug15375(1000);
     }
 
@@ -102,7 +127,7 @@ public final class TestXSSFBugs extends
      *  the wrong sheet name
      */
     @Test
-    public void bug45430() throws Exception {
+    public void bug45430() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("45430.xlsx");
         assertFalse(wb.isMacroEnabled());
         assertEquals(3, wb.getNumberOfNames());
@@ -133,9 +158,10 @@ public final class TestXSSFBugs extends
 
     /**
      * We should carry vba macros over after save
+     * @throws InvalidFormatException 
      */
     @Test
-    public void bug45431() throws Exception {
+    public void bug45431() throws IOException, InvalidFormatException {
         XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("45431.xlsm");
         OPCPackage pkg1 = wb1.getPackage();
         assertTrue(wb1.isMacroEnabled());
@@ -190,7 +216,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug47504() throws Exception {
+    public void bug47504() throws IOException {
         XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("47504.xlsx");
         assertEquals(1, wb1.getNumberOfSheets());
         XSSFSheet sh = wb1.getSheetAt(0);
@@ -218,7 +244,7 @@ public final class TestXSSFBugs extends
      *  read the file despite the naughtyness
      */
     @Test
-    public void bug49020() throws Exception {
+    public void bug49020() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("BrNotClosed.xlsx");
         wb.close();
     }
@@ -227,7 +253,7 @@ public final class TestXSSFBugs extends
      * ensure that CTPhoneticPr is loaded by the ooxml test suite so that it is included in poi-ooxml-schemas
      */
     @Test
-    public void bug49325() throws Exception {
+    public void bug49325() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49325.xlsx");
         CTWorksheet sh = wb.getSheetAt(0).getCTWorksheet();
         assertNotNull(sh.getPhoneticPr());
@@ -239,7 +265,7 @@ public final class TestXSSFBugs extends
      *  should return that sheet index properly
      */
     @Test
-    public void bug48923() throws Exception {
+    public void bug48923() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48923.xlsx");
         assertEquals(4, wb.getNumberOfNames());
 
@@ -280,7 +306,7 @@ public final class TestXSSFBugs extends
      * TODO: delete this test case when MROUND and VAR are implemented
      */
     @Test
-    public void bug48539() throws Exception {
+    public void bug48539() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48539.xlsx");
         try {
             assertEquals(3, wb.getNumberOfSheets());
@@ -325,7 +351,7 @@ public final class TestXSSFBugs extends
      *  a theme is used
      */
     @Test
-    public void bug48779() throws Exception {
+    public void bug48779() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
         XSSFCell cell = wb.getSheetAt(0).getRow(0).getCell(0);
         XSSFCellStyle cs = cell.getCellStyle();
@@ -363,7 +389,7 @@ public final class TestXSSFBugs extends
      *  for integers
      */
     @Test
-    public void bug47490() throws Exception {
+    public void bug47490() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("GeneralFormatTests.xlsx");
         Sheet s = wb.getSheetAt(1);
         Row r;
@@ -402,7 +428,7 @@ public final class TestXSSFBugs extends
      * The OPC spec tolerates both of these peculiarities, so does POI
      */
     @Test
-    public void bug49609() throws Exception {
+    public void bug49609() throws IOException {
         XSSFWorkbook wb =  XSSFTestDataSamples.openSampleWorkbook("49609.xlsx");
         assertEquals("FAM", wb.getSheetName(0));
         assertEquals("Cycle", wb.getSheetAt(0).getRow(0).getCell(1).getStringCellValue());
@@ -411,7 +437,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug49783() throws Exception {
+    public void bug49783() throws IOException {
         Workbook wb =  XSSFTestDataSamples.openSampleWorkbook("49783.xlsx");
         Sheet sheet = wb.getSheetAt(0);
         FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -445,7 +471,7 @@ public final class TestXSSFBugs extends
      *  with something like "helloworld" !
      */
     @Test
-    public void bug49941() throws Exception {
+    public void bug49941() throws IOException {
         XSSFWorkbook wb1 = new XSSFWorkbook();
         XSSFSheet s = wb1.createSheet();
         XSSFRow r = s.createRow(0);
@@ -524,7 +550,7 @@ public final class TestXSSFBugs extends
      * Repeatedly writing the same file which has styles
      */
     @Test
-    public void bug49940() throws Exception {
+    public void bug49940() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("styles.xlsx");
         assertEquals(3, wb.getNumberOfSheets());
         assertEquals(10, wb.getStylesSource().getNumCellStyles());
@@ -554,7 +580,7 @@ public final class TestXSSFBugs extends
      * entry.
      */
     @Test
-    public void bug49966() throws Exception {
+    public void bug49966() throws IOException {
         XSSFWorkbook wb1 = XSSFTestDataSamples
                 .openSampleWorkbook("shared_formulas.xlsx");
         XSSFSheet sheet = wb1.getSheetAt(0);
@@ -610,7 +636,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug49966Row() throws Exception {
+    public void bug49966Row() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples
                 .openSampleWorkbook("shared_formulas.xlsx");
         XSSFSheet sheet = wb.getSheetAt(0);
@@ -630,7 +656,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug49156() throws Exception {
+    public void bug49156() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("49156.xlsx");
         FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
 
@@ -649,7 +675,7 @@ public final class TestXSSFBugs extends
      * Newlines are valid characters in a formula
      */
     @Test
-    public void bug50440And51875() throws Exception {
+    public void bug50440And51875() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("NewlineInFormulas.xlsx");
         Sheet s = wb.getSheetAt(0);
         Cell c = s.getRow(0).getCell(0);
@@ -676,7 +702,7 @@ public final class TestXSSFBugs extends
      * Moving a cell comment from one cell to another
      */
     @Test
-    public void bug50795() throws Exception {
+    public void bug50795() throws IOException {
         XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("50795.xlsx");
         XSSFSheet sheet = wb1.getSheetAt(0);
         XSSFRow row = sheet.getRow(0);
@@ -738,7 +764,7 @@ public final class TestXSSFBugs extends
      * For those cases, ensure we don't break on reading the colour
      */
     @Test
-    public void bug50299() throws Exception {
+    public void bug50299() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50299.xlsx");
 
         // Check all the colours
@@ -769,9 +795,8 @@ public final class TestXSSFBugs extends
     /**
      * Excel .xls style indexed colours in a .xlsx file
      */
-    @SuppressWarnings("deprecation")
     @Test
-    public void bug50786() throws Exception {
+    public void bug50786() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50786-indexed_colours.xlsx");
         XSSFSheet s = wb.getSheetAt(0);
         XSSFRow r = s.getRow(2);
@@ -784,7 +809,7 @@ public final class TestXSSFBugs extends
         XSSFCellStyle cs = c.getCellStyle();
         assertEquals(42, cs.getFillForegroundColor());
         assertEquals(42, cs.getFillForegroundColorColor().getIndexed());
-        assertNotNull(cs.getFillForegroundColorColor().getRgb());
+        assertNotNull(cs.getFillForegroundColorColor().getRGB());
         assertEquals("FFCCFFCC", cs.getFillForegroundColorColor().getARGBHex());
         wb.close();
     }
@@ -794,7 +819,7 @@ public final class TestXSSFBugs extends
      *  should still be able to get colours
      */
     @Test
-    public void bug50846() throws Exception {
+    public void bug50846() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50846-border_colours.xlsx");
 
         XSSFSheet sheet = wb.getSheetAt(0);
@@ -823,9 +848,8 @@ public final class TestXSSFBugs extends
      *  then being set explicitly still should allow the
      *  fetching of the RGB.
      */
-    @SuppressWarnings("deprecation")
     @Test
-    public void bug50784() throws Exception {
+    public void bug50784() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50784-font_theme_colours.xlsx");
         XSSFSheet s = wb.getSheetAt(0);
         XSSFRow r = s.getRow(0);
@@ -836,7 +860,7 @@ public final class TestXSSFBugs extends
         XSSFColor colr =  fr.getXSSFColor();
         // No theme, has colours
         assertEquals(0, colr.getTheme());
-        assertNotNull( colr.getRgb() );
+        assertNotNull( colr.getRGB() );
 
         // Column 0 has a font with colours from a theme
         XSSFCell ct = r.getCell(0);
@@ -845,8 +869,8 @@ public final class TestXSSFBugs extends
         // Has a theme, which has the colours on it
         assertEquals(9, colt.getTheme());
         XSSFColor themeC = wb.getTheme().getThemeColor(colt.getTheme());
-        assertNotNull( themeC.getRgb() );
-        assertNotNull( colt.getRgb() );
+        assertNotNull( themeC.getRGB() );
+        assertNotNull( colt.getRGB() );
         assertEquals( themeC.getARGBHex(), colt.getARGBHex() ); // The same colour
         wb.close();
     }
@@ -856,7 +880,7 @@ public final class TestXSSFBugs extends
      *  a rich text string
      */
     @Test
-    public void bug48877() throws Exception {
+    public void bug48877() throws IOException {
         String text = "Use \n with word wrap on to create a new line.\n" +
                 "This line finishes with two trailing spaces.  ";
 
@@ -929,7 +953,7 @@ public final class TestXSSFBugs extends
      * Adding sheets when one has a table, then re-ordering
      */
     @Test
-    public void bug50867() throws Exception {
+    public void bug50867() throws IOException {
         XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("50867_with_table.xlsx");
         assertEquals(3, wb1.getNumberOfSheets());
 
@@ -1051,7 +1075,7 @@ public final class TestXSSFBugs extends
      */
     @SuppressWarnings("deprecation")
     @Test
-    public void bug49253() throws Exception {
+    public void bug49253() throws IOException {
         XSSFWorkbook wb1 = new XSSFWorkbook();
         XSSFWorkbook wb2 = new XSSFWorkbook();
 
@@ -1096,7 +1120,7 @@ public final class TestXSSFBugs extends
      * Default Column style
      */
     @Test
-    public void bug51037() throws Exception {
+    public void bug51037() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet s = wb.createSheet();
 
@@ -1175,7 +1199,7 @@ public final class TestXSSFBugs extends
      * Something with the SharedStringsTable currently breaks...
      */
     @Test
-    public void bug46662() throws Exception {
+    public void bug46662() throws IOException {
         // New file
         XSSFWorkbook wb1 = new XSSFWorkbook();
         XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
@@ -1198,7 +1222,7 @@ public final class TestXSSFBugs extends
      * Colours and styles when the list has gaps in it
      */
     @Test
-    public void bug51222() throws Exception {
+    public void bug51222() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51222.xlsx");
         XSSFSheet s = wb.getSheetAt(0);
 
@@ -1239,7 +1263,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug51470() throws Exception {
+    public void bug51470() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51470.xlsx");
         XSSFSheet sh0 = wb.getSheetAt(0);
         XSSFSheet sh1 = wb.cloneSheet(0);
@@ -1257,7 +1281,7 @@ public final class TestXSSFBugs extends
      *  comments (so /xl/comments1.xml is taken)
      */
     @Test
-    public void bug51850() throws Exception {
+    public void bug51850() throws IOException {
         XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("51850.xlsx");
         XSSFSheet sh1 = wb1.getSheetAt(0);
         XSSFSheet sh2 = wb1.getSheetAt(1);
@@ -1322,7 +1346,7 @@ public final class TestXSSFBugs extends
      * Sheet names with a , in them
      */
     @Test
-    public void bug51963() throws Exception {
+    public void bug51963() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51963.xlsx");
         Sheet sheet = wb.getSheetAt(0);
         assertEquals("Abc,1", sheet.getSheetName());
@@ -1345,7 +1369,7 @@ public final class TestXSSFBugs extends
      * DISABLED As we can't currently evaluate these
      */
     @Ignore
-    public void bug48703() throws Exception {
+    public void bug48703() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48703.xlsx");
         XSSFSheet sheet = wb.getSheetAt(0);
 
@@ -1375,7 +1399,7 @@ public final class TestXSSFBugs extends
      * Bugzilla 51710: problems reading shared formuals from .xlsx
      */
     @Test
-    public void bug51710() throws Exception {
+    public void bug51710() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("51710.xlsx");
 
         final String[] columns = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N"};
@@ -1407,7 +1431,7 @@ public final class TestXSSFBugs extends
      * Bug 53101:
      */
     @Test
-    public void bug5301() throws Exception {
+    public void bug5301() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53101.xlsx");
         FormulaEvaluator evaluator =
                 wb.getCreationHelper().createFormulaEvaluator();
@@ -1428,7 +1452,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug54436() throws Exception {
+    public void bug54436() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("54436.xlsx");
         if(!WorkbookEvaluator.getSupportedFunctionNames().contains("GETPIVOTDATA")){
             Function func = new Function() {
@@ -1449,7 +1473,7 @@ public final class TestXSSFBugs extends
      *  error message when called via WorkbookFactory with no password
      */
     @Test(expected=EncryptedDocumentException.class)
-    public void bug55692_poifs() throws Exception {
+    public void bug55692_poifs() throws IOException {
         // Via a POIFSFileSystem
         POIFSFileSystem fsP = new POIFSFileSystem(
             POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"));
@@ -1461,7 +1485,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug55692_stream() throws Exception {
+    public void bug55692_stream() throws IOException, InvalidFormatException {
         // Directly on a Stream, will go via NPOIFS and spot it's
         //  actually a .xlsx file encrypted with the default password, and open
         Workbook wb = WorkbookFactory.create(
@@ -1472,7 +1496,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug55692_npoifs() throws Exception {
+    public void bug55692_npoifs() throws IOException {
         // Via a NPOIFSFileSystem, will spot it's actually a .xlsx file
         //  encrypted with the default password, and open
         NPOIFSFileSystem fsNP = new NPOIFSFileSystem(
@@ -1485,7 +1509,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug53282() throws Exception {
+    public void bug53282() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53282b.xlsx");
         Cell c = wb.getSheetAt(0).getRow(1).getCell(0);
         assertEquals("#@_#", c.getStringCellValue());
@@ -1499,7 +1523,7 @@ public final class TestXSSFBugs extends
      * due to a lack of Styles Table
      */
     @Test
-    public void bug56278() throws Exception {
+    public void bug56278() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56278.xlsx");
         assertEquals(0, wb.getSheetIndex("Market Rates"));
 
@@ -1511,7 +1535,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug56315() throws Exception {
+    public void bug56315() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56315.xlsx");
         Cell c = wb.getSheetAt(0).getRow(1).getCell(0);
         CellValue cv = wb.getCreationHelper().createFormulaEvaluator().evaluate(c);
@@ -1521,7 +1545,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug56468() throws Exception {
+    public void bug56468() throws IOException, InterruptedException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet();
         XSSFRow row = sheet.createRow(0);
@@ -1615,7 +1639,7 @@ public final class TestXSSFBugs extends
      * SUMIF was throwing a NPE on some formulas
      */
     @Test
-    public void testBug56420SumIfNPE() throws Exception {
+    public void testBug56420SumIfNPE() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56420.xlsx");
 
         FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
@@ -1679,7 +1703,7 @@ public final class TestXSSFBugs extends
      *  with DataFormatter
      */
     @Test
-    public void bug56702() throws Exception {
+    public void bug56702() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56702.xlsx");
 
         Sheet sheet = wb.getSheetAt(0);
@@ -1754,9 +1778,11 @@ public final class TestXSSFBugs extends
         }
 
         FileOutputStream fileOutStream = new FileOutputStream(outFile);
-        wb.write(fileOutStream);
-        fileOutStream.close();
-        //System.out.println("File \""+outFile.getName()+"\" has been saved successfully");
+        try {
+            wb.write(fileOutStream);
+        } finally {
+            fileOutStream.close();
+        }
 
         FileInputStream is = new FileInputStream(outFile);
         try {
@@ -1773,7 +1799,9 @@ public final class TestXSSFBugs extends
                 }
                 assertNotNull(newWB.getSheet("test"));
             } finally {
-                newWB.close();
+                if (newWB != null) {
+                    newWB.close();
+                }
             }
         } finally {
             is.close();
@@ -1781,28 +1809,28 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void testBug56688_1() throws Exception {
+    public void testBug56688_1() throws IOException {
         XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_1.xlsx");
         checkValue(excel, "-1.0");  /* Not 0.0 because POI sees date "0" minus one month as invalid date, which is -1! */
         excel.close();
     }
 
     @Test
-    public void testBug56688_2() throws Exception {
+    public void testBug56688_2() throws IOException {
         XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_2.xlsx");
         checkValue(excel, "#VALUE!");
         excel.close();
     }
 
     @Test
-    public void testBug56688_3() throws Exception {
+    public void testBug56688_3() throws IOException {
         XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_3.xlsx");
         checkValue(excel, "#VALUE!");
         excel.close();
     }
 
     @Test
-    public void testBug56688_4() throws Exception {
+    public void testBug56688_4() throws IOException {
         XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_4.xlsx");
 
         Calendar calendar = LocaleUtil.getLocaleCalendar();
@@ -1855,7 +1883,7 @@ public final class TestXSSFBugs extends
      * function in another file
      */
     @Test
-    public void bug56502() throws Exception {
+    public void bug56502() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56502.xlsx");
         Sheet sheet = wb.getSheetAt(0);
 
@@ -1876,7 +1904,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void bug54764() throws Exception {
+    public void bug54764() throws IOException, OpenXML4JException, XmlException {
         OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("54764.xlsx");
 
         // Check the core properties - will be found but empty, due
@@ -1914,7 +1942,7 @@ public final class TestXSSFBugs extends
      *  poi-ooxml-schemas jar
      */
     @Test
-    public void bug57176() throws Exception {
+    public void bug57176() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57176.xlsx");
         CTDefinedNames definedNames = wb.getCTWorkbook().getDefinedNames();
         List<CTDefinedName> definedNameList = definedNames.getDefinedNameList();
@@ -1929,9 +1957,11 @@ public final class TestXSSFBugs extends
     /**
      * .xlsb files are not supported, but we should generate a helpful
      *  error message if given one
+     * @throws InvalidFormatException 
+     * @throws  
      */
     @Test
-    public void bug56800_xlsb() throws Exception {
+    public void bug56800_xlsb() throws IOException, InvalidFormatException {
         // Can be opened at the OPC level
         OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("Simple.xlsb");
 
@@ -1987,7 +2017,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void test57196_Detail() throws Exception {
+    public void test57196_Detail() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet("Sheet1");
         XSSFRow row = sheet.createRow(0);
@@ -2001,7 +2031,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void test57196_Detail2() throws Exception {
+    public void test57196_Detail2() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sheet = wb.createSheet("Sheet1");
         XSSFRow row = sheet.createRow(0);
@@ -2015,7 +2045,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void test57196_WorkbookEvaluator() throws Exception {
+    public void test57196_WorkbookEvaluator() throws IOException {
         String previousLogger = System.getProperty("org.apache.poi.util.POILogger");
         //System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger");
         //System.setProperty("poi.log.level", "3");
@@ -2098,10 +2128,11 @@ public final class TestXSSFBugs extends
     /**
      * A .xlsx file with no Shared Strings table should open fine
      *  in read-only mode
+     * @throws InvalidFormatException 
      */
     @SuppressWarnings("resource")
     @Test
-    public void bug57482() throws Exception {
+    public void bug57482() throws IOException, InvalidFormatException {
         for (PackageAccess access : new PackageAccess[] {
                 PackageAccess.READ_WRITE, PackageAccess.READ
         }) {
@@ -2109,12 +2140,12 @@ public final class TestXSSFBugs extends
             OPCPackage pkg = OPCPackage.open(file, access);
             try {
                 // Try to open it and read the contents
-                XSSFWorkbook wb = new XSSFWorkbook(pkg);
-                assertNotNull(wb.getSharedStringSource());
-                assertEquals(0, wb.getSharedStringSource().getCount());
+                XSSFWorkbook wb1 = new XSSFWorkbook(pkg);
+                assertNotNull(wb1.getSharedStringSource());
+                assertEquals(0, wb1.getSharedStringSource().getCount());
 
                 DataFormatter fmt = new DataFormatter();
-                XSSFSheet s = wb.getSheetAt(0);
+                XSSFSheet s = wb1.getSheetAt(0);
                 assertEquals("1",  fmt.formatCellValue(s.getRow(0).getCell(0)));
                 assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
                 assertEquals("5",  fmt.formatCellValue(s.getRow(4).getCell(0)));
@@ -2125,25 +2156,32 @@ public final class TestXSSFBugs extends
 
                 // Try to write-out and read again, should only work
                 //  in read-write mode, not read-only mode
+                XSSFWorkbook wb2 = null;
                 try {
-                    wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
-                    if (access == PackageAccess.READ)
+                    wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
+                    if (access == PackageAccess.READ) {
                         fail("Shouln't be able to write from read-only mode");
+                    }
+
+                    // Check again
+                    s = wb2.getSheetAt(0);
+                    assertEquals("1",  fmt.formatCellValue(s.getRow(0).getCell(0)));
+                    assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
+                    assertEquals("5",  fmt.formatCellValue(s.getRow(4).getCell(0)));
+                    assertEquals("Testing",  fmt.formatCellValue(s.getRow(0).getCell(3)));
+                
                 } catch (InvalidOperationException e) {
-                    if (access == PackageAccess.READ) {
-                        // Expected
-                    } else {
+                    if (access == PackageAccess.READ_WRITE) {
                         // Shouldn't occur in write-mode
                         throw e;
                     }
+                } finally {
+                    if (wb2 != null) {
+                        wb2.getPackage().revert();
+                    }
                 }
-
-                // Check again
-                s = wb.getSheetAt(0);
-                assertEquals("1",  fmt.formatCellValue(s.getRow(0).getCell(0)));
-                assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
-                assertEquals("5",  fmt.formatCellValue(s.getRow(4).getCell(0)));
-                assertEquals("Testing",  fmt.formatCellValue(s.getRow(0).getCell(3)));
+                
+                wb1.getPackage().revert();
             } finally {
                 pkg.revert();
             }
@@ -2154,7 +2192,7 @@ public final class TestXSSFBugs extends
      * "Unknown error type: -60" fetching formula error value
      */
     @Test
-    public void bug57535() throws Exception {
+    public void bug57535() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57535.xlsx");
         FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
         evaluator.clearAllCachedResultValues();
@@ -2334,7 +2372,7 @@ public final class TestXSSFBugs extends
      */
     @Test
     @Ignore("XMLBeans namespace mis-match on ooxml-strict files")
-    public void test57699() throws Exception {
+    public void test57699() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.strict.xlsx");
         assertEquals(3, wb.getNumberOfSheets());
         // TODO Check sheet contents
@@ -2400,7 +2438,7 @@ public final class TestXSSFBugs extends
      * Excel treats this as not-bulleted, so now do we
      */
     @Test
-    public void testBug57826() throws Exception {
+    public void testBug57826() throws IOException {
         XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("57826.xlsx");
 
         assertTrue("no sheets in workbook", workbook.getNumberOfSheets() >= 1);
@@ -2440,7 +2478,7 @@ public final class TestXSSFBugs extends
 	}
 
     @Test
-    public void bug57642() throws Exception {
+    public void bug57642() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet s = wb.createSheet("TestSheet");
         XSSFCell c = s.createRow(0).createCell(0);
@@ -2460,9 +2498,10 @@ public final class TestXSSFBugs extends
     /**
      * .xlsx supports 64000 cell styles, the style indexes after
      *  32,767 must not be -32,768, then -32,767, -32,766
+     * @throws InvalidFormatException 
      */
     @Test
-    public void bug57880() throws Exception {
+    public void bug57880() throws IOException, InvalidFormatException {
         int numStyles = 33000;
         XSSFWorkbook wb = new XSSFWorkbook();
         //XSSFSheet s = wb.createSheet("TestSheet");
@@ -2529,10 +2568,8 @@ public final class TestXSSFBugs extends
         data.put("4", new Object[] {4, "John", "Adwards"});
         data.put("5", new Object[] {2, "Brian", "Schultz"});
 
-        Set<String> keyset = data.keySet();
         int rownum = 1;
-        for (String key : keyset)
-        {
+        for (Map.Entry<String,Object[]> me : data.entrySet()) {
             final Row row;
             if(createRow) {
                 row = sheet.createRow(rownum++);
@@ -2541,10 +2578,8 @@ public final class TestXSSFBugs extends
             }
             assertNotNull(row);
 
-            Object [] objArr = data.get(key);
             int cellnum = 0;
-            for (Object obj : objArr)
-            {
+            for (Object obj : me.getValue()) {
                 Cell cell = row.getCell(cellnum);
                 if(cell == null){
                     cell = row.createCell(cellnum);
@@ -2577,13 +2612,6 @@ public final class TestXSSFBugs extends
             assertFalse(calc.getR().equals("A6"));
         }
 
-        /*FileOutputStream out = new FileOutputStream(new File("C:\\temp\\56574.xlsx"));
-        try {
-            wb.write(out);
-        } finally {
-            out.close();
-        }*/
-
         Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
         Sheet sheetBack = wbBack.getSheet("Func");
         assertNotNull(sheetBack);
@@ -2607,14 +2635,14 @@ public final class TestXSSFBugs extends
      * Excel 2007 generated Macro-Enabled .xlsm file
      */
     @Test
-    public void bug57181() throws Exception {
+    public void bug57181() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57181.xlsm");
         assertEquals(9, wb.getNumberOfSheets());
         wb.close();
     }
 
     @Test
-    public void bug52111() throws Exception {
+    public void bug52111() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("Intersection-52111-xssf.xlsx");
         Sheet s = wb.getSheetAt(0);
         assertFormula(wb, s.getRow(2).getCell(0), "(C2:D3 D3:E4)", "4.0");
@@ -2641,7 +2669,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void test48962() throws Exception {
+    public void test48962() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("48962.xlsx");
         Sheet sh = wb.getSheetAt(0);
         Row row = sh.getRow(1);
@@ -2666,7 +2694,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void test50755_workday_formula_example() throws Exception {
+    public void test50755_workday_formula_example() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50755_workday_formula_example.xlsx");
         Sheet sheet = wb.getSheet("Sheet1");
         for(Row aRow : sheet) {
@@ -2684,7 +2712,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void test51626() throws Exception {
+    public void test51626() throws IOException, InvalidFormatException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("51626.xlsx");
         assertNotNull(wb);
         wb.close();
@@ -2765,7 +2793,7 @@ public final class TestXSSFBugs extends
     }
 
     @Test
-    public void test55406() throws Exception {
+    public void test55406() throws IOException {
         Workbook wb = XSSFTestDataSamples.openSampleWorkbook("55406_Conditional_formatting_sample.xlsx");
         Sheet sheet = wb.getSheetAt(0);
         Cell cellA1 = sheet.getRow(0).getCell(0);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java?rev=1708236&r1=1708235&r2=1708236&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java Mon Oct 12 20:43:42 2015
@@ -17,9 +17,15 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
 
-import junit.framework.TestCase;
+import java.io.IOException;
 
 import org.apache.poi.hssf.usermodel.HSSFCellStyle;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
@@ -36,10 +42,20 @@ import org.apache.poi.xssf.XSSFTestDataS
 import org.apache.poi.xssf.model.StylesTable;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
+import org.junit.Before;
 import org.junit.Test;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellXfs;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STHorizontalAlignment;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignment;
 
-public class TestXSSFCellStyle extends TestCase {
+public class TestXSSFCellStyle {
 	private StylesTable stylesTable;
 	private CTBorder ctBorderA;
 	private CTFill ctFill;
@@ -50,8 +66,8 @@ public class TestXSSFCellStyle extends T
 	private XSSFCellStyle cellStyle;
 	private CTStylesheet ctStylesheet;
 
-	@Override
-	protected void setUp() {
+	@Before
+	public void setUp() {
 		stylesTable = new StylesTable();
 
 		ctStylesheet = stylesTable.getCTStylesheet();
@@ -93,6 +109,7 @@ public class TestXSSFCellStyle extends T
 		assertEquals(STPatternType.INT_DARK_GRAY, stylesTable.getFillAt(1).getCTFill().getPatternFill().getPatternType().intValue());
 	}
 
+	@Test
 	public void testGetSetBorderBottom() {
         //default values
         assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderBottom());
@@ -127,6 +144,7 @@ public class TestXSSFCellStyle extends T
         assertFalse(ctBorder.isSetBottom());
     }
 
+	@Test
     public void testGetSetBorderRight() {
         //default values
         assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderRight());
@@ -161,7 +179,8 @@ public class TestXSSFCellStyle extends T
         assertFalse(ctBorder.isSetRight());
     }
 
-	public void testGetSetBorderLeft() {
+	@Test
+    public void testGetSetBorderLeft() {
         //default values
         assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderLeft());
 
@@ -195,7 +214,8 @@ public class TestXSSFCellStyle extends T
         assertFalse(ctBorder.isSetLeft());
 	}
 
-	public void testGetSetBorderTop() {
+	@Test
+    public void testGetSetBorderTop() {
         //default values
         assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderTop());
 
@@ -229,7 +249,8 @@ public class TestXSSFCellStyle extends T
         assertFalse(ctBorder.isSetTop());
 	}
 
-	public void testGetSetBorderThin() {
+	@Test
+    public void testGetSetBorderThin() {
         cellStyle.setBorderTop(CellStyle.BORDER_THIN);
         assertEquals(CellStyle.BORDER_THIN, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -239,7 +260,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.THIN, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderMedium() {
+	@Test
+    public void testGetSetBorderMedium() {
         cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
         assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -249,7 +271,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderThick() {
+	@Test
+    public void testGetSetBorderThick() {
         cellStyle.setBorderTop(CellStyle.BORDER_THICK);
         assertEquals(CellStyle.BORDER_THICK, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -259,7 +282,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.THICK, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderHair() {
+	@Test
+    public void testGetSetBorderHair() {
         cellStyle.setBorderTop(CellStyle.BORDER_HAIR);
         assertEquals(CellStyle.BORDER_HAIR, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -269,7 +293,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.HAIR, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderDotted() {
+	@Test
+    public void testGetSetBorderDotted() {
         cellStyle.setBorderTop(CellStyle.BORDER_DOTTED);
         assertEquals(CellStyle.BORDER_DOTTED, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -279,7 +304,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.DOTTED, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderDashed() {
+	@Test
+    public void testGetSetBorderDashed() {
         cellStyle.setBorderTop(CellStyle.BORDER_DASHED);
         assertEquals(CellStyle.BORDER_DASHED, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -289,7 +315,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.DASHED, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderDashDot() {
+	@Test
+    public void testGetSetBorderDashDot() {
         cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT);
         assertEquals(CellStyle.BORDER_DASH_DOT, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -299,7 +326,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.DASH_DOT, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderDashDotDot() {
+	@Test
+    public void testGetSetBorderDashDotDot() {
         cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT_DOT);
         assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -309,7 +337,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.DASH_DOT_DOT, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderMediumDashDot() {
+	@Test
+    public void testGetSetBorderMediumDashDot() {
         cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT);
         assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -319,7 +348,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.MEDIUM_DASH_DOT, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderMediumDashDotDot() {
+	@Test
+    public void testGetSetBorderMediumDashDotDot() {
         cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);
         assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -329,7 +359,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.MEDIUM_DASH_DOT_DOT, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderMediumDashed() {
+	@Test
+    public void testGetSetBorderMediumDashed() {
         cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
         assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -339,7 +370,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.MEDIUM_DASHED, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderSlantDashDot() {
+	@Test
+    public void testGetSetBorderSlantDashDot() {
         cellStyle.setBorderTop(CellStyle.BORDER_SLANTED_DASH_DOT);
         assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -349,7 +381,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.SLANT_DASH_DOT, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBorderDouble() {
+	@Test
+    public void testGetSetBorderDouble() {
         cellStyle.setBorderTop(CellStyle.BORDER_DOUBLE);
         assertEquals(CellStyle.BORDER_DOUBLE, cellStyle.getBorderTop());
         int borderId = (int)cellStyle.getCoreXf().getBorderId();
@@ -359,7 +392,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(STBorderStyle.DOUBLE, ctBorder.getTop().getStyle());
 	}
 	
-	public void testGetSetBottomBorderColor() {
+	@Test
+    public void testGetSetBottomBorderColor() {
         //defaults
         assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());
         assertNull(cellStyle.getBottomBorderXSSFColor());
@@ -389,7 +423,7 @@ public class TestXSSFCellStyle extends T
         clr = new XSSFColor(java.awt.Color.CYAN);
         cellStyle.setBottomBorderColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getBottomBorderXSSFColor().getCTColor().toString());
-        byte[] rgb = cellStyle.getBottomBorderXSSFColor().getRgb();
+        byte[] rgb = cellStyle.getBottomBorderXSSFColor().getRGB();
         assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
         //another border was added to the styles table
         assertEquals(num + 1, stylesTable.getBorders().size());
@@ -399,7 +433,8 @@ public class TestXSSFCellStyle extends T
         assertNull(cellStyle.getBottomBorderXSSFColor());
     }
 
-	public void testGetSetTopBorderColor() {
+	@Test
+    public void testGetSetTopBorderColor() {
         //defaults
         assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getTopBorderColor());
         assertNull(cellStyle.getTopBorderXSSFColor());
@@ -429,7 +464,7 @@ public class TestXSSFCellStyle extends T
         clr = new XSSFColor(java.awt.Color.CYAN);
         cellStyle.setTopBorderColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getTopBorderXSSFColor().getCTColor().toString());
-        byte[] rgb = cellStyle.getTopBorderXSSFColor().getRgb();
+        byte[] rgb = cellStyle.getTopBorderXSSFColor().getRGB();
         assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
         //another border was added to the styles table
         assertEquals(num + 1, stylesTable.getBorders().size());
@@ -439,7 +474,8 @@ public class TestXSSFCellStyle extends T
         assertNull(cellStyle.getTopBorderXSSFColor());
 	}
 
-	public void testGetSetLeftBorderColor() {
+	@Test
+    public void testGetSetLeftBorderColor() {
         //defaults
         assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getLeftBorderColor());
         assertNull(cellStyle.getLeftBorderXSSFColor());
@@ -469,7 +505,7 @@ public class TestXSSFCellStyle extends T
         clr = new XSSFColor(java.awt.Color.CYAN);
         cellStyle.setLeftBorderColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getLeftBorderXSSFColor().getCTColor().toString());
-        byte[] rgb = cellStyle.getLeftBorderXSSFColor().getRgb();
+        byte[] rgb = cellStyle.getLeftBorderXSSFColor().getRGB();
         assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
         //another border was added to the styles table
         assertEquals(num + 1, stylesTable.getBorders().size());
@@ -479,7 +515,8 @@ public class TestXSSFCellStyle extends T
         assertNull(cellStyle.getLeftBorderXSSFColor());
 	}
 
-	public void testGetSetRightBorderColor() {
+	@Test
+    public void testGetSetRightBorderColor() {
         //defaults
         assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getRightBorderColor());
         assertNull(cellStyle.getRightBorderXSSFColor());
@@ -509,7 +546,7 @@ public class TestXSSFCellStyle extends T
         clr = new XSSFColor(java.awt.Color.CYAN);
         cellStyle.setRightBorderColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getRightBorderXSSFColor().getCTColor().toString());
-        byte[] rgb = cellStyle.getRightBorderXSSFColor().getRgb();
+        byte[] rgb = cellStyle.getRightBorderXSSFColor().getRGB();
         assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
         //another border was added to the styles table
         assertEquals(num + 1, stylesTable.getBorders().size());
@@ -519,7 +556,8 @@ public class TestXSSFCellStyle extends T
         assertNull(cellStyle.getRightBorderXSSFColor());
 	}
 
-	public void testGetSetFillBackgroundColor() {
+	@Test
+    public void testGetSetFillBackgroundColor() {
 
         assertEquals(IndexedColors.AUTOMATIC.getIndex(), cellStyle.getFillBackgroundColor());
         assertNull(cellStyle.getFillBackgroundXSSFColor());
@@ -541,15 +579,15 @@ public class TestXSSFCellStyle extends T
         int fillId = (int)cellStyle.getCoreXf().getFillId();
         assertTrue(fillId > 0);
         //check changes in the underlying xml bean
-        CTFill ctFill = stylesTable.getFillAt(fillId).getCTFill();
-        assertEquals(IndexedColors.RED.getIndex(), ctFill.getPatternFill().getBgColor().getIndexed());
+        CTFill ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
+        assertEquals(IndexedColors.RED.getIndex(), ctFill2.getPatternFill().getBgColor().getIndexed());
 
         //setting XSSFColor
         num = stylesTable.getFills().size();
         clr = new XSSFColor(java.awt.Color.CYAN);
         cellStyle.setFillBackgroundColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getFillBackgroundXSSFColor().getCTColor().toString());
-        byte[] rgb = cellStyle.getFillBackgroundXSSFColor().getRgb();
+        byte[] rgb = cellStyle.getFillBackgroundXSSFColor().getRGB();
         assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
         //another border was added to the styles table
         assertEquals(num + 1, stylesTable.getFills().size());
@@ -560,7 +598,8 @@ public class TestXSSFCellStyle extends T
         assertEquals(IndexedColors.AUTOMATIC.getIndex(), cellStyle.getFillBackgroundColor());
 	}
 
-	public void testDefaultStyles() throws IOException {
+	@Test
+    public void testDefaultStyles() throws IOException {
 
 		XSSFWorkbook wb1 = new XSSFWorkbook();
 
@@ -569,6 +608,7 @@ public class TestXSSFCellStyle extends T
         assertNull(style1.getFillBackgroundXSSFColor());
 
         assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb1));
+        wb1.close();
 
         //compatibility with HSSF
         HSSFWorkbook wb2 = new HSSFWorkbook();
@@ -589,8 +629,8 @@ public class TestXSSFCellStyle extends T
         wb2.close();
 	}
 
-
-	public void testGetFillForegroundColor() {
+	@Test
+    public void testGetFillForegroundColor() throws IOException {
         XSSFWorkbook wb = new XSSFWorkbook();
         StylesTable styles = wb.getStylesSource();
         assertEquals(1, wb.getNumCellStyles());
@@ -624,9 +664,11 @@ public class TestXSSFCellStyle extends T
         }
 
         assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
+        wb.close();
 	}
 
-	public void testGetFillPattern() {
+	@Test
+    public void testGetFillPattern() {
 
         assertEquals(STPatternType.INT_DARK_GRAY-1, cellStyle.getFillPattern());
 
@@ -637,8 +679,8 @@ public class TestXSSFCellStyle extends T
         int fillId = (int)cellStyle.getCoreXf().getFillId();
         assertTrue(fillId > 0);
         //check changes in the underlying xml bean
-        CTFill ctFill = stylesTable.getFillAt(fillId).getCTFill();
-        assertEquals(STPatternType.SOLID, ctFill.getPatternFill().getPatternType());
+        CTFill ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
+        assertEquals(STPatternType.SOLID, ctFill2.getPatternFill().getPatternType());
 
         //setting the same fill multiple time does not update the styles table
         for (int i = 0; i < 3; i++) {
@@ -649,16 +691,18 @@ public class TestXSSFCellStyle extends T
         cellStyle.setFillPattern(CellStyle.NO_FILL);
         assertEquals(CellStyle.NO_FILL, cellStyle.getFillPattern());
         fillId = (int)cellStyle.getCoreXf().getFillId();
-        ctFill = stylesTable.getFillAt(fillId).getCTFill();
-        assertFalse(ctFill.getPatternFill().isSetPatternType());
+        ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
+        assertFalse(ctFill2.getPatternFill().isSetPatternType());
 
 	}
 
-	public void testGetFont() {
+	@Test
+    public void testGetFont() {
 		assertNotNull(cellStyle.getFont());
 	}
 
-	public void testGetSetHidden() {
+	@Test
+    public void testGetSetHidden() {
 		assertFalse(cellStyle.getHidden());
 		cellStyle.setHidden(true);
 		assertTrue(cellStyle.getHidden());
@@ -666,7 +710,8 @@ public class TestXSSFCellStyle extends T
 		assertFalse(cellStyle.getHidden());
 	}
 
-	public void testGetSetLocked() {
+	@Test
+    public void testGetSetLocked() {
 		assertTrue(cellStyle.getLocked());
 		cellStyle.setLocked(true);
 		assertTrue(cellStyle.getLocked());
@@ -674,7 +719,8 @@ public class TestXSSFCellStyle extends T
 		assertFalse(cellStyle.getLocked());
 	}
 
-	public void testGetSetIndent() {
+	@Test
+    public void testGetSetIndent() {
 		assertEquals((short)0, cellStyle.getIndention());
 		cellStyle.setIndention((short)3);
 		assertEquals((short)3, cellStyle.getIndention());
@@ -682,7 +728,8 @@ public class TestXSSFCellStyle extends T
 		assertEquals((short)13, cellStyle.getIndention());
 	}
 
-	public void testGetSetAlignement() {
+	@Test
+    public void testGetSetAlignement() {
 		assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
 		assertEquals(HorizontalAlignment.GENERAL, cellStyle.getAlignmentEnum());
 
@@ -702,7 +749,8 @@ public class TestXSSFCellStyle extends T
 		assertEquals(STHorizontalAlignment.CENTER, cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
 	}
 
-	public void testGetSetVerticalAlignment() {
+	@Test
+    public void testGetSetVerticalAlignment() {
 		assertEquals(VerticalAlignment.BOTTOM, cellStyle.getVerticalAlignmentEnum());
 		assertEquals(XSSFCellStyle.VERTICAL_BOTTOM, cellStyle.getVerticalAlignment());
 		assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
@@ -718,7 +766,8 @@ public class TestXSSFCellStyle extends T
 		assertEquals(STVerticalAlignment.JUSTIFY, cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
 	}
 
-	public void testGetSetWrapText() {
+	@Test
+    public void testGetSetWrapText() {
 		assertFalse(cellStyle.getWrapText());
 		cellStyle.setWrapText(true);
 		assertTrue(cellStyle.getWrapText());
@@ -729,7 +778,8 @@ public class TestXSSFCellStyle extends T
 	/**
 	 * Cloning one XSSFCellStyle onto Another, same XSSFWorkbook
 	 */
-	public void testCloneStyleSameWB() {
+	@Test
+    public void testCloneStyleSameWB() throws IOException {
       XSSFWorkbook wb = new XSSFWorkbook();
       assertEquals(1, wb.getNumberOfFonts());
       
@@ -757,13 +807,18 @@ public class TestXSSFCellStyle extends T
       assertTrue(18 == clone.getDataFormat());
       assertEquals(2, wb.getNumberOfFonts());
 
-      assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
+      XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb);
+      assertNotNull(wb2);
+      wb2.close();
+      
+      wb.close();
 	}
 
 	/**
 	 * Cloning one XSSFCellStyle onto Another, different XSSFWorkbooks
 	 */
-	public void testCloneStyleDiffWB() {
+	@Test
+    public void testCloneStyleDiffWB() throws IOException {
        XSSFWorkbook wbOrig = new XSSFWorkbook();
        assertEquals(1, wbOrig.getNumberOfFonts());
        assertEquals(0, wbOrig.getStylesSource().getNumberFormats().size());
@@ -803,7 +858,7 @@ public class TestXSSFCellStyle extends T
        assertEquals(0, wbClone.getStylesSource().getNumberFormats().size());
        
        assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment());
-       assertFalse("TestingFont" == clone.getFont().getFontName());
+       assertNotEquals("TestingFont", clone.getFont().getFontName());
        
        clone.cloneStyleFrom(orig);
        
@@ -828,15 +883,25 @@ public class TestXSSFCellStyle extends T
        assertEquals(fmtClone.getFormat("Test##"), reload.getDataFormat());
        assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));
 
-       assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbOrig));
-       assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbClone));
+       XSSFWorkbook wbOrig2 = XSSFTestDataSamples.writeOutAndReadBack(wbOrig);
+       assertNotNull(wbOrig2);
+       wbOrig2.close();
+       
+       XSSFWorkbook wbClone2 = XSSFTestDataSamples.writeOutAndReadBack(wbClone);
+       assertNotNull(wbClone2);
+       wbClone2.close();
+       
+       wbReload.close();
+       wbClone.close();
+       wbOrig.close();
    }
 
     /**
      * Avoid ArrayIndexOutOfBoundsException  when creating cell style
      * in a workbook that has an empty xf table.
      */
-    public void testBug52348() {
+	@Test
+    public void testBug52348() throws IOException {
         XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
         StylesTable st = workbook.getStylesSource();
         assertEquals(0, st._getStyleXfsSize());
@@ -844,14 +909,18 @@ public class TestXSSFCellStyle extends T
         XSSFCellStyle style = workbook.createCellStyle(); // no exception at this point
         assertNull(style.getStyleXf());
 
-        assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(workbook));
+        XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+        assertNotNull(wb2);
+        wb2.close();
+        workbook.close();
     }
 
     /**
      * Avoid ArrayIndexOutOfBoundsException  when getting cell style
      * in a workbook that has an empty xf table.
      */
-    public void testBug55650() {
+	@Test
+    public void testBug55650() throws IOException {
         XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
         StylesTable st = workbook.getStylesSource();
         assertEquals(0, st._getStyleXfsSize());
@@ -860,40 +929,55 @@ public class TestXSSFCellStyle extends T
         XSSFCellStyle style = workbook.getSheetAt(0).getRow(0).getCell(0).getCellStyle();
         assertNull(style.getStyleXf());
 
-        assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(workbook));
+        XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+        assertNotNull(wb2);
+        wb2.close();
+        
+        workbook.close();
     }
 
-    public void testShrinkToFit() {
+	@Test
+    public void testShrinkToFit() throws IOException {
     	// Existing file
-    	XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("ShrinkToFit.xlsx");
-    	Sheet s = wb.getSheetAt(0);
+    	XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("ShrinkToFit.xlsx");
+    	Sheet s = wb1.getSheetAt(0);
     	Row r = s.getRow(0);
     	CellStyle cs = r.getCell(0).getCellStyle();
 
     	assertEquals(true, cs.getShrinkToFit());
 
     	// New file
-    	XSSFWorkbook wbOrig = new XSSFWorkbook();
-    	s = wbOrig.createSheet();
+    	XSSFWorkbook wb2 = new XSSFWorkbook();
+    	s = wb2.createSheet();
     	r = s.createRow(0);
 
-    	cs = wbOrig.createCellStyle();
+    	cs = wb2.createCellStyle();
     	cs.setShrinkToFit(false);
     	r.createCell(0).setCellStyle(cs);
 
-    	cs = wbOrig.createCellStyle();
+    	cs = wb2.createCellStyle();
     	cs.setShrinkToFit(true);
     	r.createCell(1).setCellStyle(cs);
 
     	// Write out, read, and check
-    	wb = XSSFTestDataSamples.writeOutAndReadBack(wbOrig);
-    	s = wb.getSheetAt(0);
+    	XSSFWorkbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
+    	s = wb3.getSheetAt(0);
     	r = s.getRow(0);
     	assertEquals(false, r.getCell(0).getCellStyle().getShrinkToFit());
     	assertEquals(true,  r.getCell(1).getCellStyle().getShrinkToFit());
 
-        assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
-        assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbOrig));
+    	XSSFWorkbook wb4 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
+    	assertNotNull(wb4);
+    	wb4.close();
+    	
+    	XSSFWorkbook wb5 = XSSFTestDataSamples.writeOutAndReadBack(wb3);
+    	assertNotNull(wb5);
+    	wb5.close();
+    	
+    	wb3.close();
+    	wb2.close();
+    	wb1.close();
+        
     }
     
     @Test
@@ -902,31 +986,23 @@ public class TestXSSFCellStyle extends T
         Sheet sheet = wb.createSheet();
         Row row = sheet.createRow(0);
         
-        //CreationHelper ch = wb.getCreationHelper();
         DataFormat format = wb.createDataFormat();
         Cell cell = row.createCell(1);
         cell.setCellValue("somevalue");
-        CellStyle cellStyle = wb.createCellStyle();
+        CellStyle cellStyle2 = wb.createCellStyle();
 
 
-        cellStyle.setDataFormat(format.getFormat("###0"));
+        cellStyle2.setDataFormat(format.getFormat("###0"));
 
-        cellStyle.setFillBackgroundColor(IndexedColors.DARK_BLUE.getIndex());
-        cellStyle.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
-        cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
+        cellStyle2.setFillBackgroundColor(IndexedColors.DARK_BLUE.getIndex());
+        cellStyle2.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
+        cellStyle2.setFillPattern(CellStyle.SOLID_FOREGROUND);
 
-        cellStyle.setAlignment(CellStyle.ALIGN_RIGHT);
-        cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP);
+        cellStyle2.setAlignment(CellStyle.ALIGN_RIGHT);
+        cellStyle2.setVerticalAlignment(CellStyle.VERTICAL_TOP);
 
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyle2);
 
-        /*OutputStream stream = new FileOutputStream("C:\\temp\\CellColor.xlsx");
-        try {
-            wb.write(stream);
-        } finally {
-            stream.close();
-        }*/
-        
         Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
         Cell cellBack = wbBack.getSheetAt(0).getRow(0).getCell(1);
         assertNotNull(cellBack);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java?rev=1708236&r1=1708235&r2=1708236&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java Mon Oct 12 20:43:42 2015
@@ -17,11 +17,16 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
 
 import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.junit.Test;
 
-public final class TestXSSFColor extends TestCase {
+public final class TestXSSFColor {
+    
+   @Test
    public void testIndexedColour() throws Exception {
       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
 
@@ -35,8 +40,8 @@ public final class TestXSSFColor extends
       // Now check the XSSFColor
       // Note - 64 is a special "auto" one with no rgb equiv
       assertEquals(64, indexed.getIndexed());
-      assertEquals(null, indexed.getRgb());
-      assertEquals(null, indexed.getRgbWithTint());
+      assertEquals(null, indexed.getRGB());
+      assertEquals(null, indexed.getRGBWithTint());
       assertEquals(null, indexed.getARGBHex());
 
       // Now move to one with indexed rgb values
@@ -49,22 +54,25 @@ public final class TestXSSFColor extends
       assertEquals(59, indexed.getIndexed());
       assertEquals("FF333300", indexed.getARGBHex());
 
-      assertEquals(3, indexed.getRgb().length);
-      assertEquals(0x33, indexed.getRgb()[0]);
-      assertEquals(0x33, indexed.getRgb()[1]);
-      assertEquals(0x00, indexed.getRgb()[2]);
-
-      assertEquals(4, indexed.getARgb().length);
-      assertEquals(-1, indexed.getARgb()[0]);
-      assertEquals(0x33, indexed.getARgb()[1]);
-      assertEquals(0x33, indexed.getARgb()[2]);
-      assertEquals(0x00, indexed.getARgb()[3]);
+      assertEquals(3, indexed.getRGB().length);
+      assertEquals(0x33, indexed.getRGB()[0]);
+      assertEquals(0x33, indexed.getRGB()[1]);
+      assertEquals(0x00, indexed.getRGB()[2]);
+
+      assertEquals(4, indexed.getARGB().length);
+      assertEquals(-1, indexed.getARGB()[0]);
+      assertEquals(0x33, indexed.getARGB()[1]);
+      assertEquals(0x33, indexed.getARGB()[2]);
+      assertEquals(0x00, indexed.getARGB()[3]);
 
       // You don't get tinted indexed colours, sorry...
-      assertEquals(null, indexed.getRgbWithTint());
+      assertEquals(null, indexed.getRGBWithTint());
+      
+      wb.close();
    }
 
-   public void testRGBColour() throws Exception {
+   @Test
+   public void testRGBColour() throws IOException {
       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50299.xlsx");
 
       // Check the CTColor is as expected
@@ -81,42 +89,45 @@ public final class TestXSSFColor extends
       assertEquals(-0.34999, rgb3.getTint(), 0.00001);
 
       assertEquals("FFFFFFFF", rgb3.getARGBHex());
-      assertEquals(3, rgb3.getRgb().length);
-      assertEquals(-1, rgb3.getRgb()[0]);
-      assertEquals(-1, rgb3.getRgb()[1]);
-      assertEquals(-1,  rgb3.getRgb()[2]);
-
-      assertEquals(4, rgb3.getARgb().length);
-      assertEquals(-1, rgb3.getARgb()[0]);
-      assertEquals(-1, rgb3.getARgb()[1]);
-      assertEquals(-1,  rgb3.getARgb()[2]);
-      assertEquals(-1,  rgb3.getARgb()[3]);
+      assertEquals(3, rgb3.getRGB().length);
+      assertEquals(-1, rgb3.getRGB()[0]);
+      assertEquals(-1, rgb3.getRGB()[1]);
+      assertEquals(-1,  rgb3.getRGB()[2]);
+
+      assertEquals(4, rgb3.getARGB().length);
+      assertEquals(-1, rgb3.getARGB()[0]);
+      assertEquals(-1, rgb3.getARGB()[1]);
+      assertEquals(-1,  rgb3.getARGB()[2]);
+      assertEquals(-1,  rgb3.getARGB()[3]);
 
       // Tint doesn't have the alpha
       // tint = -0.34999
       // 255 * (1 + tint) = 165 truncated
       // or (byte) -91 (which is 165 - 256)
-      assertEquals(3, rgb3.getRgbWithTint().length);
-      assertEquals(-91, rgb3.getRgbWithTint()[0]);
-      assertEquals(-91,  rgb3.getRgbWithTint()[1]);
-      assertEquals(-91,  rgb3.getRgbWithTint()[2]);
+      assertEquals(3, rgb3.getRGBWithTint().length);
+      assertEquals(-91, rgb3.getRGBWithTint()[0]);
+      assertEquals(-91,  rgb3.getRGBWithTint()[1]);
+      assertEquals(-91,  rgb3.getRGBWithTint()[2]);
 
       // Set the color to black (no theme).
-      rgb3.setRgb(new byte[] {0, 0, 0});
+      rgb3.setRGB(new byte[] {0, 0, 0});
       assertEquals("FF000000", rgb3.getARGBHex());
       assertEquals(0, rgb3.getCTColor().getRgb()[0]);
       assertEquals(0, rgb3.getCTColor().getRgb()[1]);
       assertEquals(0, rgb3.getCTColor().getRgb()[2]);
 
       // Set another, is fine
-      rgb3.setRgb(new byte[] {16,17,18});
+      rgb3.setRGB(new byte[] {16,17,18});
       assertEquals("FF101112", rgb3.getARGBHex());
       assertEquals(0x10, rgb3.getCTColor().getRgb()[0]);
       assertEquals(0x11, rgb3.getCTColor().getRgb()[1]);
       assertEquals(0x12, rgb3.getCTColor().getRgb()[2]);
+      
+      wb.close();
    }
 
-   public void testARGBColour() throws Exception {
+   @Test
+   public void testARGBColour() throws IOException {
       XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
 
       // Check the CTColor is as expected
@@ -128,35 +139,37 @@ public final class TestXSSFColor extends
 
       // Now check the XSSFColor
       assertEquals(0, rgb4.getIndexed());
-      assertEquals(0.0, rgb4.getTint());
+      assertEquals(0.0, rgb4.getTint(), 0);
 
       assertEquals("FFFF0000", rgb4.getARGBHex());
-      assertEquals(3, rgb4.getRgb().length);
-      assertEquals(-1, rgb4.getRgb()[0]);
-      assertEquals(0,  rgb4.getRgb()[1]);
-      assertEquals(0,  rgb4.getRgb()[2]);
-
-      assertEquals(4, rgb4.getARgb().length);
-      assertEquals(-1, rgb4.getARgb()[0]);
-      assertEquals(-1, rgb4.getARgb()[1]);
-      assertEquals(0,  rgb4.getARgb()[2]);
-      assertEquals(0,  rgb4.getARgb()[3]);
+      assertEquals(3, rgb4.getRGB().length);
+      assertEquals(-1, rgb4.getRGB()[0]);
+      assertEquals(0,  rgb4.getRGB()[1]);
+      assertEquals(0,  rgb4.getRGB()[2]);
+
+      assertEquals(4, rgb4.getARGB().length);
+      assertEquals(-1, rgb4.getARGB()[0]);
+      assertEquals(-1, rgb4.getARGB()[1]);
+      assertEquals(0,  rgb4.getARGB()[2]);
+      assertEquals(0,  rgb4.getARGB()[3]);
 
       // Tint doesn't have the alpha
-      assertEquals(3, rgb4.getRgbWithTint().length);
-      assertEquals(-1, rgb4.getRgbWithTint()[0]);
-      assertEquals(0,  rgb4.getRgbWithTint()[1]);
-      assertEquals(0,  rgb4.getRgbWithTint()[2]);
+      assertEquals(3, rgb4.getRGBWithTint().length);
+      assertEquals(-1, rgb4.getRGBWithTint()[0]);
+      assertEquals(0,  rgb4.getRGBWithTint()[1]);
+      assertEquals(0,  rgb4.getRGBWithTint()[2]);
 
 
       // Turn on tinting, and check it behaves
       // TODO These values are suspected to be wrong...
       rgb4.setTint(0.4);
-      assertEquals(0.4, rgb4.getTint());
+      assertEquals(0.4, rgb4.getTint(), 0);
 
-      assertEquals(3, rgb4.getRgbWithTint().length);
-      assertEquals(-1, rgb4.getRgbWithTint()[0]);
-      assertEquals(102,  rgb4.getRgbWithTint()[1]);
-      assertEquals(102,  rgb4.getRgbWithTint()[2]);
+      assertEquals(3, rgb4.getRGBWithTint().length);
+      assertEquals(-1, rgb4.getRGBWithTint()[0]);
+      assertEquals(102,  rgb4.getRGBWithTint()[1]);
+      assertEquals(102,  rgb4.getRGBWithTint()[2]);
+      
+      wb.close();
    }
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java?rev=1708236&r1=1708235&r2=1708236&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java Mon Oct 12 20:43:42 2015
@@ -18,20 +18,26 @@
 package org.apache.poi.xssf.usermodel.extensions;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.apache.poi.ss.usermodel.FillPatternType;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFColor;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
 
-import junit.framework.TestCase;
-
 
-public class TestXSSFCellFill extends TestCase {
+public class TestXSSFCellFill {
 
+    @Test
     public void testGetFillBackgroundColor() {
         CTFill ctFill = CTFill.Factory.newInstance();
         XSSFCellFill cellFill = new XSSFCellFill(ctFill);
@@ -42,6 +48,7 @@ public class TestXSSFCellFill extends Te
         assertEquals(2, cellFill.getFillBackgroundColor().getIndexed());
     }
 
+    @Test
     public void testGetFillForegroundColor() {
         CTFill ctFill = CTFill.Factory.newInstance();
         XSSFCellFill cellFill = new XSSFCellFill(ctFill);
@@ -52,14 +59,16 @@ public class TestXSSFCellFill extends Te
         assertEquals(8, cellFill.getFillForegroundColor().getIndexed());
     }
 
+    @Test
     public void testGetSetPatternType() {
         CTFill ctFill = CTFill.Factory.newInstance();
         XSSFCellFill cellFill = new XSSFCellFill(ctFill);
         CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
         ctPatternFill.setPatternType(STPatternType.SOLID);
-        //assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().ordinal());
+        assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().intValue()-1);
     }
 
+    @Test
     public void testGetNotModifies() {
         CTFill ctFill = CTFill.Factory.newInstance();
         XSSFCellFill cellFill = new XSSFCellFill(ctFill);
@@ -68,13 +77,14 @@ public class TestXSSFCellFill extends Te
         assertEquals(8, cellFill.getPatternType().intValue());
     }
 
-    public void testColorFromTheme() {
+    @Test
+    public void testColorFromTheme() throws IOException {
         XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("styles.xlsx");
         XSSFCell cellWithThemeColor = wb.getSheetAt(0).getRow(10).getCell(0);
         //color RGB will be extracted from theme
         XSSFColor foregroundColor = cellWithThemeColor.getCellStyle().getFillForegroundXSSFColor();
-        byte[] rgb = foregroundColor.getRgb();
-        byte[] rgbWithTint = foregroundColor.getRgbWithTint();
+        byte[] rgb = foregroundColor.getRGB();
+        byte[] rgbWithTint = foregroundColor.getRGBWithTint();
         // Dk2
         assertEquals(rgb[0],31);
         assertEquals(rgb[1],73);
@@ -86,5 +96,6 @@ public class TestXSSFCellFill extends Te
         assertEquals(rgbWithTint[0],120);
         assertEquals(rgbWithTint[1],-111);
         assertEquals(rgbWithTint[2],-80);
+        wb.close();
     }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java?rev=1708236&r1=1708235&r2=1708236&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/extractor/Word6Extractor.java Mon Oct 12 20:43:42 2015
@@ -104,8 +104,8 @@ public final class Word6Extractor extend
 	            ret[i] = doc.getTextTable().getTextPieces().get(i).getStringBuilder().toString();
 	            
 	            // Fix the line endings
-	            ret[i].replaceAll("\r", "\ufffe");
-                ret[i].replaceAll("\ufffe","\r\n");
+	            ret[i] = ret[i].replaceAll("\r", "\ufffe");
+	            ret[i] = ret[i].replaceAll("\ufffe","\r\n");
 	        }
 	    }
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java?rev=1708236&r1=1708235&r2=1708236&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics.java Mon Oct 12 20:43:42 2015
@@ -17,11 +17,20 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import junit.framework.TestCase;
-
-import java.awt.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Tests the capabilities of the EscherGraphics class.
@@ -29,55 +38,62 @@ import java.io.ByteArrayOutputStream;
  * All tests have two escher groups available to them,
  *  one anchored at 0,0,1022,255 and another anchored
  *  at 20,30,500,200
- *
- * @author Glen Stampoultzis (glens at apache.org)
  */
-public final class TestEscherGraphics extends TestCase {
+public final class TestEscherGraphics {
 	private HSSFWorkbook workbook;
 	private HSSFPatriarch patriarch;
     private HSSFShapeGroup escherGroupA;
-    private HSSFShapeGroup escherGroupB;
     private EscherGraphics graphics;
 
-    protected void setUp() throws Exception
-    {
+    @Before
+    public void setUp() throws IOException {
         workbook = new HSSFWorkbook();
 
         HSSFSheet sheet = workbook.createSheet("test");
         patriarch = sheet.createDrawingPatriarch();
         escherGroupA = patriarch.createGroup(new HSSFClientAnchor(0,0,1022,255,(short)0,0,(short) 0,0));
-        escherGroupB = patriarch.createGroup(new HSSFClientAnchor(20,30,500,200,(short)0,0,(short) 0,0));
-//        escherGroup = new HSSFShapeGroup(null, new HSSFChildAnchor());
-        graphics = new EscherGraphics(this.escherGroupA, workbook, Color.black, 1.0f);
-        super.setUp();
+        patriarch.createGroup(new HSSFClientAnchor(20,30,500,200,(short)0,0,(short) 0,0));
+        graphics = new EscherGraphics(escherGroupA, workbook, Color.black, 1.0f);
+    }
+    
+    @After
+    public void closeResources() throws IOException {
+        workbook.close();
     }
 
+    @Test
     public void testGetFont() {
         Font f = graphics.getFont();
-        if (f.toString().indexOf("dialog") == -1 && f.toString().indexOf("Dialog") == -1)
+        if (f.toString().indexOf("dialog") == -1 && f.toString().indexOf("Dialog") == -1) {
             assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
+        }
     }
 
+    @Test
     public void testGetFontMetrics() {
         Font f = graphics.getFont();
-        if (f.toString().indexOf("dialog") != -1 || f.toString().indexOf("Dialog") != -1)
+        if (f.toString().indexOf("dialog") != -1 || f.toString().indexOf("Dialog") != -1) {
             return;
+        }
         FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
         assertEquals(7, fontMetrics.charWidth('X'));
         assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString());
     }
 
+    @Test
     public void testSetFont() {
         Font f = new Font("Helvetica", 0, 12);
         graphics.setFont(f);
         assertEquals(f, graphics.getFont());
     }
 
+    @Test
     public void testSetColor() {
         graphics.setColor(Color.red);
         assertEquals(Color.red, graphics.getColor());
     }
 
+    @Test
     public void testFillRect() {
         graphics.fillRect( 10, 10, 20, 20 );
         HSSFSimpleShape s = (HSSFSimpleShape) escherGroupA.getChildren().get(0);
@@ -88,12 +104,14 @@ public final class TestEscherGraphics ex
         assertEquals(30, s.getAnchor().getDx2());
     }
 
+    @Test
     public void testDrawString() {
         graphics.drawString("This is a test", 10, 10);
         HSSFTextbox t = (HSSFTextbox) escherGroupA.getChildren().get(0);
         assertEquals("This is a test", t.getString().getString());
     }
 
+    @Test
     public void testGetDataBackAgain() throws Exception {
     	HSSFSheet s;
     	HSSFShapeGroup s1;
@@ -284,6 +302,6 @@ public final class TestEscherGraphics ex
     	assertEquals(200, s2.getAnchor().getDy2());
 
     	// Not working just yet
-    	//assertEquals("I am text box 1", tbox1.getString().getString());
+    	assertEquals("I am text box 1", tbox1.getString().getString());
     }
 }

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java?rev=1708236&r1=1708235&r2=1708236&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestEscherGraphics2d.java Mon Oct 12 20:43:42 2015
@@ -17,30 +17,44 @@
 
 package org.apache.poi.hssf.usermodel;
 
-import junit.framework.TestCase;
-
-import java.awt.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
 import java.awt.geom.Line2D;
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
 
 /**
  * Tests the Graphics2d drawing capability.
- *
- * @author Glen Stampoultzis (glens at apache.org)
  */
-public final class TestEscherGraphics2d extends TestCase {
+public final class TestEscherGraphics2d {
+    private HSSFWorkbook workbook;
 	private HSSFShapeGroup escherGroup;
 	private EscherGraphics2d graphics;
 
-	@Override
-    protected void setUp() {
-		HSSFWorkbook workbook = new HSSFWorkbook();
+	@Before
+    public void setUp() {
+		workbook = new HSSFWorkbook();
 		HSSFSheet sheet = workbook.createSheet("test");
 		escherGroup = sheet.createDrawingPatriarch().createGroup(new HSSFClientAnchor(0,0,1023,255,(short)0,0,(short) 0,0));
 		escherGroup = new HSSFShapeGroup(null, new HSSFChildAnchor());
-		EscherGraphics g = new EscherGraphics(this.escherGroup, workbook, Color.black, 1.0f);
+		EscherGraphics g = new EscherGraphics(escherGroup, workbook, Color.black, 1.0f);
 		graphics = new EscherGraphics2d(g);
 	}
+	
+	@After
+	public void closeResources() throws IOException {
+	    workbook.close();
+	}
 
+	@Test
 	public void testDrawString() {
 		graphics.drawString("This is a test", 10, 10);
 		HSSFTextbox t = (HSSFTextbox) escherGroup.getChildren().get(0);
@@ -71,7 +85,8 @@ public final class TestEscherGraphics2d
 		}
 	}
 
-	public void testFillRect() {
+	@Test
+    public void testFillRect() {
 		graphics.fillRect( 10, 10, 20, 20 );
 		HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0);
 		assertEquals(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE, s.getShapeType());
@@ -81,29 +96,37 @@ public final class TestEscherGraphics2d
 		assertEquals(30, s.getAnchor().getDx2());
 	}
 
-	public void testGetFontMetrics() {
+	@Test
+    public void testGetFontMetrics() {
 		FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
-		if (isDialogPresent()) // if dialog is returned we can't run the test properly.
+		if (isDialogPresent()) {
+		    // if dialog is returned we can't run the test properly.
 			return;
+		}
 		assertEquals(7, fontMetrics.charWidth('X'));
 		assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString());
 	}
 
-	public void testSetFont() {
+	@Test
+    public void testSetFont() {
 		Font f = new Font("Helvetica", 0, 12);
 		graphics.setFont(f);
 		assertEquals(f, graphics.getFont());
 	}
 
-	public void testSetColor() {
+	@Test
+    public void testSetColor() {
 		graphics.setColor(Color.red);
 		assertEquals(Color.red, graphics.getColor());
 	}
 
-	public void testGetFont() {
+	@Test
+    public void testGetFont() {
 		Font f = graphics.getFont();
-		if (isDialogPresent()) // if dialog is returned we can't run the test properly.
+		if (isDialogPresent()) {
+		    // if dialog is returned we can't run the test properly.
 			return;
+        }
 
 		assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
 	}
@@ -113,7 +136,8 @@ public final class TestEscherGraphics2d
 		return fontDebugStr.indexOf("dialog") != -1 || fontDebugStr.indexOf("Dialog") != -1;
 	}
 
-	public void testDraw() {
+	@Test
+    public void testDraw() {
 		graphics.draw(new Line2D.Double(10,10,20,20));
 		HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0);
 		assertTrue(s.getShapeType() == HSSFSimpleShape.OBJECT_TYPE_LINE);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org