Added test for nested annotations. development
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 12 Feb 2013 18:07:13 +0000
branchdevelopment
changeset 2063 4aff298f0fa6
parent 2062 8bf477337331
child 2064 690745064cf9
Added test for nested annotations.
tests/libjava/classloader-tests-classes/.classpath
tests/libjava/classloader-tests-classes/.project
tests/libjava/classloader-tests-classes/src/ClassWithNestedAnnotations.java
tests/libjava/src/stx/libjava/tests/lang/AnnotationTests.java
tests/libjava/src/stx/libjava/tests/lang/ClassLoaderTests.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libjava/classloader-tests-classes/.classpath	Tue Feb 12 18:07:13 2013 +0000
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libjava/classloader-tests-classes/.project	Tue Feb 12 18:07:13 2013 +0000
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>stx:libjava | tests | classloader-tests-classes</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/libjava/classloader-tests-classes/src/ClassWithNestedAnnotations.java	Tue Feb 12 18:07:13 2013 +0000
@@ -0,0 +1,10 @@
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+
+
+public class ClassWithNestedAnnotations {
+	@XmlElements(@XmlElement(name = "Text", namespace = "http://www.w3.org/2003/05/soap-envelope"))
+    private final List<Integer> field = null;
+}
\ No newline at end of file
--- a/tests/libjava/src/stx/libjava/tests/lang/AnnotationTests.java	Tue Feb 12 15:34:10 2013 +0000
+++ b/tests/libjava/src/stx/libjava/tests/lang/AnnotationTests.java	Tue Feb 12 18:07:13 2013 +0000
@@ -4,11 +4,15 @@
 import stx.libjava.tests.mocks.EnumValueAnnotation;
 import stx.libjava.tests.mocks.HeavilyAnnotatedClass;
 import stx.libjava.tests.mocks.Weather;
-
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.net.URLClassLoader;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement; // get some nice annotations
+import javax.xml.bind.annotation.XmlElements;// get some nice annotations
 
 import static org.junit.Assert.assertTrue;
 
@@ -86,4 +90,25 @@
             }
         }
     }
+    
+    @Test
+    public void testNestedAnnotations() {
+    	/* Load the class from different directory - because if classreader
+    	 * broken, then the test suite will fail to load, which should be avoided 
+    	 */
+    	try {
+    		ClassLoader cl = new URLClassLoader(ClassLoaderTests.getTestClassesDirectory());
+    		Class classWithNestedAnnotations = cl.loadClass("ClassWithNestedAnnotations");
+    		assertTrue(true); // at least, it reads
+    	} catch (Exception e) {
+    		e.printStackTrace();    		
+    		assertTrue("Got exception: " + e.getMessage(), false);
+    	}
+    	
+    	
+    	
+    }
+    
+    
+    
 }
--- a/tests/libjava/src/stx/libjava/tests/lang/ClassLoaderTests.java	Tue Feb 12 15:34:10 2013 +0000
+++ b/tests/libjava/src/stx/libjava/tests/lang/ClassLoaderTests.java	Tue Feb 12 18:07:13 2013 +0000
@@ -285,7 +285,7 @@
         assertNotSame(result1, result2);
     }
 
-    private URL[] getTestClassesDirectory() throws Exception {
+    public static URL[] getTestClassesDirectory() throws Exception {
         String[] paths = {"classloader-tests-classes/bin",
                 System.getProperty("libjava.tests.dir") + "/libjava/classloader-tests-classes/bin"};
         URL[] result = new URL[paths.length];