Return-Path: X-Original-To: apmail-poi-commits-archive@minotaur.apache.org Delivered-To: apmail-poi-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BA5CA901F for ; Mon, 22 Dec 2014 09:16:17 +0000 (UTC) Received: (qmail 83671 invoked by uid 500); 22 Dec 2014 09:16:17 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 83633 invoked by uid 500); 22 Dec 2014 09:16:17 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 83623 invoked by uid 99); 22 Dec 2014 09:16:17 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Dec 2014 09:16:17 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 5A999AC092E; Mon, 22 Dec 2014 09:16:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1647269 - in /poi/trunk/src: java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java testcases/org/apache/poi/ss/format/TestCellFormat.java Date: Mon, 22 Dec 2014 09:16:17 -0000 To: commits@poi.apache.org From: centic@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20141222091617.5A999AC092E@hades.apache.org> Author: centic Date: Mon Dec 22 09:16:16 2014 New Revision: 1647269 URL: http://svn.apache.org/r1647269 Log: Some Eclipse warnings Modified: poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java Modified: poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java?rev=1647269&r1=1647268&r2=1647269&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java Mon Dec 22 09:16:16 2014 @@ -96,7 +96,7 @@ final class OperationEvaluatorFactory { private static void put(Map m, OperationPtg ptgKey, Function instance) { // make sure ptg has single private constructor because map lookups assume singleton keys - Constructor[] cc = ptgKey.getClass().getDeclaredConstructors(); + Constructor[] cc = ptgKey.getClass().getDeclaredConstructors(); if (cc.length > 1 || !Modifier.isPrivate(cc[0].getModifiers())) { throw new RuntimeException("Failed to verify instance (" + ptgKey.getClass().getName() + ") is a singleton."); Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java?rev=1647269&r1=1647268&r2=1647269&view=diff ============================================================================== --- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java (original) +++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java Mon Dec 22 09:16:16 2014 @@ -118,38 +118,42 @@ public final class TestXSSFCell extends assertEquals(XSSFCell.CELL_TYPE_BLANK, cell_1.getCellType()); } - public void testFormulaString() { + public void testFormulaString() throws IOException { XSSFWorkbook wb = new XSSFWorkbook(); - XSSFCell cell = wb.createSheet().createRow(0).createCell(0); - CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml - - cell.setCellFormula("A2"); - assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType()); - assertEquals("A2", cell.getCellFormula()); - //the value is not set and cell's type='N' which means blank - assertEquals(STCellType.N, ctCell.getT()); - - //set cached formula value - cell.setCellValue("t='str'"); - //we are still of 'formula' type - assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType()); - assertEquals("A2", cell.getCellFormula()); - //cached formula value is set and cell's type='STR' - assertEquals(STCellType.STR, ctCell.getT()); - assertEquals("t='str'", cell.getStringCellValue()); - - //now remove the formula, the cached formula result remains - cell.setCellFormula(null); - assertEquals(XSSFCell.CELL_TYPE_STRING, cell.getCellType()); - assertEquals(STCellType.STR, ctCell.getT()); - //the line below failed prior to fix of Bug #47889 - assertEquals("t='str'", cell.getStringCellValue()); - - //revert to a blank cell - cell.setCellValue((String)null); - assertEquals(XSSFCell.CELL_TYPE_BLANK, cell.getCellType()); - assertEquals(STCellType.N, ctCell.getT()); - assertEquals("", cell.getStringCellValue()); + try { + XSSFCell cell = wb.createSheet().createRow(0).createCell(0); + CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml + + cell.setCellFormula("A2"); + assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("A2", cell.getCellFormula()); + //the value is not set and cell's type='N' which means blank + assertEquals(STCellType.N, ctCell.getT()); + + //set cached formula value + cell.setCellValue("t='str'"); + //we are still of 'formula' type + assertEquals(XSSFCell.CELL_TYPE_FORMULA, cell.getCellType()); + assertEquals("A2", cell.getCellFormula()); + //cached formula value is set and cell's type='STR' + assertEquals(STCellType.STR, ctCell.getT()); + assertEquals("t='str'", cell.getStringCellValue()); + + //now remove the formula, the cached formula result remains + cell.setCellFormula(null); + assertEquals(XSSFCell.CELL_TYPE_STRING, cell.getCellType()); + assertEquals(STCellType.STR, ctCell.getT()); + //the line below failed prior to fix of Bug #47889 + assertEquals("t='str'", cell.getStringCellValue()); + + //revert to a blank cell + cell.setCellValue((String)null); + assertEquals(XSSFCell.CELL_TYPE_BLANK, cell.getCellType()); + assertEquals(STCellType.N, ctCell.getT()); + assertEquals("", cell.getStringCellValue()); + } finally { + wb.close(); + } } /** @@ -183,15 +187,20 @@ public final class TestXSSFCell extends /** * Cell with the formula that returns error must return error code(There was * an problem that cell could not return error value form formula cell). + * @throws IOException */ - public void testGetErrorCellValueFromFormulaCell() { + public void testGetErrorCellValueFromFormulaCell() throws IOException { XSSFWorkbook wb = new XSSFWorkbook(); - XSSFSheet sheet = wb.createSheet(); - XSSFRow row = sheet.createRow(0); - XSSFCell cell = row.createCell(0); - cell.setCellFormula("SQRT(-1)"); - wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(cell); - assertEquals(36, cell.getErrorCellValue()); + try { + XSSFSheet sheet = wb.createSheet(); + XSSFRow row = sheet.createRow(0); + XSSFCell cell = row.createCell(0); + cell.setCellFormula("SQRT(-1)"); + wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(cell); + assertEquals(36, cell.getErrorCellValue()); + } finally { + wb.close(); + } } public void testMissingRAttribute() { @@ -214,8 +223,8 @@ public final class TestXSSFCell extends assertCellsWithMissingR(row); - wb = (XSSFWorkbook)_testDataProvider.writeOutAndReadBack(wb); - row = wb.getSheetAt(0).getRow(0); + XSSFWorkbook wbNew = (XSSFWorkbook)_testDataProvider.writeOutAndReadBack(wb); + row = wbNew.getSheetAt(0).getRow(0); assertCellsWithMissingR(row); } @@ -335,33 +344,37 @@ public final class TestXSSFCell extends public void test56170Reproduce() throws IOException { final Workbook wb = new XSSFWorkbook(); - final Sheet sheet = wb.createSheet(); - Row row = sheet.createRow(0); - - // by creating Cells out of order we trigger the handling in onDocumentWrite() - Cell cell1 = row.createCell(1); - Cell cell2 = row.createCell(0); - - validateRow(row); - - validateRow(row); - - // once again with removing one cell - row.removeCell(cell1); - - validateRow(row); - - // once again with removing one cell - row.removeCell(cell1); - - // now check again - validateRow(row); - - // once again with removing one cell - row.removeCell(cell2); - - // now check again - validateRow(row); + try { + final Sheet sheet = wb.createSheet(); + Row row = sheet.createRow(0); + + // by creating Cells out of order we trigger the handling in onDocumentWrite() + Cell cell1 = row.createCell(1); + Cell cell2 = row.createCell(0); + + validateRow(row); + + validateRow(row); + + // once again with removing one cell + row.removeCell(cell1); + + validateRow(row); + + // once again with removing one cell + row.removeCell(cell1); + + // now check again + validateRow(row); + + // once again with removing one cell + row.removeCell(cell2); + + // now check again + validateRow(row); + } finally { + wb.close(); + } } private void validateRow(Row row) { Modified: poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java?rev=1647269&r1=1647268&r2=1647269&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java (original) +++ poi/trunk/src/testcases/org/apache/poi/ss/format/TestCellFormat.java Mon Dec 22 09:16:16 2014 @@ -16,11 +16,14 @@ ==================================================================== */ package org.apache.poi.ss.format; +import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; -import javax.swing.*; +import javax.swing.JLabel; + +import junit.framework.TestCase; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; @@ -29,8 +32,6 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; -import junit.framework.TestCase; - public class TestCellFormat extends TestCase { private static final String _255_POUND_SIGNS; @@ -825,15 +826,19 @@ public class TestCellFormat extends Test } - public void testSimpleFractionFormat() { + public void testSimpleFractionFormat() throws IOException { CellFormat cf1 = CellFormat.getInstance("# ?/?"); // Create a workbook, row and cell to test with Workbook wb = new HSSFWorkbook(); - Sheet sheet = wb.createSheet(); - Row row = sheet.createRow(0); - Cell cell = row.createCell(0); - cell.setCellValue(123456.6); - System.out.println(cf1.apply(cell).text); - assertEquals("123456 3/5", cf1.apply(cell).text); + try { + Sheet sheet = wb.createSheet(); + Row row = sheet.createRow(0); + Cell cell = row.createCell(0); + cell.setCellValue(123456.6); + System.out.println(cf1.apply(cell).text); + assertEquals("123456 3/5", cf1.apply(cell).text); + } finally { + wb.close(); + } } } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org