ensure cleanup datas for other tests

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1133543 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-06-08 20:12:23 +00:00
parent c82abad170
commit 1fb61463c8
2 changed files with 25 additions and 13 deletions

View File

@ -19,12 +19,13 @@ package org.apache.maven.archiva.security;
* under the License.
*/
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
/**
* DefaultUserRepositoriesTest
*
@ -36,7 +37,8 @@ public class DefaultUserRepositoriesTest
@Before
public void setUp() throws Exception
public void setUp()
throws Exception
{
super.setUp();
restoreGuestInitialValues( USER_ALPACA );
@ -67,10 +69,21 @@ public class DefaultUserRepositoriesTest
// the global repo observer role.
assignGlobalRepositoryObserverRole( USER_ADMIN );
assertRepoIds( new String[] { "central", "corporate" }, userRepos.getObservableRepositoryIds( USER_ALPACA ) );
assertRepoIds( new String[] { "coporate" }, userRepos.getObservableRepositoryIds( USER_GUEST ) );
assertRepoIds( new String[] { "central", "internal", "corporate", "snapshots", "secret" }, userRepos
.getObservableRepositoryIds( USER_ADMIN ) );
assertRepoIds( new String[]{ "central", "corporate" }, userRepos.getObservableRepositoryIds( USER_ALPACA ) );
assertRepoIds( new String[]{ "coporate" }, userRepos.getObservableRepositoryIds( USER_GUEST ) );
assertRepoIds( new String[]{ "central", "internal", "corporate", "snapshots", "secret" },
userRepos.getObservableRepositoryIds( USER_ADMIN ) );
}
@After
public void tearDown()
throws Exception
{
super.tearDown();
restoreGuestInitialValues( USER_ALPACA );
restoreGuestInitialValues( USER_GUEST );
restoreGuestInitialValues( USER_ADMIN );
}
private void assertRepoIds( String[] expectedRepoIds, List<String> observableRepositoryIds )
@ -80,8 +93,9 @@ public class DefaultUserRepositoriesTest
if ( expectedRepoIds.length != observableRepositoryIds.size() )
{
fail( "Size of Observable Repository Ids wrong, expected <" + expectedRepoIds.length + "> but got <"
+ observableRepositoryIds.size() + "> instead. \nExpected: [" + StringUtils.join( expectedRepoIds, "," )
+ "]\nActual: [" + StringUtils.join( observableRepositoryIds.iterator(), "," ) + "]" );
+ observableRepositoryIds.size() + "> instead. \nExpected: ["
+ StringUtils.join( expectedRepoIds, "," ) + "]\nActual: ["
+ StringUtils.join( observableRepositoryIds.iterator(), "," ) + "]" );
}
}

View File

@ -38,9 +38,7 @@ import javax.inject.Inject;
public class RoleManagerTest
extends TestCase
{
/**
* @plexus.requirement role-hint="default"
*/
@Inject
RoleManager roleManager;