changeset 33:d649db1c7d07 draft

* src/org/RhinoTests/CompiledScriptTest.java: Added check, that ScriptEngine is not null. * src/org/RhinoTests/InvocableTest.java: * src/org/RhinoTests/JavaScriptsTest.java: * src/org/RhinoTests/ScriptExceptionTest.java: Print a message when (an expected) exception is thrown. * src/org/RhinoTests/BindingsTest.java: * src/org/RhinoTests/CompilableTest.java: Changed @author.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Mon, 10 Sep 2012 10:31:55 +0200
parents e3f5a19ce034
children 1909ce4c5896
files ChangeLog src/org/RhinoTests/BindingsTest.java src/org/RhinoTests/CompilableTest.java src/org/RhinoTests/CompiledScriptTest.java src/org/RhinoTests/InvocableTest.java src/org/RhinoTests/JavaScriptsTest.java src/org/RhinoTests/ScriptExceptionTest.java
diffstat 7 files changed, 43 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Sep 07 10:33:47 2012 +0200
+++ b/ChangeLog	Mon Sep 10 10:31:55 2012 +0200
@@ -1,3 +1,15 @@
+2012-09-10  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/org/RhinoTests/CompiledScriptTest.java:
+	Added check, that ScriptEngine is not null.
+	* src/org/RhinoTests/InvocableTest.java:
+	* src/org/RhinoTests/JavaScriptsTest.java:
+	* src/org/RhinoTests/ScriptExceptionTest.java:
+	Print a message when (an expected) exception is thrown.
+	* src/org/RhinoTests/BindingsTest.java:
+	* src/org/RhinoTests/CompilableTest.java:
+	Changed @author.
+
 2012-09-07  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/org/RhinoTests/Constants.java:
--- a/src/org/RhinoTests/BindingsTest.java	Fri Sep 07 10:33:47 2012 +0200
+++ b/src/org/RhinoTests/BindingsTest.java	Mon Sep 10 10:31:55 2012 +0200
@@ -42,7 +42,7 @@
 
 /**
  * TODO: not implemented
- * @author ptisnovs
+ * @author Pavel Tisnovsky
  *
  */
 public class BindingsTest {
--- a/src/org/RhinoTests/CompilableTest.java	Fri Sep 07 10:33:47 2012 +0200
+++ b/src/org/RhinoTests/CompilableTest.java	Mon Sep 10 10:31:55 2012 +0200
@@ -42,7 +42,7 @@
 
 /**
  * TODO: not implemented
- * @author ptisnovs
+ * @author Pavel Tisnovsky
  *
  */
 public class CompilableTest {
--- a/src/org/RhinoTests/CompiledScriptTest.java	Fri Sep 07 10:33:47 2012 +0200
+++ b/src/org/RhinoTests/CompiledScriptTest.java	Mon Sep 10 10:31:55 2012 +0200
@@ -124,8 +124,10 @@
     protected void testCompileScriptStoredInString() throws ScriptException {
     	Compilable compilingEngine = (Compilable)this.scriptEngine;
     	assertNotNull(compilingEngine, "cannot get compiling engine");
-    	CompiledScript script = compilingEngine.compile("");
-    	assertNotNull(script, "cannot compile script");
+		if (compilingEngine != null) {
+			CompiledScript script = compilingEngine.compile("");
+			assertNotNull(script, "cannot compile script");
+		}
     }
 
     /**
--- a/src/org/RhinoTests/InvocableTest.java	Fri Sep 07 10:33:47 2012 +0200
+++ b/src/org/RhinoTests/InvocableTest.java	Mon Sep 10 10:31:55 2012 +0200
@@ -104,6 +104,7 @@
             this.invocableEngine.invokeFunction("bar");
         }
         catch (NoSuchMethodException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return;
         }
         throw new Exception("NoSuchMethodException not thrown as expected!");
--- a/src/org/RhinoTests/JavaScriptsTest.java	Fri Sep 07 10:33:47 2012 +0200
+++ b/src/org/RhinoTests/JavaScriptsTest.java	Mon Sep 10 10:31:55 2012 +0200
@@ -102,7 +102,8 @@
             this.scriptEngine.eval("_unknown_function_('\tHello world!')");
         }
         catch (ScriptException e) {
-            return;
+        	System.out.println("\tException thrown as expected " + e.getMessage());
+            return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
     }
@@ -119,6 +120,7 @@
             this.scriptEngine.eval("println(bflmpsvz)");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -135,6 +137,7 @@
         try {
             this.scriptEngine.eval("xyzzy");
         } catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -201,6 +204,7 @@
             this.scriptEngine.eval((String) null);
         }
         catch (NullPointerException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("NPE not thrown as expected");
@@ -300,6 +304,7 @@
             this.scriptEngine.eval(stringReader);
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return;
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -317,6 +322,7 @@
             this.scriptEngine.eval(stringReader);
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -333,6 +339,7 @@
             StringReader stringReader = new StringReader("xyzzy");
             this.scriptEngine.eval(stringReader);
         } catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -376,6 +383,7 @@
             this.scriptEngine.eval(new InputStreamReader(inputStream, SCRIPT_DEFAULT_ENCODING));
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -394,6 +402,7 @@
             this.scriptEngine.eval(new InputStreamReader(inputStream, SCRIPT_DEFAULT_ENCODING));
         }
         catch (ScriptException e) {
+        	System.out.println("Exception thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -412,6 +421,7 @@
             this.scriptEngine.eval(new InputStreamReader(inputStream, SCRIPT_DEFAULT_ENCODING));
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
--- a/src/org/RhinoTests/ScriptExceptionTest.java	Fri Sep 07 10:33:47 2012 +0200
+++ b/src/org/RhinoTests/ScriptExceptionTest.java	Mon Sep 10 10:31:55 2012 +0200
@@ -90,6 +90,7 @@
             this.scriptEngine.eval("...");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -108,6 +109,7 @@
             this.scriptEngine.eval("_unknown_function_('\tHello world!')");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -126,6 +128,7 @@
             this.scriptEngine.eval("println(a'\tHello world!')");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -144,6 +147,7 @@
             this.scriptEngine.eval("println('\tHello world!',)");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -162,6 +166,7 @@
             this.scriptEngine.eval("println(,)");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -180,6 +185,7 @@
             this.scriptEngine.eval("println(1-*2);");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -198,6 +204,7 @@
             this.scriptEngine.eval("println(1**2);");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -216,6 +223,7 @@
             this.scriptEngine.eval("println(>>2);");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -233,6 +241,7 @@
             this.scriptEngine.eval("let x=y;");
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -252,6 +261,7 @@
             this.scriptEngine.eval(new InputStreamReader(inputStream, SCRIPT_DEFAULT_ENCODING));
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -271,6 +281,7 @@
             this.scriptEngine.eval(new InputStreamReader(inputStream, SCRIPT_DEFAULT_ENCODING));
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -290,6 +301,7 @@
             this.scriptEngine.eval(new InputStreamReader(inputStream, SCRIPT_DEFAULT_ENCODING));
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");
@@ -309,6 +321,7 @@
             this.scriptEngine.eval(new InputStreamReader(inputStream, SCRIPT_DEFAULT_ENCODING));
         }
         catch (ScriptException e) {
+        	System.out.println("\tException thrown as expected " + e.getMessage());
             return; // ok, it's correct if this exception is thrown
         }
         throw new Exception("ScriptException not thrown as expected");