Move single-use annotation test classes into SecuredAnnotationSecurityMetadataDefinitionSourceTests.

This commit is contained in:
Luke Taylor 2011-04-04 18:25:25 +01:00
parent ddaf9eb64f
commit ead669f10c
4 changed files with 44 additions and 61 deletions

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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 <Department> implements DepartmentService {
@Secured({"ROLE_ADMIN"})
public Department someUserMethod3(final Department dept) {
return super.someUserMethod3(dept);
}
}

View File

@ -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<ConfigAttribute> 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 <Department> implements DepartmentService {
@Secured({"ROLE_ADMIN"})
public Department someUserMethod3(final Department dept) {
return super.someUserMethod3(dept);
}
}