From derby-commits-return-8965-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Tue Dec 04 19:58:48 2007 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 40600 invoked from network); 4 Dec 2007 19:58:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Dec 2007 19:58:48 -0000 Received: (qmail 33151 invoked by uid 500); 4 Dec 2007 19:58:36 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 33114 invoked by uid 500); 4 Dec 2007 19:58:36 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 33103 invoked by uid 99); 4 Dec 2007 19:58:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 11:58:36 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2007 19:58:24 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 072CA1A983A; Tue, 4 Dec 2007 11:58:27 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r601064 - in /db/derby/code/branches/10.3: build.xml java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java Date: Tue, 04 Dec 2007 19:58:26 -0000 To: derby-commits@db.apache.org From: kahatlen@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071204195827.072CA1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kahatlen Date: Tue Dec 4 11:58:26 2007 New Revision: 601064 URL: http://svn.apache.org/viewvc?rev=601064&view=rev Log: DERBY-3229: testSysinfoLocale fails if derbytools.jar is first in the classpath Merged fix from trunk (revisions 598456 and 600456). Modified: db/derby/code/branches/10.3/build.xml db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java Modified: db/derby/code/branches/10.3/build.xml URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/build.xml?rev=601064&r1=601063&r2=601064&view=diff ============================================================================== --- db/derby/code/branches/10.3/build.xml (original) +++ db/derby/code/branches/10.3/build.xml Tue Dec 4 11:58:26 2007 @@ -1146,13 +1146,19 @@ + + + + + + + -
@@ -1184,6 +1190,11 @@
+ + + + +
@@ -1219,6 +1230,10 @@ + + + + Modified: db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java?rev=601064&r1=601063&r2=601064&view=diff ============================================================================== --- db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java (original) +++ db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/tools/SysinfoLocaleTest.java Tue Dec 4 11:58:26 2007 @@ -53,6 +53,9 @@ */ private final boolean localizedToGerman; + /** Name of the test. */ + private final String name; + /** The default locale before this test started. */ private Locale savedLocale; @@ -61,11 +64,24 @@ * * @param defaultLocale the default locale for this test * @param german true if output is expected to be localized to German + * @param info extra information to append to the test name (for debugging) */ - private SysinfoLocaleTest(Locale defaultLocale, boolean german) { + private SysinfoLocaleTest(Locale defaultLocale, boolean german, + String info) { super("testSysinfoLocale"); this.defaultLocale = defaultLocale; this.localizedToGerman = german; + this.name = super.getName() + ":" + info; + } + + /** + * Returns the name of the test, which includes the default locale and + * derby.ui.locale to aid debugging. + * + * @return name of the test + */ + public String getName() { + return name; } /** @@ -130,7 +146,8 @@ // always set the encoding so that we can reliably read the output prop.setProperty("derby.ui.codeset", ENCODING); - Test test = new SysinfoLocaleTest(loc, german); + String info = "defaultLocale=" + loc + ",uiLocale=" + ui; + Test test = new SysinfoLocaleTest(loc, german, info); return new SystemPropertyTestSetup(test, prop); } @@ -194,20 +211,29 @@ }; /** + * Checks that all the expected substrings are part of the output from + * sysinfo. Fails if one or more of the substrings are not found. + * + * @param expectedSubstrings substrings in the expected locale + * @param output the output from sysinfo + */ + private void assertContains(String[] expectedSubstrings, String output) { + for (int i = 0; i < expectedSubstrings.length; i++) { + String s = expectedSubstrings[i]; + if (output.indexOf(s) == -1) { + fail("Substring '" + s + "' not found in output: " + output); + } + } + } + + /** * Test method which checks that the output from sysinfo is correctly * localized. */ public void testSysinfoLocale() throws Exception { String output = getSysinfoOutput(); - - for (int i = 0; i < GERMAN_STRINGS.length; i++) { - assertEquals(localizedToGerman, - output.indexOf(GERMAN_STRINGS[i]) != -1); - } - - for (int i = 0; i < ITALIAN_STRINGS.length; i++) { - assertEquals(localizedToGerman, - output.indexOf(ITALIAN_STRINGS[i]) == -1); - } + String[] expectedSubstrings = + localizedToGerman ? GERMAN_STRINGS : ITALIAN_STRINGS; + assertContains(expectedSubstrings, output); } }