/hg/rhino-tests: Added three new tests into the test case src/or...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Thu Dec 20 04:13:31 PST 2012
changeset 257a62c6cbc5 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=257a62c6cbc5
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Dec 20 13:16:30 2012 +0100
Added three new tests into the test case src/org/RhinoTests/ScriptEngineClassTest.java.
diffstat:
ChangeLog | 5 +
src/org/RhinoTests/ScriptEngineClassTest.java | 82 +++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 0 deletions(-)
diffs (118 lines):
diff -r 3b33320797eb -r 257a62c6cbc5 ChangeLog
--- a/ChangeLog Wed Dec 19 11:03:19 2012 +0100
+++ b/ChangeLog Thu Dec 20 13:16:30 2012 +0100
@@ -1,3 +1,8 @@
+2012-12-20 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/RhinoTests/ScriptEngineClassTest.java:
+ Added three new tests into this test case.
+
2012-12-19 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/RhinoTests/ScriptExceptionClassTest.java:
diff -r 3b33320797eb -r 257a62c6cbc5 src/org/RhinoTests/ScriptEngineClassTest.java
--- a/src/org/RhinoTests/ScriptEngineClassTest.java Wed Dec 19 11:03:19 2012 +0100
+++ b/src/org/RhinoTests/ScriptEngineClassTest.java Thu Dec 20 13:16:30 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;
@@ -369,6 +370,35 @@
}
/**
+ * Test for method javax.script.ScriptEngine.getClass().getField()
+ */
+ protected void testGetField() {
+ // following fields should exists
+ final String[] fieldsThatShouldExists = {
+ "ARGV",
+ "FILENAME",
+ "ENGINE",
+ "ENGINE_VERSION",
+ "NAME",
+ "LANGUAGE",
+ "LANGUAGE_VERSION",
+ };
+ // check if all required fields really exists
+ for (String fieldThatShouldExists : fieldsThatShouldExists) {
+ try {
+ Field field = this.scriptEngineClass.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.ScriptEngine.getClass().getMethods()
*/
protected void testGetMethods() {
@@ -477,6 +507,58 @@
}
/**
+ * Test for method javax.script.ScriptEngine.getClass().getAnnotations()
+ */
+ protected void testGetAnnotations() {
+ // following annotations should be provided
+ final String[] annotationsThatShouldExists_jdk6 = {
+ };
+
+ final String[] annotationsThatShouldExists_jdk7 = {
+ };
+
+ // get all annotations
+ Annotation[] annotations = this.scriptEngineClass.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.ScriptEngine.getClass().getDeclaredAnnotations()
+ */
+ protected void testGetDeclaredAnnotations() {
+ // following annotations should be provided
+ final String[] annotationsThatShouldExists_jdk6 = {
+ };
+
+ final String[] annotationsThatShouldExists_jdk7 = {
+ };
+
+ // get all annotations
+ Annotation[] annotations = this.scriptEngineClass.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.ScriptEngine
*/
@SuppressWarnings("cast")
More information about the distro-pkg-dev
mailing list