Author: agilliland
Date: Sun Apr 9 16:51:19 2006
New Revision: 392851
URL: http://svn.apache.org/viewcvs?rev=392851&view=rev
Log:
adding new tests for properties, pings, and weblog entries.
Added:
incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java
incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java
incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogEntryTest.java
Modified:
incubator/roller/branches/roller-newbackend/build.xml
incubator/roller/branches/roller-newbackend/tests/org/roller/business/TestAll.java
incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogPageTest.java
Modified: incubator/roller/branches/roller-newbackend/build.xml
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/build.xml?rev=392851&r1=392850&r2=392851&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/build.xml (original)
+++ incubator/roller/branches/roller-newbackend/build.xml Sun Apr 9 16:51:19
2006
@@ -820,6 +820,9 @@
<include name="org/roller/business/WeblogTest.class"/>
<include name="org/roller/business/PermissionTest.class"/>
<include name="org/roller/business/WeblogPageTest.class"/>
+ <include name="org/roller/business/PingsTest.class"/>
+ <include name="org/roller/business/PropertiesTest.class"/>
+ <include name="org/roller/business/WeblogEntryTest.class"/>
</fileset>
</batchtest>
</junit>
Added:
incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java?rev=392851&view=auto
==============================================================================
---
incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java
(added)
+++
incubator/roller/branches/roller-newbackend/tests/org/roller/business/PingsTest.java
Sun Apr 9 16:51:19 2006
@@ -0,0 +1,209 @@
+/*
+ * PingsTest.java
+ *
+ * Created on April 9, 2006, 1:27 PM
+ */
+
+package org.roller.business;
+
+import java.util.List;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.roller.TestUtils;
+import org.roller.model.PingTargetManager;
+import org.roller.model.RollerFactory;
+import org.roller.pojos.PingTargetData;
+import org.roller.pojos.UserData;
+import org.roller.pojos.WebsiteData;
+
+
+/**
+ * Test Pings related business operations.
+ *
+ * That includes:
+ * - create a common ping target
+ * - create a custom ping target
+ * - update a ping target
+ * - remove a ping target
+ * - remove all custom ping targets for website
+ * - remove all custom ping targets
+ * - get a ping target by id
+ * - get all common ping targets
+ * - get all custom ping targets for website
+ *
+ */
+public class PingsTest extends TestCase {
+
+ public static Log log = LogFactory.getLog(PingsTest.class);
+
+ UserData testUser = null;
+ WebsiteData testWeblog = null;
+ PingTargetData testCommonPing = null;
+ PingTargetData testCustomPing = null;
+
+
+ public PingsTest(String name) {
+ super(name);
+ }
+
+
+ public static Test suite() {
+ return new TestSuite(PingsTest.class);
+ }
+
+
+ /**
+ * All tests in this suite require a user and a weblog.
+ */
+ public void setUp() throws Exception {
+
+ try {
+ testUser = TestUtils.setupUser("wtTestUser");
+ testWeblog = TestUtils.setupWeblog("wtTestWeblog", testUser);
+ } catch (Exception ex) {
+ log.error(ex);
+ }
+
+ testCommonPing = new PingTargetData();
+ testCommonPing.setName("testCommonPing");
+ testCommonPing.setPingUrl("http://localhost/testCommonPing");
+
+ testCustomPing = new PingTargetData();
+ testCustomPing.setName("testCommonPing");
+ testCustomPing.setPingUrl("http://localhost/testCommonPing");
+ }
+
+ public void tearDown() throws Exception {
+
+ try {
+ TestUtils.teardownWeblog(testWeblog.getHandle());
+ TestUtils.teardownUser(testUser.getUserName());
+ } catch (Exception ex) {
+ log.error(ex);
+ }
+
+ testCommonPing = null;
+ testCustomPing = null;
+ }
+
+
+ /**
+ * Test basic persistence operations ... Create, Update, Delete
+ */
+ public void testPingTargetCRUD() throws Exception {
+
+ PingTargetManager mgr =
RollerFactory.getRoller().getPingTargetManager();
+ PingTargetData ping = null;
+
+ // create common ping
+ mgr.storePingTarget(testCommonPing);
+ String commonId = testCommonPing.getId();
+
+ // make sure common ping was stored
+ ping = null;
+ ping = mgr.retrievePingTarget(commonId);
+ assertNotNull(ping);
+ assertEquals(testCommonPing.getPingUrl(), ping.getPingUrl());
+
+ // create custom ping
+ testCustomPing.setWebsite(testWeblog);
+ mgr.storePingTarget(testCustomPing);
+ String customId = testCustomPing.getId();
+
+ // make sure custom ping was stored
+ ping = null;
+ ping = mgr.retrievePingTarget(customId);
+ assertNotNull(ping);
+ assertEquals(testCustomPing.getPingUrl(), ping.getPingUrl());
+
+ // update common ping
+ ping = null;
+ ping = mgr.retrievePingTarget(commonId);
+ ping.setName("testtestCommon");
+ mgr.storePingTarget(ping);
+
+ // make sure common ping was updated
+ ping = null;
+ ping = mgr.retrievePingTarget(commonId);
+ assertNotNull(ping);
+ assertEquals("testtestCommon", ping.getName());
+
+ // update custom ping
+ ping = null;
+ ping = mgr.retrievePingTarget(customId);
+ ping.setName("testtestCustom");
+ mgr.storePingTarget(ping);
+
+ // make sure custom ping was updated
+ ping = null;
+ ping = mgr.retrievePingTarget(customId);
+ assertNotNull(ping);
+ assertEquals("testtestCustom", ping.getName());
+
+ // delete common ping
+ mgr.removePingTarget(commonId);
+
+ // make sure common ping was deleted
+ ping = null;
+ ping = mgr.retrievePingTarget(commonId);
+ assertNull(ping);
+
+ // delete custom ping
+ mgr.removePingTarget(customId);
+
+ // make sure custom ping was deleted
+ ping = null;
+ ping = mgr.retrievePingTarget(customId);
+ assertNull(ping);
+ }
+
+
+ /**
+ * Test lookup mechanisms ... id, all common, all custom for weblog
+ */
+ public void testPingTargetLookups() throws Exception {
+
+ PingTargetManager mgr =
RollerFactory.getRoller().getPingTargetManager();
+ PingTargetData ping = null;
+
+ // create common ping
+ mgr.storePingTarget(testCommonPing);
+ String commonId = testCommonPing.getId();
+
+ // create custom ping
+ testCustomPing.setWebsite(testWeblog);
+ mgr.storePingTarget(testCustomPing);
+ String customId = testCustomPing.getId();
+
+ // lookup by id
+ ping = null;
+ ping = mgr.retrievePingTarget(commonId);
+ assertNotNull(ping);
+ assertEquals(testCommonPing.getName(), ping.getName());
+
+ // lookup all common pings
+ List commonPings = mgr.getCommonPingTargets();
+ assertNotNull(commonPings);
+ assertEquals(1, commonPings.size());
+
+ // lookup all custom pings for weblog
+ List customPings = mgr.getCustomPingTargets(testWeblog);
+ assertNotNull(customPings);
+ assertEquals(1, customPings.size());
+
+ // remove custom pings for weblog
+ mgr.removeCustomPingTargets(testWeblog);
+
+ // make sure remove succeeded
+ customPings = mgr.getCustomPingTargets(testWeblog);
+ assertNotNull(customPings);
+ assertEquals(0, customPings.size());
+
+ // remove common ping
+ mgr.removePingTarget(commonId);
+ }
+
+}
Added:
incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java?rev=392851&view=auto
==============================================================================
---
incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java
(added)
+++
incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java
Sun Apr 9 16:51:19 2006
@@ -0,0 +1,89 @@
+/*
+ * PropertiesTest.java
+ *
+ * Created on April 9, 2006, 2:51 PM
+ */
+
+package org.roller.business;
+
+import java.util.Map;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.roller.model.PropertiesManager;
+import org.roller.model.RollerFactory;
+import org.roller.pojos.RollerPropertyData;
+
+/**
+ * Test Properties related business operations.
+ *
+ * That includes:
+ *
+ */
+public class PropertiesTest extends TestCase {
+
+ public static Log log = LogFactory.getLog(PropertiesTest.class);
+
+
+ public PropertiesTest(String name) {
+ super(name);
+ }
+
+
+ public static Test suite() {
+ return new TestSuite(PropertiesTest.class);
+ }
+
+
+ public void setUp() throws Exception {
+
+ }
+
+ public void tearDown() throws Exception {
+
+ }
+
+
+ public void testProperiesCRUD() throws Exception {
+
+ // remember, the properties table is initialized during Roller startup
+
+ PropertiesManager mgr =
RollerFactory.getRoller().getPropertiesManager();
+ RollerPropertyData prop = null;
+
+ // get a property by name
+ prop = mgr.getProperty("site.name");
+ assertNotNull(prop);
+
+ // update a property
+ prop.setValue("testtest");
+ mgr.store(prop);
+
+ // make sure property was updated
+ prop = null;
+ prop = mgr.getProperty("site.name");
+ assertNotNull(prop);
+ assertEquals("testtest", prop.getValue());
+
+ // get all properties
+ Map props = mgr.getProperties();
+ assertNotNull(props);
+ assertTrue(props.containsKey("site.name"));
+
+ // update multiple properties
+ prop = (RollerPropertyData) props.get("site.name");
+ prop.setValue("foofoo");
+ prop = (RollerPropertyData) props.get("site.description");
+ prop.setValue("blahblah");
+ mgr.store(props);
+
+ // make sure all properties were updated
+ props = mgr.getProperties();
+ assertNotNull(props);
+ assertEquals("foofoo",
((RollerPropertyData)props.get("site.name")).getValue());
+ assertEquals("blahblah",
((RollerPropertyData)props.get("site.description")).getValue());
+ }
+
+}
Modified:
incubator/roller/branches/roller-newbackend/tests/org/roller/business/TestAll.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/TestAll.java?rev=392851&r1=392850&r2=392851&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/tests/org/roller/business/TestAll.java
(original)
+++
incubator/roller/branches/roller-newbackend/tests/org/roller/business/TestAll.java
Sun Apr 9 16:51:19 2006
@@ -21,7 +21,6 @@
suite.addTest(WeblogTest.suite());
suite.addTest(PermissionTest.suite());
- suite.addTest(UserManagerTest.suite());
//suite.addTest(WeblogManagerTest.suite());
//suite.addTest(RefererManagerTest.suite());
//suite.addTest(IndexManagerTest.suite());
Added:
incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogEntryTest.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogEntryTest.java?rev=392851&view=auto
==============================================================================
---
incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogEntryTest.java
(added)
+++
incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogEntryTest.java
Sun Apr 9 16:51:19 2006
@@ -0,0 +1,111 @@
+/*
+ * WeblogEntryTest.java
+ *
+ * Created on April 9, 2006, 4:38 PM
+ */
+
+package org.roller.business;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.roller.TestUtils;
+import org.roller.model.RollerFactory;
+import org.roller.model.WeblogManager;
+import org.roller.pojos.UserData;
+import org.roller.pojos.WeblogEntryData;
+import org.roller.pojos.WebsiteData;
+
+/**
+ * Test WeblogEntry related business operations.
+ *
+ * That includes:
+ */
+public class WeblogEntryTest extends TestCase {
+
+ public static Log log = LogFactory.getLog(WeblogEntryTest.class);
+
+ UserData testUser = null;
+ WebsiteData testWeblog = null;
+ WeblogEntryData testEntry = null;
+
+ public WeblogEntryTest(String name) {
+ super(name);
+ }
+
+
+ public static Test suite() {
+ return new TestSuite(WeblogPageTest.class);
+ }
+
+
+ /**
+ * All tests in this suite require a user and a weblog.
+ */
+ public void setUp() throws Exception {
+
+ try {
+ testUser = TestUtils.setupUser("entryTestUser");
+ testWeblog = TestUtils.setupWeblog("entryTestWeblog", testUser);
+ } catch (Exception ex) {
+ log.error(ex);
+ }
+
+ testEntry = new WeblogEntryData();
+ testEntry.setTitle("testEntry");
+ testEntry.setLink("testEntryLink");
+ testEntry.setText("blah blah entry");
+ testEntry.setAnchor("testEntryAnchor");
+ testEntry.setPubTime(new java.sql.Timestamp(new
java.util.Date().getTime()));
+ testEntry.setUpdateTime(new java.sql.Timestamp(new
java.util.Date().getTime()));
+ }
+
+ public void tearDown() throws Exception {
+
+ try {
+ TestUtils.teardownWeblog(testWeblog.getHandle());
+ TestUtils.teardownUser(testUser.getUserName());
+ } catch (Exception ex) {
+ log.error(ex);
+ }
+
+ testEntry = null;
+ }
+
+
+ public void testWeblogEntryCRUD() throws Exception {
+
+ WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+ WeblogEntryData entry = null;
+
+ // create a weblog entry
+ mgr.storeWeblogEntry(testEntry);
+ String entryId = testEntry.getId();
+
+ // make sure entry was created
+ entry = mgr.retrieveWeblogEntry(entryId);
+ assertNotNull(entry);
+ assertEquals(testEntry.getTitle(), entry.getTitle());
+
+ // update a weblog entry
+ entry.setTitle("testtest");
+ mgr.storeWeblogEntry(entry);
+
+ // make sure entry was updated
+ entry = null;
+ entry = mgr.retrieveWeblogEntry(entryId);
+ assertNotNull(entry);
+ assertEquals("testtest", entry.getTitle());
+
+ // delete a weblog entry
+ mgr.removeWeblogEntry(entry);
+
+ // make sure entry was deleted
+ entry = null;
+ entry = mgr.retrieveWeblogEntry(entryId);
+ assertNull(entry);
+ }
+
+}
Modified:
incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogPageTest.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogPageTest.java?rev=392851&r1=392850&r2=392851&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogPageTest.java
(original)
+++
incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogPageTest.java
Sun Apr 9 16:51:19 2006
@@ -56,8 +56,12 @@
*/
public void setUp() throws Exception {
- testUser = TestUtils.setupUser("wtTestUser");
- testWeblog = TestUtils.setupWeblog("wtTestWeblog", testUser);
+ try {
+ testUser = TestUtils.setupUser("wtTestUser");
+ testWeblog = TestUtils.setupWeblog("wtTestWeblog", testUser);
+ } catch (Exception ex) {
+ log.error(ex);
+ }
testPage = new WeblogTemplate();
testPage.setName("testTemplate");
@@ -76,6 +80,8 @@
} catch (Exception ex) {
log.error(ex);
}
+
+ testPage = null;
}