db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1584493 - in /db/derby/code/trunk/java: optional/org/apache/derby/optional/lucene/LuceneSupport.java testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_11.java
Date Fri, 04 Apr 2014 01:17:38 GMT
Author: rhillegas
Date: Fri Apr  4 01:17:37 2014
New Revision: 1584493

URL: http://svn.apache.org/r1584493
Log:
DERBY-590: Require hard-upgrade to 10.11 in order to use the Lucene plugin; commit derby-590-15-aa-requireHardUpgrade.diff.

Modified:
    db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_11.java

Modified: db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java?rev=1584493&r1=1584492&r2=1584493&view=diff
==============================================================================
--- db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java
(original)
+++ db/derby/code/trunk/java/optional/org/apache/derby/optional/lucene/LuceneSupport.java
Fri Apr  4 01:17:37 2014
@@ -48,6 +48,7 @@ import java.util.ArrayList;
 import java.util.Properties;
 
 import org.apache.derby.iapi.sql.conn.ConnectionUtil;
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
 import org.apache.derby.iapi.sql.dictionary.OptionalTool;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.util.IdUtil;
@@ -137,6 +138,13 @@ public class LuceneSupport implements Op
 	public void loadTool(String... configurationParameters) throws SQLException
     {
         forbidReadOnlyConnections();
+
+        // not allowed during soft-upgrade
+        try {
+            ConnectionUtil.getCurrentLCC().getDataDictionary().checkVersion
+                ( DataDictionary.DD_VERSION_DERBY_10_11, "luceneSupport" );
+        }
+        catch (StandardException se)    { throw sqlException( se ); }
         
         Connection  conn = getDefaultConnection();
         mustBeDBO( conn );

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_11.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_11.java?rev=1584493&r1=1584492&r2=1584493&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_11.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_11.java
Fri Apr  4 01:17:37 2014
@@ -27,9 +27,11 @@ import java.sql.SQLWarning;
 import java.sql.Statement;
 import java.util.Arrays;
 import java.util.ArrayList;
+import java.util.Properties;
 import junit.framework.Test;
 import junit.framework.TestSuite;
 import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 
 /**
@@ -48,6 +50,7 @@ public class Changes10_11 extends Upgrad
     private static  final   String  HARD_UPGRADE_REQUIRED = "XCL47";
     private static  final   String  NOT_IMPLEMENTED = "0A000";
     private static  final   String  NO_ROWS_AFFECTED = "02000";
+    private static  final   String  UNKNOWN_OPTIONAL_TOOL = "X0Y88";
 
     //////////////////////////////////////////////////////////////////
     //
@@ -378,6 +381,7 @@ public class Changes10_11 extends Upgrad
         }
     }
 
+    /** Test the MERGE statement introduced by 10.11 */
     public void testMerge() throws Exception
     {
         String mergeStatement =
@@ -404,6 +408,38 @@ public class Changes10_11 extends Upgrad
         }
     }
 
+    /** Test the Lucene plugin */
+    public void testLuceneSupport() throws Exception
+    {
+        Properties  properties = TestConfiguration.getSystemProperties();
+        if ( getBooleanProperty( properties, TestConfiguration.KEY_OMIT_LUCENE ) )  { return;
}
+
+        String loadTool = "call syscs_util.syscs_register_tool( 'luceneSupport', true )";
+        String unloadTool = "call syscs_util.syscs_register_tool( 'luceneSupport', false
)";
+
+        Statement statement = createStatement();
+        switch (getPhase())
+        {
+            case PH_CREATE:
+            case PH_POST_SOFT_UPGRADE:
+                assertStatementError( UNKNOWN_OPTIONAL_TOOL, statement, loadTool );
+                break;
+            case PH_SOFT_UPGRADE:
+                assertStatementError( HARD_UPGRADE_REQUIRED, statement, loadTool );
+                break;
+            case PH_HARD_UPGRADE:
+                statement.executeUpdate( loadTool );
+                statement.executeUpdate( unloadTool );
+                break;
+        }
+    }
+
+    /** Return the boolean value of a system property */
+    private static  boolean getBooleanProperty( Properties properties, String key )
+    {
+        return Boolean.valueOf( properties.getProperty( key ) ).booleanValue();
+    }
+
     /**
      * Assert that the statement text, when executed, raises a warning.
      */



Mime
View raw message