tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r1006338 - in /tomcat/taglibs/standard/trunk/impl: ./ src/test/java/org/apache/taglibs/standard/lang/jstl/test/ src/test/resources/ src/test/resources/org/ src/test/resources/org/apache/ src/test/resources/org/apache/taglibs/ src/test/resou...
Date Sun, 10 Oct 2010 19:04:15 GMT
Author: jboynes
Date: Sun Oct 10 19:04:15 2010
New Revision: 1006338

URL: http://svn.apache.org/viewvc?rev=1006338&view=rev
Log:
make ParserTest pass, assuming EL functions should be allowed

Added:
    tomcat/taglibs/standard/trunk/impl/src/test/resources/
    tomcat/taglibs/standard/trunk/impl/src/test/resources/org/
    tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/
    tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/
    tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/
    tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/
    tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/
    tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/
    tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt
  (contents, props changed)
      - copied, changed from r1006238, tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt
    tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt
  (contents, props changed)
      - copied, changed from r1006238, tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt
Removed:
    tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt
    tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt
Modified:
    tomcat/taglibs/standard/trunk/impl/pom.xml
    tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/ParserTest.java

Modified: tomcat/taglibs/standard/trunk/impl/pom.xml
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/pom.xml?rev=1006338&r1=1006337&r2=1006338&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/pom.xml (original)
+++ tomcat/taglibs/standard/trunk/impl/pom.xml Sun Oct 10 19:04:15 2010
@@ -130,8 +130,6 @@
             <!-- Old tests -->
             <!-- Started failing for JSTL 1.2 -->
             <exclude>org/apache/taglibs/standard/lang/jstl/test/EvaluationTest.java</exclude>
-            <!-- May never have passed -->
-            <exclude>org/apache/taglibs/standard/lang/jstl/test/ParserTest.java</exclude>
           </excludes>
         </configuration>
       </plugin>

Modified: tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/ParserTest.java
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/ParserTest.java?rev=1006338&r1=1006337&r2=1006338&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/ParserTest.java
(original)
+++ tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/ParserTest.java
Sun Oct 10 19:04:15 2010
@@ -13,236 +13,126 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */ 
+ */
 
 package org.apache.taglibs.standard.lang.jstl.test;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
+import java.io.BufferedReader;
+import java.io.CharArrayReader;
+import java.io.CharArrayWriter;
 import java.io.IOException;
-import java.io.PrintStream;
-
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.PrintWriter;
+import java.nio.charset.Charset;
 import javax.servlet.jsp.JspException;
 
-import org.apache.taglibs.standard.lang.jstl.Evaluator;
-
 import junit.framework.TestCase;
+import org.apache.taglibs.standard.lang.jstl.Evaluator;
+import org.junit.Assert;
+import org.junit.Test;
 
 /**
- *
  * <p>This runs a series of tests specifically for the parser.  It
  * parses various expressions and prints out the canonical
  * representation of those parsed expressions.
- *
+ * <p/>
  * <p>The expressions are stored in an input text file, with one line
  * per expression.  Blank lines and lines that start with # are
  * ignored.  The results are written to an output file (blank lines
  * and # lines are included in the output file).  The output file may
  * be compared against an existing output file to do regression
  * testing.
- * 
+ *
  * @author Nathan Abramson - Art Technology Group
  * @version $Change: 181177 $$DateTime: 2001/06/26 08:45:09 $$Author$
- **/
+ */
 
 public class ParserTest extends TestCase {
+    private final Charset UTF8 = Charset.forName("UTF-8");
 
-  //-------------------------------------
-  // Properties
-  //-------------------------------------
-
-  //-------------------------------------
-  // Member variables
-  //-------------------------------------
-
-  //-------------------------------------
-  /**
-   *
-   * Constructor
-   **/
-  public ParserTest ()
-  {
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Runs the tests, reading expressions from pIn and writing the
-   * results to pOut.
-   **/
-  public static void runTests (DataInput pIn,
-			       PrintStream pOut)
-    throws IOException
-  {
-    while (true) {
-      String str = pIn.readLine ();
-      if (str == null) break;
-      if (str.startsWith ("#") ||
-	  "".equals (str.trim ())) {
-	pOut.println (str);
-      }
-      else {
-	// For testing non-ASCII values, the string @@non-ascii gets
-	// converted internally to '\u1111'
-	if ("@@non-ascii".equals (str)) {
-	  str = "\u1111";
-	}
-
-	pOut.println ("Attribute value: " + str);
-	try {
-	  String result = Evaluator.parseAndRender (str);
-	  pOut.println ("Parses to: " + result);
-	}
-	catch (JspException exc) {
-	  pOut.println ("Causes an error: " + exc.getMessage ());
-	}
-      }
-    }
-
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Runs the tests, reading from the given input file and writing to
-   * the given output file.
-   **/
-  public static void runTests (File pInputFile,
-			       File pOutputFile)
-    throws IOException
-  {
-    FileInputStream fin = null;
-    FileOutputStream fout = null;
-    try {
-      fin = new FileInputStream (pInputFile);
-      BufferedInputStream bin = new BufferedInputStream (fin);
-      DataInputStream din = new DataInputStream (bin);
-
-      try {
-	fout = new FileOutputStream (pOutputFile);
-	BufferedOutputStream bout = new BufferedOutputStream (fout);
-	PrintStream pout = new PrintStream (bout);
-
-	runTests (din, pout);
-
-	pout.flush ();
-      }
-      finally {
-	if (fout != null) {
-	  fout.close ();
-	}
-      }
-    }
-    finally {
-      if (fin != null) {
-	fin.close ();
-      }
+    @Test
+    public void testParser() throws IOException {
+        try {
+            System.setProperty("javax.servlet.jsp.functions.allowed", "true");
+            BufferedReader in = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("parserTests.txt"),
UTF8));
+            CharArrayWriter writer = new CharArrayWriter();
+            PrintWriter out = new PrintWriter(writer);
+
+            x(in, out);
+            out.close();
+            in.close();
+
+            LineNumberReader expected = new LineNumberReader(new InputStreamReader(getClass().getResourceAsStream("parserTestsOutput.txt"),
UTF8));
+            LineNumberReader actual = new LineNumberReader(new CharArrayReader(writer.toCharArray()));
+
+            Assert.assertFalse(isDifferentStreams(actual, expected));
+            actual.close();
+            expected.close();
+        } finally {
+            System.clearProperty("javax.servlet.jsp.functions.allowed");
+        }
+    }
+
+    /**
+     * Runs the tests, reading expressions from pIn and writing the
+     * results to pOut.
+     */
+    public static void x(BufferedReader pIn, PrintWriter pOut)
+            throws IOException {
+        while (true) {
+            String str = pIn.readLine();
+            if (str == null) break;
+            if (str.startsWith("#") ||
+                    "".equals(str.trim())) {
+                pOut.println(str);
+            } else {
+                // For testing non-ASCII values, the string @@non-ascii gets
+                // converted internally to '\u1111'
+                if ("@@non-ascii".equals(str)) {
+                    str = "\u1111";
+                }
+
+                pOut.println("Attribute value: " + str);
+                try {
+                    String result = Evaluator.parseAndRender(str);
+                    pOut.println("Parses to: " + result);
+                }
+                catch (JspException exc) {
+                    pOut.println("Causes an error: " + exc.getMessage());
+                }
+            }
+        }
+
+    }
+
+    /**
+     * Performs a line-by-line comparison of the two files, returning
+     * true if the files are different, false if not.
+     */
+    public static boolean isDifferentStreams(LineNumberReader actual,
+                                             LineNumberReader expected)
+            throws IOException {
+        while (true) {
+            String str1 = actual.readLine();
+            String str2 = expected.readLine();
+            if (str1 == null &&
+                    str2 == null) {
+                return false;
+            } else if (str1 == null ||
+                    str2 == null) {
+                return true;
+            } else {
+                if (!str1.equals(str2)) {
+                    System.out.println("Files differ at line " + actual.getLineNumber());
+                    return true;
+                }
+            }
+        }
+    }
+
+    @Test
+    public void testUnicodeCharacter() throws JspException {
+        Assert.assertEquals("\u1111", Evaluator.parseAndRender("\u1111"));
     }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Performs a line-by-line comparison of the two files, returning
-   * true if the files are different, false if not.
-   **/
-  public static boolean isDifferentStreams (DataInput pIn1,
-					  DataInput pIn2)
-    throws IOException
-  {
-    while (true) {
-      String str1 = pIn1.readLine ();
-      String str2 = pIn2.readLine ();
-      if (str1 == null &&
-	  str2 == null) {
-	return false;
-      }
-      else if (str1 == null ||
-	       str2 == null) {
-	return true;
-      }
-      else {
-	if (!str1.equals (str2)) {
-	  return true;
-	}
-      }
-    }
-  }
-
-  //-------------------------------------
-  /**
-   *
-   * Performs a line-by-line comparison of the two files, returning
-   * true if the files are different, false if not.
-   **/
-  public static void assertDifferentFiles (File pFile1,
-					  File pFile2)
-    throws IOException
-  {
-    FileInputStream fin1 = null;
-    try {
-      fin1 = new FileInputStream (pFile1);
-      BufferedInputStream bin1 = new BufferedInputStream (fin1);
-      DataInputStream din1 = new DataInputStream (bin1);
-
-      FileInputStream fin2 = null;
-      try {
-	fin2 = new FileInputStream (pFile2);
-	BufferedInputStream bin2 = new BufferedInputStream (fin2);
-	DataInputStream din2 = new DataInputStream (bin2);
-
-	if(isDifferentStreams (din1, din2)) {
-        fail("Files are different");
-    }
-      }
-      finally {
-	if (fin2 != null) {
-	  fin2.close ();
-	}
-      }
-    }
-    finally {
-      if (fin1 != null) {
-	fin1.close ();
-      }
-    }
-  }
-
-  //-------------------------------------
-  // Main method
-  //-------------------------------------
-  /**
-   *
-   * Runs the parser test
-   **/
-  public void testParser()
-    throws IOException
-  {
-
-    String input = "test/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt";
-    String output = "/tmp/parserTestsOutput.txt";
-    String compareName = "test/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt";
-
-    File in = new File (input);
-    File out = new File (output);
-
-    runTests (in, out);
-
-      File compare = new File (compareName);
-      assertDifferentFiles(out, compare);
-  }
-
-  //-------------------------------------
-  static void usage ()
-  {
-    System.err.println ("usage: java org.apache.taglibs.standard.lang.jstl.test.ParserTest
{input file} {output file} [{compare file}]");
-  }
-
-  //-------------------------------------
-
 }

Copied: tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt
(from r1006238, tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt)
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt?p2=tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt&p1=tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt&r1=1006238&r2=1006338&rev=1006338&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt
(original)
+++ tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt
Sun Oct 10 19:04:15 2010
@@ -142,7 +142,3 @@ ${a:b(c,d,e)}
 ${a(b).c}
 ${a(b)[c]}
 ${a[b()]}
-
-# non-ascii input - the parser automatically translates the @@non-ascii
-# into a UNICODE string with value \u1111
-@@non-ascii

Propchange: tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTests.txt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt
(from r1006238, tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt)
URL: http://svn.apache.org/viewvc/tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt?p2=tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt&p1=tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt&r1=1006238&r2=1006338&rev=1006338&view=diff
==============================================================================
--- tomcat/taglibs/standard/trunk/impl/src/test/java/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt
(original)
+++ tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt
Sun Oct 10 19:04:15 2010
@@ -253,8 +253,3 @@ Attribute value: ${a(b)[c]}
 Parses to: ${a(b)[c]}
 Attribute value: ${a[b()]}
 Parses to: ${a[b()]}
-
-# non-ascii input - the parser automatically translates the @@non-ascii
-# into a UNICODE string with value \u1111
-Attribute value: ?
-Parses to: ?

Propchange: tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/taglibs/standard/trunk/impl/src/test/resources/org/apache/taglibs/standard/lang/jstl/test/parserTestsOutput.txt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message