Mercurial > hg > rhino-tests
view src/org/RhinoTests/SimpleBindingsClassTest.java @ 328:482d9f98ee40 draft
Added new tests testGetResourceAsStreamPositioveTest and
toStringTest into SimpleBindingsClassTest.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Fri, 07 Mar 2014 13:21:16 +0100 |
parents | 3758c6b6d899 |
children |
line wrap: on
line source
/* Rhino test framework Copyright (C) 2011, 2012, 2013, 2014 Red Hat This file is part of IcedTea. IcedTea is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. IcedTea is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with IcedTea; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package org.RhinoTests; import java.util.Arrays; import java.util.ArrayList; 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; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Type; import java.lang.reflect.TypeVariable; import javax.script.SimpleBindings; import javax.script.Bindings; /** * Set of tests which check the API of SimpleBindings class using * Java reflection API. * * @author Pavel Tisnovsky */ public class SimpleBindingsClassTest extends BaseRhinoTest { /** * Object that represents the type of SimpleBindings. */ Class<?> simpleBindingsClass = null; @Override protected void setUp(String[] args) { // setup attribute used by tests this.simpleBindingsClass = SimpleBindings.class; } @Override protected void tearDown() { // this block could be empty return; } /** * Test for method javax.script.SimpleBindings.getClass().isAssignableFrom() */ protected void testIsAssignableFrom() { assertTrue(this.simpleBindingsClass.isAssignableFrom(SimpleBindings.class), "Method SimpleBindings.getClass().isAssignableFrom() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isInstance() */ protected void testIsInstance() { assertTrue(this.simpleBindingsClass.isInstance(new SimpleBindings()), "Method SimpleBindings.getClass().isInstance() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isInterface() */ protected void testIsInterface() { assertFalse(this.simpleBindingsClass.isInterface(), "Method SimpleBindings.getClass().isInterface() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isLocalClass() */ protected void testIsLocalClass() { assertFalse(this.simpleBindingsClass.isLocalClass(), "Method SimpleBindings.getClass().isLocalClass() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isMemberClass() */ protected void testIsMemberClass() { assertFalse(this.simpleBindingsClass.isMemberClass(), "Method SimpleBindings.getClass().isMemberClass() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isPrimitive() */ protected void testIsPrimitive() { assertFalse(this.simpleBindingsClass.isPrimitive(), "Method SimpleBindings.getClass().isPrimitive() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isSynthetic() */ protected void testIsSynthetic() { assertFalse(this.simpleBindingsClass.isSynthetic(), "Method SimpleBindings.getClass().isSynthetic() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isAnnotation() */ protected void testIsAnnotation() { assertFalse(this.simpleBindingsClass.isAnnotation(), "Method SimpleBindings.getClass().isAnnotation() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isAnnotationPresent() */ protected void testIsAnnotationPresent() { assertFalse(this.simpleBindingsClass.isAnnotationPresent(java.lang.annotation.Annotation.class), "Method SimpleBindings.getClass().isAnnotationPresent(java.lang.annotation.Annotation.class) returns wrong value"); assertFalse(this.simpleBindingsClass.isAnnotationPresent(java.lang.annotation.Documented.class), "Method SimpleBindings.getClass().isAnnotationPresent(java.lang.annotation.Documented.class) returns wrong value"); assertFalse(this.simpleBindingsClass.isAnnotationPresent(java.lang.annotation.Inherited.class), "Method SimpleBindings.getClass().isAnnotationPresent(java.lang.annotation.Inherited.class) returns wrong value"); assertFalse(this.simpleBindingsClass.isAnnotationPresent(java.lang.annotation.Retention.class), "Method SimpleBindings.getClass().isAnnotationPresent(java.lang.annotation.Retention.class) returns wrong value"); assertFalse(this.simpleBindingsClass.isAnnotationPresent(java.lang.annotation.Target.class), "Method SimpleBindings.getClass().isAnnotationPresent(java.lang.annotation.Target.class) returns wrong value"); assertFalse(this.simpleBindingsClass.isAnnotationPresent(java.lang.Deprecated.class), "Method SimpleBindings.getClass().isAnnotationPresent(java.lang.Deprecated.class) returns wrong value"); assertFalse(this.simpleBindingsClass.isAnnotationPresent(java.lang.Override.class), "Method SimpleBindings.getClass().isAnnotationPresent(java.lang.Override.class) returns wrong value"); assertFalse(this.simpleBindingsClass.isAnnotationPresent(java.lang.SuppressWarnings.class), "Method SimpleBindings.getClass().isAnnotationPresent(java.lang.SuppressWarnings.class) returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isAnonymousClass() */ protected void testIsAnonymousClass() { assertFalse(this.simpleBindingsClass.isAnonymousClass(), "Method SimpleBindings.getClass().isAnonymousClass() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isArray() */ protected void testIsArray() { assertFalse(this.simpleBindingsClass.isArray(), "Method SimpleBindings.getClass().isArray() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().isEnum() */ protected void testIsEnum() { assertFalse(this.simpleBindingsClass.isEnum(), "Method SimpleBindings.getClass().isEnum() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().getInterfaces() */ protected void testGetInterfaces() { List<Class<?>> interfaces = Arrays.asList(this.simpleBindingsClass.getInterfaces()); assertTrue(interfaces.contains(Bindings.class), "list of implemented interfaces does not contain Bindings"); } /** * Test for method javax.script.SimpleBindings.getClass().getModifiers() */ protected void testGetModifiers() { int modifiers = this.simpleBindingsClass.getModifiers(); assertTrue(Modifier.isPublic(modifiers), "Method SimpleBindings.getClass().getModifiers() - isPublic modifier is set to a wrong value"); assertFalse(Modifier.isPrivate(modifiers), "Method SimpleBindings.getClass().getModifiers() - isPrivate modifier is set to a wrong value"); assertFalse(Modifier.isProtected(modifiers), "Method SimpleBindings.getClass().getModifiers() - isProtected modifier is set to a wrong value"); assertFalse(Modifier.isAbstract(modifiers), "Method SimpleBindings.getClass().getModifiers() - isAbstract modifier is set to a wrong value"); assertFalse(Modifier.isFinal(modifiers), "Method SimpleBindings.getClass().getModifiers() - isFinal modifier is set to a wrong value"); assertFalse(Modifier.isInterface(modifiers), "Method SimpleBindings.getClass().getModifiers() - isInterface modifier is set to a wrong value"); assertFalse(Modifier.isNative(modifiers), "Method SimpleBindings.getClass().getModifiers() - isNative modifier is set to a wrong value"); assertFalse(Modifier.isStatic(modifiers), "Method SimpleBindings.getClass().getModifiers() - isStatic modifier is set to a wrong value"); assertFalse(Modifier.isStrict(modifiers), "Method SimpleBindings.getClass().getModifiers() - isStrict modifier is set to a wrong value"); assertFalse(Modifier.isSynchronized(modifiers), "Method SimpleBindings.getClass().getModifiers() - isSynchronized modifier is set to a wrong value"); assertFalse(Modifier.isTransient(modifiers), "Method SimpleBindings.getClass().getModifiers() - isTransient modifier is set to a wrong value"); assertFalse(Modifier.isVolatile(modifiers), "Method SimpleBindings.getClass().getModifiers() - isVolatile modifier is set to a wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().getName() */ protected void testGetName() { String name = this.simpleBindingsClass.getName(); assertEquals(name, "javax.script.SimpleBindings", "Method SimpleBindings.getClass().getName() returns wrong value " + name); } /** * Test for method javax.script.SimpleBindings.getClass().getPackage() */ protected void testGetPackage() { Package p = this.simpleBindingsClass.getPackage(); String packageName = p.getName(); assertEquals(packageName, "javax.script", "Method SimpleBindings.getClass().getPackage().getName() returns wrong value " + packageName); } /** * Test for method javax.script.SimpleBindings.getClass().getSimpleName() */ protected void testGetSimpleName() { String simpleName = this.simpleBindingsClass.getSimpleName(); assertEquals(simpleName, "SimpleBindings", "Method SimpleBindings.getClass().getSimpleName() returns wrong value " + simpleName); } /** * Test for method javax.script.SimpleBindings.getClass().getCanonicalName() */ protected void testGetCanonicalName() { String canonicalName = this.simpleBindingsClass.getCanonicalName(); assertEquals(canonicalName, "javax.script.SimpleBindings", "Method javax.script.SimpleBindings.getClass().getCanonicalName() returns wrong value " + canonicalName); } /** * Test for method javax.script.SimpleBindings.getClass().getSuperclass() */ protected void testGetSuperclass() { Class<?> superClass = this.simpleBindingsClass.getSuperclass(); String superClassName = superClass.getName(); assertEquals(superClassName, "java.lang.Object", "Method SimpleBindings.getClass().getSuperclass() returns wrong value " + superClassName); } /** * Test for method javax.script.SimpleBindings.getClass().getConstructors() */ protected void testGetConstructors() { // map of constructors which should exists @SuppressWarnings("unused") Map<String, String> testedConstructors = null; Map<String, String> testedConstructors_jdk6 = new HashMap<String, String>(); Map<String, String> testedConstructors_jdk7 = new HashMap<String, String>(); Map<String, String> testedConstructors_jdk8 = new HashMap<String, String>(); testedConstructors_jdk6.put("public javax.script.SimpleBindings(java.util.Map)", "javax.script.SimpleBindings"); testedConstructors_jdk6.put("public javax.script.SimpleBindings()", "javax.script.SimpleBindings"); testedConstructors_jdk7.put("public javax.script.SimpleBindings(java.util.Map)", "javax.script.SimpleBindings"); testedConstructors_jdk7.put("public javax.script.SimpleBindings()", "javax.script.SimpleBindings"); testedConstructors_jdk8.put("public javax.script.SimpleBindings(java.util.Map)", "javax.script.SimpleBindings"); testedConstructors_jdk8.put("public javax.script.SimpleBindings()", "javax.script.SimpleBindings"); // get the right map containing constructor signatures switch (getJavaVersion()) { case 6: testedConstructors = testedConstructors_jdk6; break; case 7: testedConstructors = testedConstructors_jdk7; break; case 8: testedConstructors = testedConstructors_jdk8; break; } // get all constructors for this class Constructor<?>[] constructors = this.simpleBindingsClass.getConstructors(); // basic check for a number of constructors assertEquals(constructors.length, 2, "only 2 constructors should be set"); // check if all constructors exists for (Constructor<?> constructor : constructors) { String constructorName = constructor.getName(); String constructorString = constructor.toString(); assertTrue(testedConstructors.containsKey(constructorString), "wrong constructor.toString() " + constructorName); assertEquals(testedConstructors.get(constructorString), constructorName, "wrong constructor name " + constructorName); } } /** * Test for method javax.script.SimpleBindings.getClass().getDeclaredConstructors() */ protected void testGetDeclaredConstructors() { // map of constructors which should exists @SuppressWarnings("unused") Map<String, String> testedConstructors = null; Map<String, String> testedConstructors_jdk6 = new HashMap<String, String>(); Map<String, String> testedConstructors_jdk7 = new HashMap<String, String>(); Map<String, String> testedConstructors_jdk8 = new HashMap<String, String>(); testedConstructors_jdk6.put("public javax.script.SimpleBindings(java.util.Map)", "javax.script.SimpleBindings"); testedConstructors_jdk6.put("public javax.script.SimpleBindings()", "javax.script.SimpleBindings"); testedConstructors_jdk7.put("public javax.script.SimpleBindings(java.util.Map)", "javax.script.SimpleBindings"); testedConstructors_jdk7.put("public javax.script.SimpleBindings()", "javax.script.SimpleBindings"); testedConstructors_jdk8.put("public javax.script.SimpleBindings(java.util.Map)", "javax.script.SimpleBindings"); testedConstructors_jdk8.put("public javax.script.SimpleBindings()", "javax.script.SimpleBindings"); // get the right map containing constructor signatures switch (getJavaVersion()) { case 6: testedConstructors = testedConstructors_jdk6; break; case 7: testedConstructors = testedConstructors_jdk7; break; case 8: testedConstructors = testedConstructors_jdk8; break; } // get all declared constructors for this class Constructor<?>[] declaredConstructors = this.simpleBindingsClass.getDeclaredConstructors(); // basic check for a number of declared constructors assertEquals(declaredConstructors.length, 2, "only 2 constructors should be set"); // check if all declared constructors exists for (Constructor<?> declaredConstructor : declaredConstructors) { String constructorName = declaredConstructor.getName(); String constructorString = declaredConstructor.toString(); assertTrue(testedConstructors.containsKey(constructorString), "wrong constructor.toString() " + constructorName); assertEquals(testedConstructors.get(constructorString), constructorName, "wrong constructor name " + constructorName); } } /** * Test for method javax.script.SimpleBindings.getClass().getConstructor() */ protected void testGetConstructor() { // following constructors should exist Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>(); constructorsThatShouldExist_jdk6.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class}); constructorsThatShouldExist_jdk6.put("javax.script.SimpleBindings", new Class[] {}); Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>(); constructorsThatShouldExist_jdk7.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class}); constructorsThatShouldExist_jdk7.put("javax.script.SimpleBindings", new Class[] {}); Map<String, Class[]> constructorsThatShouldExist_jdk8 = new TreeMap<String, Class[]>(); constructorsThatShouldExist_jdk8.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class}); constructorsThatShouldExist_jdk8.put("javax.script.SimpleBindings", new Class[] {}); Map<String, Class[]> constructorsThatShouldExist = null; switch (getJavaVersion()) { case 6: constructorsThatShouldExist = constructorsThatShouldExist_jdk6; break; case 7: constructorsThatShouldExist = constructorsThatShouldExist_jdk7; break; case 8: constructorsThatShouldExist = constructorsThatShouldExist_jdk8; break; } // check if all required constructors really exist for (Map.Entry<String, Class[]> constructorThatShouldExists : constructorsThatShouldExist.entrySet()) { try { Constructor constructor = this.simpleBindingsClass.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.SimpleBindings.getClass().getDeclaredConstructor() */ protected void testGetDeclaredConstructor() { // following constructors should exist Map<String, Class[]> constructorsThatShouldExist_jdk6 = new TreeMap<String, Class[]>(); constructorsThatShouldExist_jdk6.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class}); constructorsThatShouldExist_jdk6.put("javax.script.SimpleBindings", new Class[] {}); Map<String, Class[]> constructorsThatShouldExist_jdk7 = new TreeMap<String, Class[]>(); constructorsThatShouldExist_jdk7.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class}); constructorsThatShouldExist_jdk7.put("javax.script.SimpleBindings", new Class[] {}); Map<String, Class[]> constructorsThatShouldExist_jdk8 = new TreeMap<String, Class[]>(); constructorsThatShouldExist_jdk8.put("javax.script.SimpleBindings", new Class[] {java.util.Map.class}); constructorsThatShouldExist_jdk8.put("javax.script.SimpleBindings", new Class[] {}); Map<String, Class[]> constructorsThatShouldExist = null; switch (getJavaVersion()) { case 6: constructorsThatShouldExist = constructorsThatShouldExist_jdk6; break; case 7: constructorsThatShouldExist = constructorsThatShouldExist_jdk7; break; case 8: constructorsThatShouldExist = constructorsThatShouldExist_jdk8; break; } // check if all required constructors really exist for (Map.Entry<String, Class[]> constructorThatShouldExists : constructorsThatShouldExist.entrySet()) { try { Constructor constructor = this.simpleBindingsClass.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.SimpleBindings.getClass().getFields() */ protected void testGetFields() { // following fields should exists final String[] fieldsThatShouldExist_jdk6 = { }; final String[] fieldsThatShouldExist_jdk7 = { }; final String[] fieldsThatShouldExist_jdk8 = { }; // get the right array of field signatures String[] fieldsThatShouldExist = null; switch (getJavaVersion()) { case 6: fieldsThatShouldExist = fieldsThatShouldExist_jdk6; break; case 7: fieldsThatShouldExist = fieldsThatShouldExist_jdk7; break; case 8: fieldsThatShouldExist = fieldsThatShouldExist_jdk8; break; } // get all fields Field[] fields = this.simpleBindingsClass.getFields(); // and transform the array into a list of field names List<String> fieldsAsString = new ArrayList<String>(); for (Field field : fields) { fieldsAsString.add(field.toString()); } // check if all required fields really exists for (String fieldThatShouldExists : fieldsThatShouldExist) { assertTrue(fieldsAsString.contains(fieldThatShouldExists), "field " + fieldThatShouldExists + " not found"); } } /** * Test for method javax.script.SimpleBindings.getClass().getDeclaredFields() */ protected void testGetDeclaredFields() { // following declared fields should exists final String[] declaredFieldsThatShouldExist_jdk6 = { "private java.util.Map javax.script.SimpleBindings.map", }; final String[] declaredFieldsThatShouldExist_jdk7 = { "private java.util.Map javax.script.SimpleBindings.map", }; final String[] declaredFieldsThatShouldExist_jdk8 = { "private java.util.Map javax.script.SimpleBindings.map", }; // get the right array of field signatures // following fields should be declared String[] declaredFieldsThatShouldExist = null; switch (getJavaVersion()) { case 6: declaredFieldsThatShouldExist = declaredFieldsThatShouldExist_jdk6; break; case 7: declaredFieldsThatShouldExist = declaredFieldsThatShouldExist_jdk7; break; case 8: declaredFieldsThatShouldExist = declaredFieldsThatShouldExist_jdk8; break; } // get all declared fields Field[] declaredFields = this.simpleBindingsClass.getDeclaredFields(); // and transform the array into a list of field names List<String> declaredFieldsAsString = new ArrayList<String>(); for (Field field : declaredFields) { declaredFieldsAsString.add(field.toString()); } // check if all required fields really exists for (String declaredFieldThatShouldExists : declaredFieldsThatShouldExist) { assertTrue(declaredFieldsAsString.contains(declaredFieldThatShouldExists), "field " + declaredFieldThatShouldExists + " not found"); } } /** * Test for method javax.script.SimpleBindings.getClass().getField() */ protected void testGetField() { // following fields should exists final String[] fieldsThatShouldExist_jdk6 = { }; final String[] fieldsThatShouldExist_jdk7 = { }; final String[] fieldsThatShouldExist_jdk8 = { }; String[] fieldsThatShouldExist = null; switch (getJavaVersion()) { case 6: fieldsThatShouldExist = fieldsThatShouldExist_jdk6; break; case 7: fieldsThatShouldExist = fieldsThatShouldExist_jdk7; break; case 8: fieldsThatShouldExist = fieldsThatShouldExist_jdk8; break; } // check if all required fields really exists for (String fieldThatShouldExists : fieldsThatShouldExist) { try { Field field = this.simpleBindingsClass.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.SimpleBindings.getClass().getDeclaredField() */ protected void testGetDeclaredField() { // following declared fields should exists final String[] declaredFieldsThatShouldExist_jdk6 = { "map", }; final String[] declaredFieldsThatShouldExist_jdk7 = { "map", }; final String[] declaredFieldsThatShouldExist_jdk8 = { "map", }; // get the right array of field signatures // following fields should be declared String[] declaredFieldsThatShouldExist = null; switch (getJavaVersion()) { case 6: declaredFieldsThatShouldExist = declaredFieldsThatShouldExist_jdk6; break; case 7: declaredFieldsThatShouldExist = declaredFieldsThatShouldExist_jdk7; break; case 8: declaredFieldsThatShouldExist = declaredFieldsThatShouldExist_jdk8; break; } // check if all required declared fields really exists for (String declaredFieldThatShouldExists : declaredFieldsThatShouldExist) { try { Field field = this.simpleBindingsClass.getDeclaredField(declaredFieldThatShouldExists); String fieldName = field.getName(); assertTrue(fieldName.equals(declaredFieldThatShouldExists), "field " + declaredFieldThatShouldExists + " not found"); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } } } /** * Test for method javax.script.SimpleBindings.getClass().getMethods() */ protected void testGetMethods() { // following methods should be inherited final String[] methodsThatShouldExist_jdk6 = { "public boolean java.lang.Object.equals(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsKey(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsValue(java.lang.Object)", "public boolean javax.script.SimpleBindings.isEmpty()", "public final native java.lang.Class java.lang.Object.getClass()", "public final native void java.lang.Object.notify()", "public final native void java.lang.Object.notifyAll()", "public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException", "public final void java.lang.Object.wait() throws java.lang.InterruptedException", "public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException", "public int javax.script.SimpleBindings.size()", "public java.lang.Object javax.script.SimpleBindings.get(java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.Object,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.String,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.remove(java.lang.Object)", "public java.lang.String java.lang.Object.toString()", "public java.util.Collection javax.script.SimpleBindings.values()", "public java.util.Set javax.script.SimpleBindings.entrySet()", "public java.util.Set javax.script.SimpleBindings.keySet()", "public native int java.lang.Object.hashCode()", "public void javax.script.SimpleBindings.clear()", "public void javax.script.SimpleBindings.putAll(java.util.Map)", }; final String[] methodsThatShouldExist_jdk7 = { "public boolean java.lang.Object.equals(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsKey(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsValue(java.lang.Object)", "public boolean javax.script.SimpleBindings.isEmpty()", "public final native java.lang.Class java.lang.Object.getClass()", "public final native void java.lang.Object.notify()", "public final native void java.lang.Object.notifyAll()", "public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException", "public final void java.lang.Object.wait() throws java.lang.InterruptedException", "public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException", "public int javax.script.SimpleBindings.size()", "public java.lang.Object javax.script.SimpleBindings.get(java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.Object,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.String,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.remove(java.lang.Object)", "public java.lang.String java.lang.Object.toString()", "public java.util.Collection javax.script.SimpleBindings.values()", "public java.util.Set javax.script.SimpleBindings.entrySet()", "public java.util.Set javax.script.SimpleBindings.keySet()", "public native int java.lang.Object.hashCode()", "public void javax.script.SimpleBindings.clear()", "public void javax.script.SimpleBindings.putAll(java.util.Map)", }; final String[] methodsThatShouldExist_jdk8 = { "public boolean java.lang.Object.equals(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsKey(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsValue(java.lang.Object)", "public boolean javax.script.SimpleBindings.isEmpty()", "public final native java.lang.Class java.lang.Object.getClass()", "public final native void java.lang.Object.notify()", "public final native void java.lang.Object.notifyAll()", "public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException", "public final void java.lang.Object.wait() throws java.lang.InterruptedException", "public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException", "public int javax.script.SimpleBindings.size()", "public java.lang.Object javax.script.SimpleBindings.get(java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.Object,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.String,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.remove(java.lang.Object)", "public java.lang.String java.lang.Object.toString()", "public java.util.Collection javax.script.SimpleBindings.values()", "public java.util.Set javax.script.SimpleBindings.entrySet()", "public java.util.Set javax.script.SimpleBindings.keySet()", "public native int java.lang.Object.hashCode()", "public void javax.script.SimpleBindings.clear()", "public void javax.script.SimpleBindings.putAll(java.util.Map)", }; // get all inherited methods Method[] methods = this.simpleBindingsClass.getMethods(); // and transform the array into a list of method names List<String> methodsAsString = new ArrayList<String>(); for (Method method : methods) { methodsAsString.add(method.toString()); } String[] methodsThatShouldExist = null; switch (getJavaVersion()) { case 6: methodsThatShouldExist = methodsThatShouldExist_jdk6; break; case 7: methodsThatShouldExist = methodsThatShouldExist_jdk7; break; case 8: methodsThatShouldExist = methodsThatShouldExist_jdk8; break; } // check if all required methods really exists for (String methodThatShouldExists : methodsThatShouldExist) { assertTrue(methodsAsString.contains(methodThatShouldExists), "method " + methodThatShouldExists + " not found"); } } /** * Test for method javax.script.SimpleBindings.getClass().getDeclaredMethods() */ protected void testGetDeclaredMethods() { // following methods should be declared final String[] declaredMethodsThatShouldExist_jdk6 = { "private void javax.script.SimpleBindings.checkKey(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsKey(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsValue(java.lang.Object)", "public boolean javax.script.SimpleBindings.isEmpty()", "public int javax.script.SimpleBindings.size()", "public java.lang.Object javax.script.SimpleBindings.get(java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.Object,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.String,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.remove(java.lang.Object)", "public java.util.Collection javax.script.SimpleBindings.values()", "public java.util.Set javax.script.SimpleBindings.entrySet()", "public java.util.Set javax.script.SimpleBindings.keySet()", "public void javax.script.SimpleBindings.clear()", "public void javax.script.SimpleBindings.putAll(java.util.Map)", }; final String[] declaredMethodsThatShouldExist_jdk7 = { "private void javax.script.SimpleBindings.checkKey(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsKey(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsValue(java.lang.Object)", "public boolean javax.script.SimpleBindings.isEmpty()", "public int javax.script.SimpleBindings.size()", "public java.lang.Object javax.script.SimpleBindings.get(java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.Object,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.String,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.remove(java.lang.Object)", "public java.util.Collection javax.script.SimpleBindings.values()", "public java.util.Set javax.script.SimpleBindings.entrySet()", "public java.util.Set javax.script.SimpleBindings.keySet()", "public void javax.script.SimpleBindings.clear()", "public void javax.script.SimpleBindings.putAll(java.util.Map)", }; final String[] declaredMethodsThatShouldExist_jdk8 = { "private void javax.script.SimpleBindings.checkKey(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsKey(java.lang.Object)", "public boolean javax.script.SimpleBindings.containsValue(java.lang.Object)", "public boolean javax.script.SimpleBindings.isEmpty()", "public int javax.script.SimpleBindings.size()", "public java.lang.Object javax.script.SimpleBindings.get(java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.Object,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.put(java.lang.String,java.lang.Object)", "public java.lang.Object javax.script.SimpleBindings.remove(java.lang.Object)", "public java.util.Collection javax.script.SimpleBindings.values()", "public java.util.Set javax.script.SimpleBindings.entrySet()", "public java.util.Set javax.script.SimpleBindings.keySet()", "public void javax.script.SimpleBindings.clear()", "public void javax.script.SimpleBindings.putAll(java.util.Map)", }; // get all declared methods Method[] declaredMethods = this.simpleBindingsClass.getDeclaredMethods(); // and transform the array into a list of method names List<String> methodsAsString = new ArrayList<String>(); for (Method method : declaredMethods) { methodsAsString.add(method.toString()); } String[] declaredMethodsThatShouldExist = null; switch (getJavaVersion()) { case 6: declaredMethodsThatShouldExist = declaredMethodsThatShouldExist_jdk6; break; case 7: declaredMethodsThatShouldExist = declaredMethodsThatShouldExist_jdk7; break; case 8: declaredMethodsThatShouldExist = declaredMethodsThatShouldExist_jdk8; break; } // check if all required methods really exists for (String methodThatShouldExists : declaredMethodsThatShouldExist) { assertTrue(methodsAsString.contains(methodThatShouldExists), "declared method " + methodThatShouldExists + " not found"); } } /** * Test for method javax.script.SimpleBindings.getClass().getMethod() */ protected void testGetMethod() { // following methods should exist Map<String, Class[]> methodsThatShouldExist_jdk6 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk6.put("get", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.Object.class, java.lang.Object.class}); methodsThatShouldExist_jdk6.put("clear", new Class[] {}); methodsThatShouldExist_jdk6.put("size", new Class[] {}); methodsThatShouldExist_jdk6.put("isEmpty", new Class[] {}); methodsThatShouldExist_jdk6.put("values", new Class[] {}); methodsThatShouldExist_jdk6.put("entrySet", new Class[] {}); methodsThatShouldExist_jdk6.put("putAll", new Class[] {java.util.Map.class}); methodsThatShouldExist_jdk6.put("remove", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk6.put("keySet", new Class[] {}); methodsThatShouldExist_jdk6.put("containsValue", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk6.put("containsKey", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk6.put("wait", new Class[] {long.class}); methodsThatShouldExist_jdk6.put("wait", new Class[] {long.class, int.class}); methodsThatShouldExist_jdk6.put("wait", new Class[] {}); methodsThatShouldExist_jdk6.put("hashCode", new Class[] {}); methodsThatShouldExist_jdk6.put("getClass", new Class[] {}); methodsThatShouldExist_jdk6.put("equals", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk6.put("toString", new Class[] {}); methodsThatShouldExist_jdk6.put("notify", new Class[] {}); methodsThatShouldExist_jdk6.put("notifyAll", new Class[] {}); Map<String, Class[]> methodsThatShouldExist_jdk7 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk7.put("remove", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk7.put("get", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.Object.class, java.lang.Object.class}); methodsThatShouldExist_jdk7.put("values", new Class[] {}); methodsThatShouldExist_jdk7.put("clear", new Class[] {}); methodsThatShouldExist_jdk7.put("isEmpty", new Class[] {}); methodsThatShouldExist_jdk7.put("size", new Class[] {}); methodsThatShouldExist_jdk7.put("entrySet", new Class[] {}); methodsThatShouldExist_jdk7.put("putAll", new Class[] {java.util.Map.class}); methodsThatShouldExist_jdk7.put("keySet", new Class[] {}); methodsThatShouldExist_jdk7.put("containsKey", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk7.put("containsValue", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk7.put("wait", new Class[] {long.class, int.class}); methodsThatShouldExist_jdk7.put("wait", new Class[] {long.class}); methodsThatShouldExist_jdk7.put("wait", new Class[] {}); methodsThatShouldExist_jdk7.put("equals", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk7.put("toString", new Class[] {}); methodsThatShouldExist_jdk7.put("hashCode", new Class[] {}); methodsThatShouldExist_jdk7.put("getClass", new Class[] {}); methodsThatShouldExist_jdk7.put("notify", new Class[] {}); methodsThatShouldExist_jdk7.put("notifyAll", new Class[] {}); Map<String, Class[]> methodsThatShouldExist_jdk8 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk8.put("remove", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk8.put("get", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk8.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk8.put("put", new Class[] {java.lang.Object.class, java.lang.Object.class}); methodsThatShouldExist_jdk8.put("values", new Class[] {}); methodsThatShouldExist_jdk8.put("clear", new Class[] {}); methodsThatShouldExist_jdk8.put("isEmpty", new Class[] {}); methodsThatShouldExist_jdk8.put("size", new Class[] {}); methodsThatShouldExist_jdk8.put("entrySet", new Class[] {}); methodsThatShouldExist_jdk8.put("putAll", new Class[] {java.util.Map.class}); methodsThatShouldExist_jdk8.put("keySet", new Class[] {}); methodsThatShouldExist_jdk8.put("containsValue", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk8.put("containsKey", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk8.put("wait", new Class[] {long.class, int.class}); methodsThatShouldExist_jdk8.put("wait", new Class[] {long.class}); methodsThatShouldExist_jdk8.put("wait", new Class[] {}); methodsThatShouldExist_jdk8.put("equals", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk8.put("toString", new Class[] {}); methodsThatShouldExist_jdk8.put("hashCode", new Class[] {}); methodsThatShouldExist_jdk8.put("getClass", new Class[] {}); methodsThatShouldExist_jdk8.put("notify", new Class[] {}); methodsThatShouldExist_jdk8.put("notifyAll", new Class[] {}); Map<String, Class[]> methodsThatShouldExist = null; switch (getJavaVersion()) { case 6: methodsThatShouldExist = methodsThatShouldExist_jdk6; break; case 7: methodsThatShouldExist = methodsThatShouldExist_jdk7; break; case 8: methodsThatShouldExist = methodsThatShouldExist_jdk8; break; } // check if all required methods really exist for (Map.Entry<String, Class[]> methodThatShouldExists : methodsThatShouldExist.entrySet()) { try { Method method = this.simpleBindingsClass.getMethod(methodThatShouldExists.getKey(), methodThatShouldExists.getValue()); assertNotNull(method, "method " + methodThatShouldExists.getKey() + " not found"); String methodName = method.getName(); assertNotNull(methodName, "method " + methodThatShouldExists.getKey() + " does not have name assigned"); assertTrue(methodName.equals(methodThatShouldExists.getKey()), "method " + methodThatShouldExists.getKey() + " not found"); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } } } /** * Test for method javax.script.SimpleBindings.getClass().getDeclaredMethod() */ protected void testGetDeclaredMethod() { // following methods should exist Map<String, Class[]> methodsThatShouldExist_jdk6 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk6.put("get", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.Object.class, java.lang.Object.class}); methodsThatShouldExist_jdk6.put("clear", new Class[] {}); methodsThatShouldExist_jdk6.put("size", new Class[] {}); methodsThatShouldExist_jdk6.put("isEmpty", new Class[] {}); methodsThatShouldExist_jdk6.put("values", new Class[] {}); methodsThatShouldExist_jdk6.put("entrySet", new Class[] {}); methodsThatShouldExist_jdk6.put("putAll", new Class[] {java.util.Map.class}); methodsThatShouldExist_jdk6.put("checkKey", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk6.put("remove", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk6.put("keySet", new Class[] {}); methodsThatShouldExist_jdk6.put("containsValue", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk6.put("containsKey", new Class[] {java.lang.Object.class}); Map<String, Class[]> methodsThatShouldExist_jdk7 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk7.put("remove", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk7.put("get", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.Object.class, java.lang.Object.class}); methodsThatShouldExist_jdk7.put("values", new Class[] {}); methodsThatShouldExist_jdk7.put("clear", new Class[] {}); methodsThatShouldExist_jdk7.put("isEmpty", new Class[] {}); methodsThatShouldExist_jdk7.put("size", new Class[] {}); methodsThatShouldExist_jdk7.put("entrySet", new Class[] {}); methodsThatShouldExist_jdk7.put("putAll", new Class[] {java.util.Map.class}); methodsThatShouldExist_jdk7.put("checkKey", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk7.put("keySet", new Class[] {}); methodsThatShouldExist_jdk7.put("containsKey", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk7.put("containsValue", new Class[] {java.lang.Object.class}); Map<String, Class[]> methodsThatShouldExist_jdk8 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk8.put("remove", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk8.put("get", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk8.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk8.put("put", new Class[] {java.lang.Object.class, java.lang.Object.class}); methodsThatShouldExist_jdk8.put("values", new Class[] {}); methodsThatShouldExist_jdk8.put("clear", new Class[] {}); methodsThatShouldExist_jdk8.put("isEmpty", new Class[] {}); methodsThatShouldExist_jdk8.put("size", new Class[] {}); methodsThatShouldExist_jdk8.put("entrySet", new Class[] {}); methodsThatShouldExist_jdk8.put("putAll", new Class[] {java.util.Map.class}); methodsThatShouldExist_jdk8.put("checkKey", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk8.put("keySet", new Class[] {}); methodsThatShouldExist_jdk8.put("containsValue", new Class[] {java.lang.Object.class}); methodsThatShouldExist_jdk8.put("containsKey", new Class[] {java.lang.Object.class}); Map<String, Class[]> methodsThatShouldExist = null; switch (getJavaVersion()) { case 6: methodsThatShouldExist = methodsThatShouldExist_jdk6; break; case 7: methodsThatShouldExist = methodsThatShouldExist_jdk7; break; case 8: methodsThatShouldExist = methodsThatShouldExist_jdk8; break; } // check if all required methods really exist for (Map.Entry<String, Class[]> methodThatShouldExists : methodsThatShouldExist.entrySet()) { try { Method method = this.simpleBindingsClass.getDeclaredMethod(methodThatShouldExists.getKey(), methodThatShouldExists.getValue()); assertNotNull(method, "method " + methodThatShouldExists.getKey() + " not found"); String methodName = method.getName(); assertNotNull(methodName, "method " + methodThatShouldExists.getKey() + " does not have name assigned"); assertTrue(methodName.equals(methodThatShouldExists.getKey()), "method " + methodThatShouldExists.getKey() + " not found"); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } } } /** * Test for method javax.script.SimpleBindings.getClass().getAnnotations() */ protected void testGetAnnotations() { // following annotations should be provided final String[] annotationsThatShouldExists_jdk6 = { // this should be really empty }; final String[] annotationsThatShouldExists_jdk7 = { // this should be really empty }; final String[] annotationsThatShouldExists_jdk8 = { // this should be really empty }; // get all annotations Annotation[] annotations = this.simpleBindingsClass.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 = null; switch (getJavaVersion()) { case 6: annotationsThatShouldExists = annotationsThatShouldExists_jdk6; break; case 7: annotationsThatShouldExists = annotationsThatShouldExists_jdk7; break; case 8: annotationsThatShouldExists = annotationsThatShouldExists_jdk8; break; } // check if all required annotations really exists for (String annotationThatShouldExists : annotationsThatShouldExists) { assertTrue(annotationsAsString.contains(annotationThatShouldExists), "annotation " + annotationThatShouldExists + " not found"); } } /** * Test for method javax.script.SimpleBindings.getClass().getDeclaredAnnotations() */ protected void testGetDeclaredAnnotations() { // following annotations should be provided final String[] annotationsThatShouldExists_jdk6 = { }; final String[] annotationsThatShouldExists_jdk7 = { }; final String[] annotationsThatShouldExists_jdk8 = { }; // get all annotations Annotation[] annotations = this.simpleBindingsClass.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 = null; switch (getJavaVersion()) { case 6: annotationsThatShouldExists = annotationsThatShouldExists_jdk6; break; case 7: annotationsThatShouldExists = annotationsThatShouldExists_jdk7; break; case 8: annotationsThatShouldExists = annotationsThatShouldExists_jdk8; break; } // check if all required annotations really exists for (String annotationThatShouldExists : annotationsThatShouldExists) { assertTrue(annotationsAsString.contains(annotationThatShouldExists), "annotation " + annotationThatShouldExists + " not found"); } } /** * Test for method javax.script.SimpleBindings.getClass().getAnnotation() */ protected void testGetAnnotation() { Annotation annotation; annotation = this.simpleBindingsClass.getAnnotation(java.lang.annotation.Annotation.class); assertNull(annotation, "annotation java.lang.annotation.Annotation should not be returned"); annotation = this.simpleBindingsClass.getAnnotation(java.lang.annotation.Documented.class); assertNull(annotation, "annotation java.lang.annotation.Documented should not be returned"); annotation = this.simpleBindingsClass.getAnnotation(java.lang.annotation.Inherited.class); assertNull(annotation, "annotation java.lang.annotation.Inherited should not be returned"); annotation = this.simpleBindingsClass.getAnnotation(java.lang.annotation.Retention.class); assertNull(annotation, "annotation java.lang.annotation.Retention should not be returned"); annotation = this.simpleBindingsClass.getAnnotation(java.lang.annotation.Target.class); assertNull(annotation, "annotation java.lang.annotation.Target should not be returned"); annotation = this.simpleBindingsClass.getAnnotation(java.lang.Deprecated.class); assertNull(annotation, "annotation java.lang.Deprecated should not be returned"); annotation = this.simpleBindingsClass.getAnnotation(java.lang.Override.class); assertNull(annotation, "annotation java.lang.Override should not be returned"); annotation = this.simpleBindingsClass.getAnnotation(java.lang.SuppressWarnings.class); assertNull(annotation, "annotation java.lang.SuppressWarnings should not be returned"); } /** * Test for method javax.script.SimpleBindings.getClass().getComponentType() */ protected void testGetComponentType() { Class<?> cls = this.simpleBindingsClass.getComponentType(); assertNull(cls, "getComponentType() should returns null"); } /** * Test for method javax.script.SimpleBindings.getClass().getClasses() */ protected void testGetClasses() { Class<?>[] cls = this.simpleBindingsClass.getClasses(); assertNotNull(cls, "getClasses() returns null"); assertEquals(cls.length, 0, "getClasses() returns wrong value!"); } /** * Test for method javax.script.SimpleBindings.getClass().getDeclaredClasses() */ protected void testGetDeclaredClasses() { Class<?>[] cls = this.simpleBindingsClass.getDeclaredClasses(); assertNotNull(cls, "getDeclaredClasses() returns null"); assertEquals(cls.length, 0, "getDeclaredClasses() returns wrong value!"); } /** * Test for method javax.script.SimpleBindings.getClass().getDeclaringClass() */ protected void testGetDeclaringClass() { Class<?> cls = this.simpleBindingsClass.getDeclaringClass(); assertNull(cls, "getDeclaringClass() does not return null"); } /** * Test for method javax.script.SimpleBindings.getClass().getEnclosingClass() */ protected void testGetEnclosingClass() { Class<?> cls = this.simpleBindingsClass.getEnclosingClass(); assertNull(cls, "getEnclosingClass() does not return null"); } /** * Test for method javax.script.SimpleBindings.getClass().getEnclosingConstructor() */ protected void testGetEnclosingConstructor() { Constructor<?> cons = this.simpleBindingsClass.getEnclosingConstructor(); assertNull(cons, "getEnclosingConstructor() does not return null"); } /** * Test for method javax.script.SimpleBindings.getClass().getEnclosingMethod() */ protected void testGetEnclosingMethod() { Method m = this.simpleBindingsClass.getEnclosingMethod(); assertNull(m, "getEnclosingMethod() does not return null"); } /** * Test for method javax.script.SimpleBindings.getClass().getGenericSuperclass() */ protected void testGetGenericSuperclass() { Type genericSuperclass = this.simpleBindingsClass.getGenericSuperclass(); assertNotNull(genericSuperclass, "getGenericSuperclass() does not return null"); } /** * Test for method javax.script.SimpleBindings.getClass().getGenericInterfaces() */ protected void testGetGenericInterfaces() { // array of interface names that should exists final String[] genericInterfaceNames_jdk6 = { "interface javax.script.Bindings", }; final String[] genericInterfaceNames_jdk7 = { }; final String[] genericInterfaceNames_jdk8 = { }; // get the right array of field signatures String[] genericInterfaceNames = null; switch (getJavaVersion()) { case 6: genericInterfaceNames = genericInterfaceNames_jdk6; break; case 7: genericInterfaceNames = genericInterfaceNames_jdk7; break; case 8: genericInterfaceNames = genericInterfaceNames_jdk8; break; } // get all generic interfaces Type[] genericInterfaces = this.simpleBindingsClass.getGenericInterfaces(); assertNotNull(genericInterfaces, "getGenericInterfaces() returns null"); assertEquals(1, genericInterfaces.length, "array of wrong size returned by getGenericInterfaces " + genericInterfaces.length); // and transform the array into a list of field names List<String> interfacesAsString = new ArrayList<String>(); for (Type genericInterface : genericInterfaces) { interfacesAsString.add(genericInterface.toString()); } // check if all required interfaces really exists for (String interfaceThatShouldExists : genericInterfaceNames) { assertTrue(interfacesAsString.contains(interfaceThatShouldExists), "interface " + interfaceThatShouldExists + " not found"); } } /** * Test for method javax.script.SimpleBindings.getClass().getEnumConstants() */ protected void testGetEnumConstants() { Object[] enumConstants = this.simpleBindingsClass.getEnumConstants(); assertNull(enumConstants, "getEnumConstants() does not return null"); } /** * Test for method javax.script.SimpleBindings.getClass().getTypeParameters() */ protected void testGetTypeParameters() { TypeVariable<?>[] typeParameters = this.simpleBindingsClass.getTypeParameters(); assertNotNull(typeParameters, "getTypeParameters() return null"); assertEquals(0, typeParameters.length, "array of wrong size returned by getTypeParameters() " + typeParameters.length); } /** * Test for method javax.script.SimpleBindings.getClass().getSigners() */ protected void testGetSigners() { Object[] signers = this.simpleBindingsClass.getSigners(); assertNull(signers, "getSigners() does not return null"); } /** * Test for method javax.script.SimpleBindings.getClass().desiredAssertionStatus() */ protected void testDesiredAssertionStatus() { assertFalse(this.simpleBindingsClass.desiredAssertionStatus(), "Method SimpleBindings.getClass().desiredAssertionStatus() returns wrong value"); } /** * Test for method javax.script.SimpleBindings.getClass().asSubclass() */ protected void testAsSubclass() { try { this.simpleBindingsClass.asSubclass(simpleBindingsClass); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } try { this.simpleBindingsClass.asSubclass(Object.class); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } try { this.simpleBindingsClass.asSubclass(java.lang.Void.class); throw new AssertionError("Class.asSubclass(java.lang.Void.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.Number.class); throw new AssertionError("Class.asSubclass(java.lang.Number.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.Byte.class); throw new AssertionError("Class.asSubclass(java.lang.Byte.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.Double.class); throw new AssertionError("Class.asSubclass(java.lang.Double.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.Float.class); throw new AssertionError("Class.asSubclass(java.lang.Float.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.Integer.class); throw new AssertionError("Class.asSubclass(java.lang.Integer.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.Long.class); throw new AssertionError("Class.asSubclass(java.lang.Long.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.Short.class); throw new AssertionError("Class.asSubclass(java.lang.Short.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.String.class); throw new AssertionError("Class.asSubclass(java.lang.String.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.StringBuffer.class); throw new AssertionError("Class.asSubclass(java.lang.StringBuffer.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.lang.StringBuilder.class); throw new AssertionError("Class.asSubclass(java.lang.StringBuilder.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.applet.Applet.class); throw new AssertionError("Class.asSubclass(java.applet.Applet.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.Button.class); throw new AssertionError("Class.asSubclass(java.awt.Button.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.Canvas.class); throw new AssertionError("Class.asSubclass(java.awt.Canvas.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.CardLayout.class); throw new AssertionError("Class.asSubclass(java.awt.CardLayout.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.Checkbox.class); throw new AssertionError("Class.asSubclass(java.awt.Checkbox.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.Choice.class); throw new AssertionError("Class.asSubclass(java.awt.Choice.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.Color.class); throw new AssertionError("Class.asSubclass(java.awt.Color.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.Font.class); throw new AssertionError("Class.asSubclass(java.awt.Font.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.Image.class); throw new AssertionError("Class.asSubclass(java.awt.Image.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.Label.class); throw new AssertionError("Class.asSubclass(java.awt.Label.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.List.class); throw new AssertionError("Class.asSubclass(java.awt.List.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.awt.Menu.class); throw new AssertionError("Class.asSubclass(java.awt.Menu.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.io.File.class); throw new AssertionError("Class.asSubclass(java.io.File.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.io.Reader.class); throw new AssertionError("Class.asSubclass(java.io.Reader.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.io.Writer.class); throw new AssertionError("Class.asSubclass(java.io.Writer.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.io.StringReader.class); throw new AssertionError("Class.asSubclass(java.io.StringReader.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.io.StringWriter.class); throw new AssertionError("Class.asSubclass(java.io.StringWriter.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.io.InputStream.class); throw new AssertionError("Class.asSubclass(java.io.InputStream.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.io.OutputStream.class); throw new AssertionError("Class.asSubclass(java.io.OutputStream.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.io.ObjectInputStream.class); throw new AssertionError("Class.asSubclass(java.io.ObjectInputStream.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.io.ObjectOutputStream.class); throw new AssertionError("Class.asSubclass(java.io.ObjectOutputStream.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.math.BigDecimal.class); throw new AssertionError("Class.asSubclass(java.math.BigDecimal.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.math.BigInteger.class); throw new AssertionError("Class.asSubclass(java.math.BigInteger.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.ArrayList.class); throw new AssertionError("Class.asSubclass(java.util.ArrayList.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.LinkedList.class); throw new AssertionError("Class.asSubclass(java.util.LinkedList.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.HashMap.class); throw new AssertionError("Class.asSubclass(java.util.HashMap.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.TreeMap.class); throw new AssertionError("Class.asSubclass(java.util.TreeMap.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.HashSet.class); throw new AssertionError("Class.asSubclass(java.util.HashSet.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.TreeSet.class); throw new AssertionError("Class.asSubclass(java.util.TreeSet.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.Stack.class); throw new AssertionError("Class.asSubclass(java.util.Stack.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.Vector.class); throw new AssertionError("Class.asSubclass(java.util.Vector.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.Hashtable.class); throw new AssertionError("Class.asSubclass(java.util.Hashtable.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.Calendar.class); throw new AssertionError("Class.asSubclass(java.util.Calendar.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.Arrays.class); throw new AssertionError("Class.asSubclass(java.util.Arrays.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(java.util.Collections.class); throw new AssertionError("Class.asSubclass(java.util.Collections.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(javax.swing.JPanel.class); throw new AssertionError("Class.asSubclass(javax.swing.JPanel.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(javax.swing.JColorChooser.class); throw new AssertionError("Class.asSubclass(javax.swing.JColorChooser.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(javax.swing.JScrollBar.class); throw new AssertionError("Class.asSubclass(javax.swing.JScrollBar.class) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.asSubclass(javax.swing.JSlider.class); throw new AssertionError("Class.asSubclass(javax.swing.JSlider.class) does not throw any exception"); } catch (Exception e) { // expected exception } } /** * Test for method javax.script.SimpleBindings.getClass().cast() */ protected void testCast() { try { this.simpleBindingsClass.cast(new javax.script.SimpleBindings()); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } try { this.simpleBindingsClass.cast(new Object()); throw new AssertionError("Class.cast(new Object()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new Object().getClass()); throw new AssertionError("Class.cast(new Object().getClass()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new String()); throw new AssertionError("Class.cast(new String()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(Boolean.valueOf(true)); throw new AssertionError("Class.cast(Boolean.valueOf(true)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(Boolean.valueOf(false)); throw new AssertionError("Class.cast(Boolean.valueOf(false)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(Character.valueOf('a')); throw new AssertionError("Class.cast(Character.valueOf('a')) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(Byte.valueOf((byte)42)); throw new AssertionError("Class.cast(Byte.valueOf((byte)42)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(Short.valueOf((short)42)); throw new AssertionError("Class.cast(Short.valueOf((short)42)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(Integer.valueOf(42)); throw new AssertionError("Class.cast(Integer.valueOf(42)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(Long.valueOf(42L)); throw new AssertionError("Class.cast(Long.valueOf(42L)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(Float.valueOf(42f)); throw new AssertionError("Class.cast(Float.valueOf(42f)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(Double.valueOf(42.)); throw new AssertionError("Class.cast(Double.valueOf(42.)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new Throwable()); throw new AssertionError("Class.cast(new Throwable()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new Throwable("xyzzy")); throw new AssertionError("Class.cast(new Throwable(\"xyzzy\")) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new RuntimeException()); throw new AssertionError("Class.cast(new RuntimeException()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new RuntimeException("xyzzy")); throw new AssertionError("Class.cast(new RuntimeException(\"xyzzy\")) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new Error()); throw new AssertionError("Class.cast(new Error()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new Error("xyzzy")); throw new AssertionError("Class.cast(new Error(\"xyzzy\")) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new java.io.File("xyzzy")); throw new AssertionError("Class.cast(new java.io.File(\"xyzzy\")) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new java.lang.String()); throw new AssertionError("Class.cast(new java.lang.String()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new java.lang.StringBuffer()); throw new AssertionError("Class.cast(new java.lang.StringBuffer()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new java.lang.StringBuilder()); throw new AssertionError("Class.cast(new java.lang.StringBuilder()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(java.awt.Color.black); throw new AssertionError("Class.cast(java.awt.Color.black) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new java.awt.Frame()); throw new AssertionError("Class.cast(new java.awt.Frame()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new java.awt.Frame(new String())); throw new AssertionError("Class.cast(new java.awt.Frame(new String())) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new java.awt.Label()); throw new AssertionError("Class.cast(new java.awt.Label()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new java.awt.Label(new String())); throw new AssertionError("Class.cast(new java.awt.Label(new String())) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new java.awt.Label("xyzzy")); throw new AssertionError("Class.cast(new java.awt.Label(\"xyzzy\")) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new javax.swing.JLabel()); throw new AssertionError("Class.cast(new javax.swing.JLabel()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new javax.swing.JLabel(new String())); throw new AssertionError("Class.cast(new javax.swing.JLabel(new String())) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new javax.swing.JLabel("xyzzy")); throw new AssertionError("Class.cast(new javax.swing.JLabel(\"xyzzy\")) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.simpleBindingsClass.cast(new javax.swing.JPanel()); throw new AssertionError("Class.cast(new javax.swing.JPanel()) does not throw any exception"); } catch (Exception e) { // expected exception } } /** * Test for method javax.script.SimpleBindings.getClass().newInstance() */ protected void testNewInstance() { try { Object o = this.simpleBindingsClass.newInstance(); } catch (InstantiationException e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } catch (IllegalAccessException e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } } /** * Test for method javax.script.SimpleBindings.getClass().getResourceNPETest() */ protected void testGetResourceNPETest() { try { Object resource = this.simpleBindingsClass.getResource(null); throw new AssertionError("NullPointerException expected!"); } catch (NullPointerException e) { //This is OK OK } } /** * Test for method javax.script.SimpleBindings.getClass().getResourceNegativeTest() */ protected void testGetResourceNegativeTest() { Object resource = this.simpleBindingsClass.getResource("unknown"); assertNull(resource, "getResource() does not return null"); } /** * Test for method javax.script.SimpleBindings.getClass().getResourcePositiveTest() */ protected void testGetResourcePositiveTest() { Object resource; resource = this.simpleBindingsClass.getResource("/org/RhinoTests/AbstractScriptEngineClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/AbstractScriptEngineClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/BaseRhinoTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/BaseRhinoTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/BindingsClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/BindingsClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/BindingsTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/BindingsTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/CompilableClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/CompilableClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/CompilableTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/CompilableTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/CompiledScriptClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/CompiledScriptClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/CompiledScriptTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/CompiledScriptTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/Constants.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/Constants.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/InvocableClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/InvocableClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/InvocableTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/InvocableTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/JavaScriptSnippets.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/JavaScriptSnippets.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/JavaScriptsTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/JavaScriptsTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptContextClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptContextClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptContextTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptContextTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptEngineClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptEngineFactoryClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineFactoryClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptEngineFactoryTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineFactoryTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptEngineManagerClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineManagerClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptEngineManagerTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineManagerTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptEngineTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptExceptionClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptExceptionClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/ScriptExceptionTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptExceptionTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/SimpleBindingsClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/SimpleBindingsClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/SimpleBindingsTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/SimpleBindingsTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/SimpleScriptContextClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/SimpleScriptContextClassTest.class\") returns null"); resource = this.simpleBindingsClass.getResource("/org/RhinoTests/SimpleScriptContextTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/SimpleScriptContextTest.class\") returns null"); } /** * Test for method javax.script.SimpleBindings.getClass().getResourceAsStreamNPETest() */ protected void testGetResourceAsStreamNPETest() { try { Object resource = this.simpleBindingsClass.getResourceAsStream(null); throw new AssertionError("NullPointerException expected!"); } catch (NullPointerException e) { //This is OK OK } } /** * Test for method javax.script.SimpleBindings.getClass().getResourceAsStreamNegativeTest() */ protected void testGetResourceAsStreamNegativeTest() { Object stream = null; stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/AbstractScriptEngineClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/AbstractScriptEngineClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/BaseRhinoTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/BaseRhinoTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/BindingsClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/BindingsClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/BindingsTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/BindingsTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/CompilableClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/CompilableClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/CompilableTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/CompilableTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/CompiledScriptClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/CompiledScriptClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/CompiledScriptTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/CompiledScriptTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/Constants.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/Constants.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/InvocableClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/InvocableClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/InvocableTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/InvocableTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/JavaScriptSnippets.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/JavaScriptSnippets.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/JavaScriptsTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/JavaScriptsTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptContextClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptContextClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptContextTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptContextTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptEngineClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptEngineClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptEngineFactoryClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptEngineFactoryClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptEngineFactoryTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptEngineFactoryTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptEngineManagerClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptEngineManagerClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptEngineManagerTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptEngineManagerTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptEngineTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptEngineTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptExceptionClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptExceptionClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/ScriptExceptionTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/ScriptExceptionTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/SimpleBindingsClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/SimpleBindingsClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/SimpleBindingsTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/SimpleBindingsTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/SimpleScriptContextClassTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/SimpleScriptContextClassTest.class\") returns null"); stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/SimpleScriptContextTest.class"); assertNotNull(stream, "getAsStreamResource(\"/org/RhinoTests/SimpleScriptContextTest.class\") returns null"); } /** * Test for method javax.script.SimpleBindings.getClass().getResourceAsStreamPositiveTest() */ protected void testGetResourceAsStreamPositiveTest() { Object stream; stream = this.simpleBindingsClass.getResourceAsStream("/org/RhinoTests/AbstractScriptEngineClassTest.class"); assertNotNull(stream, "getResourceAsStream(\"/org/RhinoTests/AbstractScriptEngineClassTest.class\") returns null"); } /** * Test for method javax.script.SimpleBindings.getClass().toString() */ protected void testToString() { String asString; asString = this.simpleBindingsClass.toString(); assertEquals("class javax.script.SimpleBindings", asString, "wrong toString() return value"); } /** * Test for instanceof operator applied to a class javax.script.SimpleBindings */ @SuppressWarnings("cast") protected void testInstanceOf() { // tested object Object o = new SimpleBindings(); // basic check of instanceof operator assertTrue(o instanceof SimpleBindings, "instanceof SimpleBindings is wrongly evaluated to false"); // check operator instanceof against all superclasses assertTrue(o instanceof Object, "instanceof Object is wrongly evaluated to false"); } /** * Entry point to this test case. * * @param args parameters passed from command line */ public static void main(String[] args) { new SimpleBindingsClassTest().doTests(args); } }