roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1505415 - in /roller/trunk: ./ app/ app/src/test/java/org/apache/roller/derby/ app/src/test/java/org/apache/roller/derby/ant/ app/src/test/java/org/apache/roller/weblogger/business/ test-utils/
Date Sun, 21 Jul 2013 16:33:21 GMT
Author: gmazza
Date: Sun Jul 21 16:33:20 2013
New Revision: 1505415

URL: http://svn.apache.org/r1505415
Log:
Removed the test-utils submodule, and moved the only two classes we needed from it to the
app/src/test directory.

Added:
    roller/trunk/app/src/test/java/org/apache/roller/derby/
    roller/trunk/app/src/test/java/org/apache/roller/derby/ant/
    roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StartDerbyTask.java
    roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StopDerbyTask.java
Removed:
    roller/trunk/test-utils/
Modified:
    roller/trunk/app/pom.xml
    roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/SQLScriptRunnerTest.java
    roller/trunk/pom.xml

Modified: roller/trunk/app/pom.xml
URL: http://svn.apache.org/viewvc/roller/trunk/app/pom.xml?rev=1505415&r1=1505414&r2=1505415&view=diff
==============================================================================
--- roller/trunk/app/pom.xml (original)
+++ roller/trunk/app/pom.xml Sun Jul 21 16:33:20 2013
@@ -430,9 +430,16 @@
         <!-- test deps -->
 
         <dependency>
-            <groupId>org.apache.roller</groupId>
-            <artifactId>test-utils</artifactId>
-            <version>${roller.version}</version>
+            <groupId>org.apache.derby</groupId>
+            <artifactId>derbynet</artifactId>
+            <version>${derby.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.ant</groupId>
+            <artifactId>ant</artifactId>
+            <version>1.9.2</version>
             <scope>test</scope>
         </dependency>
 
@@ -440,6 +447,7 @@
             <groupId>org.apache.derby</groupId>
             <artifactId>derbyclient</artifactId>
             <version>${derby.version}</version>
+            <scope>test</scope>
         </dependency>
 
         <dependency>
@@ -453,27 +461,6 @@
 
         <finalName>roller</finalName>
 
-        <pluginManagement>
-            <plugins>
-                <!-- Allow for standalone Tomcat deployment
-                     using mvn tomcat7:redeploy (See
-                     http://www.jroller.com/gmazza/entry/web_service_tutorial#maventomcat
-                     for necessary config info)
-                -->
-                <plugin>
-                    <groupId>org.apache.tomcat.maven</groupId>
-                    <artifactId>tomcat7-maven-plugin</artifactId>
-                    <version>2.1</version>
-                    <configuration>
-                        <server>myTomcat</server>
-                        <path>/${project.build.finalName}</path>
-                    </configuration>
-                </plugin>
-
-            </plugins>
-
-        </pluginManagement>
-
         <plugins>
 
             <plugin>
@@ -503,7 +490,7 @@
                     </systemProperties>
                 </configuration>
                 <dependencies>
-                    <!-- Dependencies not needed during testing but when using mvn jetty:run
-->
+                    <!-- Dependencies not needed during mvn test when using mvn jetty:run
-->
                     <dependency>
                         <groupId>org.apache.derby</groupId>
                         <artifactId>derby</artifactId>
@@ -517,6 +504,21 @@
                 </dependencies>
             </plugin>
 
+            <!-- Allow for standalone Tomcat deployment
+                 using mvn tomcat7:redeploy (See
+                 http://www.jroller.com/gmazza/entry/web_service_tutorial#maventomcat
+                 for necessary config info)
+            -->
+            <plugin>
+                <groupId>org.apache.tomcat.maven</groupId>
+                <artifactId>tomcat7-maven-plugin</artifactId>
+                <version>2.1</version>
+                <configuration>
+                    <server>myTomcat</server>
+                    <path>/${project.build.finalName}</path>
+                </configuration>
+            </plugin>
+
             <plugin>
                 <artifactId>maven-resources-plugin</artifactId>
                 <version>2.6</version>
@@ -638,7 +640,7 @@
 
                     <execution>
                         <id>startdb</id>
-                        <phase>process-test-resources</phase>
+                        <phase>test-compile</phase>
                         <goals>
                             <goal>run</goal>
                         </goals>
@@ -646,7 +648,7 @@
                             <target>
                                 <!-- Derby only for unit testing and jetty:run dev testing:
skipped when maven.text.skip is set -->
                                 <delete dir="${basedir}/target/derby-system" verbose="true"
failonerror="false" />
-                                <taskdef name="startdb" classname="org.apache.roller.weblogger.ant.StartDerbyTask"
+                                <taskdef name="startdb" classname="org.apache.roller.derby.ant.StartDerbyTask"
                                          classpathref="maven.test.classpath"/>
                                 <startdb databaseDir="${basedir}/target/derby-system"
                                          port="3223"
@@ -666,7 +668,7 @@
                         <configuration>
                             <target>
                                 <!-- Derby only for unit testing: skip when maven.test.skip
is set -->
-                                <taskdef name="stopdb" classname="org.apache.roller.weblogger.ant.StopDerbyTask"
+                                <taskdef name="stopdb" classname="org.apache.roller.derby.ant.StopDerbyTask"
                                          classpathref="maven.test.classpath"/>
                                 <stopdb databaseDir="${basedir}/target/derby-system"
                                         port="3223"

Added: roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StartDerbyTask.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StartDerbyTask.java?rev=1505415&view=auto
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StartDerbyTask.java (added)
+++ roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StartDerbyTask.java Sun Jul
21 16:33:20 2013
@@ -0,0 +1,164 @@
+/*
+ * 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.
+ */
+package org.apache.roller.derby.ant;
+
+import org.apache.derby.drda.NetworkServerControl;
+import org.apache.roller.weblogger.business.startup.SQLScriptRunner;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+/**
+ * Ant Task to start Derby
+ * @author Dave Johnson
+ */
+public class StartDerbyTask extends Task {
+    private String databaseDir = null;
+    private String databaseScriptsDir = null;
+    private String port = null;
+    private boolean skip = false;
+    
+    public void execute() throws BuildException {
+        try {
+            if (!isSkip()) {
+
+                System.out.println("==============");
+                System.out.println("Starting Derby");
+                System.out.println("==============");
+
+                System.setProperty("derby.system.home", databaseDir);
+
+                System.setProperty("derby.drda.portNumber", port);
+                System.setProperty("derby.drda.host", "localhost");
+                System.setProperty("derby.drda.maxThreads","10");
+                //System.setProperty("derby.drda.logConnections","true");
+                NetworkServerControl server = new NetworkServerControl();
+                server.start(new PrintWriter(System.out));
+                try {Thread.sleep(2000);} catch (Exception ignored) {}
+                System.out.println("Runtime Info: " + server.getRuntimeInfo());
+                System.out.println("System Info:  " + server.getSysinfo());
+
+                Class.forName("org.apache.derby.jdbc.ClientDriver");
+                Connection conn = DriverManager.getConnection(
+                    "jdbc:derby://localhost:" + port + "/memory:rollerdb;create=true","APP",
"APP");
+
+                //Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+                //Connection conn = DriverManager.getConnection(
+                    //"jdbc:derby:rollerdb;create=true","APP", "APP");
+
+                // create roller tables
+
+                SQLScriptRunner runner1 = new SQLScriptRunner(
+                        databaseScriptsDir
+                        + File.separator + "droptables.sql");
+                runner1.runScript(conn, false);
+
+                SQLScriptRunner runner = new SQLScriptRunner(
+                        databaseScriptsDir
+                        + File.separator + "derby"
+                        + File.separator + "createdb.sql");
+                try {
+                    runner.runScript(conn, true);
+                } catch (Exception ignored) {
+                    for (String message : runner.getMessages()) {
+                        System.out.println(message);
+                    }
+                    ignored.printStackTrace();
+                }               
+
+                
+            } else {
+                System.out.println("Skipping Derby startup");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new BuildException("ERROR starting Derby");
+        }
+        
+    }
+    /**
+     * @return Returns the databaseDir.
+     */
+    public String getDatabaseDir() {
+        return databaseDir;
+    }
+    /**
+     * @param databaseDir The databaseDir to set.
+     */
+    public void setDatabaseDir(String databaseDir) {
+        this.databaseDir = databaseDir;
+    }
+    /**
+     * @return Returns the port.
+     */
+    public String getPort() {
+        return port;
+    }
+    /**
+     * @param port The port to set.
+     */
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+    /**
+     * @return the skip
+     */
+    public boolean isSkip() {
+        return skip;
+    }
+
+    /**
+     * @param skip the skip to set
+     */
+    public void setSkip(boolean skip) {
+        this.skip = skip;
+    }
+
+    /**
+     * @return the databaseScriptsDir
+     */
+    public String getDatabaseScriptsDir() {
+        return databaseScriptsDir;
+    }
+
+    /**
+     * @param databaseScriptsDir the databaseScriptsDir to set
+     */
+    public void setDatabaseScriptsDir(String databaseScriptsDir) {
+        this.databaseScriptsDir = databaseScriptsDir;
+    }
+
+    public void main(String[] args) {
+        try {
+            System.setProperty("derby.system.home", args[0]);
+            System.setProperty("derby.drda.portNumber", args[1]);
+            System.setProperty("derby.drda.host", "localhost");
+            System.setProperty("derby.drda.maxThreads", "10");
+            System.setProperty("derby.drda.logConnections", "true");
+            NetworkServerControl server = new NetworkServerControl();
+            server.start(new PrintWriter(System.out));
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+}

Added: roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StopDerbyTask.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StopDerbyTask.java?rev=1505415&view=auto
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StopDerbyTask.java (added)
+++ roller/trunk/app/src/test/java/org/apache/roller/derby/ant/StopDerbyTask.java Sun Jul
21 16:33:20 2013
@@ -0,0 +1,151 @@
+/*
+ * 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.
+ */
+package org.apache.roller.derby.ant;
+
+import org.apache.derby.drda.NetworkServerControl;
+import org.apache.roller.weblogger.business.startup.SQLScriptRunner;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DriverManager;
+
+/**
+ * Ant Task to stop Derby
+ * @author Dave Johnson
+ */
+public class StopDerbyTask extends Task {
+    private String databaseDir = null;
+    private String databaseScriptsDir = null;
+    private String port = null;
+    private boolean skip = false;
+
+    public void execute() throws BuildException {
+        try {
+            if (!isSkip()) {
+
+                Class.forName("org.apache.derby.jdbc.ClientDriver");
+                
+                String driverURL =
+                    "jdbc:derby://localhost:" + port + "/memory:rollerdb";
+                Connection conn =
+                    DriverManager.getConnection(driverURL,"APP", "APP");
+
+                //Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+                //Connection conn = DriverManager.getConnection(
+                    //"jdbc:derby:rollerdb;create=true","APP", "APP");
+
+                // drop Roller tables
+                SQLScriptRunner runner = new SQLScriptRunner(
+                        databaseScriptsDir
+                        + File.separator + "droptables.sql");
+                runner.runScript(conn, false);
+
+                System.out.println("==============");
+                System.out.println("Stopping Derby");
+                System.out.println("==============");
+                
+                try {
+                    DriverManager.getConnection(driverURL + ";shutdown=true");
+                } catch (Exception ignored) {}
+
+                System.setProperty("derby.system.home", databaseDir);
+
+                // Network Derby
+                System.setProperty("derby.drda.portNumber", port);
+                System.setProperty("derby.drda.host", "localhost");
+                System.setProperty("derby.drda.maxThreads","10");
+                //System.setProperty("derby.drda.logConnections","true");
+                NetworkServerControl server = new NetworkServerControl();
+                server.shutdown();
+
+                //try {
+                //    while (true) {
+                //       server.ping();
+                //    }
+                //} catch (Exception expected) {}
+
+                // Embedded Derby
+                //DriverManager.getConnection("jdbc:derby:;shutdown=true");
+
+                //try {Thread.sleep(2000);} catch (Exception ignored) {}
+
+            } else {
+                System.out.println("Skipping Derby shutdown");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new BuildException(e.getMessage());
+        }
+    }
+    /**
+     * @return Returns the port.
+     */
+    public String getPort() {
+        return port;
+    }
+    /**
+     * @param port The port to set.
+     */
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+    /**
+     * @return the skip
+     */
+    public boolean isSkip() {
+        return skip;
+    }
+
+    /**
+     * @param skip the skip to set
+     */
+    public void setSkip(boolean skip) {
+        this.skip = skip;
+    }
+
+    /**
+     * @return the databaseDir
+     */
+    public String getDatabaseDir() {
+        return databaseDir;
+    }
+
+    /**
+     * @param databaseDir the databaseDir to set
+     */
+    public void setDatabaseDir(String databaseDir) {
+        this.databaseDir = databaseDir;
+    }
+
+    /**
+     * @return the databaseScriptsDir
+     */
+    public String getDatabaseScriptsDir() {
+        return databaseScriptsDir;
+    }
+
+    /**
+     * @param databaseScriptsDir the databaseScriptsDir to set
+     */
+    public void setDatabaseScriptsDir(String databaseScriptsDir) {
+        this.databaseScriptsDir = databaseScriptsDir;
+    }
+}

Modified: roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/SQLScriptRunnerTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/SQLScriptRunnerTest.java?rev=1505415&r1=1505414&r2=1505415&view=diff
==============================================================================
--- roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/SQLScriptRunnerTest.java
(original)
+++ roller/trunk/app/src/test/java/org/apache/roller/weblogger/business/SQLScriptRunnerTest.java
Sun Jul 21 16:33:20 2013
@@ -23,7 +23,7 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import junit.framework.TestCase;
 import org.apache.roller.weblogger.business.startup.WebloggerStartup;
-import org.apache.roller.util.SQLScriptRunner;
+import org.apache.roller.weblogger.business.startup.SQLScriptRunner;
 import org.apache.roller.weblogger.TestUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;

Modified: roller/trunk/pom.xml
URL: http://svn.apache.org/viewvc/roller/trunk/pom.xml?rev=1505415&r1=1505414&r2=1505415&view=diff
==============================================================================
--- roller/trunk/pom.xml (original)
+++ roller/trunk/pom.xml Sun Jul 21 16:33:20 2013
@@ -33,7 +33,6 @@
     </properties>
 
     <modules>
-        <module>test-utils</module>
         <module>app</module>
     </modules>
 



Mime
View raw message