Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Declaring Annotations

Hello Adrian,

Adrian Colyer ha scritto:

From a quick glance... your test case is testing that the annotations is
present on the *class*, but your aspect is declaring annotations on the
*methods* of the class.
i corrected the test case, so that it tests if *methods* are annotated.
http://veleno.pastebin.com/311834

and now i get an assertion failed.

  9.
     public void testDeclareAnnotation() throws NoSuchInterfaceException{
 10.
11.
             Pusher p = (Pusher)
     fComponentNoDelegators.getFcInterface("m");
 12.
13.
             Method
     <http://www.google.com/search?q=allinurl%3AMethod+java.sun.com&bntl=1>[]
     annotatedMethods = p.getClass().getDeclaredMethods();
 14.
15.
             //every method on the pusher interface should be annotated
 16.
             for (Method
     <http://www.google.com/search?q=allinurl%3AMethod+java.sun.com&bntl=1>
     m :annotatedMethods){
 17.
                     //get annotations declared
 18.
                     Annotation
     <http://www.google.com/search?q=allinurl%3AAnnotation+java.sun.com&bntl=1>
     [] annots = m.getDeclaredAnnotations();
 19.
20.
                     assertNotNull(annots);
 21.
                     assertTrue(annots.length != 0);
 22.
             }
 23.
24. 25.
     junit.framework.AssertionFailedError
 26.
             at junit.framework.Assert.fail(Assert.java:47)
 27.
             at junit.framework.Assert.assertTrue(Assert.java:20)
 28.
             at junit.framework.Assert.assertTrue(Assert.java:27)
 29.
             at
     aormf.tests.AnnotationDeclarationTest.testDeclareAnnotation(AnnotationDeclarationTest.java:64)
 30.
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
     Method
     <http://www.google.com/search?q=allinurl%3AMethod+java.sun.com&bntl=1>)
 31.
             at
     sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 32.
             at
     sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 33.
             at java.lang.reflect.Method.invoke(Method
     <http://www.google.com/search?q=allinurl%3AMethod+java.sun.com&bntl=1>.java:585)
 34.
             at junit.framework.TestCase.runTest(TestCase.java:154)
 35.
             at junit.framework.TestCase.runBare(TestCase.java:127)
 36.
             at junit.framework.TestResult$1.protect(TestResult.java:106)
 37.
             at
     junit.framework.TestResult.runProtected(TestResult.java:124)
 38.
             at junit.framework.TestResult.run(TestResult.java:109)
 39.
             at junit.framework.TestCase.run(TestCase.java:118)
 40.
             at junit.framework.TestSuite.runTest(TestSuite.java:208)
 41.
             at junit.framework.TestSuite.run(TestSuite.java:203)
 42.
             at
     org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
 43.
             at
     org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
 44.
             at
     org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)



The fact is that in eclipse, if i open the Pusher.java, it properly display on the left border of the editor window a message "annotated by AnnotatorAspect.declar @method: public *aormf.components.Pusher+.*(..): @ManagedResourceAnnotation).

thanks for any help




Back to the top