roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghu...@apache.org
Subject svn commit: r1651622 - in /roller/trunk: app/src/main/java/org/apache/roller/weblogger/TestUtils.java docs/testing/junit-cleartables-mysql.sql docs/testing/roller-junit.properties
Date Wed, 14 Jan 2015 11:33:44 GMT
Author: ghuber
Date: Wed Jan 14 11:33:43 2015
New Revision: 1651622

URL: http://svn.apache.org/r1651622
Log:
Make sure local unit tests work.

Added:
    roller/trunk/docs/testing/roller-junit.properties
Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/TestUtils.java
    roller/trunk/docs/testing/junit-cleartables-mysql.sql

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=1651622&r1=1651621&r2=1651622&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 Wed Jan 14 11:33:43
2015
@@ -79,7 +79,8 @@ public final class TestUtils {
             // always initialize the properties manager and flush
             WebloggerFactory.getWeblogger().initialize();
 
-            // Reset data for local tests see events-custom.properties
+            // Reset data for local tests see
+            // docs/testing/roller-junit.properties for howto
             Boolean local = WebloggerConfig.getBooleanProperty(
                     "junit.testdata.reset", false);
 
@@ -306,14 +307,13 @@ public final class TestUtils {
     /**
      * Convenience method for creating a weblog category.
      */
-    public static WeblogCategory setupWeblogCategory(Weblog weblog,
-            String name) throws Exception {
+    public static WeblogCategory setupWeblogCategory(Weblog weblog, String name)
+            throws Exception {
 
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger()
                 .getWeblogEntryManager();
 
-        WeblogCategory testCat = new WeblogCategory(weblog, name,
-                null, null);
+        WeblogCategory testCat = new WeblogCategory(weblog, name, null, null);
         mgr.saveWeblogCategory(testCat);
 
         // flush to db
@@ -357,12 +357,14 @@ public final class TestUtils {
     }
 
     /**
-     * Convenience method for creating a published weblog entry with the blog's default category
+     * Convenience method for creating a published weblog entry with the blog's
+     * default category
      */
-    public static WeblogEntry setupWeblogEntry(String anchor, Weblog weblog, User user) throws
Exception {
+    public static WeblogEntry setupWeblogEntry(String anchor, Weblog weblog,
+            User user) throws Exception {
 
-        return TestUtils.setupWeblogEntry(anchor, weblog.getWeblogCategories().iterator().next(),
PubStatus.PUBLISHED,
-                weblog, user);
+        return TestUtils.setupWeblogEntry(anchor, weblog.getWeblogCategories()
+                .iterator().next(), PubStatus.PUBLISHED, weblog, user);
     }
 
     /**
@@ -609,13 +611,13 @@ public final class TestUtils {
     /**
      * Convenience method for creating a weblog folder.
      */
-    public static WeblogBookmarkFolder setupFolder(Weblog weblog, String name) throws Exception
{
+    public static WeblogBookmarkFolder setupFolder(Weblog weblog, String name)
+            throws Exception {
 
         BookmarkManager mgr = WebloggerFactory.getWeblogger()
                 .getBookmarkManager();
 
-        WeblogBookmarkFolder testFolder = new WeblogBookmarkFolder(
-                name, weblog);
+        WeblogBookmarkFolder testFolder = new WeblogBookmarkFolder(name, weblog);
         mgr.saveFolder(testFolder);
 
         // flush to db

Modified: roller/trunk/docs/testing/junit-cleartables-mysql.sql
URL: http://svn.apache.org/viewvc/roller/trunk/docs/testing/junit-cleartables-mysql.sql?rev=1651622&r1=1651621&r2=1651622&view=diff
==============================================================================
--- roller/trunk/docs/testing/junit-cleartables-mysql.sql (original)
+++ roller/trunk/docs/testing/junit-cleartables-mysql.sql Wed Jan 14 11:33:43 2015
@@ -22,24 +22,22 @@
 
 -- Any changes here should also be in docs/testing/junit-cleartables-mysql.sql.
 
-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 mt from weblog 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 weblog w, roller_mediafile mf where w.id = mf.weblogid and w.creator like
'junit_%';
+delete md from weblog w, roller_mediafiledir md where w.id = md.websiteid and w.creator like
'junit_%';
+delete from roller_mediafile WHERE creator like 'junit_%';
+delete from roller_mediafiledir;
 
--- no weblog
--- delete from roller_mediafile WHERE creator like 'junit_%';
--- delete from roller_mediafiledir;
+delete r from weblog w, referer r WHERE w.id = r.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 weblog WHERE 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 b from weblog w, bookmark_folder f, bookmark b where f.id = b.folderid and w.id =
f.websiteid and w.creator like 'junit_%';
+delete from bookmark_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_user 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_%';

Added: roller/trunk/docs/testing/roller-junit.properties
URL: http://svn.apache.org/viewvc/roller/trunk/docs/testing/roller-junit.properties?rev=1651622&view=auto
==============================================================================
--- roller/trunk/docs/testing/roller-junit.properties (added)
+++ roller/trunk/docs/testing/roller-junit.properties Wed Jan 14 11:33:43 2015
@@ -0,0 +1,72 @@
+## Eclipse/MySql junit custom properties for running local tests
+
+## Copy file roller-junit.properties (this file) to app/src/test/resource
+
+## Copy file junit-cleartables-mysql.sql to app/src/test/resources/dbscripts/junit-cleartables-mysql.sql
+
+## Note: running local tests will execute dbscripts/junit-cleartables-mysql.sql and will
+## clear files, so check before running or create an additional database with the details
below
+
+## Rename app/src/test/resource/roller-junit.properties when not testing!!
+
+database.configurationType=jdbc
+database.jdbc.driverClass=com.mysql.jdbc.Driver
+database.jdbc.connectionURL=jdbc:mysql://localhost:3306/rollerdev?autoReconnect=true&useUnicode=true&characterEncoding=utf-8&mysqlEncoding=utf8
+database.jdbc.username=testuser
+database.jdbc.password=testuser
+
+hibernate.dialect=org.hibernate.dialect.MySQLDialect
+hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory
+
+## Run junit-cleartables-mysql.sql to reset data
+junit.testdata.reset=true
+
+# turn off transaction manager during JUnit testing (TODO: find way to activate for JUnit
tests)
+# use CMA authentication to work around Spring init issues in UI tests
+authentication.cma.enabled=true
+
+# use plain text passwords in testing
+passwds.encryption.enabled=false
+
+# we don't want to start with any folders/bookmarks for testing
+newuser.blogroll=
+
+# we don't want to start with any weblog categories for testing
+newuser.categories=
+
+# put directories in ${build.tests}
+themes.dir=${project.build.testOutputDirectory}${file.separator}themes
+search.index.dir=${project.build.testOutputDirectory}${file.separator}index
+uploads.dir=${project.build.testOutputDirectory}${file.separator}uploadsdir
+mediafiles.storage.dir=${project.build.testOutputDirectory}${file.separator}mediafiles
+cache.dir=${project.build.testOutputDirectory}${file.separator}planet-cache
+
+# don't auto migrate during tests
+uploads.migrate.auto=false
+
+# override tasks.enabled so we can add a test task
+tasks.enabled=TestTask
+
+# test task
+tasks.TestTask.class=org.apache.roller.weblogger.business.TestTask
+tasks.TestTask.startTime=immediate
+tasks.TestTask.interval=1800
+tasks.TestTask.leaseTime=300
+
+# logging
+log4j.rootCategory=INFO, roller
+log4j.appender.roller.File=${project.build.directory}/roller.log
+log4j.category.org.apache.roller=INFO
+log4j.category.net.java.roller=ERROR
+
+log4j.category.org.apache.struts=DEBUG
+#log4j.category.org.apache.roller.planet.business.jpa.JPAPropertiesManagerImpl=DEBUG
+#log4j.category.org.apache.roller.weblogger.business.jpa.JPAPropertiesManagerImpl=DEBUG
+#log4j.category.org.apache.roller.weblogger.business=DEBUG
+
+#log4j.category.org.apache.roller.planet.config.PlanetConfig=DEBUG
+#log4j.category.org.apache.roller.weblogger.config.WebloggerConfig=DEBUG
+
+#log4j.category.org.apache.roller.weblogger.planet.tasks=DEBUG
+#log4j.category.org.apache.roller.planet.business=DEBUG
+#log4j.category.org.apache.roller.weblogger.planet.business=DEBUG



Mime
View raw message