Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 873B12009F3 for ; Sat, 21 May 2016 00:05:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 85D32160A2A; Fri, 20 May 2016 22:05:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id A4C70160A25 for ; Sat, 21 May 2016 00:05:06 +0200 (CEST) Received: (qmail 60154 invoked by uid 500); 20 May 2016 22:05:05 -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 60144 invoked by uid 99); 20 May 2016 22:05:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 May 2016 22:05:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 74D74C9325 for ; Fri, 20 May 2016 22:05:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.374 X-Spam-Level: X-Spam-Status: No, score=0.374 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id MuY9PeAlzdeq for ; Fri, 20 May 2016 22:05:04 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id A76A25F4EC for ; Fri, 20 May 2016 22:05:03 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 6E5CDE006A for ; Fri, 20 May 2016 22:05:02 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 923EC3A0113 for ; Fri, 20 May 2016 22:05:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1744802 - in /poi/trunk/src: java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java Date: Fri, 20 May 2016 22:05:01 -0000 To: commits@poi.apache.org From: kiwiwings@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160520220501.923EC3A0113@svn01-us-west.apache.org> archived-at: Fri, 20 May 2016 22:05:07 -0000 Author: kiwiwings Date: Fri May 20 22:05:00 2016 New Revision: 1744802 URL: http://svn.apache.org/viewvc?rev=1744802&view=rev Log: findbugs fixes Modified: poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java Modified: poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java?rev=1744802&r1=1744801&r2=1744802&view=diff ============================================================================== --- poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java (original) +++ poi/trunk/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java Fri May 20 22:05:00 2016 @@ -34,8 +34,6 @@ import org.apache.poi.ss.usermodel.Workb * Represents a workbook being used for forked evaluation. Most operations are delegated to the * shared master workbook, except those that potentially involve cell values that may have been * updated after a call to {@link #getOrCreateUpdatableCell(String, int, int)}. - * - * @author Josh Micich */ final class ForkedEvaluationWorkbook implements EvaluationWorkbook { @@ -69,15 +67,9 @@ final class ForkedEvaluationWorkbook imp } public void copyUpdatedCells(Workbook workbook) { - String[] sheetNames = new String[_sharedSheetsByName.size()]; - _sharedSheetsByName.keySet().toArray(sheetNames); - OrderedSheet[] oss = new OrderedSheet[sheetNames.length]; - for (int i = 0; i < sheetNames.length; i++) { - String sheetName = sheetNames[i]; - oss[i] = new OrderedSheet(sheetName, _masterBook.getSheetIndex(sheetName)); - } - for (int i = 0; i < oss.length; i++) { - String sheetName = oss[i].getSheetName(); + String[] sheetNames = new String[_sharedSheetsByName.size()]; + _sharedSheetsByName.keySet().toArray(sheetNames); + for (String sheetName : sheetNames) { ForkedEvaluationSheet sheet = _sharedSheetsByName.get(sheetName); sheet.copyUpdatedCells(workbook.getSheet(sheetName)); } @@ -144,20 +136,4 @@ final class ForkedEvaluationWorkbook imp public UDFFinder getUDFFinder(){ return _masterBook.getUDFFinder(); } - - private static final class OrderedSheet implements Comparable { - private final String _sheetName; - private final int _index; - - public OrderedSheet(String sheetName, int index) { - _sheetName = sheetName; - _index = index; - } - public String getSheetName() { - return _sheetName; - } - public int compareTo(OrderedSheet o) { - return _index - o._index; - } - } } Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java?rev=1744802&r1=1744801&r2=1744802&view=diff ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java (original) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListLevel.java Fri May 20 22:05:00 2016 @@ -96,8 +96,8 @@ public final class ListLevel setStartAt( startAt ); _lvlf.setNfc( (byte) numberFormatCode ); _lvlf.setJc( (byte) alignment ); - _grpprlChpx = numberProperties; - _grpprlPapx = entryProperties; + _grpprlChpx = numberProperties.clone(); + _grpprlPapx = entryProperties.clone(); _xst = new Xst(numberText); } Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java?rev=1744802&r1=1744801&r2=1744802&view=diff ============================================================================== --- poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java (original) +++ poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java Fri May 20 22:05:00 2016 @@ -17,19 +17,24 @@ package org.apache.poi.ss.formula.eval.forked; -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; + +import java.io.IOException; -import org.apache.poi.ss.formula.eval.NumberEval; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.formula.IStabilityClassifier; - -/** - * @author Josh Micich - */ -public final class TestForkedEvaluator extends TestCase { +import org.apache.poi.ss.formula.eval.NumberEval; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +public final class TestForkedEvaluator { + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + /** * set up a calculation workbook with input cells nicely segregated on a * sheet called "Inputs" @@ -53,7 +58,8 @@ public final class TestForkedEvaluator e /** * Shows a basic use-case for {@link ForkedEvaluator} */ - public void testBasic() { + @Test + public void testBasic() throws IOException { HSSFWorkbook wb = createWorkbook(); // The stability classifier is useful to reduce memory consumption of caching logic @@ -78,6 +84,8 @@ public final class TestForkedEvaluator e assertEquals(4.0, ((NumberEval) fe2.evaluate("Calculations", 0, 0)).getNumberValue(), 0.0); fe1.updateCell("Inputs", 0, 0, new NumberEval(3.0)); assertEquals(13.9, ((NumberEval) fe1.evaluate("Calculations", 0, 0)).getNumberValue(), 0.0); + + wb.close(); } /** @@ -90,29 +98,19 @@ public final class TestForkedEvaluator e * was considered less desirable because so far, the underlying 'master' workbook is strictly * read-only with respect to the ForkedEvaluator. */ - public void testMissingInputCell() { + @Test + public void testMissingInputCell() throws IOException { + expectedEx.expect(UnsupportedOperationException.class); + expectedEx.expectMessage("Underlying cell 'A2' is missing in master sheet."); + HSSFWorkbook wb = createWorkbook(); - ForkedEvaluator fe = ForkedEvaluator.create(wb, null, null); - - // attempt update input at cell A2 (which is missing) try { - fe.updateCell("Inputs", 1, 0, new NumberEval(4.0)); - throw new AssertionFailedError( - "Expected exception to be thrown due to missing input cell"); - } catch (NullPointerException e) { - StackTraceElement[] stes = e.getStackTrace(); - if (stes[0].getMethodName().equals("getIdentityKey")) { - throw new AssertionFailedError("Identified bug with update of missing input cell"); - } - throw e; - } catch (UnsupportedOperationException e) { - if (e.getMessage().equals( - "Underlying cell 'A2' is missing in master sheet.")) { - // expected during successful test - } else { - throw e; - } + ForkedEvaluator fe = ForkedEvaluator.create(wb, null, null); + // attempt update input at cell A2 (which is missing) + fe.updateCell("Inputs", 1, 0, new NumberEval(4.0)); + } finally { + wb.close(); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org