changeset 19:8faf0aad2428 draft

Replaced tabs with spaces to make an indentation more consistent. Fixed JavaDoc typo and make doc more descriptive. Added new class which contains all supported file extensions for JavaScript scripts.
author Pavel Tisnovsky <ptisnovs@redhat.com>
date Mon, 06 Aug 2012 17:05:10 +0200
parents 77d7df3f99f8
children 625ff78f80c7
files ChangeLog src/org/RhinoTests/BaseRhinoTest.java src/org/RhinoTests/Constants.java src/org/RhinoTests/ScriptEngineTest.java
diffstat 4 files changed, 65 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Aug 01 11:29:33 2012 +0200
+++ b/ChangeLog	Mon Aug 06 17:05:10 2012 +0200
@@ -1,3 +1,14 @@
+2012-08-06  Pavel Tisnovsky  <ptisnovs@redhat.com>
+
+	* src/org/RhinoTests/BaseRhinoTest.java:
+	Replaced tabs with spaces to make an indentation
+	more consistent. Fixed JavaDoc typo.
+	* src/org/RhinoTests/Constants.java:
+	Added new class which contains all supported file
+	extensions for JavaScript scripts.
+	* src/org/RhinoTests/ScriptEngineTest.java:
+	JavaDoc for some test methods made more descriptive. 
+
 2012-08-01  Pavel Tisnovsky  <ptisnovs@redhat.com>
 
 	* src/org/RhinoTests/BaseRhinoTest.java:
--- a/src/org/RhinoTests/BaseRhinoTest.java	Wed Aug 01 11:29:33 2012 +0200
+++ b/src/org/RhinoTests/BaseRhinoTest.java	Mon Aug 06 17:05:10 2012 +0200
@@ -1,7 +1,7 @@
 /*
   Rhino test framework
 
-   Copyright (C) 2011  Red Hat
+   Copyright (C) 2011, 2012  Red Hat
 
 This file is part of IcedTea.
 
@@ -52,14 +52,14 @@
  * @author Pavel Tisnovsky
  */
 public abstract class BaseRhinoTest {
-	/**
-	 * Number of tests that passed.
-	 */
+    /**
+     * Number of tests that passed.
+     */
     private int passed = 0;
 
     /**
-	 * Number of tests that failed.
-	 */
+     * Number of tests that failed.
+     */
     private int failed = 0;
 
     /**
@@ -222,7 +222,7 @@
      *             thrown to indicate that an assertion has failed
      */
     protected static void assertEquals(Object o1, Object o2, String message) throws AssertionError {
-    	assertTrue(o1.equals(o2), message);
+        assertTrue(o1.equals(o2), message);
     }
 
     /**
@@ -480,8 +480,8 @@
      * @return Java version
      */
     protected int getJavaVersion() {
-    	String javaVersionStr = System.getProperty("java.version");
-    	String[] parts = javaVersionStr.split("\\.");
-    	return Integer.parseInt(parts[1]);
+        String javaVersionStr = System.getProperty("java.version");
+        String[] parts = javaVersionStr.split("\\.");
+        return Integer.parseInt(parts[1]);
     }
 }
--- a/src/org/RhinoTests/Constants.java	Wed Aug 01 11:29:33 2012 +0200
+++ b/src/org/RhinoTests/Constants.java	Mon Aug 06 17:05:10 2012 +0200
@@ -71,4 +71,14 @@
         protected static final String MIME_TYPE_APPLICATION_JAVASCRIPT = "application/javascript";
         protected static final String MIME_TYPE_APPLICATION_ECMASCRIPT = "application/ecmascript";
     }
+
+    /**
+     * Constants for known file extensions for JavaScript engine.
+     * 
+     * @author Pavel Tisnovsky
+     */
+    public class FileExtensions {
+        protected static final String EXTENSION_js = "js";
+    }
+
 }
--- a/src/org/RhinoTests/ScriptEngineTest.java	Wed Aug 01 11:29:33 2012 +0200
+++ b/src/org/RhinoTests/ScriptEngineTest.java	Mon Aug 06 17:05:10 2012 +0200
@@ -1,7 +1,7 @@
 /*
   Rhino test framework
 
-   Copyright (C) 2011  Red Hat
+   Copyright (C) 2011, 2012  Red Hat
 
 This file is part of IcedTea.
 
@@ -48,7 +48,7 @@
 
 /**
  * Basic ScriptEngine test suite. Following tests checks if ScriptEngineManager
- * is able to find particular scripting engine using various methods.
+ * is able to find particular scripting engine using various searching methods.
  * 
  * TODO: add new tests, comments
  * 
@@ -57,11 +57,17 @@
 public class ScriptEngineTest extends BaseRhinoTest {
     ScriptEngineManager engineManager;
 
+    /**
+     * Set up the test suite.
+     */
     @Override
     protected void setUp(String[] args) {
         this.engineManager = new ScriptEngineManager();
     }
 
+    /**
+     * Tear down the test suite.
+     */
     @Override
     protected void tearDown() {
         // empty block
@@ -122,7 +128,7 @@
      * Test if script engine could be found using name "ecmascript"
      * @throws Exception this exception is thrown if none script engine could be found.
      */
-    protected void testGetEngineByNamescmascript() throws Exception {
+    protected void testGetEngineByNameecmascript() throws Exception {
         tryToFindEngineByName(Constants.EngineNames.ENGINE_NAME_ecmascript);
     }
 
@@ -147,7 +153,7 @@
      * @throws Exception this exception is thrown if none script engine could be found.
      */
     protected void testGetEngineByExtension() throws Exception {
-        ScriptEngine scriptEngine = this.engineManager.getEngineByExtension(Constants.EngineNames.ENGINE_NAME_js);
+        ScriptEngine scriptEngine = this.engineManager.getEngineByExtension(Constants.FileExtensions.EXTENSION_js);
         assertNotNull(scriptEngine, "JavaScript engine manager not found");
     }
 
@@ -219,7 +225,7 @@
 
     /**
      * Check if two script engine factories are equals.
-     * @throws Exception thrownif script engine factories are not equals.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     private void compareTwoScriptFactories(ScriptEngineFactory f1, ScriptEngineFactory f2) throws Exception {
         assertEquals(f1, f2, "script engine factories differ");
@@ -227,7 +233,7 @@
 
     /**
      * Get script engine factory by name.
-     * @throws Exception
+     * @throws Exception thrown if script engine factory can not be found
      */
     private ScriptEngineFactory getFactoryByEngineName(String engineName) throws Exception {
         return tryToFindEngineByName(engineName).getFactory();
@@ -235,7 +241,7 @@
 
     /**
      * Get script engine factory by MIME type.
-     * @throws Exception
+     * @throws Exception thrown if script engine factory can not be found
      */
     private ScriptEngineFactory getFactoryByMimeType(String mimeType) throws Exception {
         return tryToFindEngineByMimeType(mimeType).getFactory();
@@ -243,7 +249,7 @@
 
     /**
      * Compare two script engine factories selected by its name.
-     * @throws Exception
+     * @throws Exception thrown if script engine factories are not equals.
      */
     private void compareTwoFactoriesGetByEngineName(String engineName1, String engineName2) throws Exception {
         ScriptEngineFactory f1 = getFactoryByEngineName(engineName1);
@@ -253,7 +259,7 @@
 
     /**
      * Compare two script engine factories selected by its MIME types.
-     * @throws Exception
+     * @throws Exception thrown if script engine factories are not equals.
      */
     private void compareTwoFactoriesGetByMimeType(String mimeType1, String mimeType2) throws Exception {
         ScriptEngineFactory f1 = getFactoryByMimeType(mimeType1);
@@ -263,7 +269,7 @@
 
     /**
      * Compare two script engine factories selected by its name and MIME type.
-     * @throws Exception
+     * @throws Exception thrown if script engine factories are not equals.
      */
     private void compareTwoFactoriesGetByNameAndMimeType(String engineName, String mimeType) throws Exception {
         ScriptEngineFactory f1 = getFactoryByEngineName(engineName);
@@ -273,7 +279,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual1() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_javascript, Constants.EngineNames.ENGINE_NAME_javascript);
@@ -281,7 +287,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual2() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_javascript, Constants.EngineNames.ENGINE_NAME_JavaScript);
@@ -289,7 +295,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual3() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_javascript, Constants.EngineNames.ENGINE_NAME_ecmascript);
@@ -297,7 +303,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual4() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_javascript, Constants.EngineNames.ENGINE_NAME_ECMAScript);
@@ -305,7 +311,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual5() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_JavaScript, Constants.EngineNames.ENGINE_NAME_JavaScript);
@@ -313,7 +319,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual6() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_JavaScript, Constants.EngineNames.ENGINE_NAME_ecmascript);
@@ -321,7 +327,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual7() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_JavaScript, Constants.EngineNames.ENGINE_NAME_ECMAScript);
@@ -329,7 +335,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual8() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_ecmascript, Constants.EngineNames.ENGINE_NAME_ecmascript);
@@ -337,7 +343,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual9() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_ecmascript, Constants.EngineNames.ENGINE_NAME_ECMAScript);
@@ -345,7 +351,7 @@
 
     /**
      * Test if two script engine factories get by name are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual10() throws Exception {
         compareTwoFactoriesGetByEngineName(Constants.EngineNames.ENGINE_NAME_ECMAScript, Constants.EngineNames.ENGINE_NAME_ECMAScript);
@@ -353,7 +359,7 @@
 
     /**
      * Test if two script engine factories get by MIME type are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual11() throws Exception {
         compareTwoFactoriesGetByMimeType(Constants.MimeTypes.MIME_TYPE_TEXT_JAVASCRIPT, Constants.MimeTypes.MIME_TYPE_TEXT_JAVASCRIPT);
@@ -361,7 +367,7 @@
 
     /**
      * Test if two script engine factories get by MIME type are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual12() throws Exception {
         compareTwoFactoriesGetByMimeType(Constants.MimeTypes.MIME_TYPE_TEXT_JAVASCRIPT, Constants.MimeTypes.MIME_TYPE_TEXT_ECMASCRIPT);
@@ -369,7 +375,7 @@
 
     /**
      * Test if two script engine factories get by MIME type are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual13() throws Exception {
         compareTwoFactoriesGetByMimeType(Constants.MimeTypes.MIME_TYPE_TEXT_JAVASCRIPT, Constants.MimeTypes.MIME_TYPE_APPLICATION_JAVASCRIPT);
@@ -377,7 +383,7 @@
 
     /**
      * Test if two script engine factories get by MIME type are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual14() throws Exception {
         compareTwoFactoriesGetByMimeType(Constants.MimeTypes.MIME_TYPE_TEXT_JAVASCRIPT, Constants.MimeTypes.MIME_TYPE_APPLICATION_ECMASCRIPT);
@@ -385,7 +391,7 @@
 
     /**
      * Test if two script engine factories get by name and MIME type are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual15() throws Exception {
         compareTwoFactoriesGetByNameAndMimeType(Constants.EngineNames.ENGINE_NAME_javascript, Constants.MimeTypes.MIME_TYPE_TEXT_JAVASCRIPT);
@@ -393,7 +399,7 @@
 
     /**
      * Test if two script engine factories get by name and MIME type are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual16() throws Exception {
         compareTwoFactoriesGetByNameAndMimeType(Constants.EngineNames.ENGINE_NAME_javascript, Constants.MimeTypes.MIME_TYPE_TEXT_ECMASCRIPT);
@@ -401,7 +407,7 @@
 
     /**
      * Test if two script engine factories get by name and MIME type are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual17() throws Exception {
         compareTwoFactoriesGetByNameAndMimeType(Constants.EngineNames.ENGINE_NAME_javascript, Constants.MimeTypes.MIME_TYPE_APPLICATION_JAVASCRIPT);
@@ -409,7 +415,7 @@
 
     /**
      * Test if two script engine factories get by name and MIME type are equal.
-     * @throws Exception if this test case fails.
+     * @throws Exception thrown if script engine factories are not equals.
      */
     protected void testIfTwoEnginesFactoriesAreEqual18() throws Exception {
         compareTwoFactoriesGetByNameAndMimeType(Constants.EngineNames.ENGINE_NAME_javascript, Constants.MimeTypes.MIME_TYPE_APPLICATION_ECMASCRIPT);