浏览代码

Remove adapter test dependencies on MockPrincipal.

Ben Alex 21 年之前
父节点
当前提交
29c8e110f5

+ 7 - 4
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

+ 5 - 2
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)));
     }

+ 6 - 3
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()