roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghu...@apache.org
Subject svn commit: r1509084 - in /roller/trunk: app/src/main/java/org/apache/roller/weblogger/ app/src/main/java/org/apache/roller/weblogger/business/startup/ app/src/test/resources/sql/test/ tools/ tools/tests/
Date Thu, 01 Aug 2013 05:49:09 GMT
Author: ghuber
Date: Thu Aug  1 05:49:08 2013
New Revision: 1509084

URL: http://svn.apache.org/r1509084
Log:
Keep local test local.

Added:
    roller/trunk/tools/
    roller/trunk/tools/tests/
    roller/trunk/tools/tests/junit-cleartables-mysql.sql
Removed:
    roller/trunk/app/src/test/resources/sql/test/
Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseScriptProvider.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java?rev=1509084&r1=1509083&r2=1509084&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java Thu Aug  1 05:49:08
2013
@@ -23,25 +23,18 @@
 
 package org.apache.roller.weblogger;
 
-import java.io.InputStream;
-import java.sql.Connection;
-
-import org.apache.commons.lang3.StringUtils;
 import org.apache.roller.planet.business.PlanetManager;
 import org.apache.roller.planet.pojos.Planet;
 import org.apache.roller.planet.pojos.PlanetGroup;
 import org.apache.roller.planet.pojos.Subscription;
 import org.apache.roller.planet.pojos.SubscriptionEntry;
 import org.apache.roller.weblogger.business.BookmarkManager;
-import org.apache.roller.weblogger.business.DatabaseProvider;
 import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.pings.AutoPingManager;
 import org.apache.roller.weblogger.business.pings.PingTargetManager;
-import org.apache.roller.weblogger.business.startup.ClasspathDatabaseScriptProvider;
-import org.apache.roller.weblogger.business.startup.SQLScriptRunner;
 import org.apache.roller.weblogger.business.startup.WebloggerStartup;
 import org.apache.roller.weblogger.pojos.AutoPing;
 import org.apache.roller.weblogger.pojos.PingTarget;
@@ -66,8 +59,6 @@ public final class TestUtils {
 
         if (!WebloggerFactory.isBootstrapped()) {
 
-            System.out.println("Bootstrapping system, please wait....");
-
             // do core services preparation
             WebloggerStartup.prepare();
 
@@ -77,29 +68,6 @@ public final class TestUtils {
             // always initialize the properties manager and flush
             WebloggerFactory.getWeblogger().initialize();
 
-            // Reset for local tests
-            // On junit test jvm argument -Droller.tests.reset=true/false
-            String local = System.getProperty("roller.tests.reset");
-            if (StringUtils.isNotEmpty(local) && local.equals("true")) {
-
-                System.out
-                        .println("Resetting tables for local tests: roller.tests.reset="
-                                + local);
-
-                try {
-                    clearTestData();
-                } catch (Exception e) {
-                    System.out.println("Error resetting tables : "
-                            + e.getMessage());
-                } finally {
-                    // flush
-                    endSession(true);
-                }
-            }
-
-            System.out
-                    .println("Bootstrapping successful, running tests please wait....");
-
         }
     }
 
@@ -128,58 +96,6 @@ public final class TestUtils {
     }
 
     /**
-     * Clear test data.
-     * 
-     * @throws Exception
-     *             the exception
-     */
-    private static void clearTestData() throws Exception {
-
-        DatabaseProvider dbp = WebloggerStartup.getDatabaseProvider();
-        Connection con = dbp.getConnection();
-
-        // normally local tests run against mysql
-        String databaseProductName = con.getMetaData().getDatabaseProductName();
-        String dbname = "mysql";
-        if (databaseProductName.toLowerCase().indexOf("derby") > 0) {
-            // tests against Derby
-            dbname = "derby";
-        }
-
-        // Somewhere on classpath
-        ClasspathDatabaseScriptProvider scriptProvider = new ClasspathDatabaseScriptProvider();
-
-        InputStream script = scriptProvider
-                .getAbsoluteDatabaseScript("sql/test/junit-cleartables-" + dbname
-                        + ".sql");
-
-        try {
-
-            if (script != null) {
-
-                // run script to reset tables
-                SQLScriptRunner create = new SQLScriptRunner(script);
-                create.runScript(con, true);
-
-            } else {
-
-                throw new RuntimeException(
-                        "Resetting tables script unsupported database or not found :"
-                                + dbname);
-
-            }
-
-        } finally {
-            try {
-                script.close();
-            } catch (Exception e) {
-                // ignored
-            }
-        }
-
-    }
-
-    /**
      * Convenience method that creates a user and stores it.
      */
     public static User setupUser(String userName) throws Exception {

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java?rev=1509084&r1=1509083&r2=1509084&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java
Thu Aug  1 05:49:08 2013
@@ -33,17 +33,4 @@ public class ClasspathDatabaseScriptProv
         return this.getClass().getResourceAsStream(resourcePath);
     }
 
-    /**
-     * @see org.apache.roller.weblogger.business.startup.DatabaseScriptProvider#getAbsoluteDatabaseScript(java.lang.String)
-     */
-    public InputStream getAbsoluteDatabaseScript(String path) {
-
-        // Add leading slash if not present
-        if (!path.startsWith("/")) {
-            path = "/" + path;
-        }
-
-        return ClasspathDatabaseScriptProvider.class.getResourceAsStream(path);
-    }
-
 }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseScriptProvider.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseScriptProvider.java?rev=1509084&r1=1509083&r2=1509084&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseScriptProvider.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseScriptProvider.java
Thu Aug  1 05:49:08 2013
@@ -31,10 +31,4 @@ public interface DatabaseScriptProvider 
      */
     InputStream getDatabaseScript(String path) throws Exception;
 
-    /**
-     * Get an InputStream to a database script at the given path relative to
-     * classes folder.
-     */
-    InputStream getAbsoluteDatabaseScript(String absolutePath) throws Exception;
-
 }

Added: roller/trunk/tools/tests/junit-cleartables-mysql.sql
URL: http://svn.apache.org/viewvc/roller/trunk/tools/tests/junit-cleartables-mysql.sql?rev=1509084&view=auto
==============================================================================
--- roller/trunk/tools/tests/junit-cleartables-mysql.sql (added)
+++ roller/trunk/tools/tests/junit-cleartables-mysql.sql Thu Aug  1 05:49:08 2013
@@ -0,0 +1,36 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+--  contributor license agreements.  The ASF licenses this file to You
+-- under the Apache License, Version 2.0 (the "License"); you may not
+-- use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.  For additional information regarding
+-- copyright in this work, please see the NOTICE file in the top level
+-- directory of this distribution.
+
+-- Script is used to clear old data prior to running local tests
+
+delete mt from website w, roller_mediafile mf, roller_mediafiletag mt where w.id = mf.weblogid
and mt.mediafile_id = mf.id and w.creator like 'junit_%';
+delete mf from website w, roller_mediafile mf where w.id = mf.weblogid and w.creator like
'junit_%';
+delete md from website w, roller_mediafiledir md where w.id = md.websiteid and w.creator
like 'junit_%';
+
+delete r from website w, referer r WHERE w.id = r.websiteid and w.creator like 'junit_%';
+
+delete from website WHERE creator like 'junit_%';
+
+delete b from website w, folder f, bookmark b where f.id = b.folderid and w.id = f.websiteid
and w.creator like 'junit_%';
+delete from folder WHERE websiteid like 'junit_%';
+
+delete from userrole WHERE username like 'junit_%';
+delete from roller_permission WHERE username like 'junit_%';
+delete from rolleruser WHERE username like 'junit_%';
+delete from roller_userattribute WHERE username like 'junit_%';
+delete from roller_oauthconsumer WHERE username like 'junit_%';
+delete from roller_oauthaccessor WHERE username like 'junit_%';
+



Mime
View raw message