From 29c8e110f5336e895f74e9b723a7834fbcb35e40 Mon Sep 17 00:00:00 2001 From: Ben Alex Date: Mon, 1 Nov 2004 02:08:42 +0000 Subject: [PATCH] Remove adapter test dependencies on MockPrincipal. --- .../catalina/CatalinaAcegiUserRealmTests.java | 11 +++++++---- .../adapters/jboss/JbossIntegrationFilterTests.java | 7 +++++-- .../adapters/resin/ResinAcegiAuthenticatorTests.java | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/adapters/catalina/src/test/java/org/acegisecurity/adapters/catalina/CatalinaAcegiUserRealmTests.java b/adapters/catalina/src/test/java/org/acegisecurity/adapters/catalina/CatalinaAcegiUserRealmTests.java index cf86a87cee..0877ac62b9 100644 --- a/adapters/catalina/src/test/java/org/acegisecurity/adapters/catalina/CatalinaAcegiUserRealmTests.java +++ b/adapters/catalina/src/test/java/org/acegisecurity/adapters/catalina/CatalinaAcegiUserRealmTests.java @@ -19,7 +19,6 @@ import junit.framework.TestCase; import net.sf.acegisecurity.GrantedAuthority; import net.sf.acegisecurity.GrantedAuthorityImpl; -import net.sf.acegisecurity.adapters.MockPrincipal; import net.sf.acegisecurity.adapters.PrincipalAcegiUserToken; import org.apache.catalina.LifecycleException; @@ -243,7 +242,11 @@ public class CatalinaAcegiUserRealmTests extends TestCase { public void testHasRoleWithAPrincipalTheAdapterDidNotCreateFails() { CatalinaAcegiUserRealm adapter = new CatalinaAcegiUserRealm(); - assertTrue(!adapter.hasRole(new MockPrincipal(), "ROLE_ONE")); + assertTrue(!adapter.hasRole(new Principal() { + public String getName() { + return "MockPrincipal"; + } + }, "ROLE_ONE")); } public void testHasRoleWithPrincipalAcegiUserToken() { @@ -261,8 +264,8 @@ public class CatalinaAcegiUserRealmTests extends TestCase { throws Exception { CatalinaAcegiUserRealm adapter = new CatalinaAcegiUserRealm(); - URL url = Thread.currentThread().getContextClassLoader().getResource( - "net/sf/acegisecurity/adapters/" + fileName); + URL url = Thread.currentThread().getContextClassLoader().getResource("net/sf/acegisecurity/adapters/" + + fileName); if (url == null) { throw new Exception("Could not find " + fileName diff --git a/adapters/jboss/src/test/java/org/acegisecurity/adapters/jboss/JbossIntegrationFilterTests.java b/adapters/jboss/src/test/java/org/acegisecurity/adapters/jboss/JbossIntegrationFilterTests.java index c0da66a084..6135fbb867 100644 --- a/adapters/jboss/src/test/java/org/acegisecurity/adapters/jboss/JbossIntegrationFilterTests.java +++ b/adapters/jboss/src/test/java/org/acegisecurity/adapters/jboss/JbossIntegrationFilterTests.java @@ -19,7 +19,6 @@ import junit.framework.TestCase; import net.sf.acegisecurity.GrantedAuthority; import net.sf.acegisecurity.GrantedAuthorityImpl; -import net.sf.acegisecurity.adapters.MockPrincipal; import net.sf.acegisecurity.adapters.PrincipalAcegiUserToken; import org.springframework.mock.web.MockHttpServletRequest; @@ -115,7 +114,11 @@ public class JbossIntegrationFilterTests extends TestCase { public void testReturnsNullIfPrincipalNotAnAuthenticationImplementation() { JbossIntegrationFilter filter = new MockJbossIntegrationFilter(new MockInitialContext( - makeIntoSubject(new MockPrincipal()))); + makeIntoSubject(new Principal() { + public String getName() { + return "MockPrincipal"; + } + }))); assertEquals(null, filter.extractFromContainer(new MockHttpServletRequest(null, null))); } diff --git a/adapters/resin/src/test/java/org/acegisecurity/adapters/resin/ResinAcegiAuthenticatorTests.java b/adapters/resin/src/test/java/org/acegisecurity/adapters/resin/ResinAcegiAuthenticatorTests.java index 81fe306aff..ced4f95f0a 100644 --- a/adapters/resin/src/test/java/org/acegisecurity/adapters/resin/ResinAcegiAuthenticatorTests.java +++ b/adapters/resin/src/test/java/org/acegisecurity/adapters/resin/ResinAcegiAuthenticatorTests.java @@ -19,7 +19,6 @@ import junit.framework.TestCase; import net.sf.acegisecurity.GrantedAuthority; import net.sf.acegisecurity.GrantedAuthorityImpl; -import net.sf.acegisecurity.adapters.MockPrincipal; import net.sf.acegisecurity.adapters.PrincipalAcegiUserToken; import java.security.Principal; @@ -257,8 +256,12 @@ public class ResinAcegiAuthenticatorTests extends TestCase { "net/sf/acegisecurity/adapters/adaptertest-valid.xml"); adapter.setKey(ADAPTER_KEY); adapter.init(); - assertTrue(!adapter.isUserInRole(null, null, null, new MockPrincipal(), - "ROLE_ONE")); + assertTrue(!adapter.isUserInRole(null, null, null, + new Principal() { + public String getName() { + return "MockPrincipal"; + } + }, "ROLE_ONE")); } public void testHasRoleWithPrincipalAcegiUserToken()