Package org.codehaus.backport175.reader

Examples of org.codehaus.backport175.reader.Annotation


        annotations = Annotations.getAnnotations(Target.METHOD);
    }

    public void testReadInResolvedValues() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.METHOD.getDeclaringClass());
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$Complex", Target.METHOD);
        TestAnnotations.Complex ann = (TestAnnotations.Complex)annotation;
        assertEquals(111, ann.i());
        double[] doubleArr = ann.doubleArr();
        assertEquals(1.1D, doubleArr[0], 0);
        assertEquals(2.2D, doubleArr[1], 0);
View Full Code Here


        enumRef = ann.enumeration();
        assertTrue(enumRef.equals(AnnotationElement.Type.ANNOTATION));
    }

    public void testNestedClassAnn() {
        Annotation annotation = Annotations.getAnnotation(Nested.Anno.class, Nested.class);
        assertNotNull(annotation);
        assertEquals("nested", ((Nested.Anno)annotation).value());

        //test enclosing doesn't have it..
        annotation = Annotations.getAnnotation(Nested.Anno.class, AnnotationReaderTest.class);
View Full Code Here

        super(name);
    }

    public void testToString() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.METHOD.getDeclaringClass());
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$Complex", Target.METHOD);
        assertEquals(
                "@test.TestAnnotations$Complex(" +
                "i=111, " +
                "doubleArr=[1.1, 2.2, 3.3, 4.4], " +
                "type=double[][][].class, " +
                "enumeration=org.codehaus.backport175.reader.bytecode.AnnotationElement$Type.ANNOTATION, " +
                "typeArr=[test.reader.Target[].class, test.reader.Target.class]" +
                ")",
                annotation.toString()
        );
    }
View Full Code Here

        assertFalse(Annotations.isAnnotationPresent(Target.class, Target.class));
    }

    public void testClassAnn1() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$VoidTyped");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.VoidTyped.class, type);
    }
View Full Code Here

        assertEquals(TestAnnotations.VoidTyped.class, type);
    }

    public void testClassAnn2() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$DefaultString");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.DefaultString.class, type);

        TestAnnotations.DefaultString ann = (TestAnnotations.DefaultString)annotation;
        assertEquals("hello\"there", ann.value());
    }
View Full Code Here

        assertEquals("hello\"there", ann.value());
    }

    public void testClassAnn3() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$Simple");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.Simple.class, type);

        TestAnnotations.Simple ann = (TestAnnotations.Simple)annotation;
        assertEquals("foo", ann.val());
        assertEquals("bar", ann.s());
View Full Code Here

        assertEquals("bar", ann.s());
    }

    public void testClassAnn4() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$StringArray");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.StringArray.class, type);

        TestAnnotations.StringArray ann = (TestAnnotations.StringArray)annotation;
        String[] ss = ann.ss();
        assertEquals("hello", ss[0]);
View Full Code Here

        assertEquals("world", ss[1]);
    }

    public void testClassAnn5() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("test.TestAnnotations$LongArray");
        Class type = annotation.annotationType();
        assertEquals(TestAnnotations.LongArray.class, type);

        TestAnnotations.LongArray ann = (TestAnnotations.LongArray)annotation;
        long[] longArr = ann.l();
        assertEquals(1l, longArr[0]);
View Full Code Here

    public void testClassAnnDuplicatedMapping() {
        Annotation[] annotations = Annotations.getAnnotations(Target.class);
        int found = 0;
        for (int i = 0; i < annotations.length; i++) {
            Annotation annotation = annotations[i];
            if (annotation instanceof TestAnnotations.LongArray) {
                found++;
            }
        }
        assertEquals(1, found);
View Full Code Here

        assertEquals(1, found);
    }

    public void testClassAnnNotThere() {
        final AnnotationReader reader = AnnotationReader.getReaderFor(Target.class);
        Annotation annotation = reader.getAnnotation("noThere");
        assertNull(annotation);
    }
View Full Code Here

TOP

Related Classes of org.codehaus.backport175.reader.Annotation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.