Move single-use annotation test classes into SecuredAnnotationSecurityMetadataDefinitionSourceTests.
This commit is contained in:
parent
ddaf9eb64f
commit
ead669f10c
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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);
|
|
||||||
}
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,10 +14,12 @@
|
||||||
*/
|
*/
|
||||||
package org.springframework.security.access.annotation;
|
package org.springframework.security.access.annotation;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import org.junit.*;
|
||||||
import org.springframework.security.access.ConfigAttribute;
|
import org.springframework.security.access.ConfigAttribute;
|
||||||
import org.springframework.security.access.SecurityConfig;
|
import org.springframework.security.access.SecurityConfig;
|
||||||
|
|
||||||
|
@ -28,15 +30,17 @@ import org.springframework.security.access.SecurityConfig;
|
||||||
* @author Mark St.Godard
|
* @author Mark St.Godard
|
||||||
* @author Joe Scalise
|
* @author Joe Scalise
|
||||||
* @author Ben Alex
|
* @author Ben Alex
|
||||||
|
* @author Luke Taylor
|
||||||
*/
|
*/
|
||||||
public class SecuredAnnotationSecurityMetadataDefinitionSourceTests extends TestCase {
|
public class SecuredAnnotationSecurityMetadataDefinitionSourceTests {
|
||||||
//~ Instance fields ================================================================================================
|
//~ Instance fields ================================================================================================
|
||||||
|
|
||||||
private SecuredAnnotationSecurityMetadataSource mds = new SecuredAnnotationSecurityMetadataSource();;
|
private SecuredAnnotationSecurityMetadataSource mds = new SecuredAnnotationSecurityMetadataSource();
|
||||||
|
|
||||||
//~ Methods ========================================================================================================
|
//~ Methods ========================================================================================================
|
||||||
|
|
||||||
public void testGenericsSuperclassDeclarationsAreIncludedWhenSubclassesOverride() {
|
@Test
|
||||||
|
public void genericsSuperclassDeclarationsAreIncludedWhenSubclassesOverride() {
|
||||||
Method method = null;
|
Method method = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -78,7 +82,7 @@ public class SecuredAnnotationSecurityMetadataDefinitionSourceTests extends Test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetAttributesClass() {
|
public void classLevelAttributesAreFound() {
|
||||||
Collection<ConfigAttribute> attrs = this.mds.findAttributes(BusinessService.class);
|
Collection<ConfigAttribute> attrs = this.mds.findAttributes(BusinessService.class);
|
||||||
|
|
||||||
assertNotNull(attrs);
|
assertNotNull(attrs);
|
||||||
|
@ -92,7 +96,7 @@ public class SecuredAnnotationSecurityMetadataDefinitionSourceTests extends Test
|
||||||
assertEquals("ROLE_USER", sc.getAttribute());
|
assertEquals("ROLE_USER", sc.getAttribute());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetAttributesMethod() {
|
public void methodLevelAttributesAreFound() {
|
||||||
Method method = null;
|
Method method = null;
|
||||||
|
|
||||||
try {
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue