changeset 238:187af2160af7 draft

Added new target for report generator. Added new test testNewInstance into the test suite InvocableClassTest.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Mon, 23 Sep 2013 10:37:44 +0200
parents 361269035966
children d1076a7a7c31
files ChangeLog src/org/RhinoTests/InvocableClassTest.java src/org/RhinoTests/Reporter/IndexPageGenerator.java
diffstat 3 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Sep 20 11:15:56 2013 +0200
+++ b/ChangeLog	Mon Sep 23 10:37:44 2013 +0200
@@ -1,3 +1,11 @@
+2013-09-23  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/org/RhinoTests/InvocableClassTest.java:
+	Added new test testNewInstance into the test suite
+	InvocableClassTest.
+	* src/org/RhinoTests/Reporter/IndexPageGenerator.java:
+	Added new target for report generator.
+
 2013-09-20  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/org/RhinoTests/CompiledScriptClassTest.java:
--- a/src/org/RhinoTests/InvocableClassTest.java	Fri Sep 20 11:15:56 2013 +0200
+++ b/src/org/RhinoTests/InvocableClassTest.java	Mon Sep 23 10:37:44 2013 +0200
@@ -1420,6 +1420,23 @@
     }
 
     /**
+     * Test for method javax.script.Invocable.getClass().newInstance()
+     */
+    protected void testNewInstance() {
+        try {
+            Object o = this.invocableClass.newInstance();
+            throw new AssertionError("Class.newInstance() does not throw any exception");
+        }
+        catch (InstantiationException e) {
+            // expected exception
+        }
+        catch (IllegalAccessException e) {
+            // expected exception
+        }
+
+    }
+
+    /**
      * Test for instanceof operator applied to a class javax.script.Invocable
      */
     @SuppressWarnings("cast")
--- a/src/org/RhinoTests/Reporter/IndexPageGenerator.java	Fri Sep 20 11:15:56 2013 +0200
+++ b/src/org/RhinoTests/Reporter/IndexPageGenerator.java	Mon Sep 23 10:37:44 2013 +0200
@@ -64,6 +64,7 @@
         TestResult testResult = TestResult.readSummary(testResultForDate);
         testResult.setDate(date);
         createIndexPageFromTemplate(testResult, params);
+        createStubPageFromTemplate(testResult, params);
     }
 
     private static void createIndexPageFromTemplate(TestResult testResult, CommandLineParameters params) {
@@ -78,6 +79,16 @@
         FileUtils.writeTextFile(params.getReportDir() + "/index.html", out);
     }
 
+    private static void createStubPageFromTemplate(TestResult testResult, CommandLineParameters params) {
+        List<String> out = new LinkedList<String>();
+        out.add(testResult.getDate());
+        out.add("" + testResult.getPassed());
+        out.add("" + testResult.getFailed());
+        out.add("" + testResult.getError());
+        // write list of string to a file with given name
+        FileUtils.writeTextFile(params.getReportDir() + "/result.txt", out);
+    }
+
 	private static String replacePlaceholder(TestResult testResult, Pattern pattern, String templateLine) {
 		Matcher matcher = pattern.matcher(templateLine);
 		// if some pattern ${PLACEHOLDER} is found on the template line,