Permalink
Browse files

Make sure local unit tests work.

git-svn-id: https://svn.apache.org/repos/asf/roller/trunk@1651622 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
Greg Huber
Greg Huber committed Jan 14, 2015
1 parent eb02d7b commit 2ce983010c49b0ae658d32595200c24212e1aeab
@@ -79,7 +79,8 @@ public static void setupWeblogger() throws Exception {
// 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 static void teardownPermissions(WeblogPermission perm)
/**
* 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 static WeblogEntry setupWeblogEntry(String anchor,
}
/**
* 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 static void teardownHitCount(String id) throws Exception {
/**
* 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
@@ -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_%';
@@ -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

0 comments on commit 2ce9830

Please sign in to comment.