Rollback accidental commit :/.

This commit is contained in:
Oliver Gierke
2010-06-15 05:33:39 +00:00
parent 897aab9f59
commit 420f8237c0
2 changed files with 1 additions and 259 deletions

View File

@@ -19,18 +19,13 @@ package org.springframework.core.annotation;
import static org.junit.Assert.*;
import static org.springframework.core.annotation.AnnotationUtils.*;
import java.io.Serializable;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;
import java.util.List;
import org.junit.Test;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationUtils.ParameterAnnotation;
/**
* @author Rod Johnson
@@ -209,45 +204,6 @@ public class AnnotationUtilsTests {
assertNotNull(order);
}
@Test
public void testDetectsParameterAnnotation() throws Exception {
Method method = InterfaceWithAnnotatedMethodParameters.class.getMethod("foo", String.class, Long.class);
ParameterAnnotation<MyAnnotation> parameterAnnotation = getParameterAnnotation(method, MyAnnotation.class);
assertParameterAnnotationWith(parameterAnnotation, "foo", 1, Long.class);
List<ParameterAnnotation<MyAnnotation>> parameterAnnotations = getParameterAnnotations(method,
MyAnnotation.class);
assertNotNull(parameterAnnotations);
assertEquals(1, parameterAnnotations.size());
assertEquals(parameterAnnotation, parameterAnnotations.get(0));
}
@Test
public void testDetectsFirstParameterAnnotationForMultipleOnes() throws Exception {
Method method = InterfaceWithAnnotatedMethodParameters.class.getMethod("bar", String.class, String.class,
Serializable.class);
ParameterAnnotation<MyAnnotation> parameterAnnotation = getParameterAnnotation(method, MyAnnotation.class);
assertParameterAnnotationWith(parameterAnnotation, "first", 0, String.class);
List<ParameterAnnotation<MyAnnotation>> parameterAnnotations = getParameterAnnotations(method,
MyAnnotation.class);
assertNotNull(parameterAnnotations);
assertEquals(2, parameterAnnotations.size());
assertEquals(parameterAnnotation, parameterAnnotations.get(0));
assertParameterAnnotationWith(parameterAnnotations.get(1), "third", 2, Serializable.class);
}
private void assertParameterAnnotationWith(ParameterAnnotation<MyAnnotation> parameterAnnotation, String value,
int index, Class<?> parameterType) {
assertNotNull(parameterAnnotation);
assertEquals(index, parameterAnnotation.getParameterIndex());
assertNotNull(parameterAnnotation.getAnnotation());
assertEquals(value, parameterAnnotation.getAnnotation().value());
assertEquals(parameterType, parameterAnnotation.getParameterType());
}
public static interface AnnotatedInterface {
@Order(0)
@@ -365,24 +321,10 @@ public class AnnotationUtilsTests {
}
}
public static interface InterfaceWithAnnotatedMethodParameters {
void foo(String foo, @MyAnnotation("foo") Long bar);
void bar(@MyAnnotation("first") String first, String second,
@Transactional @MyAnnotation("third") Serializable third);
}
}
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface Transactional {
}
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@interface MyAnnotation {
String value() default "";
}