[Jsptest-svn-commits] SF.net SVN: jsptest: [208] trunk
Status: Alpha
Brought to you by:
lkoskela
|
From: <lko...@us...> - 2008-04-09 19:53:01
|
Revision: 208
http://jsptest.svn.sourceforge.net/jsptest/?rev=208&view=rev
Author: lkoskela
Date: 2008-04-09 12:52:32 -0700 (Wed, 09 Apr 2008)
Log Message:
-----------
Applied Mathias Broekelmann's patch, adding support for special characters (. and -) in the directory path of a JSP file.
Modified Paths:
--------------
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/BasicJspTest.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/JasperCompiler.java
Added Paths:
-----------
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/resources/websrc/su-b.dir/
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/resources/websrc/su-b.dir/page_in_sub.dir.jsp
Modified: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/BasicJspTest.java
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/BasicJspTest.java 2008-04-09 17:56:07 UTC (rev 207)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/BasicJspTest.java 2008-04-09 19:52:32 UTC (rev 208)
@@ -61,6 +61,12 @@
output().shouldContain("Hello from Jasper");
}
+ public void testJspFileInSubDirectoryWithSpecialCharsInPath()
+ throws Exception {
+ get("/su-b.dir/page_in_sub.dir.jsp");
+ output().shouldContain("Hello from Jasper");
+ }
+
public void testJspPathNotStartingWithSlash() throws Exception {
try {
get("sub/dir/page_in_subdir.jsp");
Added: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/resources/websrc/su-b.dir/page_in_sub.dir.jsp
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/resources/websrc/su-b.dir/page_in_sub.dir.jsp (rev 0)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/resources/websrc/su-b.dir/page_in_sub.dir.jsp 2008-04-09 19:52:32 UTC (rev 208)
@@ -0,0 +1,7 @@
+<%@ page language="Java" %>
+<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
+<html>
+ <body>
+ <p>Hello <%= "from" %> Jasper</p>
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/JasperCompiler.java
===================================================================
--- trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/JasperCompiler.java 2008-04-09 17:56:07 UTC (rev 207)
+++ trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/JasperCompiler.java 2008-04-09 19:52:32 UTC (rev 208)
@@ -285,11 +285,11 @@
private String resolveJavaSourceFileName(String jspPath) {
String name = encodeSpecialCharacters(jspPath);
- name = name.replace(".jsp", "_jsp.java");
+ // name = name.replace(".jsp", "_jsp.java");
if (name.startsWith("/")) {
name = name.substring(1);
}
- return name;
+ return name + ".java";
}
private String encodeSpecialCharacters(String name) {
@@ -300,6 +300,8 @@
result.append("_002d");
} else if (chars[i] == '_') {
result.append("_005f");
+ } else if (chars[i] == '.') {
+ result.append("_002e");
} else {
result.append(chars[i]);
}
@@ -317,8 +319,9 @@
private void resolveClassName(JspCompilationInfo info) {
String baseName = new File(info.getJavaSource()).getName();
baseName = baseName.substring(0, baseName.indexOf("."));
- info.setClassName(getPackagePrefix()
- + getSubDirPackagePrefix(info) + baseName);
+ String packageName = getPackagePrefix()
+ + getSubDirPackagePrefix(info);
+ info.setClassName(packageName + baseName);
}
private String getPackagePrefix() {
@@ -334,9 +337,10 @@
if (dirPrefix.startsWith("/")) {
dirPrefix = dirPrefix.substring(1);
}
- if (dirPrefix.lastIndexOf("/") != -1) {
- dirPrefix = dirPrefix.substring(0, dirPrefix
- .lastIndexOf("/"));
+ int lastSlashIndex = dirPrefix.lastIndexOf("/");
+ if (lastSlashIndex != -1) {
+ dirPrefix = dirPrefix.substring(0, lastSlashIndex);
+ dirPrefix = encodeSpecialCharacters(dirPrefix);
dirPrefix = dirPrefix.replace('/', '.') + ".";
} else {
dirPrefix = "";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|