changeset 24:23e45df03db4 draft

Added 16 new negative tests to the test suite src/org/RhinoTests/ScriptEngineTest.java.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Thu, 16 Aug 2012 11:58:45 +0200
parents 425a6823067b
children c131ac811c4f
files ChangeLog src/org/RhinoTests/ScriptEngineTest.java
diffstat 2 files changed, 172 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Aug 15 13:48:07 2012 +0200
+++ b/ChangeLog	Thu Aug 16 11:58:45 2012 +0200
@@ -1,3 +1,8 @@
+2012-08-16  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/org/RhinoTests/ScriptEngineTest.java:
+	Added 16 new negative tests.
+
 2012-08-15  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/org/RhinoTests/ScriptContextClassTest.java:
--- a/src/org/RhinoTests/ScriptEngineTest.java	Wed Aug 15 13:48:07 2012 +0200
+++ b/src/org/RhinoTests/ScriptEngineTest.java	Thu Aug 16 11:58:45 2012 +0200
@@ -507,6 +507,173 @@
     }
 
     /**
+     * Test if NPE is thrown if getEngineByMimeType() is called with null.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative1() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        try {
+            @SuppressWarnings("unused")
+            ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType(null);
+        }
+        catch (NullPointerException e)
+        {
+            return;
+        }
+        throw new Exception("NPE was not thrown as expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative2() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative3() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("  ");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative4() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("   ");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative5() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("\t");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative6() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType(" \t");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative7() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("\b");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative8() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("\b\b");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative9() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType(" \b\b");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative10() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("\000");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative11() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("\u0000");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative12() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("js ");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative13() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("\tjs");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative14() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("js\t");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative15() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType(" js");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
+     * Test if none script engine is found using wrong MIME type.
+     * @throws Exception if this test case fails.
+     */
+    protected void testGetEngineByMimeTypeNegative16() throws Exception {
+        assertNotNull(engineManager, "Script engine manager was not created");
+        ScriptEngine scriptEngine = this.engineManager.getEngineByMimeType("\bjs");
+        assertNull(scriptEngine, "JavaScript engine manager was found but it's not expected");
+    }
+
+    /**
      * Check if two script engine factories are equals.
      * @throws Exception thrown if script engine factories are not equals.
      */