Skip to content

Commit 6d8dd79

Browse files
committed
Verify that inner classes are handled correctly
Test both the directory indexer and the annotation processor (the latter in the integration test). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 19acfb8 commit 6d8dd79

4 files changed

Lines changed: 55 additions & 3 deletions

File tree

src/it/apt-test/src/main/java/org/scijava/annotation/its/Annotated.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@
3838
* @author Johannes Schindelin
3939
*/
4040
@CustomAnnotation(greeting = "Hey, what's up, doc?")
41-
public class Annotated { }
41+
public class Annotated {
42+
@CustomAnnotation(greeting = "Howdy, stranger!")
43+
public class Inner {}
44+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"class":"org.scijava.annotations.its.Annotated","values":{"greeting":"Hey, what's up, doc?"}}
1+
{"class":"org.scijava.annotations.its.Annotated","values":{"greeting":"Hey, what's up, doc?"}}{"class":"org.scijava.annotations.its.Annotated$Inner","values":{"greeting":"Howdy, stranger!"}}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* #%L
3+
* Annotation index (processor and index access library).
4+
* %%
5+
* Copyright (C) 2009 - 2013 Board of Regents of the University of Wisconsin-Madison.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
*
28+
* The views and conclusions contained in the software and documentation are
29+
* those of the authors and should not be interpreted as representing official
30+
* policies, either expressed or implied, of any organization.
31+
* #L%
32+
*/
33+
34+
package org.scijava.annotations;
35+
36+
/**
37+
* A simple class with an annotated inner class.
38+
*
39+
* @author Johannes Schindelin
40+
*/
41+
public class AnnotatedInnerClass {
42+
43+
@Complex(simple = @Simple)
44+
public class InnerClass {}
45+
}

src/test/java/org/scijava/annotations/DirectoryIndexerTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
package org.scijava.annotations;
3535

3636
import static org.junit.Assert.assertEquals;
37+
import static org.junit.Assert.assertNotNull;
3738
import static org.junit.Assert.assertTrue;
3839
import static org.junit.Assume.assumeTrue;
3940

@@ -83,7 +84,7 @@ public void testIndexer() throws Exception {
8384
map.put(item.className(), item);
8485
}
8586

86-
assertEquals(3, map.size());
87+
assertEquals(4, map.size());
8788
Complex a = map.get(AnnotatedA.class.getName()).annotation();
8889
assertEquals("Hello, World!", a.simple().string1());
8990

@@ -109,6 +110,9 @@ public void testIndexer() throws Exception {
109110
assertEquals(-47, c.array1()[1]);
110111
assertEquals(-53, c.array1()[2]);
111112
assertEquals(-59, c.array1()[3]);
113+
114+
c = map.get(AnnotatedInnerClass.InnerClass.class.getName()).annotation();
115+
assertNotNull(c);
112116
}
113117

114118
public static String getResourcePath(final Class<?> clazz) {

0 commit comments

Comments
 (0)