Package org.castor.core.annotationprocessing

Examples of org.castor.core.annotationprocessing.BaseAnnotationProcessingService


                .isAnnotationPresent(UnsupportedAnnotation.class));

    }

    public void testAddGetAnnotationProcessor() {
        BaseAnnotationProcessingService baps = new BaseAnnotationProcessingService();
        SupportedAnnotationProcessor annotationProcessor = new SupportedAnnotationProcessor();

        assertNotNull(baps.getAnnotationProcessors());
        assertFalse(baps.getAnnotationProcessors()
                .contains(annotationProcessor));

        baps.addAnnotationProcessor(annotationProcessor);

        assertNotNull(baps.getAnnotationProcessors());
        assertTrue(baps.getAnnotationProcessors().contains(annotationProcessor));

    }
View Full Code Here


        assertTrue(baps.getAnnotationProcessors().contains(annotationProcessor));

    }

    public void testProcessAnnotations() {
        BaseAnnotationProcessingService baps = new BaseAnnotationProcessingService();
        SupportedAnnotationProcessor annotationProcessor = new SupportedAnnotationProcessor();
        baps.addAnnotationProcessor(annotationProcessor);
        Annotation[] annotations = AnnotationHolder.class.getAnnotations();
        assertEquals(2, annotations.length);
        /*
         * now annotations[] contains @SupportedAnnotation and
         * @UnsupportedAnnotation
         */

        MyPropertyHolder holder = new MyPropertyHolder();
        holder.addNature(BaseNature.class.getName());

        BaseNature info = new BaseNature(holder) {
            public String getId() {
                return BaseNature.class.getName();
            }
        };

        /*
         * try to process all annotations
         */
        Annotation[] unprocessed = baps.processAnnotations(info, annotations);

        /*
         * we know, that we don't have processor for @UnsupportedAnnotation, so
         *
         * @UnsupportedAnnotation is put into unprocessed[]
View Full Code Here

        assertEquals(UnsupportedAnnotation.class, unprocessed[0]
                .annotationType());
    }

    public void testProcessAnnotation() {
        BaseAnnotationProcessingService baps = new BaseAnnotationProcessingService();
        baps.addAnnotationProcessor(new SupportedAnnotationProcessor());

        MyPropertyHolder holder = new MyPropertyHolder();
        holder.addNature(BaseNature.class.getName());
        BaseNature info = new BaseNature(holder) {
            public String getId() {
                return BaseNature.class.getName();
            }
        };

        /*
         * our AnnotationHolder has 2 Annotations: @UnsupportedAnnotation and
         *
         * @SupportedAnnotation, so we get them
         */
        Annotation unsupportedAnnotation = AnnotationHolder.class
                .getAnnotation(UnsupportedAnnotation.class);
        Annotation supportedAnnotation = AnnotationHolder.class
                .getAnnotation(SupportedAnnotation.class);
        assertNotNull(unsupportedAnnotation);
        assertNotNull(supportedAnnotation);

        /*
         * we know, that we don't have processor for @UnsupportedAnnotation, so
         * processing it will return false.
         */
        assertFalse(baps.processAnnotation(info, unsupportedAnnotation));
        assertTrue(baps.processAnnotation(info, supportedAnnotation));

    }
View Full Code Here

TOP

Related Classes of org.castor.core.annotationprocessing.BaseAnnotationProcessingService

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.