weaver 2004/10/29 07:35:15
Modified: portal/src/test/org/apache/jetspeed/userinfo
TestUserInfoManager.java
Added: portal/src/test/org/apache/jetspeed/userinfo user-info.xml
Log:
Using new spring supported testcase.
added spring config for testing
Revision Changes Path
1.17 +24 -78
jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java
Index: TestUserInfoManager.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/userinfo/TestUserInfoManager.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- TestUserInfoManager.java 11 Oct 2004 23:26:06 -0000 1.16
+++ TestUserInfoManager.java 29 Oct 2004 14:35:15 -0000 1.17
@@ -16,6 +16,7 @@
import java.io.FileReader;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -26,8 +27,8 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.apache.jetspeed.AbstractPrefsSupportedTestCase;
import org.apache.jetspeed.cache.PortletCache;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
import org.apache.jetspeed.factory.JetspeedPortletFactory;
import org.apache.jetspeed.factory.JetspeedPortletFactoryProxy;
import org.apache.jetspeed.mockobjects.request.MockRequestContext;
@@ -35,32 +36,10 @@
import org.apache.jetspeed.prefs.PropertyException;
import org.apache.jetspeed.prefs.om.Property;
import org.apache.jetspeed.request.RequestContext;
-import org.apache.jetspeed.security.AuthenticationProvider;
-import org.apache.jetspeed.security.AuthenticationProviderProxy;
import org.apache.jetspeed.security.SecurityException;
import org.apache.jetspeed.security.SecurityHelper;
-import org.apache.jetspeed.security.SecurityProvider;
import org.apache.jetspeed.security.User;
-import org.apache.jetspeed.security.UserManager;
-import org.apache.jetspeed.security.impl.AuthenticationProviderImpl;
-import org.apache.jetspeed.security.impl.AuthenticationProviderProxyImpl;
-import org.apache.jetspeed.security.impl.GroupManagerImpl;
-import org.apache.jetspeed.security.impl.PermissionManagerImpl;
-import org.apache.jetspeed.security.impl.RoleManagerImpl;
-import org.apache.jetspeed.security.impl.SecurityProviderImpl;
-import org.apache.jetspeed.security.impl.UserManagerImpl;
-import org.apache.jetspeed.security.spi.CredentialHandler;
-import org.apache.jetspeed.security.spi.GroupSecurityHandler;
-import org.apache.jetspeed.security.spi.RoleSecurityHandler;
-import org.apache.jetspeed.security.spi.SecurityMappingHandler;
-import org.apache.jetspeed.security.spi.UserSecurityHandler;
-import org.apache.jetspeed.security.spi.impl.CommonQueries;
-import org.apache.jetspeed.security.spi.impl.DefaultCredentialHandler;
-import org.apache.jetspeed.security.spi.impl.DefaultGroupSecurityHandler;
-import org.apache.jetspeed.security.spi.impl.DefaultRoleSecurityHandler;
-import org.apache.jetspeed.security.spi.impl.DefaultSecurityMappingHandler;
-import org.apache.jetspeed.security.spi.impl.DefaultUserSecurityHandler;
-import org.apache.jetspeed.userinfo.impl.UserInfoManagerImpl;
+import org.apache.jetspeed.security.util.test.AbstractSecurityTestcase;
import org.apache.jetspeed.util.descriptor.ExtendedPortletMetadata;
import org.apache.jetspeed.util.descriptor.PortletApplicationDescriptor;
@@ -69,33 +48,15 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Le Strat</a>
*/
-public class TestUserInfoManager extends AbstractPrefsSupportedTestCase
+public class TestUserInfoManager extends AbstractSecurityTestcase
{
/** The user info manager. */
private UserInfoManager uim;
-
- /** The user manager. */
- private UserManager ums;
- private Object gms;
-
- private Object rms;
-
- private PermissionManagerImpl pms;
-
-
-
- /**
- * <p>Defines the testcase name for JUnit.</p>
- *
- * @param name the testcase's name.
- */
- public TestUserInfoManager(String name)
- {
- super(name);
- }
+ private PortletRegistry portletRegistry;
+
/**
* @see junit.framework.TestCase#setUp()
*/
@@ -104,30 +65,10 @@
super.setUp();
PortletCache portletCache = new PortletCache();
- new JetspeedPortletFactoryProxy(new JetspeedPortletFactory(portletCache));
+ new JetspeedPortletFactoryProxy(new JetspeedPortletFactory(portletCache));
- // SPI Security handlers.
- CommonQueries cq = new CommonQueries(persistenceStore);
- CredentialHandler ch = new DefaultCredentialHandler(cq);
- UserSecurityHandler ush = new DefaultUserSecurityHandler(cq);
- RoleSecurityHandler rsh = new DefaultRoleSecurityHandler(cq);
- GroupSecurityHandler gsh = new DefaultGroupSecurityHandler(cq);
- SecurityMappingHandler smh = new DefaultSecurityMappingHandler(cq);
-
- // Security Providers.
- AuthenticationProvider atnProvider = new
AuthenticationProviderImpl("DefaultAuthenticator", "The default authenticator",
"login.conf", ch, ush);
- List atnProviders = new ArrayList();
- atnProviders.add(atnProvider);
- AuthenticationProviderProxy atnProviderProxy = new
AuthenticationProviderProxyImpl(atnProviders, "DefaultAuthenticator");
- SecurityProvider securityProvider = new
SecurityProviderImpl(atnProviderProxy, rsh, gsh, smh);
-
- ums = new UserManagerImpl(securityProvider);
- gms = new GroupManagerImpl(securityProvider);
- rms = new RoleManagerImpl(securityProvider);
-
- ums = new UserManagerImpl(securityProvider);
- uim = new UserInfoManagerImpl(ums, portletRegistry);
-
+ uim = (UserInfoManager)
ctx.getBean("org.apache.jetspeed.userinfo.UserInfoManager");
+ portletRegistry = (PortletRegistry) ctx.getBean("portletRegistry");
}
/**
@@ -153,16 +94,14 @@
// persist the app
try
- {
- persistenceStore.getTransaction().begin();
- portletRegistry.registerPortletApplication(app);
- persistenceStore.getTransaction().commit();
+ {
+ portletRegistry.registerPortletApplication(app);
}
catch (Exception e)
{
String msg =
"Unable to register portlet application, " + app.getName() + ",
through the portlet portletRegistry: " + e.toString();
- persistenceStore.getTransaction().rollback();
+
throw new Exception(msg, e);
}
@@ -193,10 +132,8 @@
// remove the app
try
- {
- persistenceStore.getTransaction().begin();
- portletRegistry.removeApplication(app);
- persistenceStore.getTransaction().commit();
+ {
+ portletRegistry.removeApplication(app);
}
catch (Exception e)
{
@@ -224,7 +161,7 @@
/**
* <p>Init test user.</p>
*/
- private void initUser()
+ private void initUser() throws Exception
{
User user = null;
try
@@ -281,4 +218,13 @@
}
}
+ protected String[] getConfigurations()
+ {
+
+ String[] confs = super.getConfigurations();
+ List confList = new ArrayList(Arrays.asList(confs));
+ confList.add("META-INF/registry-dao.xml");
+ confList.add("org/apache/jetspeed/userinfo/user-info.xml");
+ return (String[]) confList.toArray(new String[1]);
+ }
}
1.1
jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/userinfo/user-info.xml
Index: user-info.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<!--
Copyright 2004 The Apache Software Foundation
Licensed 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.
-->
<beans>
<!-- User Info -->
<bean id="org.apache.jetspeed.userinfo.UserInfoManager"
class="org.apache.jetspeed.userinfo.impl.UserInfoManagerImpl"
>
<constructor-arg ><ref
bean="org.apache.jetspeed.security.UserManager"/></constructor-arg>
<constructor-arg ><ref
bean="org.apache.jetspeed.components.portletregistry.PortletRegistry"/></constructor-arg>
</bean>
</beans>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]