/hg/rhino-tests: Added three new tests for methods GetCanonicalN...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Thu Jan 10 00:29:40 PST 2013
changeset 7df6314535c9 in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=7df6314535c9
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jan 10 09:32:48 2013 +0100
Added three new tests for methods GetCanonicalName(), getConstructor() and
getDeclaredConstructor() into RhinoTests/BindingsClassTest.java.
diffstat:
ChangeLog | 6 ++
src/org/RhinoTests/BindingsClassTest.java | 72 ++++++++++++++++++++++++++++++-
2 files changed, 77 insertions(+), 1 deletions(-)
diffs (116 lines):
diff -r 90f140ca1129 -r 7df6314535c9 ChangeLog
--- a/ChangeLog Wed Jan 09 10:47:01 2013 +0100
+++ b/ChangeLog Thu Jan 10 09:32:48 2013 +0100
@@ -1,3 +1,9 @@
+2013-01-10 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/RhinoTests/BindingsClassTest.java:
+ Added three new tests for methods GetCanonicalName(), getConstructor() and
+ getDeclaredConstructor().
+
2013-01-09 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/RhinoTests/SimpleBindingsClassTest.java:
diff -r 90f140ca1129 -r 7df6314535c9 src/org/RhinoTests/BindingsClassTest.java
--- a/src/org/RhinoTests/BindingsClassTest.java Wed Jan 09 10:47:01 2013 +0100
+++ b/src/org/RhinoTests/BindingsClassTest.java Thu Jan 10 09:32:48 2013 +0100
@@ -1,7 +1,7 @@
/*
Rhino test framework
- Copyright (C) 2011, 2012 Red Hat
+ Copyright (C) 2011, 2012, 2013 Red Hat
This file is part of IcedTea.
@@ -45,6 +45,7 @@
import java.util.List;
import java.util.Map;
import java.util.HashMap;
+import java.util.TreeMap;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
@@ -261,6 +262,15 @@
}
/**
+ * Test for method javax.script.Bindings.getClass().getCanonicalName()
+ */
+ protected void testGetCanonicalName() {
+ String canonicalName = this.bindingsClass.getCanonicalName();
+ assertEquals(canonicalName, "javax.script.Bindings",
+ "Method javax.script.Bindings.getClass().getCanonicalName() returns wrong value " + canonicalName);
+ }
+
+ /**
* Test for method javax.script.Bindings.getClass().getSuperclass()
*/
protected void testGetSuperclass() {
@@ -314,6 +324,66 @@
}
/**
+ * Test for method javax.script.Bindings.getClass().getConstructor()
+ */
+ protected void testGetConstructor() {
+ // following constructors should exist
+ Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+
+ Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+
+ Map<String, Class[]> constructorsThatShouldExist = getJavaVersion() < 7 ? constructorsThatShouldExist_jdk6 : constructorsThatShouldExist_jdk7;
+
+ // check if all required constructors really exist
+ for (Map.Entry<String, Class[]> constructorThatShouldExists : constructorsThatShouldExist.entrySet()) {
+ try {
+ Constructor constructor = this.bindingsClass.getConstructor(constructorThatShouldExists.getValue());
+ assertNotNull(constructor,
+ "constructor " + constructorThatShouldExists.getKey() + " not found");
+ String constructorName = constructor.getName();
+ assertNotNull(constructorName,
+ "constructor " + constructorThatShouldExists.getKey() + " does not have name assigned");
+ assertTrue(constructorName.equals(constructorThatShouldExists.getKey()),
+ "constructor " + constructorThatShouldExists.getKey() + " not found");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new AssertionError(e.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Test for method javax.script.Bindings.getClass().getDeclaredConstructor()
+ */
+ protected void testGetDeclaredConstructor() {
+ // following constructors should exist
+ Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>();
+
+ Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>();
+
+ Map<String, Class[]> constructorsThatShouldExist = getJavaVersion() < 7 ? constructorsThatShouldExist_jdk6 : constructorsThatShouldExist_jdk7;
+
+ // check if all required constructors really exist
+ for (Map.Entry<String, Class[]> constructorThatShouldExists : constructorsThatShouldExist.entrySet()) {
+ try {
+ Constructor constructor = this.bindingsClass.getDeclaredConstructor(constructorThatShouldExists.getValue());
+ assertNotNull(constructor,
+ "constructor " + constructorThatShouldExists.getKey() + " not found");
+ String constructorName = constructor.getName();
+ assertNotNull(constructorName,
+ "constructor " + constructorThatShouldExists.getKey() + " does not have name assigned");
+ assertTrue(constructorName.equals(constructorThatShouldExists.getKey()),
+ "constructor " + constructorThatShouldExists.getKey() + " not found");
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new AssertionError(e.getMessage());
+ }
+ }
+ }
+
+ /**
* Test for method javax.script.Bindings.getClass().getFields()
*/
protected void testGetFields() {
More information about the distro-pkg-dev
mailing list