From ead669f10c11e60a6b67917c16028920b1fc6bbd Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Mon, 4 Apr 2011 18:25:25 +0100 Subject: [PATCH] Move single-use annotation test classes into SecuredAnnotationSecurityMetadataDefinitionSourceTests. --- .../access/annotation/Department.java | 28 ----------- .../access/annotation/DepartmentService.java | 13 ----- .../annotation/DepartmentServiceImpl.java | 14 ------ ...SecurityMetadataDefinitionSourceTests.java | 50 ++++++++++++++++--- 4 files changed, 44 insertions(+), 61 deletions(-) delete mode 100644 core/src/test/java/org/springframework/security/access/annotation/Department.java delete mode 100644 core/src/test/java/org/springframework/security/access/annotation/DepartmentService.java delete mode 100644 core/src/test/java/org/springframework/security/access/annotation/DepartmentServiceImpl.java diff --git a/core/src/test/java/org/springframework/security/access/annotation/Department.java b/core/src/test/java/org/springframework/security/access/annotation/Department.java deleted file mode 100644 index 6c5aebb5b4..0000000000 --- a/core/src/test/java/org/springframework/security/access/annotation/Department.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.springframework.security.access.annotation; - -/** - * - * @author Joe Scalise - */ -public class Department extends Entity { - //~ Instance fields ======================================================== - - private boolean active = true; - - //~ Constructors =========================================================== - - public Department(String name) { - super(name); - } - - //~ Methods ================================================================ - - public boolean isActive() { - return this.active; - } - - void deactive() { - this.active = true; - } - -} diff --git a/core/src/test/java/org/springframework/security/access/annotation/DepartmentService.java b/core/src/test/java/org/springframework/security/access/annotation/DepartmentService.java deleted file mode 100644 index f6ff1c21bc..0000000000 --- a/core/src/test/java/org/springframework/security/access/annotation/DepartmentService.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.springframework.security.access.annotation; - -import org.springframework.security.access.annotation.Secured; - -/** - * - * @author Joe Scalise - */ -public interface DepartmentService extends BusinessService { - - @Secured({"ROLE_USER"}) - Department someUserMethod3(Department dept); -} diff --git a/core/src/test/java/org/springframework/security/access/annotation/DepartmentServiceImpl.java b/core/src/test/java/org/springframework/security/access/annotation/DepartmentServiceImpl.java deleted file mode 100644 index 10ceb01751..0000000000 --- a/core/src/test/java/org/springframework/security/access/annotation/DepartmentServiceImpl.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.springframework.security.access.annotation; - -import org.springframework.security.access.annotation.Secured; - -/** - * @author Joe Scalise - */ -public class DepartmentServiceImpl extends BusinessServiceImpl implements DepartmentService { - - @Secured({"ROLE_ADMIN"}) - public Department someUserMethod3(final Department dept) { - return super.someUserMethod3(dept); - } -} diff --git a/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataDefinitionSourceTests.java b/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataDefinitionSourceTests.java index afb7a4c7d0..980dcbff55 100644 --- a/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataDefinitionSourceTests.java +++ b/core/src/test/java/org/springframework/security/access/annotation/SecuredAnnotationSecurityMetadataDefinitionSourceTests.java @@ -14,10 +14,12 @@ */ package org.springframework.security.access.annotation; +import static org.junit.Assert.*; + import java.lang.reflect.Method; import java.util.Collection; -import junit.framework.TestCase; +import org.junit.*; import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.SecurityConfig; @@ -28,15 +30,17 @@ import org.springframework.security.access.SecurityConfig; * @author Mark St.Godard * @author Joe Scalise * @author Ben Alex + * @author Luke Taylor */ -public class SecuredAnnotationSecurityMetadataDefinitionSourceTests extends TestCase { +public class SecuredAnnotationSecurityMetadataDefinitionSourceTests { //~ Instance fields ================================================================================================ - private SecuredAnnotationSecurityMetadataSource mds = new SecuredAnnotationSecurityMetadataSource();; + private SecuredAnnotationSecurityMetadataSource mds = new SecuredAnnotationSecurityMetadataSource(); //~ Methods ======================================================================================================== - public void testGenericsSuperclassDeclarationsAreIncludedWhenSubclassesOverride() { + @Test + public void genericsSuperclassDeclarationsAreIncludedWhenSubclassesOverride() { Method method = null; try { @@ -78,7 +82,7 @@ public class SecuredAnnotationSecurityMetadataDefinitionSourceTests extends Test } } - public void testGetAttributesClass() { + public void classLevelAttributesAreFound() { Collection attrs = this.mds.findAttributes(BusinessService.class); assertNotNull(attrs); @@ -92,7 +96,7 @@ public class SecuredAnnotationSecurityMetadataDefinitionSourceTests extends Test assertEquals("ROLE_USER", sc.getAttribute()); } - public void testGetAttributesMethod() { + public void methodLevelAttributesAreFound() { Method method = null; try { @@ -127,3 +131,37 @@ public class SecuredAnnotationSecurityMetadataDefinitionSourceTests extends Test } } + +class Entity { + public Entity(String someParameter) {} +} + +class Department extends Entity { + private boolean active = true; + + public Department(String name) { + super(name); + } + + public boolean isActive() { + return this.active; + } + + void deactive() { + this.active = true; + } +} + +interface DepartmentService extends BusinessService { + + @Secured({"ROLE_USER"}) + Department someUserMethod3(Department dept); +} + +class DepartmentServiceImpl extends BusinessServiceImpl implements DepartmentService { + + @Secured({"ROLE_ADMIN"}) + public Department someUserMethod3(final Department dept) { + return super.someUserMethod3(dept); + } +}