From 0f32b3fc40989a3edb481d2975ca9f5f5d03cb1d Mon Sep 17 00:00:00 2001 From: Andrei Stefan Date: Fri, 25 Jan 2008 15:04:29 +0000 Subject: [PATCH] reverted to junit 3 --- .../AclImplementationSecurityCheckTests.java | 29 +++++++++---------- .../acls/domain/AuditLoggerTests.java | 29 ++++++++----------- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/core/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java b/core/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java index bdf3807fd7..6753471fe2 100644 --- a/core/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java +++ b/core/src/test/java/org/springframework/security/acls/domain/AclImplementationSecurityCheckTests.java @@ -1,10 +1,8 @@ package org.springframework.security.acls.domain; import junit.framework.Assert; +import junit.framework.TestCase; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; import org.springframework.security.AccessDeniedException; import org.springframework.security.Authentication; import org.springframework.security.GrantedAuthority; @@ -24,15 +22,19 @@ import org.springframework.security.providers.TestingAuthenticationToken; * * @author Andrei Stefan */ -public class AclImplementationSecurityCheckTests { - @Before - @After - public void clearContext() { +public class AclImplementationSecurityCheckTests extends TestCase { + + //~ Methods ======================================================================================================== + + protected void setUp() throws Exception { SecurityContextHolder.clearContext(); } - @Test - public void securityCheckNoACEs() { + protected void tearDown() throws Exception { + SecurityContextHolder.clearContext(); + } + + public void testSecurityCheckNoACEs() { Authentication auth = new TestingAuthenticationToken("user", "password", new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_GENERAL"), new GrantedAuthorityImpl("ROLE_AUDITING"), new GrantedAuthorityImpl("ROLE_OWNERSHIP") }); @@ -96,8 +98,7 @@ public class AclImplementationSecurityCheckTests { } } - @Test - public void securityCheckWithMultipleACEs() { + public void testSecurityCheckWithMultipleACEs() { // Create a simple authentication with ROLE_GENERAL Authentication auth = new TestingAuthenticationToken("user", "password", new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_GENERAL") }); @@ -198,8 +199,7 @@ public class AclImplementationSecurityCheckTests { } } - @Test - public void securityCheckWithInheritableACEs() { + public void testSecurityCheckWithInheritableACEs() { // Create a simple authentication with ROLE_GENERAL Authentication auth = new TestingAuthenticationToken("user", "password", new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_GENERAL") }); @@ -257,8 +257,7 @@ public class AclImplementationSecurityCheckTests { } } - @Test - public void securityCheckPrincipalOwner() { + public void testSecurityCheckPrincipalOwner() { Authentication auth = new TestingAuthenticationToken("user", "password", new GrantedAuthority[] { new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_ONE"), new GrantedAuthorityImpl("ROLE_ONE") }); diff --git a/core/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java b/core/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java index 6cd3cc831a..039855aef4 100644 --- a/core/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java +++ b/core/src/test/java/org/springframework/security/acls/domain/AuditLoggerTests.java @@ -5,10 +5,8 @@ import java.io.PrintStream; import java.io.Serializable; import junit.framework.Assert; +import junit.framework.TestCase; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; import org.springframework.security.acls.AccessControlEntry; import org.springframework.security.acls.Acl; import org.springframework.security.acls.AuditableAccessControlEntry; @@ -20,24 +18,25 @@ import org.springframework.security.acls.sid.Sid; * * @author Andrei Stefan */ -public class AuditLoggerTests { +public class AuditLoggerTests extends TestCase { + //~ Instance fields ================================================================================================ + private PrintStream console; - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + private ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + + //~ Methods ======================================================================================================== - @Before - public void onSetUp() { + public void setUp() throws Exception { console = System.out; System.setOut(new PrintStream(bytes)); } - @After - public void onTearDown() { + public void tearDown() throws Exception { System.setOut(console); } - @Test - public void loggingTests() { + public void testLoggingTests() { ConsoleAuditLogger logger = new ConsoleAuditLogger(); MockAccessControlEntryImpl auditableAccessControlEntry = new MockAccessControlEntryImpl(); @@ -68,9 +67,8 @@ public class AuditLoggerTests { Assert.assertTrue(bytes.size() == 0); } - /** - * Mock {@link AuditableAccessControlEntry}. - */ + //~ Inner Classes ================================================================================================== + private class MockAccessControlEntryImpl implements AuditableAccessControlEntry { private boolean auditFailure = false; @@ -113,9 +111,6 @@ public class AuditLoggerTests { } } - /** - * Mock {@link AccessControlEntry}. - */ private class MockAccessControlEntry implements AccessControlEntry { public Acl getAcl() {