From 9899011ba6dc5f7dedc28591c1a2b91e42017d4b Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 5 Dec 2011 15:56:07 +0000 Subject: [PATCH] fix unit tests for RssServlet git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1210509 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-web/archiva-webapp/pom.xml | 1 + .../archiva/web/rss/RoleManagerStub.java | 117 +++++ .../archiva/web/rss/SecuritySystemStub.java | 435 +++++++++++++++++- .../resources/spring-context-rss-servlet.xml | 2 + 4 files changed, 554 insertions(+), 1 deletion(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java diff --git a/archiva-modules/archiva-web/archiva-webapp/pom.xml b/archiva-modules/archiva-web/archiva-webapp/pom.xml index 48837cc89..f66cc7a02 100644 --- a/archiva-modules/archiva-web/archiva-webapp/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp/pom.xml @@ -836,6 +836,7 @@ org.apache.maven.plugins maven-surefire-plugin + -XX:MaxPermSize=256m -client alphabetical ${project.build.directory}/appserver-base diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java new file mode 100644 index 000000000..1984d8eca --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/RoleManagerStub.java @@ -0,0 +1,117 @@ +package org.apache.archiva.web.rss; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +import org.codehaus.plexus.redback.role.RoleManager; +import org.codehaus.plexus.redback.role.RoleManagerException; +import org.codehaus.plexus.redback.role.model.RedbackRoleModel; +import org.springframework.stereotype.Service; + +import java.net.URL; + +/** + * @author Olivier Lamy + */ +@Service("RoleManagerStub") +public class RoleManagerStub + implements RoleManager +{ + public void loadRoleModel( URL resourceLocation ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void loadRoleModel( RedbackRoleModel model ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void createTemplatedRole( String templateId, String resource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeTemplatedRole( String templateId, String resource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateRole( String templateId, String oldResource, String newResource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void assignRole( String roleId, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void assignRoleByName( String roleName, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void assignTemplatedRole( String templateId, String resource, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void unassignRole( String roleId, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void unassignRoleByName( String roleName, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean roleExists( String roleId ) + throws RoleManagerException + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean templatedRoleExists( String templateId, String resource ) + throws RoleManagerException + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public RedbackRoleModel getModel() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void verifyTemplatedRole( String templateID, String resource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java index d9d45208e..918816df5 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/web/rss/SecuritySystemStub.java @@ -32,10 +32,13 @@ import org.codehaus.plexus.redback.system.SecuritySession; import org.codehaus.plexus.redback.system.SecuritySystem; import org.codehaus.plexus.redback.users.User; import org.codehaus.plexus.redback.users.UserManager; +import org.codehaus.plexus.redback.users.UserManagerListener; import org.codehaus.plexus.redback.users.UserNotFoundException; +import org.codehaus.plexus.redback.users.UserQuery; import org.codehaus.plexus.redback.users.jdo.JdoUser; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -126,7 +129,437 @@ public class SecuritySystemStub public UserManager getUserManager() { - return null; + return new UserManager() + { + public boolean isReadOnly() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public String getId() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void addUserManagerListener( UserManagerListener listener ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeUserManagerListener( UserManagerListener listener ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public User createUser( String username, String fullName, String emailAddress ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User createGuestUser() + { + return new User() + { + public Object getPrincipal() + { + return "guest"; + } + + public String getUsername() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setUsername( String name ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getFullName() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setFullName( String name ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getEmail() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setEmail( String address ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getPassword() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPassword( String rawPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getEncodedPassword() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setEncodedPassword( String encodedPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getLastPasswordChange() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLastPasswordChange( Date passwordChangeDate ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public List getPreviousEncodedPasswords() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPreviousEncodedPasswords( List encodedPasswordList ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void addPreviousEncodedPassword( String encodedPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isPermanent() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPermanent( boolean permanent ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isLocked() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLocked( boolean locked ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isPasswordChangeRequired() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPasswordChangeRequired( boolean changeRequired ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isValidated() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setValidated( boolean valid ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public int getCountFailedLoginAttempts() + { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setCountFailedLoginAttempts( int count ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getAccountCreationDate() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setAccountCreationDate( Date date ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getLastLoginDate() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLastLoginDate( Date date ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + }; + } + + public UserQuery createUserQuery() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List getUsers() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List getUsers( boolean orderAscending ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User addUser( User user ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User updateUser( User user ) + throws UserNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User findUser( String username ) + throws UserNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User getGuestUser() + throws UserNotFoundException + { + return new User() + { + public Object getPrincipal() + { + return "guest"; + } + + public String getUsername() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setUsername( String name ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getFullName() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setFullName( String name ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getEmail() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setEmail( String address ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getPassword() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPassword( String rawPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public String getEncodedPassword() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setEncodedPassword( String encodedPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getLastPasswordChange() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLastPasswordChange( Date passwordChangeDate ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public List getPreviousEncodedPasswords() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPreviousEncodedPasswords( List encodedPasswordList ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void addPreviousEncodedPassword( String encodedPassword ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isPermanent() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPermanent( boolean permanent ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isLocked() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLocked( boolean locked ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isPasswordChangeRequired() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setPasswordChangeRequired( boolean changeRequired ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean isValidated() + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setValidated( boolean valid ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public int getCountFailedLoginAttempts() + { + return 0; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setCountFailedLoginAttempts( int count ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getAccountCreationDate() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setAccountCreationDate( Date date ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Date getLastLoginDate() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void setLastLoginDate( Date date ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + }; + } + + public List findUsersByUsernameKey( String usernameKey, boolean orderAscending ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List findUsersByFullNameKey( String fullNameKey, boolean orderAscending ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List findUsersByEmailKey( String emailKey, boolean orderAscending ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List findUsersByQuery( UserQuery query ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public User findUser( Object principal ) + throws UserNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean userExists( Object principal ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public void deleteUser( Object principal ) + throws UserNotFoundException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void deleteUser( String username ) + throws UserNotFoundException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void addUserUnchecked( User user ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void eraseDatabase() + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public User updateUser( User user, boolean passwordChangeRequired ) + throws UserNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + }; } public boolean isAuthenticated( AuthenticationDataSource arg0 ) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml index 4b0b49e88..6e3dc3ec3 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/resources/spring-context-rss-servlet.xml @@ -63,5 +63,7 @@ + + \ No newline at end of file -- 2.39.5