You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2014/03/18 22:10:04 UTC

svn commit: r1579040 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java

Author: rhillegas
Date: Tue Mar 18 21:10:03 2014
New Revision: 1579040

URL: http://svn.apache.org/r1579040
Log:
DERBY-3155: Run all MERGE tests with and without collations; commit derby-3155-47-aa-collations.diff.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java?rev=1579040&r1=1579039&r2=1579040&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/MergeStatementTest.java Tue Mar 18 21:10:03 2014
@@ -42,6 +42,7 @@ import org.apache.derby.iapi.types.Harmo
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
+import org.apache.derbyTesting.junit.Decorator;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.TestConfiguration;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
@@ -99,6 +100,18 @@ public class MergeStatementTest extends 
 
     ///////////////////////////////////////////////////////////////////////////////////
     //
+    // NESTED CLASSES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public  static  class   Collated    extends MergeStatementTest
+    {
+        public  Collated( String name ) { super( name ); }
+        public  String  expectedCollation() { return "TERRITORY_BASED"; }
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
     // CONSTRUCTOR
     //
     ///////////////////////////////////////////////////////////////////////////////////
@@ -114,6 +127,15 @@ public class MergeStatementTest extends 
 
     ///////////////////////////////////////////////////////////////////////////////////
     //
+    // OVERRIDABLE BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /** Return the expected collation of this database */
+    public  String  expectedCollation() { return "UCS_BASIC"; }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
     // JUnit BEHAVIOR
     //
     ///////////////////////////////////////////////////////////////////////////////////
@@ -124,9 +146,48 @@ public class MergeStatementTest extends 
      */
     public static Test suite()
     {
-        TestSuite suite = (TestSuite) TestConfiguration.embeddedSuite(MergeStatementTest.class);
+        TestSuite suite = new TestSuite();
 
-        Test        cleanTest = new CleanDatabaseTestSetup( suite );
+        suite.addTest( standardDecoration( false ) );
+        suite.addTest( standardDecoration( true ) );
+        
+        return suite;
+    }
+
+    /**
+     * Decorate a test with standard decorators.
+     */
+    private static  Test    standardDecoration( Test raw )
+    {
+        Test        cleanTest = new CleanDatabaseTestSetup( raw );
+        Test        authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication
+            ( cleanTest, LEGAL_USERS, "MergeStatementPermissions" );
+        Test        authorizedTest = TestConfiguration.sqlAuthorizationDecorator( authenticatedTest );
+
+        return authorizedTest;
+    }
+
+    /**
+     * Decorate a test with standard decorators.
+     */
+    private static  Test    standardDecoration( boolean withCollation )
+    {
+        Test        cleanTest;
+        if ( withCollation )
+        {
+            cleanTest = Decorator.territoryCollatedDatabase
+                (
+                 TestConfiguration.embeddedSuite( MergeStatementTest.Collated.class ),
+                 "en"
+                 );
+        }
+        else
+        {
+            cleanTest = new CleanDatabaseTestSetup
+                (
+                 TestConfiguration.embeddedSuite( MergeStatementTest.class )
+                 );
+        }
         Test        authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication
             ( cleanTest, LEGAL_USERS, "MergeStatementPermissions" );
         Test        authorizedTest = TestConfiguration.sqlAuthorizationDecorator( authenticatedTest );
@@ -134,6 +195,14 @@ public class MergeStatementTest extends 
         return authorizedTest;
     }
 
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        // in case decoration cleverness didn't really turn on sql authorization
+        enableSQLAuthorization();
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // TESTS
@@ -9208,6 +9277,28 @@ public class MergeStatementTest extends 
         goodStatement( dboConnection, "drop procedure truncateTriggerHistory_057" );
     }
     
+    /**
+     * <p>
+     * Verify that the collation is what we expect.
+     * </p>
+     */
+    public  void    test_058_collation()
+        throws Exception
+    {
+        Connection  dboConnection = openUserConnection( TEST_DBO );
+
+        assertResults
+            (
+             dboConnection,
+             "values syscs_util.syscs_get_database_property( 'derby.database.collation' )",
+             new String[][]
+             {
+                 { expectedCollation() },
+             },
+             true
+             );
+    }
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // ROUTINES
@@ -9549,5 +9640,32 @@ public class MergeStatementTest extends 
     {
         return original.replace ( "2 *", " " );
     }
+
+    /** Make sure that SQL authorization is turned on */
+    private void    enableSQLAuthorization()
+        throws Exception
+    {
+        Connection  dboConnection = openUserConnection( TEST_DBO );
+        ResultSet   rs = chattyPrepare
+            (
+             dboConnection,
+             "values syscs_util.syscs_get_database_property( 'derby.database.sqlAuthorization' )"
+             ).executeQuery();
+
+        try {
+            if ( rs.next() )
+            {
+                if ( "true".equals( rs.getString( 1 ) ) )   { return; }
+            }
+        }
+        finally
+        {
+            rs.close();
+        }
+
+        goodStatement( dboConnection, "call syscs_util.syscs_set_database_property( 'derby.database.sqlAuthorization', 'true' )" );
+        // bounce the database to turn on SQL authorization
+        bounceDatabase( TEST_DBO );
+    }
     
 }