Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 5574 invoked from network); 28 May 2007 09:33:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 May 2007 09:33:15 -0000 Received: (qmail 49370 invoked by uid 500); 28 May 2007 09:33:20 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 49302 invoked by uid 500); 28 May 2007 09:33:20 -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 49291 invoked by uid 99); 28 May 2007 09:33:19 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 May 2007 02:33:19 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME 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; Mon, 28 May 2007 02:33:14 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 447191A981A; Mon, 28 May 2007 02:32:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r542175 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java Date: Mon, 28 May 2007 09:32:54 -0000 To: derby-commits@db.apache.org From: mikem@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070528093254.447191A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mikem Date: Mon May 28 02:32:53 2007 New Revision: 542175 URL: http://svn.apache.org/viewvc?view=rev&rev=542175 Log: DERBY-2669 add test case to CollationTest2 to test case of setting teritory based collation without setting territory attribute. I tried to make it so that the test will run in norway, english and polish territory where the test can handle results and not run in other territories - but sort of hard to test. Let me know if the testDefaultJVMTerritoryCollation() fails, and what the value of territory is for the vm it failed in. Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java?view=diff&rev=542175&r1=542174&r2=542175 ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/CollationTest2.java Mon May 28 02:32:53 2007 @@ -28,6 +28,7 @@ import java.sql.SQLException; import java.sql.Statement; +import java.util.Locale; import java.util.Properties; import javax.sql.DataSource; @@ -112,10 +113,11 @@ **/ private static final boolean verbose_debug = false; - private static final int TEST_DEFAULT = 0; - private static final int TEST_ENGLISH = 1; - private static final int TEST_POLISH = 2; - private static final int TEST_NORWAY = 3; + private static final int TEST_DEFAULT = 0; + private static final int TEST_ENGLISH = 1; + private static final int TEST_POLISH = 2; + private static final int TEST_NORWAY = 3; + private static final int TEST_DEFAULT_TERRITORY = 4; /** * logical database names to use for the DataSource connection. @@ -130,7 +132,8 @@ "defaultdb2", "enddb2", "poldb2", - "nordb2" + "nordb2", + "defaultdb3" }; @@ -147,9 +150,18 @@ null, "en", "pl", - "no_NO" + "no_NO", + null }; + private static final String[] TEST_COLLATION_ATTRIBUTE = + { + null, + ";collation=TERRITORY_BASED", + ";collation=TERRITORY_BASED", + ";collation=TERRITORY_BASED", + ";collation=TERRITORY_BASED" + }; private static final String[] NAMES = { @@ -387,10 +399,6 @@ ResultSet rs = conn.getMetaData().getColumns(null, "APP", "CUSTOMER", "%"); - if (SanityManager.DEBUG) { - SanityManager.DEBUG_PRINT("", "called GetColumns:"); - } - Assert.assertTrue("catch bug where no rows are returned.", rs.next()); if (verbose_debug) @@ -424,13 +432,23 @@ DataSource ds = JDBCDataSource.getDataSourceLogical(TEST_DATABASE[db_index]); - String conn_string = - "create=true" + - ((TEST_CONNECTION_ATTRIBUTE[db_index] == null) ? - "" : - ";territory=" + - TEST_CONNECTION_ATTRIBUTE[db_index] + - ";collation=TERRITORY_BASED"); + // what territory, if any to specify + String territory_str = + (TEST_CONNECTION_ATTRIBUTE[db_index] == null) ? + "" : ";territory=" + TEST_CONNECTION_ATTRIBUTE[db_index]; + + String collation_str = + (TEST_COLLATION_ATTRIBUTE[db_index] == null) ? + "" : ";collation=TERRITORY_BASED"; + + // build strings of the form: + // create=true + // create=true;territory=en;collation=TERRITORY_BASED + // create=true;collation=TERRITORY_BASED + String conn_string = "create=true" + territory_str + collation_str; + + if (verbose_debug) + System.out.println("connection attribute string: " + conn_string); JDBCDataSource.setBeanProperty(ds, "connectionAttributes", conn_string); @@ -1426,6 +1444,36 @@ runDerby2670(conn); conn.close(); } + public void testDefaultJVMTerritoryCollation() throws SQLException + { + boolean run_test = false; + int db_index = -1; + + Locale locale = Locale.getDefault(); + + if (locale.getLanguage().equals("en")) + { + run_test = true; + db_index = TEST_ENGLISH; + } + else if (locale.getLanguage().equals("no")) + { + run_test = true; + db_index = TEST_NORWAY; + } + else if (locale.getLanguage().equals("po")) + { + run_test = true; + db_index = TEST_POLISH; + } + + if (run_test) + { + Connection conn = setUpDBandOpenConnection(TEST_DEFAULT_TERRITORY); + runTestIter(conn, db_index); + conn.close(); + } + } public static Test suite() @@ -1439,7 +1487,7 @@ test = new SupportFilesSetup(test); // turn on log statement text for sequence of statements in derby.log. - /* if (verbose_debug) */ + if (verbose_debug) { Properties props = new Properties(); props.setProperty("derby.language.logStatementText", "true"); @@ -1461,6 +1509,10 @@ // database to use for testing collation, norway territory. test = TestConfiguration.additionalDatabaseDecorator( test, TEST_DATABASE[TEST_NORWAY]); + + // database to use for testing collation, default jvm territory + test = TestConfiguration.additionalDatabaseDecorator( + test, TEST_DATABASE[TEST_DEFAULT_TERRITORY]); return test;