weaver 2004/10/29 07:02:28
Modified: components/prefs/src/test/org/apache/jetspeed/prefs
TestPropertyManager.java TestPreferences.java
Added: components/prefs/src/test/org/apache/jetspeed/prefs
TestPreferencesNoPropManager.java
Log:
see: http://nagoya.apache.org/jira/browse/JS2-144
- Refactored prefs
Revision Changes Path
1.19 +26 -31
jakarta-jetspeed-2/components/prefs/src/test/org/apache/jetspeed/prefs/TestPropertyManager.java
Index: TestPropertyManager.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/prefs/src/test/org/apache/jetspeed/prefs/TestPropertyManager.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- TestPropertyManager.java 1 Aug 2004 20:23:00 -0000 1.18
+++ TestPropertyManager.java 29 Oct 2004 14:02:28 -0000 1.19
@@ -22,9 +22,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import
org.apache.jetspeed.components.persistence.store.util.PersistenceSupportedTestCase;
-import org.apache.jetspeed.prefs.impl.PreferencesProviderImpl;
-import org.apache.jetspeed.prefs.impl.PropertyManagerImpl;
+import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
import org.apache.jetspeed.prefs.om.Property;
/**
@@ -32,7 +30,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Le Strat</a>
*/
-public class TestPropertyManager extends PersistenceSupportedTestCase
+public class TestPropertyManager extends DatasourceEnabledSpringTestCase
{
/** The property manager. */
@@ -44,28 +42,8 @@
private final static int USER_PROPERTY_SET_TYPE = 0;
private final static int SYSTEM_PROPERTY_SET_TYPE = 1;
- private PreferencesProviderImpl provider;
+ private PreferencesProvider provider;
- /**
- * <p>Defines the test case name for junit.</p>
- * @param testName The test case name.
- */
- public TestPropertyManager(String testName)
- {
- super(testName);
- }
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception
- {
- super.setUp();
- pms =new PropertyManagerImpl(persistenceStore);
- provider = new PreferencesProviderImpl(persistenceStore,
"org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl", true);
- // Class.forName("org.apache.jetspeed.prefs.impl.PreferencesImpl");
- provider.start();
- }
/**
* @see junit.framework.TestCase#tearDown()
@@ -86,7 +64,7 @@
/**
* <p>Test add property keys to a [EMAIL PROTECTED] Preferences} node.</p>
*/
- public void testAddPropertyKeys() throws PropertyException
+ public void testAddPropertyKeys() throws Exception
{
Map propertyKeys = initPropertyKeysMap();
Preferences pref =
Preferences.userRoot().node("/user/principal1/propertyset1");
@@ -102,8 +80,9 @@
/**
* <p>Test get property key.</p>
+ * @throws Exception
*/
- public void testGetPropertyKeys()
+ public void testGetPropertyKeys() throws Exception
{
initPropertyKeys();
Preferences pref =
Preferences.userRoot().node("/user/principal1/propertyset1");
@@ -114,7 +93,7 @@
/**
* <p>Test update property key.</p>
*/
- public void testUpdatePropertyKey() throws PropertyException
+ public void testUpdatePropertyKey() throws Exception
{
initPropertyKeys();
Preferences pref =
Preferences.userRoot().node("/user/principal1/propertyset1");
@@ -139,7 +118,7 @@
/**
* <p>Test remove property keys.</p>
*/
- public void testRemovePropertyKeys() throws PropertyException
+ public void testRemovePropertyKeys() throws Exception
{
initPropertyKeys();
Preferences pref =
Preferences.userRoot().node("/user/principal1/propertyset1");
@@ -174,7 +153,7 @@
/**
* <p>Init property property keys.</p>
*/
- protected void initPropertyKeys()
+ protected void initPropertyKeys() throws Exception
{
Map propertyKeys = initPropertyKeysMap();
Preferences pref =
Preferences.userRoot().node("/user/principal1/propertyset1");
@@ -191,7 +170,7 @@
/**
* <p>Clean properties.</p>
*/
- protected void clean()
+ protected void clean() throws Exception
{
Preferences pref =
Preferences.userRoot().node("/user/principal1/propertyset1");
try
@@ -207,6 +186,22 @@
{
System.out.println("BackingStoreException" + bse);
}
+ }
+
+ protected String[] getConfigurations()
+ {
+ return new String[]{"META-INF/prefs-dao.xml", "META-INF/transaction.xml"};
+ }
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ provider = (PreferencesProvider) ctx.getBean("prefsProvider");
+
+ pms = (PropertyManager) ctx.getBean("propertyManager");
}
}
1.20 +17 -50
jakarta-jetspeed-2/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java
Index: TestPreferences.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferences.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- TestPreferences.java 12 Oct 2004 19:46:30 -0000 1.19
+++ TestPreferences.java 29 Oct 2004 14:02:28 -0000 1.20
@@ -22,9 +22,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import
org.apache.jetspeed.components.persistence.store.util.PersistenceSupportedTestCase;
-import org.apache.jetspeed.prefs.impl.PreferencesProviderImpl;
-import org.apache.jetspeed.prefs.impl.PropertyManagerImpl;
+import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
/**
* <p>
@@ -33,7 +31,7 @@
*
* @author <a href="[EMAIL PROTECTED]">David Le Strat </a>
*/
-public class TestPreferences extends PersistenceSupportedTestCase
+public class TestPreferences extends DatasourceEnabledSpringTestCase
{
/** The property manager. */
@@ -47,20 +45,9 @@
private final static int USER_PROPERTY_SET_TYPE = 0;
private final static int SYSTEM_PROPERTY_SET_TYPE = 1;
- private PreferencesProviderImpl provider;
+ private PreferencesProvider provider;
- /**
- * <p>
- * Defines the test case name for junit.
- * </p>
- *
- * @param testName
- * The test case name.
- */
- public TestPreferences( String testName )
- {
- super(testName);
- }
+ private PreferencesProvider providerNoProp;
/**
* @see junit.framework.TestCase#setUp()
@@ -68,10 +55,10 @@
public void setUp() throws Exception
{
super.setUp();
- pms = new PropertyManagerImpl(persistenceStore);
- provider = new PreferencesProviderImpl(persistenceStore,
- "org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl", true);
- provider.start();
+ provider = (PreferencesProvider) ctx.getBean("prefsProvider");
+
+ pms = (PropertyManager) ctx.getBean("propertyManager");
+
// Make sure we are starting with a clean slate
clearChildren(Preferences.userRoot());
clearChildren(Preferences.systemRoot());
@@ -100,9 +87,7 @@
*/
public void testUserRoot()
{
- pms = new PropertyManagerImpl(persistenceStore);
- provider = new PreferencesProviderImpl(persistenceStore,
- "org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl", true);
+
Preferences prefs = Preferences.userRoot();
if (null != prefs)
{
@@ -114,20 +99,6 @@
}
}
- public void testSansPropertyManager()
- {
- pms = new PropertyManagerImpl(persistenceStore);
- provider = new PreferencesProviderImpl(persistenceStore,
- "org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl", false);
- Preferences pref0 = Preferences.userRoot();
- // Test that the property manager is off
- Preferences pref1 = pref0.node("testOpenNode");
- pref1.put("0", "I am 0 key");
-
- assertNotNull(pref1.get("0", null));
-
- }
-
/**
* <p>
* Test system root.
@@ -135,9 +106,6 @@
*/
public void testSystemRoot()
{
- pms = new PropertyManagerImpl(persistenceStore);
- provider = new PreferencesProviderImpl(persistenceStore,
- "org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl", true);
Preferences prefs = Preferences.systemRoot();
if (null != prefs)
{
@@ -156,9 +124,6 @@
*/
public void testNodeAndChildrenNames()
{
- pms = new PropertyManagerImpl(persistenceStore);
- provider = new PreferencesProviderImpl(persistenceStore,
- "org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl", true);
Preferences prefs = Preferences.userRoot();
// Test without children.
try
@@ -220,12 +185,10 @@
* Test adding properties to a property set node and get property keys for a
* given node.
* </p>
+ * @throws Exception
*/
- public void testPropertyAndPropertyKeys()
+ public void testPropertyAndPropertyKeys() throws Exception
{
- pms = new PropertyManagerImpl(persistenceStore);
- provider = new PreferencesProviderImpl(persistenceStore,
- "org.apache.jetspeed.prefs.impl.PreferencesFactoryImpl", true);
// 1. Current node does not have any property associated to it.
// No property has been defined nor added to the node. There should be
@@ -339,7 +302,7 @@
* Init property property keys.
* </p>
*/
- protected void initPropertyKeys()
+ protected void initPropertyKeys() throws Exception
{
Map propertyKeys = initPropertyKeysMap();
Preferences pref =
Preferences.userRoot().node("/user/principal1/propertyset1");
@@ -358,7 +321,7 @@
* Clean properties.
* </p>
*/
- protected void clean()
+ protected void clean() throws Exception
{
Preferences pref =
Preferences.userRoot().node("/user/principal1/propertyset1");
try
@@ -390,4 +353,8 @@
}
}
+ protected String[] getConfigurations()
+ {
+ return new String[]{"META-INF/prefs-dao.xml", "META-INF/transaction.xml"};
+ }
}
1.1
jakarta-jetspeed-2/components/prefs/src/test/org/apache/jetspeed/prefs/TestPreferencesNoPropManager.java
Index: TestPreferencesNoPropManager.java
===================================================================
/*
* Created on Oct 21, 2004
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package org.apache.jetspeed.prefs;
import java.util.Map;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
/**
* <p>
* TestPreferencesNoPropManager
* </p>
* <p>
*
* </p>
* @author <a href="mailto:[EMAIL PROTECTED]">Scott T. Weaver</a>
* @version $Id: TestPreferencesNoPropManager.java,v 1.1 2004/10/29 14:02:28 weaver
Exp $
*
*/
public class TestPreferencesNoPropManager extends DatasourceEnabledSpringTestCase
{
/**
* The property manager.
*/
private static PropertyManager pms;
private PreferencesProvider provider;
/**
* @see junit.framework.TestCase#setUp()
*/
public void setUp() throws Exception
{
super.setUp();
provider = (PreferencesProvider) ctx.getBean("prefsProvider");
pms = (PropertyManager) ctx.getBean("propertyManager");
// Make sure we are starting with a clean slate
clearChildren(Preferences.userRoot());
clearChildren(Preferences.systemRoot());
}
/**
* @see junit.framework.TestCase#tearDown()
*/
public void tearDown() throws Exception
{
clean();
// super.tearDown();
}
protected String[] getConfigurations()
{
return new String[]{"META-INF/prefs-noprop-dao.xml",
"META-INF/transaction.xml"};
}
protected void clearChildren(Preferences node) throws Exception
{
String[] names = node.childrenNames();
for(int i=0; i < names.length; i++)
{
node.node(names[i]).removeNode();
}
}
/**
* <p>
* Clean properties.
* </p>
*/
protected void clean() throws Exception
{
Preferences pref =
Preferences.userRoot().node("/user/principal1/propertyset1");
try
{
Map propertyKeys = pms.getPropertyKeys(pref);
pms.removePropertyKeys(pref, propertyKeys.keySet());
Preferences.userRoot().node("/user").removeNode();
Preferences.userRoot().node("/an1").removeNode();
Preferences.userRoot().node("/rn1").removeNode();
Preferences.userRoot().node("/testOpenNode").removeNode();
Preferences.userRoot().node("/removeTest").removeNode();
}
catch (PropertyException pex)
{
System.out.println("PropertyException" + pex);
}
catch (BackingStoreException bse)
{
System.out.println("BackingStoreException" + bse);
}
}
public void testSansPropertyManager() throws Exception
{
// Make sure we are starting with a clean slate
clearChildren(Preferences.userRoot());
clearChildren(Preferences.systemRoot());
Preferences pref0 = Preferences.userRoot();
// Test that the property manager is off
Preferences pref1 = pref0.node("testOpenNode");
pref1.put("0", "I am 0 key");
assertNotNull(pref1.get("0", null));
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]