use of org.apache.dubbo.common.extension.Adaptive in project dubbo by alibaba.
the class AnnotationUtilsTest method testGetValue.
@Test
public void testGetValue() {
Adaptive adaptive = A.class.getAnnotation(Adaptive.class);
String[] value = getValue(adaptive);
assertEquals(asList("a", "b", "c"), asList(value));
}
use of org.apache.dubbo.common.extension.Adaptive in project dubbo by alibaba.
the class AnnotationUtilsTest method assertADeclaredAnnotations.
private void assertADeclaredAnnotations(List<Annotation> annotations, int offset) {
int size = 3 + offset;
assertEquals(size, annotations.size());
Service service = (Service) annotations.get(offset++);
assertEquals("java.lang.CharSequence", service.interfaceName());
assertEquals(CharSequence.class, service.interfaceClass());
com.alibaba.dubbo.config.annotation.Service s = (com.alibaba.dubbo.config.annotation.Service) annotations.get(offset++);
assertEquals("java.lang.CharSequence", service.interfaceName());
assertEquals(CharSequence.class, service.interfaceClass());
Adaptive adaptive = (Adaptive) annotations.get(offset++);
assertArrayEquals(new String[] { "a", "b", "c" }, adaptive.value());
}
use of org.apache.dubbo.common.extension.Adaptive in project dubbo by alibaba.
the class AnnotationUtilsTest method testGetAllDeclaredAnnotations.
@Test
public void testGetAllDeclaredAnnotations() {
List<Annotation> annotations = getAllDeclaredAnnotations(A.class);
assertADeclaredAnnotations(annotations, 0);
annotations = getAllDeclaredAnnotations(B.class);
assertTrue(isSameType(annotations.get(0), Service5.class));
assertADeclaredAnnotations(annotations, 1);
annotations = new LinkedList<>(getAllDeclaredAnnotations(C.class));
assertTrue(isSameType(annotations.get(0), MyAdaptive.class));
assertTrue(isSameType(annotations.get(1), Service5.class));
assertADeclaredAnnotations(annotations, 2);
annotations = getAllDeclaredAnnotations(findMethod(A.class, "execute"));
MyAdaptive myAdaptive = (MyAdaptive) annotations.get(0);
assertArrayEquals(new String[] { "e" }, myAdaptive.value());
annotations = getAllDeclaredAnnotations(findMethod(B.class, "execute"));
Adaptive adaptive = (Adaptive) annotations.get(0);
assertArrayEquals(new String[] { "f" }, adaptive.value());
}
Aggregations