/hg/rhino-tests: Ten new tests added into ScriptContextTest.

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Thu May 15 11:41:26 UTC 2014


changeset 3c0edf5a83fc in /hg/rhino-tests
details: http://icedtea.classpath.org/hg/rhino-tests?cmd=changeset;node=3c0edf5a83fc
author: ptisnovs
date: Thu May 15 13:41:19 2014 +0200

	Ten new tests added into ScriptContextTest.


diffstat:

 ChangeLog                                 |    5 +
 src/org/RhinoTests/ScriptContextTest.java |  169 +++++++++++++++++++++++++++++-
 2 files changed, 173 insertions(+), 1 deletions(-)

diffs (202 lines):

diff -r 5f9eba77856c -r 3c0edf5a83fc ChangeLog
--- a/ChangeLog	Thu May 15 11:45:12 2014 +0200
+++ b/ChangeLog	Thu May 15 13:41:19 2014 +0200
@@ -1,3 +1,8 @@
+2014-05-15  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/RhinoTests/ScriptContextTest.java:
+	Ten new tests added into ScriptContextTest.
+
 2014-05-15  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/RhinoTests/BaseRhinoTest.java:
diff -r 5f9eba77856c -r 3c0edf5a83fc src/org/RhinoTests/ScriptContextTest.java
--- a/src/org/RhinoTests/ScriptContextTest.java	Thu May 15 11:45:12 2014 +0200
+++ b/src/org/RhinoTests/ScriptContextTest.java	Thu May 15 13:41:19 2014 +0200
@@ -40,18 +40,185 @@
 
 package org.RhinoTests;
 
+import javax.script.ScriptContext;
+import javax.script.SimpleScriptContext;
+
 /**
  * TODO: not implemented
  * @author ptisnovs
  *
  */
-public class ScriptContextTest {
+public class ScriptContextTest extends BaseRhinoTest {
+
+    @Override
+    protected void setUp(String[] args) {
+        // this block could be empty
+        return;
+    }
+
+    @Override
+    protected void tearDown() {
+        // this block could be empty
+        return;
+    }
+
+    /**
+     * Test for toString() method.
+     */
+    protected void testToString() {
+        // tested object
+        Object object = new SimpleScriptContext();
+
+        // call the toString() method
+        String string = object.toString();
+
+        assertTrue(string != null, "toString() method returned null!");
+        assertTrue(string.startsWith("javax.script.SimpleScriptContext"), "bad toString() return value " + string);
+    }
+
+    /**
+     * Test for method SimpleScriptContext.setAttribute().
+     */
+    protected void testSetAttribute1() {
+        // tested object
+        SimpleScriptContext object = new SimpleScriptContext();
+        try {
+            object.setAttribute("name", "value", ScriptContext.ENGINE_SCOPE);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            throw new AssertionError(e.getMessage());
+        }
+    }
+
+    /**
+     * Test for method SimpleScriptContext.setAttribute().
+     */
+    protected void testSetAttribute2() {
+        // tested object
+        SimpleScriptContext object = new SimpleScriptContext();
+        try {
+            object.setAttribute("name", "", ScriptContext.ENGINE_SCOPE);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            throw new AssertionError(e.getMessage());
+        }
+    }
+
+    /**
+     * Test for method SimpleScriptContext.setAttribute().
+     */
+    protected void testSetAttribute3() {
+        // tested object
+        SimpleScriptContext object = new SimpleScriptContext();
+        try {
+            object.setAttribute("name", null, ScriptContext.ENGINE_SCOPE);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            throw new AssertionError(e.getMessage());
+        }
+    }
+
+    /**
+     * Test for method SimpleScriptContext.setAttribute().
+     */
+    protected void testSetAttribute4() {
+        // tested object
+        SimpleScriptContext object = new SimpleScriptContext();
+        try {
+            object.setAttribute("", "value", ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("ScriptContext.setAttribute(\"\", \"value\", ScriptContext.ENGINE_SCOPE.) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+    }
+
+    /**
+     * Test for method SimpleScriptContext.setAttribute().
+     */
+    protected void testSetAttribute5() {
+        // tested object
+        SimpleScriptContext object = new SimpleScriptContext();
+        try {
+            object.setAttribute("", "", ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("ScriptContext.setAttribute(\"\", \"\", ScriptContext.ENGINE_SCOPE) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+    }
+
+    /**
+     * Test for method SimpleScriptContext.setAttribute().
+     */
+    protected void testSetAttribute6() {
+        // tested object
+        SimpleScriptContext object = new SimpleScriptContext();
+        try {
+            object.setAttribute("", null, ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("ScriptContext.setAttribute(\"\", null, ScriptContext.ENGINE_SCOPE) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+    }
+
+    /**
+     * Test for method SimpleScriptContext.setAttribute().
+     */
+    protected void testSetAttribute7() {
+        // tested object
+        SimpleScriptContext object = new SimpleScriptContext();
+        try {
+            object.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("ScriptContext.setAttribute(null, \"value\", ScriptContext.ENGINE_SCOPE) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+    }
+
+    /**
+     * Test for method SimpleScriptContext.setAttribute().
+     */
+    protected void testSetAttribute8() {
+        // tested object
+        SimpleScriptContext object = new SimpleScriptContext();
+        try {
+            object.setAttribute(null, "", ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("ScriptContext.setAttribute(null, \"\", ScriptContext.ENGINE_SCOPE) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+    }
+
+    /**
+     * Test for method SimpleScriptContext.setAttribute().
+     */
+    protected void testSetAttribute9() {
+        // tested object
+        SimpleScriptContext object = new SimpleScriptContext();
+        try {
+            object.setAttribute(null, null, ScriptContext.ENGINE_SCOPE);
+            throw new AssertionError("ScriptContext.setAttribute(null, null, ScriptContext.ENGINE_SCOPE) does not throw any exception");
+        }
+        catch (Exception e) {
+            // expected exception
+        }
+    }
+
     /**
      * Entry point to this test case.
      *
      * @param args parameters passed from command line
      */
     public static void main(String[] args) {
+        new ScriptContextTest().doTests(args);
     }
 
 }
+


More information about the distro-pkg-dev mailing list