/hg/rhino-tests: Added three new tests into src/org/RhinoTests/I...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Fri Dec 14 01:55:24 PST 2012
changeset 688976f71a2d in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=688976f71a2d
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Dec 14 10:58:28 2012 +0100
Added three new tests into src/org/RhinoTests/InvocableClassTest.java:
- getAnnotations()
- getDeclaredAnnotations()
- getField()
diffstat:
ChangeLog | 8 +++
src/org/RhinoTests/InvocableClassTest.java | 75 ++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 0 deletions(-)
diffs (114 lines):
diff -r 90ebe9af7914 -r 688976f71a2d ChangeLog
--- a/ChangeLog Thu Dec 13 10:46:21 2012 +0100
+++ b/ChangeLog Fri Dec 14 10:58:28 2012 +0100
@@ -1,3 +1,11 @@
+2012-12-14 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/RhinoTests/InvocableClassTest.java:
+ Added three new tests into this test case:
+ - getAnnotations()
+ - getDeclaredAnnotations()
+ - getField()
+
2012-12-13 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/RhinoTests/SimpleBindingsClassTest.java:
diff -r 90ebe9af7914 -r 688976f71a2d src/org/RhinoTests/InvocableClassTest.java
--- a/src/org/RhinoTests/InvocableClassTest.java Thu Dec 13 10:46:21 2012 +0100
+++ b/src/org/RhinoTests/InvocableClassTest.java Fri Dec 14 10:58:28 2012 +0100
@@ -46,6 +46,7 @@
import java.util.Map;
import java.util.HashMap;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -355,6 +356,28 @@
}
/**
+ * Test for method javax.script.Invocable.getClass().getField()
+ */
+ protected void testGetField() {
+ // following fields should exists
+ final String[] fieldsThatShouldExists = {
+ };
+ // check if all required fields really exists
+ for (String fieldThatShouldExists : fieldsThatShouldExists) {
+ try {
+ Field field = this.invocableClass.getField(fieldThatShouldExists);
+ String fieldName = field.getName();
+ assertTrue(fieldName.equals(fieldThatShouldExists),
+ "field " + fieldThatShouldExists + " not found");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new AssertionError(e.getMessage());
+ }
+ }
+ }
+
+ /**
* Test for method javax.script.Invocable.getClass().getMethods()
*/
protected void testGetMethods() {
@@ -423,6 +446,58 @@
}
/**
+ * Test for method javax.script.Invocable.getClass().getAnnotations()
+ */
+ protected void testGetAnnotations() {
+ // following annotations should be provided
+ final String[] annotationsThatShouldExists_jdk6 = {
+ };
+
+ final String[] annotationsThatShouldExists_jdk7 = {
+ };
+
+ // get all annotations
+ Annotation[] annotations = this.invocableClass.getAnnotations();
+ // and transform the array into a list of annotation names
+ List<String> annotationsAsString = new ArrayList<String>();
+ for (Annotation annotation : annotations) {
+ annotationsAsString.add(annotation.toString());
+ }
+ String[] annotationsThatShouldExists = getJavaVersion() < 7 ? annotationsThatShouldExists_jdk6 : annotationsThatShouldExists_jdk7;
+ // check if all required annotations really exists
+ for (String annotationThatShouldExists : annotationsThatShouldExists) {
+ assertTrue(annotationsAsString.contains(annotationThatShouldExists),
+ "annotation " + annotationThatShouldExists + " not found");
+ }
+ }
+
+ /**
+ * Test for method javax.script.Invocable.getClass().getDeclaredAnnotations()
+ */
+ protected void testGetDeclaredAnnotations() {
+ // following annotations should be provided
+ final String[] annotationsThatShouldExists_jdk6 = {
+ };
+
+ final String[] annotationsThatShouldExists_jdk7 = {
+ };
+
+ // get all annotations
+ Annotation[] annotations = this.invocableClass.getDeclaredAnnotations();
+ // and transform the array into a list of annotation names
+ List<String> annotationsAsString = new ArrayList<String>();
+ for (Annotation annotation : annotations) {
+ annotationsAsString.add(annotation.toString());
+ }
+ String[] annotationsThatShouldExists = getJavaVersion() < 7 ? annotationsThatShouldExists_jdk6 : annotationsThatShouldExists_jdk7;
+ // check if all required annotations really exists
+ for (String annotationThatShouldExists : annotationsThatShouldExists) {
+ assertTrue(annotationsAsString.contains(annotationThatShouldExists),
+ "annotation " + annotationThatShouldExists + " not found");
+ }
+ }
+
+ /**
* Test for instanceof operator applied to a class javax.script.Invocable
*/
@SuppressWarnings("cast")
More information about the distro-pkg-dev
mailing list