You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/07/12 10:58:11 UTC
svn commit: r1502486 - in /tomcat/trunk:
test/org/apache/jasper/TestJspC.java webapps/docs/changelog.xml
Author: markt
Date: Fri Jul 12 08:58:10 2013
New Revision: 1502486
URL: http://svn.apache.org/r1502486
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=55245
Add JspC test cases.
Patch by Jeremy Boynes.
Added:
tomcat/trunk/test/org/apache/jasper/TestJspC.java (with props)
Modified:
tomcat/trunk/webapps/docs/changelog.xml
Added: tomcat/trunk/test/org/apache/jasper/TestJspC.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/TestJspC.java?rev=1502486&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/TestJspC.java (added)
+++ tomcat/trunk/test/org/apache/jasper/TestJspC.java Fri Jul 12 08:58:10 2013
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.jasper;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestJspC {
+
+ private JspC jspc;
+ private File outputDir;
+
+ @Before
+ public void init() {
+ jspc = new JspC();
+ outputDir = new File("output/jspc");
+ }
+
+ @Test
+ public void precompileWebapp_2_2() throws IOException {
+ File appDir = new File("test/webapp-2.2");
+ File webappOut = new File(outputDir, appDir.getName());
+ precompile(appDir, webappOut);
+ verify(webappOut);
+ }
+
+ @Test
+ public void precompileWebapp_2_3() throws IOException {
+ File appDir = new File("test/webapp-2.3");
+ File webappOut = new File(outputDir, appDir.getName());
+ precompile(appDir, webappOut);
+ verify(webappOut);
+ }
+
+ @Test
+ public void precompileWebapp_2_4() throws IOException {
+ File appDir = new File("test/webapp-2.4");
+ File webappOut = new File(outputDir, appDir.getName());
+ precompile(appDir, webappOut);
+ verify(webappOut);
+ }
+
+ @Test
+ public void precompileWebapp_2_5() throws IOException {
+ File appDir = new File("test/webapp-2.5");
+ File webappOut = new File(outputDir, appDir.getName());
+ precompile(appDir, webappOut);
+ verify(webappOut);
+ }
+
+ @Test
+ public void precompileWebapp_3_0() throws IOException {
+ File appDir = new File("test/webapp-3.0");
+ File webappOut = new File(outputDir, appDir.getName());
+ precompile(appDir, webappOut);
+ verify(webappOut);
+ }
+
+ @Test
+ public void precompileWebapp_3_1() throws IOException {
+ File appDir = new File("test/webapp-3.1");
+ File webappOut = new File(outputDir, appDir.getName());
+ precompile(appDir, webappOut);
+ verify(webappOut);
+ }
+
+ private void verify(File webappOut) {
+ // for now, just check some expected files exist
+ Assert.assertTrue(new File(webappOut, "generated_web.xml").exists());
+ Assert.assertTrue(new File(webappOut,
+ "org/apache/jsp/el_002das_002dliteral_jsp.java").exists());
+ Assert.assertTrue(new File(webappOut,
+ "org/apache/jsp/tld_002dversions_jsp.java").exists());
+ }
+
+ private void precompile(File appDir, File webappOut) throws IOException {
+ remove(webappOut);
+ webappOut.mkdirs();
+ jspc.setUriroot(appDir.toString());
+ jspc.setOutputDir(webappOut.toString());
+ jspc.setValidateXml(false);
+ jspc.setWebXml(new File(webappOut, "generated_web.xml").toString());
+ jspc.execute();
+ }
+
+
+ private void remove(File base) throws IOException{
+ if (!base.exists()) {
+ return;
+ }
+ Files.walkFileTree(base.toPath(), new SimpleFileVisitor<Path>(){
+ @Override
+ public FileVisitResult visitFile(Path file,
+ BasicFileAttributes attrs) throws IOException {
+ Files.delete(file);
+ return FileVisitResult.CONTINUE;
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir,
+ IOException exc) throws IOException {
+ Files.delete(dir);
+ return FileVisitResult.CONTINUE;
+ }
+ });
+ }
+}
Propchange: tomcat/trunk/test/org/apache/jasper/TestJspC.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1502486&r1=1502485&r2=1502486&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Jul 12 08:58:10 2013
@@ -181,6 +181,9 @@
Update Jasper to use the new common web.xml parsing code. Includes
patches by Jeremy Boynes. (markt/violetagg)
</scode>
+ <add>
+ Create test cases for JspC. Patch by Jeremy Boynes. (markt)
+ </add>
</changelog>
</subsection>
<subsection name="Cluster">
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org