Search in sources :

Example 6 with Service

use of org.apache.dubbo.config.annotation.Service in project dubbo by alibaba.

the class AnnotationUtilsTest method testGetDeclaredAnnotations.

@Test
public void testGetDeclaredAnnotations() {
    List<Annotation> annotations = getDeclaredAnnotations(A.class);
    assertADeclaredAnnotations(annotations, 0);
    annotations = getDeclaredAnnotations(A.class, a -> isSameType(a, Service.class));
    assertEquals(1, annotations.size());
    Service service = (Service) annotations.get(0);
    assertEquals("java.lang.CharSequence", service.interfaceName());
    assertEquals(CharSequence.class, service.interfaceClass());
}
Also used : AnnotationUtils.isAnnotationPresent(org.apache.dubbo.common.utils.AnnotationUtils.isAnnotationPresent) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) AnnotationUtils.findMetaAnnotation(org.apache.dubbo.common.utils.AnnotationUtils.findMetaAnnotation) Inherited(java.lang.annotation.Inherited) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Adaptive(org.apache.dubbo.common.extension.Adaptive) AnnotationUtils.getMetaAnnotations(org.apache.dubbo.common.utils.AnnotationUtils.getMetaAnnotations) MethodUtils.findMethod(org.apache.dubbo.common.utils.MethodUtils.findMethod) AnnotationUtils.findMetaAnnotations(org.apache.dubbo.common.utils.AnnotationUtils.findMetaAnnotations) Retention(java.lang.annotation.Retention) AnnotationUtils.getAnnotation(org.apache.dubbo.common.utils.AnnotationUtils.getAnnotation) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Arrays.asList(java.util.Arrays.asList) AnnotationUtils.getAttribute(org.apache.dubbo.common.utils.AnnotationUtils.getAttribute) AnnotationUtils.isSameType(org.apache.dubbo.common.utils.AnnotationUtils.isSameType) Service(org.apache.dubbo.config.annotation.Service) Documented(java.lang.annotation.Documented) AnnotationUtils.excludedType(org.apache.dubbo.common.utils.AnnotationUtils.excludedType) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) LinkedList(java.util.LinkedList) AnnotationUtils.isAnyAnnotationPresent(org.apache.dubbo.common.utils.AnnotationUtils.isAnyAnnotationPresent) Target(java.lang.annotation.Target) ElementType(java.lang.annotation.ElementType) AnnotationUtils.getAllMetaAnnotations(org.apache.dubbo.common.utils.AnnotationUtils.getAllMetaAnnotations) Test(org.junit.jupiter.api.Test) AnnotationUtils.isType(org.apache.dubbo.common.utils.AnnotationUtils.isType) Assertions.assertArrayEquals(org.junit.jupiter.api.Assertions.assertArrayEquals) List(java.util.List) AnnotationUtils.getAllDeclaredAnnotations(org.apache.dubbo.common.utils.AnnotationUtils.getAllDeclaredAnnotations) DubboService(org.apache.dubbo.config.annotation.DubboService) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Annotation(java.lang.annotation.Annotation) AnnotationUtils.getValue(org.apache.dubbo.common.utils.AnnotationUtils.getValue) AnnotationUtils.findAnnotation(org.apache.dubbo.common.utils.AnnotationUtils.findAnnotation) RetentionPolicy(java.lang.annotation.RetentionPolicy) AnnotationUtils.getDeclaredAnnotations(org.apache.dubbo.common.utils.AnnotationUtils.getDeclaredAnnotations) Service(org.apache.dubbo.config.annotation.Service) DubboService(org.apache.dubbo.config.annotation.DubboService) AnnotationUtils.findMetaAnnotation(org.apache.dubbo.common.utils.AnnotationUtils.findMetaAnnotation) AnnotationUtils.getAnnotation(org.apache.dubbo.common.utils.AnnotationUtils.getAnnotation) Annotation(java.lang.annotation.Annotation) AnnotationUtils.findAnnotation(org.apache.dubbo.common.utils.AnnotationUtils.findAnnotation) Test(org.junit.jupiter.api.Test)

Example 7 with Service

use of org.apache.dubbo.config.annotation.Service in project dubbo by alibaba.

the class AnnotationUtilsTest method testFindAnnotation.

@Test
public void testFindAnnotation() {
    Service service = findAnnotation(A.class, Service.class);
    assertEquals("java.lang.CharSequence", service.interfaceName());
    assertEquals(CharSequence.class, service.interfaceClass());
    service = findAnnotation(B.class, Service.class);
    assertEquals(CharSequence.class, service.interfaceClass());
}
Also used : Service(org.apache.dubbo.config.annotation.Service) DubboService(org.apache.dubbo.config.annotation.DubboService) Test(org.junit.jupiter.api.Test)

Aggregations

Service (org.apache.dubbo.config.annotation.Service)7 Test (org.junit.jupiter.api.Test)5 DubboService (org.apache.dubbo.config.annotation.DubboService)4 Annotation (java.lang.annotation.Annotation)2 Adaptive (org.apache.dubbo.common.extension.Adaptive)2 DemoService (org.apache.dubbo.config.spring.api.DemoService)2 AbstractAnnotationBeanPostProcessor (com.alibaba.spring.beans.factory.annotation.AbstractAnnotationBeanPostProcessor)1 AnnotationUtils (com.alibaba.spring.util.AnnotationUtils)1 AnnotationUtils.getAttribute (com.alibaba.spring.util.AnnotationUtils.getAttribute)1 AnnotationUtils.getAttributes (com.alibaba.spring.util.AnnotationUtils.getAttributes)1 Documented (java.lang.annotation.Documented)1 ElementType (java.lang.annotation.ElementType)1 Inherited (java.lang.annotation.Inherited)1 Retention (java.lang.annotation.Retention)1 RetentionPolicy (java.lang.annotation.RetentionPolicy)1 Target (java.lang.annotation.Target)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1