From commits-return-130-apmail-jmeter-commits-archive=jmeter.apache.org@jmeter.apache.org Mon Nov 14 19:33:31 2011 Return-Path: X-Original-To: apmail-jmeter-commits-archive@minotaur.apache.org Delivered-To: apmail-jmeter-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 CCB069115 for ; Mon, 14 Nov 2011 19:33:31 +0000 (UTC) Received: (qmail 33091 invoked by uid 500); 14 Nov 2011 19:33:31 -0000 Delivered-To: apmail-jmeter-commits-archive@jmeter.apache.org Received: (qmail 33075 invoked by uid 500); 14 Nov 2011 19:33:31 -0000 Mailing-List: contact commits-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jmeter.apache.org Delivered-To: mailing list commits@jmeter.apache.org Received: (qmail 33068 invoked by uid 99); 14 Nov 2011 19:33:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Nov 2011 19:33:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Nov 2011 19:33:28 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id AA1AF2388A02 for ; Mon, 14 Nov 2011 19:33:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1201842 - /jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java Date: Mon, 14 Nov 2011 19:33:07 -0000 To: commits@jmeter.apache.org From: pmouawad@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111114193307.AA1AF2388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: pmouawad Date: Mon Nov 14 19:33:07 2011 New Revision: 1201842 URL: http://svn.apache.org/viewvc?rev=1201842&view=rev Log: close reader Modified: jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java Modified: jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java?rev=1201842&r1=1201841&r2=1201842&view=diff ============================================================================== --- jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java (original) +++ jmeter/trunk/test/src/org/apache/jmeter/resources/PackageTest.java Mon Nov 14 19:33:07 2011 @@ -31,6 +31,7 @@ import java.util.MissingResourceExceptio import java.util.PropertyResourceBundle; import org.apache.jmeter.gui.util.JMeterMenuBar; +import org.apache.jorphan.util.JOrphanUtils; import junit.framework.Test; import junit.framework.TestCase; @@ -91,47 +92,53 @@ public class PackageTest extends TestCas return 0; } } - BufferedReader fileReader = new BufferedReader(new InputStreamReader(ras)); - String s; - while ((s = fileReader.readLine()) != null) { - if (s.length() > 0 && !s.startsWith("#") && !s.startsWith("!")) { - int equ = s.indexOf('='); - String key = s.substring(0, equ); - if (resourcePrefix.equals(MESSAGES)){// Only relevant for messages - /* - * JMeterUtils.getResString() converts space to _ and lowercases - * the key, so make sure all keys pass the test - */ - if ((key.indexOf(' ') >= 0) || !key.toLowerCase(java.util.Locale.ENGLISH).equals(key)) { - System.out.println("Invalid key for JMeterUtils " + key); - fails++; - } - } - String val = s.substring(equ + 1); - l.add(key); // Store the key - /* - * Now check for invalid message format: if string contains {0} - * and ' there may be a problem, so do a format with dummy - * parameters and check if there is a { in the output. A bit - * crude, but should be enough for now. - */ - if (val.indexOf("{0}") > 0 && val.indexOf("'") > 0) { - String m = java.text.MessageFormat.format(val, DUMMY_PARAMS); - if (m.indexOf("{") > 0) { - fails++; - System.out.println("Incorrect message format ? (input/output) for: "+key); - System.out.println(val); - System.out.println(m); - } - } - - if (!isPureAscii(val)) { - fails++; - System.out.println("Incorrect char value in: "+s); - } - } + BufferedReader fileReader = null; + try { + fileReader = new BufferedReader(new InputStreamReader(ras)); + String s; + while ((s = fileReader.readLine()) != null) { + if (s.length() > 0 && !s.startsWith("#") && !s.startsWith("!")) { + int equ = s.indexOf('='); + String key = s.substring(0, equ); + if (resourcePrefix.equals(MESSAGES)){// Only relevant for messages + /* + * JMeterUtils.getResString() converts space to _ and lowercases + * the key, so make sure all keys pass the test + */ + if ((key.indexOf(' ') >= 0) || !key.toLowerCase(java.util.Locale.ENGLISH).equals(key)) { + System.out.println("Invalid key for JMeterUtils " + key); + fails++; + } + } + String val = s.substring(equ + 1); + l.add(key); // Store the key + /* + * Now check for invalid message format: if string contains {0} + * and ' there may be a problem, so do a format with dummy + * parameters and check if there is a { in the output. A bit + * crude, but should be enough for now. + */ + if (val.indexOf("{0}") > 0 && val.indexOf("'") > 0) { + String m = java.text.MessageFormat.format(val, DUMMY_PARAMS); + if (m.indexOf("{") > 0) { + fails++; + System.out.println("Incorrect message format ? (input/output) for: "+key); + System.out.println(val); + System.out.println(m); + } + } + + if (!isPureAscii(val)) { + fails++; + System.out.println("Incorrect char value in: "+s); + } + } + } + return fails; + } + finally { + JOrphanUtils.closeQuietly(fileReader); } - return fails; } // Helper method to construct resource name