Mercurial > hg > rhino-tests
view src/org/RhinoTests/ScriptEngineClassTest.java @ 338:c4c9da65a928 draft
Enhancements of various tests in ScriptEngineClassTest.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Fri, 21 Mar 2014 11:42:16 +0100 |
parents | 4dee1c9a9f58 |
children | 2b9db1e50f41 |
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.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; /** * Set of tests which check the API of ScriptEngine interface using * Java reflection API. * * @author Pavel Tisnovsky */ public class ScriptEngineClassTest extends BaseRhinoTest { /** * Object that represents the type of ScriptEngine. */ Class<?> scriptEngineClass = null; @Override protected void setUp(String[] args) { // setup attribute used by tests this.scriptEngineClass = ScriptEngine.class; } @Override protected void tearDown() { // this block could be empty return; } /** * Test for method javax.script.ScriptEngine.getClass().isAssignableFrom() */ protected void testIsAssignableFrom() { assertTrue(this.scriptEngineClass.isAssignableFrom(ScriptEngine.class), "Method ScriptEngine.getClass().isAssignableFrom() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isInstance() */ protected void testIsInstance() { assertTrue(this.scriptEngineClass.isInstance(new ScriptEngineManager().getEngineByName(Constants.EngineNames.ENGINE_NAME_JavaScript)), "Method ScriptEngine.getClass().isInstance() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isInterface() */ protected void testIsInterface() { assertTrue(this.scriptEngineClass.isInterface(), "Method ScriptEngine.getClass().isInterface() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isLocalClass() */ protected void testIsLocalClass() { assertFalse(this.scriptEngineClass.isLocalClass(), "Method ScriptEngine.getClass().isLocalClass() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isMemberClass() */ protected void testIsMemberClass() { assertFalse(this.scriptEngineClass.isMemberClass(), "Method ScriptEngine.getClass().isMemberClass() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isPrimitive() */ protected void testIsPrimitive() { assertFalse(this.scriptEngineClass.isPrimitive(), "Method ScriptEngine.getClass().isPrimitive() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isSynthetic() */ protected void testIsSynthetic() { assertFalse(this.scriptEngineClass.isSynthetic(), "Method ScriptEngine.getClass().isSynthetic() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isAnnotation() */ protected void testIsAnnotation() { assertFalse(this.scriptEngineClass.isAnnotation(), "Method ScriptEngine.getClass().isAnnotation() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isAnnotationPresent() */ protected void testIsAnnotationPresent() { assertFalse(this.scriptEngineClass.isAnnotationPresent(java.lang.annotation.Annotation.class), "Method ScriptEngine.getClass().isAnnotationPresent(java.lang.annotation.Annotation.class) returns wrong value"); assertFalse(this.scriptEngineClass.isAnnotationPresent(java.lang.annotation.Documented.class), "Method ScriptEngine.getClass().isAnnotationPresent(java.lang.annotation.Documented.class) returns wrong value"); assertFalse(this.scriptEngineClass.isAnnotationPresent(java.lang.annotation.Inherited.class), "Method ScriptEngine.getClass().isAnnotationPresent(java.lang.annotation.Inherited.class) returns wrong value"); assertFalse(this.scriptEngineClass.isAnnotationPresent(java.lang.annotation.Retention.class), "Method ScriptEngine.getClass().isAnnotationPresent(java.lang.annotation.Retention.class) returns wrong value"); assertFalse(this.scriptEngineClass.isAnnotationPresent(java.lang.annotation.Target.class), "Method ScriptEngine.getClass().isAnnotationPresent(java.lang.annotation.Target.class) returns wrong value"); assertFalse(this.scriptEngineClass.isAnnotationPresent(java.lang.Deprecated.class), "Method ScriptEngine.getClass().isAnnotationPresent(java.lang.Deprecated.class) returns wrong value"); assertFalse(this.scriptEngineClass.isAnnotationPresent(java.lang.Override.class), "Method ScriptEngine.getClass().isAnnotationPresent(java.lang.Override.class) returns wrong value"); assertFalse(this.scriptEngineClass.isAnnotationPresent(java.lang.SuppressWarnings.class), "Method ScriptEngine.getClass().isAnnotationPresent(java.lang.SuppressWarnings.class) returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isAnonymousClass() */ protected void testIsAnonymousClass() { assertFalse(this.scriptEngineClass.isAnonymousClass(), "Method ScriptEngine.getClass().isAnonymousClass() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isArray() */ protected void testIsArray() { assertFalse(this.scriptEngineClass.isArray(), "Method ScriptEngine.getClass().isArray() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().isEnum() */ protected void testIsEnum() { assertFalse(this.scriptEngineClass.isEnum(), "Method ScriptEngine.getClass().isEnum() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().getInterfaces() */ protected void testGetInterfaces() { List<Class<?>> interfaces = Arrays.asList(this.scriptEngineClass.getInterfaces()); assertTrue(interfaces.isEmpty(), "list of implemented interfaces should be empty"); } /** * Test for method javax.script.ScriptEngine.getClass().getModifiers() */ protected void testGetModifiers() { int modifiers = this.scriptEngineClass.getModifiers(); assertTrue(Modifier.isPublic(modifiers), "Method ScriptEngine.getClass().getModifiers() - isPublic modifier is set to a wrong value"); assertFalse(Modifier.isPrivate(modifiers), "Method ScriptEngine.getClass().getModifiers() - isPrivate modifier is set to a wrong value"); assertFalse(Modifier.isProtected(modifiers), "Method ScriptEngine.getClass().getModifiers() - isProtected modifier is set to a wrong value"); assertTrue(Modifier.isAbstract(modifiers), "Method ScriptEngine.getClass().getModifiers() - isAbstract modifier is set to a wrong value"); assertFalse(Modifier.isFinal(modifiers), "Method ScriptEngine.getClass().getModifiers() - isFinal modifier is set to a wrong value"); assertTrue(Modifier.isInterface(modifiers), "Method ScriptEngine.getClass().getModifiers() - isInterface modifier is set to a wrong value"); assertFalse(Modifier.isNative(modifiers), "Method ScriptEngine.getClass().getModifiers() - isNative modifier is set to a wrong value"); assertFalse(Modifier.isStatic(modifiers), "Method ScriptEngine.getClass().getModifiers() - isStatic modifier is set to a wrong value"); assertFalse(Modifier.isStrict(modifiers), "Method ScriptEngine.getClass().getModifiers() - isStrict modifier is set to a wrong value"); assertFalse(Modifier.isSynchronized(modifiers), "Method ScriptEngine.getClass().getModifiers() - isSynchronized modifier is set to a wrong value"); assertFalse(Modifier.isTransient(modifiers), "Method ScriptEngine.getClass().getModifiers() - isTransient modifier is set to a wrong value"); assertFalse(Modifier.isVolatile(modifiers), "Method ScriptEngine.getClass().getModifiers() - isVolatile modifier is set to a wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().getName() */ protected void testGetName() { String name = this.scriptEngineClass.getName(); assertEquals(name, "javax.script.ScriptEngine", "Method ScriptEngine.getClass().getName() returns wrong value " + name); } /** * Test for method javax.script.ScriptEngine.getClass().getPackage() */ protected void testGetPackage() { Package p = this.scriptEngineClass.getPackage(); String packageName = p.getName(); assertEquals(packageName, "javax.script", "Method ScriptEngine.getClass().getPackage().getName() returns wrong value " + packageName); } /** * Test for method javax.script.ScriptEngine.getClass().getSimpleName() */ protected void testGetSimpleName() { String simpleName = this.scriptEngineClass.getSimpleName(); assertEquals(simpleName, "ScriptEngine", "Method ScriptEngine.getClass().getSimpleName() returns wrong value " + simpleName); } /** * Test for method javax.script.ScriptEngine.getClass().getCanonicalName() */ protected void testGetCanonicalName() { String canonicalName = this.scriptEngineClass.getCanonicalName(); assertEquals(canonicalName, "javax.script.ScriptEngine", "Method javax.script.ScriptEngine.getClass().getCanonicalName() returns wrong value " + canonicalName); } /** * Test for method javax.script.ScriptEngine.getClass().getSuperclass() */ protected void testGetSuperclass() { Class<?> superClass = this.scriptEngineClass.getSuperclass(); assertNull(superClass, "Method ScriptEngine.getClass().getSuperclass() does not return null"); } /** * Test for method javax.script.ScriptEngine.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>(); // 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.scriptEngineClass.getConstructors(); // basic check for a number of constructors assertEquals(constructors.length, 0, "no constructors should be set"); } /** * Test for method javax.script.ScriptEngine.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>(); // 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.scriptEngineClass.getDeclaredConstructors(); // basic check for a number of declared constructors assertEquals(declaredConstructors.length, 0, "no constructors should be set"); } /** * Test for method javax.script.ScriptEngine.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_jdk8 = new TreeMap<String, 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.scriptEngineClass.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.ScriptEngine.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_jdk8 = new TreeMap<String, 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.scriptEngineClass.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.ScriptEngine.getClass().getFields() */ protected void testGetFields() { // following fields should exists final String[] fieldsThatShouldExist_jdk6 = { "public static final java.lang.String javax.script.ScriptEngine.ARGV", "public static final java.lang.String javax.script.ScriptEngine.FILENAME", "public static final java.lang.String javax.script.ScriptEngine.ENGINE", "public static final java.lang.String javax.script.ScriptEngine.ENGINE_VERSION", "public static final java.lang.String javax.script.ScriptEngine.NAME", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION", }; final String[] fieldsThatShouldExist_jdk7 = { "public static final java.lang.String javax.script.ScriptEngine.ARGV", "public static final java.lang.String javax.script.ScriptEngine.FILENAME", "public static final java.lang.String javax.script.ScriptEngine.ENGINE", "public static final java.lang.String javax.script.ScriptEngine.ENGINE_VERSION", "public static final java.lang.String javax.script.ScriptEngine.NAME", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION", }; final String[] fieldsThatShouldExist_jdk8 = { "public static final java.lang.String javax.script.ScriptEngine.ARGV", "public static final java.lang.String javax.script.ScriptEngine.FILENAME", "public static final java.lang.String javax.script.ScriptEngine.ENGINE", "public static final java.lang.String javax.script.ScriptEngine.ENGINE_VERSION", "public static final java.lang.String javax.script.ScriptEngine.NAME", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION", }; // 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.scriptEngineClass.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.ScriptEngine.getClass().getDeclaredFields() */ protected void testGetDeclaredFields() { // following declared fields should exists final String[] declaredFieldsThatShouldExist_jdk6 = { "public static final java.lang.String javax.script.ScriptEngine.ARGV", "public static final java.lang.String javax.script.ScriptEngine.FILENAME", "public static final java.lang.String javax.script.ScriptEngine.ENGINE", "public static final java.lang.String javax.script.ScriptEngine.ENGINE_VERSION", "public static final java.lang.String javax.script.ScriptEngine.NAME", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION", }; final String[] declaredFieldsThatShouldExist_jdk7 = { "public static final java.lang.String javax.script.ScriptEngine.ARGV", "public static final java.lang.String javax.script.ScriptEngine.FILENAME", "public static final java.lang.String javax.script.ScriptEngine.ENGINE", "public static final java.lang.String javax.script.ScriptEngine.ENGINE_VERSION", "public static final java.lang.String javax.script.ScriptEngine.NAME", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION", }; final String[] declaredFieldsThatShouldExist_jdk8 = { "public static final java.lang.String javax.script.ScriptEngine.ARGV", "public static final java.lang.String javax.script.ScriptEngine.FILENAME", "public static final java.lang.String javax.script.ScriptEngine.ENGINE", "public static final java.lang.String javax.script.ScriptEngine.ENGINE_VERSION", "public static final java.lang.String javax.script.ScriptEngine.NAME", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE", "public static final java.lang.String javax.script.ScriptEngine.LANGUAGE_VERSION", }; // 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.scriptEngineClass.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.ScriptEngine.getClass().getField() */ protected void testGetField() { // following fields should exists final String[] fieldsThatShouldExist_jdk6 = { "ARGV", "FILENAME", "ENGINE", "ENGINE_VERSION", "NAME", "LANGUAGE", "LANGUAGE_VERSION", }; final String[] fieldsThatShouldExist_jdk7 = { "ARGV", "FILENAME", "ENGINE", "ENGINE_VERSION", "NAME", "LANGUAGE", "LANGUAGE_VERSION", }; final String[] fieldsThatShouldExist_jdk8 = { "ARGV", "FILENAME", "ENGINE", "ENGINE_VERSION", "NAME", "LANGUAGE", "LANGUAGE_VERSION", }; 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.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().getDeclaredField() */ protected void testGetDeclaredField() { // following declared fields should exists final String[] declaredFieldsThatShouldExist_jdk6 = { "ARGV", "FILENAME", "ENGINE", "ENGINE_VERSION", "NAME", "LANGUAGE", "LANGUAGE_VERSION", }; final String[] declaredFieldsThatShouldExist_jdk7 = { "ARGV", "FILENAME", "ENGINE", "ENGINE_VERSION", "NAME", "LANGUAGE", "LANGUAGE_VERSION", }; final String[] declaredFieldsThatShouldExist_jdk8 = { "ARGV", "FILENAME", "ENGINE", "ENGINE_VERSION", "NAME", "LANGUAGE", "LANGUAGE_VERSION", }; // 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.scriptEngineClass.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.ScriptEngine.getClass().getMethods() */ protected void testGetMethods() { // following methods should be inherited final String[] methodsThatShouldExist_jdk6 = { "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.get(java.lang.String)", "public abstract javax.script.Bindings javax.script.ScriptEngine.createBindings()", "public abstract javax.script.Bindings javax.script.ScriptEngine.getBindings(int)", "public abstract javax.script.ScriptContext javax.script.ScriptEngine.getContext()", "public abstract javax.script.ScriptEngineFactory javax.script.ScriptEngine.getFactory()", "public abstract void javax.script.ScriptEngine.put(java.lang.String,java.lang.Object)", "public abstract void javax.script.ScriptEngine.setBindings(javax.script.Bindings,int)", "public abstract void javax.script.ScriptEngine.setContext(javax.script.ScriptContext)", }; final String[] methodsThatShouldExist_jdk7 = { "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.get(java.lang.String)", "public abstract javax.script.Bindings javax.script.ScriptEngine.createBindings()", "public abstract javax.script.Bindings javax.script.ScriptEngine.getBindings(int)", "public abstract javax.script.ScriptContext javax.script.ScriptEngine.getContext()", "public abstract javax.script.ScriptEngineFactory javax.script.ScriptEngine.getFactory()", "public abstract void javax.script.ScriptEngine.put(java.lang.String,java.lang.Object)", "public abstract void javax.script.ScriptEngine.setBindings(javax.script.Bindings,int)", "public abstract void javax.script.ScriptEngine.setContext(javax.script.ScriptContext)", }; final String[] methodsThatShouldExist_jdk8 = { "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.get(java.lang.String)", "public abstract javax.script.Bindings javax.script.ScriptEngine.createBindings()", "public abstract javax.script.Bindings javax.script.ScriptEngine.getBindings(int)", "public abstract javax.script.ScriptContext javax.script.ScriptEngine.getContext()", "public abstract javax.script.ScriptEngineFactory javax.script.ScriptEngine.getFactory()", "public abstract void javax.script.ScriptEngine.put(java.lang.String,java.lang.Object)", "public abstract void javax.script.ScriptEngine.setBindings(javax.script.Bindings,int)", "public abstract void javax.script.ScriptEngine.setContext(javax.script.ScriptContext)", }; // get all inherited methods Method[] methods = this.scriptEngineClass.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.ScriptEngine.getClass().getDeclaredMethods() */ protected void testGetDeclaredMethods() { // following methods should be declared final String[] declaredMethodsThatShouldExist_jdk6 = { "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.get(java.lang.String)", "public abstract javax.script.Bindings javax.script.ScriptEngine.createBindings()", "public abstract javax.script.Bindings javax.script.ScriptEngine.getBindings(int)", "public abstract javax.script.ScriptContext javax.script.ScriptEngine.getContext()", "public abstract javax.script.ScriptEngineFactory javax.script.ScriptEngine.getFactory()", "public abstract void javax.script.ScriptEngine.put(java.lang.String,java.lang.Object)", "public abstract void javax.script.ScriptEngine.setBindings(javax.script.Bindings,int)", "public abstract void javax.script.ScriptEngine.setContext(javax.script.ScriptContext)", }; final String[] declaredMethodsThatShouldExist_jdk7 = { "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.get(java.lang.String)", "public abstract javax.script.Bindings javax.script.ScriptEngine.createBindings()", "public abstract javax.script.Bindings javax.script.ScriptEngine.getBindings(int)", "public abstract javax.script.ScriptContext javax.script.ScriptEngine.getContext()", "public abstract javax.script.ScriptEngineFactory javax.script.ScriptEngine.getFactory()", "public abstract void javax.script.ScriptEngine.put(java.lang.String,java.lang.Object)", "public abstract void javax.script.ScriptEngine.setBindings(javax.script.Bindings,int)", "public abstract void javax.script.ScriptEngine.setContext(javax.script.ScriptContext)", }; final String[] declaredMethodsThatShouldExist_jdk8 = { "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.io.Reader,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.Bindings) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.eval(java.lang.String,javax.script.ScriptContext) throws javax.script.ScriptException", "public abstract java.lang.Object javax.script.ScriptEngine.get(java.lang.String)", "public abstract javax.script.Bindings javax.script.ScriptEngine.createBindings()", "public abstract javax.script.Bindings javax.script.ScriptEngine.getBindings(int)", "public abstract javax.script.ScriptContext javax.script.ScriptEngine.getContext()", "public abstract javax.script.ScriptEngineFactory javax.script.ScriptEngine.getFactory()", "public abstract void javax.script.ScriptEngine.put(java.lang.String,java.lang.Object)", "public abstract void javax.script.ScriptEngine.setBindings(javax.script.Bindings,int)", "public abstract void javax.script.ScriptEngine.setContext(javax.script.ScriptContext)", }; // get all declared methods Method[] declaredMethods = this.scriptEngineClass.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.ScriptEngine.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.String.class}); methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk6.put("getFactory", new Class[] {}); methodsThatShouldExist_jdk6.put("getContext", new Class[] {}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk6.put("setBindings", new Class[] {javax.script.Bindings.class, int.class}); methodsThatShouldExist_jdk6.put("getBindings", new Class[] {int.class}); methodsThatShouldExist_jdk6.put("createBindings", new Class[] {}); methodsThatShouldExist_jdk6.put("setContext", new Class[] {javax.script.ScriptContext.class}); Map<String, Class[]> methodsThatShouldExist_jdk7 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk7.put("get", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk7.put("getFactory", new Class[] {}); methodsThatShouldExist_jdk7.put("getContext", new Class[] {}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk7.put("getBindings", new Class[] {int.class}); methodsThatShouldExist_jdk7.put("setBindings", new Class[] {javax.script.Bindings.class, int.class}); methodsThatShouldExist_jdk7.put("createBindings", new Class[] {}); methodsThatShouldExist_jdk7.put("setContext", new Class[] {javax.script.ScriptContext.class}); Map<String, Class[]> methodsThatShouldExist_jdk8 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.io.Reader.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.lang.String.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.io.Reader.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk8.put("setBindings", new Class[] {javax.script.Bindings.class, int.class}); methodsThatShouldExist_jdk8.put("getBindings", new Class[] {int.class}); methodsThatShouldExist_jdk8.put("createBindings", new Class[] {}); methodsThatShouldExist_jdk8.put("setContext", new Class[] {javax.script.ScriptContext.class}); methodsThatShouldExist_jdk8.put("get", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk8.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk8.put("getFactory", new Class[] {}); methodsThatShouldExist_jdk8.put("getContext", 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.scriptEngineClass.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.ScriptEngine.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.String.class}); methodsThatShouldExist_jdk6.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk6.put("getFactory", new Class[] {}); methodsThatShouldExist_jdk6.put("getContext", new Class[] {}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk6.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk6.put("setBindings", new Class[] {javax.script.Bindings.class, int.class}); methodsThatShouldExist_jdk6.put("getBindings", new Class[] {int.class}); methodsThatShouldExist_jdk6.put("createBindings", new Class[] {}); methodsThatShouldExist_jdk6.put("setContext", new Class[] {javax.script.ScriptContext.class}); Map<String, Class[]> methodsThatShouldExist_jdk7 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk7.put("get", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk7.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk7.put("getFactory", new Class[] {}); methodsThatShouldExist_jdk7.put("getContext", new Class[] {}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk7.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk7.put("getBindings", new Class[] {int.class}); methodsThatShouldExist_jdk7.put("setBindings", new Class[] {javax.script.Bindings.class, int.class}); methodsThatShouldExist_jdk7.put("createBindings", new Class[] {}); methodsThatShouldExist_jdk7.put("setContext", new Class[] {javax.script.ScriptContext.class}); Map<String, Class[]> methodsThatShouldExist_jdk8 = new TreeMap<String, Class[]>(); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.io.Reader.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.lang.String.class, javax.script.Bindings.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.io.Reader.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.lang.String.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.io.Reader.class, javax.script.ScriptContext.class}); methodsThatShouldExist_jdk8.put("eval", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk8.put("setBindings", new Class[] {javax.script.Bindings.class, int.class}); methodsThatShouldExist_jdk8.put("getBindings", new Class[] {int.class}); methodsThatShouldExist_jdk8.put("createBindings", new Class[] {}); methodsThatShouldExist_jdk8.put("setContext", new Class[] {javax.script.ScriptContext.class}); methodsThatShouldExist_jdk8.put("get", new Class[] {java.lang.String.class}); methodsThatShouldExist_jdk8.put("put", new Class[] {java.lang.String.class, java.lang.Object.class}); methodsThatShouldExist_jdk8.put("getFactory", new Class[] {}); methodsThatShouldExist_jdk8.put("getContext", 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.scriptEngineClass.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.ScriptEngine.getClass().getAnnotations() */ protected void testGetAnnotations() { // following annotations should be provided final String[] annotationsThatShouldExists_jdk6 = { // this should be really empty }; final String[] annotationsThatShouldExists_jdk7 = { }; final String[] annotationsThatShouldExists_jdk8 = { }; // 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 = 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.ScriptEngine.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.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 = 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.ScriptEngine.getClass().getAnnotation() */ protected void testGetAnnotation() { Annotation annotation; annotation = this.scriptEngineClass.getAnnotation(java.lang.annotation.Annotation.class); assertNull(annotation, "annotation java.lang.annotation.Annotation should not be returned"); annotation = this.scriptEngineClass.getAnnotation(java.lang.annotation.Documented.class); assertNull(annotation, "annotation java.lang.annotation.Documented should not be returned"); annotation = this.scriptEngineClass.getAnnotation(java.lang.annotation.Inherited.class); assertNull(annotation, "annotation java.lang.annotation.Inherited should not be returned"); annotation = this.scriptEngineClass.getAnnotation(java.lang.annotation.Retention.class); assertNull(annotation, "annotation java.lang.annotation.Retention should not be returned"); annotation = this.scriptEngineClass.getAnnotation(java.lang.annotation.Target.class); assertNull(annotation, "annotation java.lang.annotation.Target should not be returned"); annotation = this.scriptEngineClass.getAnnotation(java.lang.Deprecated.class); assertNull(annotation, "annotation java.lang.Deprecated should not be returned"); annotation = this.scriptEngineClass.getAnnotation(java.lang.Override.class); assertNull(annotation, "annotation java.lang.Override should not be returned"); annotation = this.scriptEngineClass.getAnnotation(java.lang.SuppressWarnings.class); assertNull(annotation, "annotation java.lang.SuppressWarnings should not be returned"); } /** * Test for method javax.script.ScriptEngine.getClass().getComponentType() */ protected void testGetComponentType() { Class<?> cls = this.scriptEngineClass.getComponentType(); assertNull(cls, "getComponentType() should returns null"); } /** * Test for method javax.script.ScriptEngine.getClass().getClasses() */ protected void testGetClasses() { Class<?>[] cls = this.scriptEngineClass.getClasses(); assertNotNull(cls, "getClasses() returns null"); assertEquals(cls.length, 0, "getClasses() returns wrong value!"); } /** * Test for method javax.script.ScriptEngine.getClass().getDeclaredClasses() */ protected void testGetDeclaredClasses() { Class<?>[] cls = this.scriptEngineClass.getDeclaredClasses(); assertNotNull(cls, "getDeclaredClasses() returns null"); assertEquals(cls.length, 0, "getDeclaredClasses() returns wrong value!"); } /** * Test for method javax.script.ScriptEngine.getClass().getDeclaringClass() */ protected void testGetDeclaringClass() { Class<?> cls = this.scriptEngineClass.getDeclaringClass(); assertNull(cls, "getDeclaringClass() does not return null"); } /** * Test for method javax.script.ScriptEngine.getClass().getEnclosingClass() */ protected void testGetEnclosingClass() { Class<?> cls = this.scriptEngineClass.getEnclosingClass(); assertNull(cls, "getEnclosingClass() does not return null"); } /** * Test for method javax.script.ScriptEngine.getClass().getEnclosingConstructor() */ protected void testGetEnclosingConstructor() { Constructor<?> cons = this.scriptEngineClass.getEnclosingConstructor(); assertNull(cons, "getEnclosingConstructor() does not return null"); } /** * Test for method javax.script.ScriptEngine.getClass().getEnclosingMethod() */ protected void testGetEnclosingMethod() { Method m = this.scriptEngineClass.getEnclosingMethod(); assertNull(m, "getEnclosingMethod() does not return null"); } /** * Test for method javax.script.ScriptEngine.getClass().getGenericSuperclass() */ protected void testGetGenericSuperclass() { Type genericSuperclass = this.scriptEngineClass.getGenericSuperclass(); assertNull(genericSuperclass, "getGenericSuperclass() does not return null"); } /** * Test for method javax.script.ScriptEngine.getClass().getGenericInterfaces() */ protected void testGetGenericInterfaces() { // array of interface names that should exists final String[] genericInterfaceNames_jdk6 = { }; 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.scriptEngineClass.getGenericInterfaces(); assertNotNull(genericInterfaces, "getGenericInterfaces() returns null"); assertEquals(0, 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.ScriptEngine.getClass().getEnumConstants() */ protected void testGetEnumConstants() { Object[] enumConstants = this.scriptEngineClass.getEnumConstants(); assertNull(enumConstants, "getEnumConstants() does not return null"); } /** * Test for method javax.script.ScriptEngine.getClass().getTypeParameters() */ protected void testGetTypeParameters() { TypeVariable<?>[] typeParameters = this.scriptEngineClass.getTypeParameters(); assertNotNull(typeParameters, "getTypeParameters() return null"); assertEquals(0, typeParameters.length, "array of wrong size returned by getTypeParameters() " + typeParameters.length); } /** * Test for method javax.script.ScriptEngine.getClass().getSigners() */ protected void testGetSigners() { Object[] signers = this.scriptEngineClass.getSigners(); assertNull(signers, "getSigners() does not return null"); } /** * Test for method javax.script.ScriptEngine.getClass().desiredAssertionStatus() */ protected void testDesiredAssertionStatus() { assertFalse(this.scriptEngineClass.desiredAssertionStatus(), "Method ScriptEngine.getClass().desiredAssertionStatus() returns wrong value"); } /** * Test for method javax.script.ScriptEngine.getClass().asSubclass() */ protected void testAsSubclass() { try { this.scriptEngineClass.asSubclass(scriptEngineClass); } catch (Exception e) { e.printStackTrace(); throw new AssertionError(e.getMessage()); } try { this.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.ScriptEngine.getClass().cast() */ protected void testCast() { try { this.scriptEngineClass.cast(new Object()); throw new AssertionError("Class.cast(new Object()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(new Object().getClass()); throw new AssertionError("Class.cast(new Object().getClass()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(new String()); throw new AssertionError("Class.cast(new String()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(Boolean.valueOf(true)); throw new AssertionError("Class.cast(Boolean.valueOf(true)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(Boolean.valueOf(false)); throw new AssertionError("Class.cast(Boolean.valueOf(false)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(Character.valueOf('a')); throw new AssertionError("Class.cast(Character.valueOf('a')) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.cast(Integer.valueOf(42)); throw new AssertionError("Class.cast(Integer.valueOf(42)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(Long.valueOf(42L)); throw new AssertionError("Class.cast(Long.valueOf(42L)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(Float.valueOf(42f)); throw new AssertionError("Class.cast(Float.valueOf(42f)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(Double.valueOf(42.)); throw new AssertionError("Class.cast(Double.valueOf(42.)) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(new Throwable()); throw new AssertionError("Class.cast(new Throwable()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(new Throwable("xyzzy")); throw new AssertionError("Class.cast(new Throwable(\"xyzzy\")) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(new RuntimeException()); throw new AssertionError("Class.cast(new RuntimeException()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(new RuntimeException("xyzzy")); throw new AssertionError("Class.cast(new RuntimeException(\"xyzzy\")) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(new Error()); throw new AssertionError("Class.cast(new Error()) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.cast(new Error("xyzzy")); throw new AssertionError("Class.cast(new Error(\"xyzzy\")) does not throw any exception"); } catch (Exception e) { // expected exception } try { this.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.scriptEngineClass.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.ScriptEngine.getClass().newInstance() */ protected void testNewInstance() { try { Object o = this.scriptEngineClass.newInstance(); throw new AssertionError("Class.newInstance() does not throw any exception"); } catch (InstantiationException e) { // expected exception } catch (IllegalAccessException e) { // expected exception } } /** * Test for method javax.script.ScriptEngine.getClass().getResourceNPETest() */ protected void testGetResourceNPETest() { try { Object resource = this.scriptEngineClass.getResource(null); throw new AssertionError("NullPointerException expected!"); } catch (NullPointerException e) { //This is OK OK } } /** * Test for method javax.script.ScriptEngine.getClass().getResourceNegativeTest() */ protected void testGetResourceNegativeTest() { Object resource = this.scriptEngineClass.getResource("unknown"); assertNull(resource, "getResource() does not return null"); } /** * Test for method javax.script.ScriptEngine.getClass().getResourcePositiveTest() */ protected void testGetResourcePositiveTest() { Object resource; resource = this.scriptEngineClass.getResource("/org/RhinoTests/AbstractScriptEngineClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/AbstractScriptEngineClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/BaseRhinoTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/BaseRhinoTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/BindingsClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/BindingsClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/BindingsTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/BindingsTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/CompilableClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/CompilableClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/CompilableTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/CompilableTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/CompiledScriptClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/CompiledScriptClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/CompiledScriptTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/CompiledScriptTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/Constants.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/Constants.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/InvocableClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/InvocableClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/InvocableTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/InvocableTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/JavaScriptSnippets.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/JavaScriptSnippets.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/JavaScriptsTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/JavaScriptsTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptContextClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptContextClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptContextTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptContextTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptEngineClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptEngineFactoryClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineFactoryClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptEngineFactoryTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineFactoryTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptEngineManagerClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineManagerClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptEngineManagerTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineManagerTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptEngineTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptEngineTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptExceptionClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptExceptionClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/ScriptExceptionTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/ScriptExceptionTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/SimpleBindingsClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/SimpleBindingsClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/SimpleBindingsTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/SimpleBindingsTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/SimpleScriptContextClassTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/SimpleScriptContextClassTest.class\") returns null"); resource = this.scriptEngineClass.getResource("/org/RhinoTests/SimpleScriptContextTest.class"); assertNotNull(resource, "getResource(\"/org/RhinoTests/SimpleScriptContextTest.class\") returns null"); } /** * Test for instanceof operator applied to a class javax.script.ScriptEngine */ @SuppressWarnings("cast") protected void testInstanceOf() { // tested object Object o = new ScriptEngineManager().getEngineByName(Constants.EngineNames.ENGINE_NAME_JavaScript); // basic check of instanceof operator assertTrue(o instanceof ScriptEngine, "instanceof ScriptEngine 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 ScriptEngineClassTest().doTests(args); } }