Java源码示例:org.springframework.core.annotation.subpackage.NonPublicAnnotatedClass

示例1
@Test
public void getValueFromNonPublicAnnotation() throws Exception {
	Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
	assertEquals(1, declaredAnnotations.length);
	Annotation annotation = declaredAnnotations[0];
	assertNotNull(annotation);
	assertEquals("NonPublicAnnotation", annotation.annotationType().getSimpleName());
	assertEquals(42, getValue(annotation, VALUE));
	assertEquals(42, getValue(annotation));
}
 
示例2
@Test
public void getDefaultValueFromNonPublicAnnotation() {
	Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
	assertEquals(1, declaredAnnotations.length);
	Annotation annotation = declaredAnnotations[0];
	assertNotNull(annotation);
	assertEquals("NonPublicAnnotation", annotation.annotationType().getSimpleName());
	assertEquals(-1, getDefaultValue(annotation, VALUE));
	assertEquals(-1, getDefaultValue(annotation));
}
 
示例3
@Test
public void getValueFromNonPublicAnnotation() throws Exception {
	Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
	assertThat(declaredAnnotations).hasSize(1);
	Annotation annotation = declaredAnnotations[0];
	MergedAnnotation<Annotation> mergedAnnotation = MergedAnnotation.from(annotation);
	assertThat(mergedAnnotation.getType().getSimpleName()).isEqualTo("NonPublicAnnotation");
	assertThat(mergedAnnotation.synthesize().annotationType().getSimpleName()).isEqualTo("NonPublicAnnotation");
	assertThat(mergedAnnotation.getInt("value")).isEqualTo(42);
}
 
示例4
@Test
public void getDefaultValueFromNonPublicAnnotation() {
	Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
	assertThat(declaredAnnotations).hasSize(1);
	Annotation declaredAnnotation = declaredAnnotations[0];
	MergedAnnotation<?> annotation = MergedAnnotation.from(declaredAnnotation);
	assertThat(annotation.getType().getName()).isEqualTo(
			"org.springframework.core.annotation.subpackage.NonPublicAnnotation");
	assertThat(annotation.getDefaultValue("value")).contains(-1);
}
 
示例5
@Test
public void getValueFromNonPublicAnnotation() throws Exception {
	Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
	assertEquals(1, declaredAnnotations.length);
	Annotation annotation = declaredAnnotations[0];
	assertNotNull(annotation);
	assertEquals("NonPublicAnnotation", annotation.annotationType().getSimpleName());
	assertEquals(42, getValue(annotation, VALUE));
	assertEquals(42, getValue(annotation));
}
 
示例6
@Test
public void getDefaultValueFromNonPublicAnnotation() {
	Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
	assertEquals(1, declaredAnnotations.length);
	Annotation annotation = declaredAnnotations[0];
	assertNotNull(annotation);
	assertEquals("NonPublicAnnotation", annotation.annotationType().getSimpleName());
	assertEquals(-1, getDefaultValue(annotation, VALUE));
	assertEquals(-1, getDefaultValue(annotation));
}
 
示例7
@Test
public void getValueFromNonPublicAnnotation() throws Exception {
	Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
	assertEquals(1, declaredAnnotations.length);
	Annotation annotation = declaredAnnotations[0];
	assertNotNull(annotation);
	assertEquals("NonPublicAnnotation", annotation.annotationType().getSimpleName());
	assertEquals(42, getValue(annotation, VALUE));
	assertEquals(42, getValue(annotation));
}
 
示例8
@Test
public void getDefaultValueFromNonPublicAnnotation() throws Exception {
	Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
	assertEquals(1, declaredAnnotations.length);
	Annotation annotation = declaredAnnotations[0];
	assertNotNull(annotation);
	assertEquals("NonPublicAnnotation", annotation.annotationType().getSimpleName());
	assertEquals(-1, getDefaultValue(annotation, VALUE));
	assertEquals(-1, getDefaultValue(annotation));
}