db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1588933 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: functionTests/tests/lang/ junit/
Date Mon, 21 Apr 2014 17:23:34 GMT
Author: rhillegas
Date: Mon Apr 21 17:23:33 2014
New Revision: 1588933

URL: http://svn.apache.org/r1588933
Log:
DERBY-6544: Run locale-sensitive Lucene tests in single-use databases; commit derby-6544-01-aa-singleUseDatabases.diff.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneCoarseAuthorizationTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/luceneSupport.policy
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneCoarseAuthorizationTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneCoarseAuthorizationTest.java?rev=1588933&r1=1588932&r2=1588933&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneCoarseAuthorizationTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneCoarseAuthorizationTest.java
Mon Apr 21 17:23:33 2014
@@ -39,10 +39,13 @@ import java.sql.Timestamp;
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Locale;
 import java.util.Properties;
+import org.apache.lucene.analysis.Analyzer;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import org.apache.derby.iapi.sql.conn.ConnectionUtil;
+import org.apache.derby.optional.api.LuceneUtils;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.JDBC;
 import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
@@ -69,9 +72,13 @@ public class LuceneCoarseAuthorizationTe
     private static  final   String      READ_WRITE_USER = "READWRITEUSER";
     private static  final   String[]    LEGAL_USERS = { RUTH, READ_ONLY_USER, READ_WRITE_USER
};
 
+    private static  final   String      ENGLISH_ANALYZER =
+        "org.apache.derbyTesting.functionTests.tests.lang.LuceneCoarseAuthorizationTest.getEnglishAnalyzer";
+
     private static  final   String      LOAD_TOOL = "call syscs_util.syscs_register_tool(
'luceneSupport', true )";
     private static  final   String      UNLOAD_TOOL = "call syscs_util.syscs_register_tool(
'luceneSupport', false )";
-    private static  final   String      INDEX_POEMS = "call LuceneSupport.createIndex( 'ruth',
'poems', 'poemText', null )";
+    private static  final   String      INDEX_POEMS =
+        "call LuceneSupport.createIndex( 'ruth', 'poems', 'poemText', '" + ENGLISH_ANALYZER
+ "' )";
     private static  final   String      UPDATE_POEMS_INDEX =
         "call LuceneSupport.updateIndex( 'ruth', 'poems', 'poemText', 'org.apache.derby.optional.api.LuceneUtils.standardAnalyzer'
)";
     private static  final   String      DROP_POEMS_INDEX = "call LuceneSupport.dropIndex(
'ruth', 'poems', 'poemText' )";
@@ -118,8 +125,9 @@ public class LuceneCoarseAuthorizationTe
             ( unsecureTest, LEGAL_USERS, "LuceneCoarsePermissions" );
 
         Test        coarseTest = new DatabasePropertyTestSetup( authenticatedTest, makeProperties()
);
+        Test        singleUseTest = TestConfiguration.singleUseDatabaseDecorator( coarseTest
);
 
-        return coarseTest;
+        return singleUseTest;
     }
     private static  Properties  makeProperties()
     {
@@ -201,7 +209,7 @@ public class LuceneCoarseAuthorizationTe
         String[][]  defaultIndexList =
             new String[][]
             {
-                { "RUTH", "POEMS", "POEMTEXT", "org.apache.derby.optional.api.LuceneUtils.defaultAnalyzer"
},
+                { "RUTH", "POEMS", "POEMTEXT", ENGLISH_ANALYZER },
             };
 
         assertResults
@@ -292,6 +300,20 @@ public class LuceneCoarseAuthorizationTe
 
     ///////////////////////////////////////////////////////////////////////////////////
     //
+    // EXTERNAL ENTRY POINTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /** Return the Analyzer for an English Locale */
+    public  static  Analyzer    getEnglishAnalyzer()
+        throws Exception
+    {
+        return LuceneUtils.getAnalyzerForLocale( Locale.US );
+    }
+    
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
     // MINIONS
     //
     ///////////////////////////////////////////////////////////////////////////////////

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java?rev=1588933&r1=1588932&r2=1588933&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportPermsTest.java
Mon Apr 21 17:23:33 2014
@@ -75,6 +75,8 @@ public class LuceneSupportPermsTest exte
     private static  final   String      LUCENE_VERSION_PROPERTY = "derby.tests.lucene.version";
     private static  String              LUCENE_VERSION = "LUCENE_45";
 
+    private static  final   String      DB_NAME = "lucenesupportpermsdb";
+
     private static  final   String      TEST_DBO = "TEST_DBO";
     private static  final   String      RUTH = "RUTH";
     private static  final   String      ALICE = "ALICE";
@@ -152,12 +154,19 @@ public class LuceneSupportPermsTest exte
         Test        secureTest = new SecurityManagerSetup( suite, POLICY_FILE );
         Test        authenticatedTest = DatabasePropertyTestSetup.builtinAuthentication
             ( secureTest, LEGAL_USERS, "LuceneSupportPermissions" );
-        Test        authorizedTest = TestConfiguration.sqlAuthorizationDecorator( authenticatedTest
);
+        Test        authorizedTest = TestConfiguration.sqlAuthorizationDecoratorSingleUse(
authenticatedTest, DB_NAME, false );
         Test        localizedTest = new LocaleTestSetup( authorizedTest, new Locale( LANGUAGE,
COUNTRY ) );
 
         return localizedTest;
     }
 
+    protected void tearDown()
+        throws Exception
+    {
+        TestConfiguration.getCurrent().shutdownEngine();
+        super.tearDown();
+    }
+
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // TESTS

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportTest.java?rev=1588933&r1=1588932&r2=1588933&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LuceneSupportTest.java
Mon Apr 21 17:23:33 2014
@@ -53,7 +53,8 @@ public class LuceneSupportTest extends B
 		TestSuite suite = new TestSuite("LuceneSupportTest");
 
         Test    baseTest = TestConfiguration.embeddedSuite(LuceneSupportTest.class);
-        Test        localizedTest = new LocaleTestSetup( baseTest, new Locale( "en", "US"
) );
+        Test        singleUseTest = TestConfiguration.singleUseDatabaseDecorator( baseTest
);
+        Test        localizedTest = new LocaleTestSetup( singleUseTest, new Locale( "en",
"US" ) );
 		
 		suite.addTest(SecurityManagerSetup.noSecurityManager(localizedTest));
  

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/luceneSupport.policy
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/luceneSupport.policy?rev=1588933&r1=1588932&r2=1588933&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/luceneSupport.policy
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/luceneSupport.policy
Mon Apr 21 17:23:33 2014
@@ -454,8 +454,8 @@ grant codeBase "${derbyTesting.codejar}d
   permission java.util.PropertyPermission "derby.system.home", "read";
 
   // all databases under derby.system.home 
-  permission java.io.FilePermission "${derby.system.home}${/}dbsqlauth${/}lucene", "read,write,delete";
-  permission java.io.FilePermission "${derby.system.home}${/}dbsqlauth${/}lucene${/}-", "read,write,delete";
+  permission java.io.FilePermission "${derby.system.home}${/}lucenesupportpermsdb${/}lucene",
"read,write,delete";
+  permission java.io.FilePermission "${derby.system.home}${/}lucenesupportpermsdb${/}lucene${/}-",
"read,write,delete";
 
   permission java.io.FilePermission "${derbyTesting.lucene.core.jar.file}", "read";
   permission java.util.PropertyPermission "user.dir", "read";
@@ -468,8 +468,8 @@ grant codeBase "${derbyTesting.codejar}d
 grant codeBase "${derbyTesting.lucene.core}"
 {
   // permissions for file access, write access only to sandbox:
-  permission java.io.FilePermission "${derby.system.home}${/}dbsqlauth${/}lucene", "read,write,delete";
-  permission java.io.FilePermission "${derby.system.home}${/}dbsqlauth${/}lucene${/}-", "read,write,delete";
+  permission java.io.FilePermission "${derby.system.home}${/}lucenesupportpermsdb${/}lucene",
"read,write,delete";
+  permission java.io.FilePermission "${derby.system.home}${/}lucenesupportpermsdb${/}lucene${/}-",
"read,write,delete";
   
   // Basic permissions needed for Lucene to work:
   permission java.util.PropertyPermission "user.dir", "read";

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=1588933&r1=1588932&r2=1588933&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Mon Apr 21 17:23:33 2014
@@ -950,6 +950,19 @@ public final class TestConfiguration {
      */
     public static Test sqlAuthorizationDecoratorSingleUse(Test test)
     {
+        return sqlAuthorizationDecoratorSingleUse( test, DEFAULT_DBNAME_SQL, true );
+    }
+    
+    /**
+     * Same as sqlAuthorizationDecoratorSingleUse, except that you can name the database
yourself.
+     *
+     * @param test Test to be decorated
+     * @return decorated test.
+     *
+     * @see TestConfiguration#sqlAuthorizationDecorator(Test test)
+     */
+    public static Test sqlAuthorizationDecoratorSingleUse(Test test, String dbName, boolean
removeDatabase)
+    {
         // Set the SQL authorization mode as a database property
         // with a modified DatabasePropertyTestSetup that does not
         // reset it.
@@ -958,14 +971,20 @@ public final class TestConfiguration {
         Test setSQLAuthMode = DatabasePropertyTestSetup.getNoTeardownInstance(
                 test, sqlAuth, true);
 
-        setSQLAuthMode = new DatabaseChangeSetup(
-            new DropDatabaseSetup(setSQLAuthMode, DEFAULT_DBNAME_SQL) {
-                protected void tearDown() throws Exception {
-                    // test responsible for shutdown
-                    removeDatabase();
-                }
-            },
-            DEFAULT_DBNAME_SQL, DEFAULT_DBNAME_SQL, true);
+        if ( removeDatabase )
+        {
+            setSQLAuthMode =
+                new DropDatabaseSetup(setSQLAuthMode, dbName)
+                {
+                    protected void tearDown() throws Exception {
+                        // test responsible for shutdown
+                        removeDatabase();
+                    }
+                };
+        }
+        
+        setSQLAuthMode = new DatabaseChangeSetup
+            ( setSQLAuthMode, dbName, dbName, true );
 
         return changeUserDecorator(setSQLAuthMode,
                                    DerbyConstants.TEST_DBO,



Mime
View raw message