[Jsptest-svn-commits] SF.net SVN: jsptest:[239] trunk
Status: Alpha
Brought to you by:
lkoskela
|
From: <lko...@us...> - 2008-11-07 20:14:26
|
Revision: 239
http://jsptest.svn.sourceforge.net/jsptest/?rev=239&view=rev
Author: lkoskela
Date: 2008-11-07 20:14:01 +0000 (Fri, 07 Nov 2008)
Log Message:
-----------
Applied formatting throughout the codebase with a custom Eclipse formatting config
Modified Paths:
--------------
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/html/FormAssertionTest.java
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/html/PageAssertionTest.java
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/CustomTag.java
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/CustomTagTest.java
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/RequestAndSessionAttributeTest.java
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TaglibTest.java
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TaglibsDefinedInJarFileTest.java
trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TestMockingTaglibs.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/JspCompilationInfo.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/CommandLineJavac.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/JavaCompiler.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/SunJavaC.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/CustomClassLoader.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/IO.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/Path.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/StreamConsumer.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/Strings.java
trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java
trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/CustomClassLoaderTest.java
trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/IOTest.java
trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/PathTest.java
trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/StreamConsumerTest.java
trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/StringsTest.java
trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/XMLTest.java
trunk/jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/Jsp.java
trunk/jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/JspCompilerFactory.java
trunk/jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/JspExecution.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/HtmlTestCase.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/JspTestCase.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/AbstractAssertion.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/DOMAssertion.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/ElementAssertion.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/ElementChooser.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/ExpectedAssertionFailure.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/FormAssertion.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/FormFieldAssertion.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/LinkAssertion.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/NameChooser.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/OutputAssertion.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/PageAssertion.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/Form.java
trunk/jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/html/FormField.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/AbstractFakeJspCompilerTestCase.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/AbstractHtmlTestCaseTestCase.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/TestHtmlTestCase.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/TestHtmlTestCaseElementAssertions.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/TestHtmlTestCaseFormAssertions.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/TestHtmlTestCaseLinkAssertions.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/TestHtmlTestCasePageAssertions.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/TestJspTestCase.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/assertion/TestExpectedAssertionFailure.java
trunk/jsptest-generic/jsptest-framework/src/test/java/net/sf/jsptest/compiler/dummy/FakeJspCompiler.java
trunk/jsptest-jsp12/src/main/java/net/sf/jsptest/compiler/jsp12/JspCompilerImpl.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/JasperCompiler.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/JasperExecution.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/JspCompilerImpl.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/JspExecutionImpl.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/JspImpl.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/JspTestServletOutputStream.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockHttpServletRequest.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockHttpServletResponse.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockHttpSession.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockJspFactory.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockJspWriter.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockOptions.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockPageContext.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockServletConfig.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockServletContext.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockServletInputStream.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/MockTagInfo.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/taglibs/ClasspathTldLocator.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/taglibs/ExplodedTldLocator.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/taglibs/MockTagInfo.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/taglibs/MockTldLocationsCache.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/taglibs/TldLocation.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/taglibs/TldLocator.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/taglibs/TldUriMappings.java
trunk/jsptest-jsp20/src/main/java/net/sf/jsptest/compiler/jsp20/mock/taglibs/WebInfLibTldLocator.java
trunk/jsptest-jsp20/src/main/java/org/apache/jasper/compiler/MockTagPluginManager.java
trunk/jsptest-jsp20/src/test/java/net/sf/jsptest/compiler/jsp20/TestJspImpl.java
trunk/jsptest-jsp20/src/test/java/net/sf/jsptest/compiler/jsp20/mock/taglibs/TestClasspathTldLocator.java
trunk/jsptest-jsp21/src/main/java/net/sf/jsptest/compiler/jsp21/JspCompilerImpl.java
Modified: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/html/FormAssertionTest.java
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/html/FormAssertionTest.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/html/FormAssertionTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.acceptance.html;
import junit.framework.AssertionFailedError;
@@ -42,15 +41,11 @@
public void testAssertingAgainstFormFieldValue() throws Exception {
setRequestAttribute("j_username", "bob");
get("/html/forms/simpleform.jsp");
- form("form_name").field("text_field_1")
- .shouldHaveValue("one");
- form("form_name").field("text_field_2")
- .shouldHaveValue("two");
+ form("form_name").field("text_field_1").shouldHaveValue("one");
+ form("form_name").field("text_field_2").shouldHaveValue("two");
try {
- form("form_name").field("text_field_1").shouldHaveValue(
- "three");
- throw new RuntimeException(
- "The field value shouldn't match!");
+ form("form_name").field("text_field_1").shouldHaveValue("three");
+ throw new RuntimeException("The field value shouldn't match!");
} catch (AssertionFailedError expected) {
}
}
Modified: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/html/PageAssertionTest.java
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/html/PageAssertionTest.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/html/PageAssertionTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.acceptance.html;
import junit.framework.AssertionFailedError;
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-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/BasicJspTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.acceptance.jsp;
import junit.framework.AssertionFailedError;
@@ -50,8 +49,7 @@
}
}
- public void testJspFileWithSpecialCharactersInName()
- throws Exception {
+ public void testJspFileWithSpecialCharactersInName() throws Exception {
get("/name$_test-file2.jsp");
output().shouldContain("Hello from Jasper");
}
@@ -61,8 +59,7 @@
output().shouldContain("Hello from Jasper");
}
- public void testJspFileInSubDirectoryWithSpecialCharsInPath()
- throws Exception {
+ public void testJspFileInSubDirectoryWithSpecialCharsInPath() throws Exception {
get("/su-b.dir/page_in_sub.dir.jsp");
output().shouldContain("Hello from Jasper");
}
Modified: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/CustomTag.java
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/CustomTag.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/CustomTag.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,12 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.acceptance.jsp;
import java.io.IOException;
import java.util.Enumeration;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
@@ -48,9 +46,7 @@
try {
JspWriter out = pageContext.getOut();
out.println("<pre>");
- out
- .println("This content is coming from CustomTag for timezone "
- + timezone);
+ out.println("This content is coming from CustomTag for timezone " + timezone);
printRequestMethod(out);
printRequestAttributes(out);
printSessionAttributes(out);
@@ -63,31 +59,25 @@
}
private void printRequestMethod(JspWriter out) throws IOException {
- out.println("HTTP request method: "
- + getRequest().getMethod());
+ out.println("HTTP request method: " + getRequest().getMethod());
}
- private void printRequestAttributes(JspWriter out)
- throws IOException {
+ private void printRequestAttributes(JspWriter out) throws IOException {
Enumeration attrNames = getRequest().getAttributeNames();
while (attrNames.hasMoreElements()) {
String name = (String) attrNames.nextElement();
- String value = String.valueOf(getRequest().getAttribute(
- name));
- out.println("HTTP request attribute: " + name + "="
- + value);
+ String value = String.valueOf(getRequest().getAttribute(name));
+ out.println("HTTP request attribute: " + name + "=" + value);
}
}
- private void printSessionAttributes(JspWriter out)
- throws IOException {
+ private void printSessionAttributes(JspWriter out) throws IOException {
HttpSession session = getRequest().getSession(true);
Enumeration attrNames = session.getAttributeNames();
while (attrNames.hasMoreElements()) {
String name = (String) attrNames.nextElement();
String value = String.valueOf(session.getAttribute(name));
- out.println("HTTP session attribute: " + name + "="
- + value);
+ out.println("HTTP session attribute: " + name + "=" + value);
}
}
Modified: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/CustomTagTest.java
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/CustomTagTest.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/CustomTagTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.acceptance.jsp;
import net.sf.jsptest.JspTestCase;
@@ -29,8 +28,7 @@
public void testRenderingJspUsingCustomTaglibs() throws Exception {
get("/taglibs/custom-taglib.jsp");
- output().shouldContain(
- "This content is coming from CustomTag");
+ output().shouldContain("This content is coming from CustomTag");
}
public void testTaglibAttributes() throws Exception {
@@ -59,7 +57,6 @@
output().shouldContain("request attribute: Rn2=Rv2");
output().shouldContain("session attribute: Sn1=Sv1");
output().shouldContain("session attribute: Sn2=Sv2");
-
// POST
setRequestAttribute("Rn1", "Rv1");
setRequestAttribute("Rn2", "Rv2");
@@ -71,5 +68,4 @@
output().shouldContain("session attribute: Sn1=Sv1");
output().shouldContain("session attribute: Sn2=Sv2");
}
-
}
Modified: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/RequestAndSessionAttributeTest.java
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/RequestAndSessionAttributeTest.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/RequestAndSessionAttributeTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.acceptance.jsp;
import net.sf.jsptest.JspTestCase;
@@ -43,8 +42,7 @@
output().shouldContain("session attribute: 'Sn2'='Sv2'");
}
- public void testRequestAndSessionAttributesCanBeObjects()
- throws Exception {
+ public void testRequestAndSessionAttributesCanBeObjects() throws Exception {
setRequestAttribute("request", (Object) "1");
setSessionAttribute("session", (Object) new Integer(2));
get("/echo_attributes.jsp");
@@ -52,8 +50,7 @@
output().shouldContain("session attribute: 'session'='2'");
}
- public void testSessionAndRequestAttributesDontOverrideEachOther()
- throws Exception {
+ public void testSessionAndRequestAttributesDontOverrideEachOther() throws Exception {
setRequestAttribute("name", "request");
setSessionAttribute("name", "session");
get("/echo_attributes.jsp");
Modified: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TaglibTest.java
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TaglibTest.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TaglibTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.acceptance.jsp;
import net.sf.jsptest.JspTestCase;
Modified: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TaglibsDefinedInJarFileTest.java
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TaglibsDefinedInJarFileTest.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TaglibsDefinedInJarFileTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.acceptance.jsp;
import net.sf.jsptest.JspTestCase;
Modified: trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TestMockingTaglibs.java
===================================================================
--- trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TestMockingTaglibs.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-acceptance/jsptest-acceptance-jsp20/src/test/java/net/sf/jsptest/acceptance/jsp/TestMockingTaglibs.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,13 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.acceptance.jsp;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
-
import net.sf.jsptest.JspTestCase;
/**
@@ -27,36 +25,36 @@
*/
public class TestMockingTaglibs extends JspTestCase {
- protected String getJspPackageName() {
- return "cust.om.tags";
- }
+ protected String getJspPackageName() {
+ return "cust.om.tags";
+ }
- protected String getWebRoot() {
- return "src/test/resources/websrc";
- }
+ protected String getWebRoot() {
+ return "src/test/resources/websrc";
+ }
- /**
- * This taglib class gets to replace the real thing.
- */
- public static class MockCustomTag extends CustomTag {
- public int doAfterBody() throws JspException {
- try {
- JspWriter out = pageContext.getOut();
- out.println("<pre>");
- out.println("This content is coming from the mock CustomTag"
- + " for timezone " + timezone);
- out.println("</pre>");
- } catch (Exception e) {
- throw new JspException(e);
- }
- return TagSupport.EVAL_PAGE;
- }
- }
+ /**
+ * This taglib class gets to replace the real thing.
+ */
+ public static class MockCustomTag extends CustomTag {
- public void testRenderingJspUsingCustomTaglibs() throws Exception {
- substituteTaglib("custom", MockCustomTag.class);
- get("/taglibs/custom-taglib.jsp");
- output()
- .shouldContain("This content is coming from the mock CustomTag");
- }
+ public int doAfterBody() throws JspException {
+ try {
+ JspWriter out = pageContext.getOut();
+ out.println("<pre>");
+ out.println("This content is coming from the mock CustomTag" + " for timezone "
+ + timezone);
+ out.println("</pre>");
+ } catch (Exception e) {
+ throw new JspException(e);
+ }
+ return TagSupport.EVAL_PAGE;
+ }
+ }
+
+ public void testRenderingJspUsingCustomTaglibs() throws Exception {
+ substituteTaglib("custom", MockCustomTag.class);
+ get("/taglibs/custom-taglib.jsp");
+ output().shouldContain("This content is coming from the mock CustomTag");
+ }
}
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/JspCompilationInfo.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/JspCompilationInfo.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/JspCompilationInfo.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.compiler;
import java.io.File;
@@ -21,31 +20,22 @@
import java.util.Map;
/**
- * The <tt>JspCompilationInfo</tt> class acts as a simple data struct, being
- * passed around as a blackboard of sorts where different compilation methods
- * obtain prerequisite information (where to find input) and add newly created
- * information (where the output went).
+ * The <tt>JspCompilationInfo</tt> class acts as a simple data struct, being passed around as a
+ * blackboard of sorts where different compilation methods obtain prerequisite information (where to
+ * find input) and add newly created information (where the output went).
*
* @author Lasse Koskela
*/
public class JspCompilationInfo {
private String classFileLocation;
-
private String jspSourceLocation;
-
private String jspClassName;
-
private String javaSourceLocation;
-
private String jspPath;
-
private String classOutputDir;
-
private String webRoot;
-
private Map taglibs;
-
private static Map compilationHistory = new HashMap();
public JspCompilationInfo() {
@@ -132,8 +122,7 @@
File jsp = new File(jspSourceLocation);
File java = new File(javaSourceLocation);
File clazz = new File(classFileLocation);
- return (doesNotExistOrIsTooOld(clazz)
- || doesNotExistOrIsTooOld(java)
+ return (doesNotExistOrIsTooOld(clazz) || doesNotExistOrIsTooOld(java)
|| jsp.lastModified() > java.lastModified() || taglibsHaveChangedSinceLastCompile());
}
@@ -153,10 +142,8 @@
private boolean doesNotExistOrIsTooOld(File file) {
long expirationAge = 5 * 60 * 1000L;
- long expirationThreshold = System.currentTimeMillis()
- - expirationAge;
- return file.exists() == false
- || file.lastModified() < expirationThreshold;
+ long expirationThreshold = System.currentTimeMillis() - expirationAge;
+ return file.exists() == false || file.lastModified() < expirationThreshold;
}
public void setTaglibs(Map taglibs) {
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/CommandLineJavac.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/CommandLineJavac.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/CommandLineJavac.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,14 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.compiler.java;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
-
import net.sf.jsptest.utils.StreamConsumer;
/**
@@ -28,73 +26,68 @@
*/
public class CommandLineJavac implements JavaCompiler {
- private static final String SEPARATOR = System
- .getProperty("path.separator");
+ private static final String SEPARATOR = System.getProperty("path.separator");
- public boolean compile(String srcFile, String destDir, String[] classpath)
- throws Exception {
- srcFile = new File(srcFile).getCanonicalPath();
- String cp = join(classpath);
- String[] command = buildCommandLine(srcFile, destDir, cp);
- return execute(command);
- }
+ public boolean compile(String srcFile, String destDir, String[] classpath) throws Exception {
+ srcFile = new File(srcFile).getCanonicalPath();
+ String cp = join(classpath);
+ String[] command = buildCommandLine(srcFile, destDir, cp);
+ return execute(command);
+ }
- private String[] buildCommandLine(String pathToJavaSource,
- String outputDirectory, String classpathString) {
- return new String[] { "javac", "-classpath", classpathString, "-d",
- outputDirectory, pathToJavaSource };
- }
+ private String[] buildCommandLine(String pathToJavaSource, String outputDirectory,
+ String classpathString) {
+ return new String[] { "javac", "-classpath", classpathString, "-d", outputDirectory,
+ pathToJavaSource };
+ }
- private String join(String[] classpath) {
- StringBuffer s = new StringBuffer(5000);
- for (int i = 0; i < classpath.length; i++) {
- if (s.length() > 0) {
- s.append(SEPARATOR);
- }
- s.append(classpath[i]);
- }
- return s.toString();
- }
+ private String join(String[] classpath) {
+ StringBuffer s = new StringBuffer(5000);
+ for (int i = 0; i < classpath.length; i++) {
+ if (s.length() > 0) {
+ s.append(SEPARATOR);
+ }
+ s.append(classpath[i]);
+ }
+ return s.toString();
+ }
- private boolean execute(String[] commandLine) throws IOException,
- InterruptedException {
- Process p = Runtime.getRuntime().exec(commandLine);
- String processOutput = readOutput(p);
- boolean success = (p.waitFor() == 0);
- if (!success) {
- System.err.println(processOutput);
- }
- return success;
- }
+ private boolean execute(String[] commandLine) throws IOException, InterruptedException {
+ Process p = Runtime.getRuntime().exec(commandLine);
+ String processOutput = readOutput(p);
+ boolean success = (p.waitFor() == 0);
+ if (!success) {
+ System.err.println(processOutput);
+ }
+ return success;
+ }
- private String readOutput(final Process p) throws IOException {
- try {
- StringWriter output = new StringWriter();
- final PrintWriter ps = new PrintWriter(output);
- Thread stderrThread = new Thread(new StreamConsumer("STDERR", p
- .getErrorStream(), ps));
- Thread stdoutThread = new Thread(new StreamConsumer("STDOUT", p
- .getInputStream(), ps));
- p.getOutputStream().close();
- stderrThread.start();
- stdoutThread.start();
- stderrThread.join();
- stdoutThread.join();
- return output.toString();
- } catch (Exception e) {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
- return sw.toString();
- }
- }
+ private String readOutput(final Process p) throws IOException {
+ try {
+ StringWriter output = new StringWriter();
+ final PrintWriter ps = new PrintWriter(output);
+ Thread stderrThread = new Thread(new StreamConsumer("STDERR", p.getErrorStream(), ps));
+ Thread stdoutThread = new Thread(new StreamConsumer("STDOUT", p.getInputStream(), ps));
+ p.getOutputStream().close();
+ stderrThread.start();
+ stdoutThread.start();
+ stderrThread.join();
+ stdoutThread.join();
+ return output.toString();
+ } catch (Exception e) {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+ return sw.toString();
+ }
+ }
- public boolean isAvailable() {
- try {
- Process p = Runtime.getRuntime().exec("javac");
- String s = readOutput(p);
- return s.indexOf("Usage: javac") != -1;
- } catch (Exception e) {
- return false;
- }
- }
+ public boolean isAvailable() {
+ try {
+ Process p = Runtime.getRuntime().exec("javac");
+ String s = readOutput(p);
+ return s.indexOf("Usage: javac") != -1;
+ } catch (Exception e) {
+ return false;
+ }
+ }
}
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/JavaCompiler.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/JavaCompiler.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/JavaCompiler.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.compiler.java;
/**
@@ -23,25 +22,22 @@
*/
public interface JavaCompiler {
- /**
- * Compiles the given .java source file into the given .class file using an
- * explicitly set class path.
- *
- * @param pathToJavaSource
- * Path to the source file to compile.
- * @param outputDirectory
- * Path to the output directory under which to generate the
- * .class file
- * @param classpath
- * The class path to use for compilation.
- */
- boolean compile(String pathToJavaSource, String outputDirectory,
- String[] classpath) throws Exception;
+ /**
+ * Compiles the given .java source file into the given .class file using an explicitly set class
+ * path.
+ *
+ * @param pathToJavaSource
+ * Path to the source file to compile.
+ * @param outputDirectory
+ * Path to the output directory under which to generate the .class file
+ * @param classpath
+ * The class path to use for compilation.
+ */
+ boolean compile(String pathToJavaSource, String outputDirectory, String[] classpath)
+ throws Exception;
- /**
- * Indicates whether this Java compiler implementation is available on the
- * current system.
- */
- boolean isAvailable();
-
-}
\ No newline at end of file
+ /**
+ * Indicates whether this Java compiler implementation is available on the current system.
+ */
+ boolean isAvailable();
+}
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/SunJavaC.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/SunJavaC.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/SunJavaC.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,81 +13,73 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.compiler.java;
import java.lang.reflect.Method;
/**
- * This implementation uses the java compiler from sun which ships with since
- * the jdk since java 1.3. The code is inspired by the javac ant task
- * implementation.
+ * This implementation uses the java compiler from sun which ships with since the jdk since java
+ * 1.3. The code is inspired by the javac ant task implementation.
*
* @author mathias.broekelmann
- *
*/
public class SunJavaC implements JavaCompiler {
- private static final String SEPARATOR = System
- .getProperty("path.separator");
+ private static final String SEPARATOR = System.getProperty("path.separator");
- public boolean compile(String pathToJavaSource, String outputDirectory,
- String[] classpath) throws Exception {
- String classpathString = join(classpath);
- String[] args = buildArgs(pathToJavaSource, outputDirectory,
- classpathString);
- return compile(args);
- }
+ public boolean compile(String pathToJavaSource, String outputDirectory, String[] classpath)
+ throws Exception {
+ String classpathString = join(classpath);
+ String[] args = buildArgs(pathToJavaSource, outputDirectory, classpathString);
+ return compile(args);
+ }
- private boolean compile(String[] args) {
- try {
- Class compilerClass = getCompileClass();
- Method compilerMethod = resolveCompilerMethod(compilerClass);
- Object compilerInstance = compilerClass.newInstance();
- Object[] compilerArguments = new Object[] { args };
- int returnCode = ((Integer) compilerMethod.invoke(compilerInstance,
- compilerArguments)).intValue();
- return returnCode == 0;
- } catch (Throwable e) {
- System.err.println(e.getMessage());
- return false;
- }
- }
+ private boolean compile(String[] args) {
+ try {
+ Class compilerClass = getCompileClass();
+ Method compilerMethod = resolveCompilerMethod(compilerClass);
+ Object compilerInstance = compilerClass.newInstance();
+ Object[] compilerArguments = new Object[] { args };
+ int returnCode = ((Integer) compilerMethod.invoke(compilerInstance, compilerArguments))
+ .intValue();
+ return returnCode == 0;
+ } catch (Throwable e) {
+ System.err.println(e.getMessage());
+ return false;
+ }
+ }
- private String[] buildArgs(String pathToJavaSource, String outputDirectory,
- String classpathString) {
- return new String[] { "-classpath", classpathString, "-d",
- outputDirectory, pathToJavaSource };
- }
+ private String[] buildArgs(String pathToJavaSource, String outputDirectory,
+ String classpathString) {
+ return new String[] { "-classpath", classpathString, "-d", outputDirectory,
+ pathToJavaSource };
+ }
- private String join(String[] classpath) {
- StringBuffer s = new StringBuffer(5000);
- for (int i = 0; i < classpath.length; i++) {
- if (s.length() > 0) {
- s.append(SEPARATOR);
- }
- s.append(classpath[i]);
- }
- return s.toString();
- }
+ private String join(String[] classpath) {
+ StringBuffer s = new StringBuffer(5000);
+ for (int i = 0; i < classpath.length; i++) {
+ if (s.length() > 0) {
+ s.append(SEPARATOR);
+ }
+ s.append(classpath[i]);
+ }
+ return s.toString();
+ }
- public boolean isAvailable() {
- try {
- resolveCompilerMethod(getCompileClass());
- return true;
- } catch (Throwable ex) {
- return false;
- }
- }
+ public boolean isAvailable() {
+ try {
+ resolveCompilerMethod(getCompileClass());
+ return true;
+ } catch (Throwable ex) {
+ return false;
+ }
+ }
- private Method resolveCompilerMethod(Class compilerClass)
- throws NoSuchMethodException {
- return compilerClass.getMethod("compile", new Class[] { (new String[0])
- .getClass() });
- }
+ private Method resolveCompilerMethod(Class compilerClass) throws NoSuchMethodException {
+ return compilerClass.getMethod("compile", new Class[] { (new String[0]).getClass() });
+ }
- private Class getCompileClass() throws ClassNotFoundException {
- return Class.forName("com.sun.tools.javac.Main");
- }
-
+ private Class getCompileClass() throws ClassNotFoundException {
+ return Class.forName("com.sun.tools.javac.Main");
+ }
}
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/CustomClassLoader.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/CustomClassLoader.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/CustomClassLoader.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,45 +13,42 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.utils;
import java.io.File;
/**
- * A class loader implementation that first checks if the class asked for can be
- * found under the given base directory and only then delegates to the parent
- * class' implementation.
+ * A class loader implementation that first checks if the class asked for can be found under the
+ * given base directory and only then delegates to the parent class' implementation.
*
* @author Lasse Koskela
*/
public class CustomClassLoader extends ClassLoader {
- private File baseDir;
+ private File baseDir;
- public CustomClassLoader(String baseDir) {
- this(new File(baseDir));
- }
+ public CustomClassLoader(String baseDir) {
+ this(new File(baseDir));
+ }
- public CustomClassLoader(File baseDir) {
- this.baseDir = baseDir;
- }
+ public CustomClassLoader(File baseDir) {
+ this.baseDir = baseDir;
+ }
- public Class loadClass(String name) throws ClassNotFoundException {
- File classFile = new File(baseDir, name.replace('.', '/') + ".class");
- if (!classFile.exists()) {
- return super.loadClass(name);
- }
- try {
- byte[] data = IO.readToByteArray(classFile);
- return defineClass(name, data);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
+ public Class loadClass(String name) throws ClassNotFoundException {
+ File classFile = new File(baseDir, name.replace('.', '/') + ".class");
+ if (!classFile.exists()) {
+ return super.loadClass(name);
+ }
+ try {
+ byte[] data = IO.readToByteArray(classFile);
+ return defineClass(name, data);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
- protected Class defineClass(String name, byte[] data)
- throws ClassFormatError {
- return super.defineClass(name, data, 0, data.length);
- }
-}
\ No newline at end of file
+ protected Class defineClass(String name, byte[] data) throws ClassFormatError {
+ return super.defineClass(name, data, 0, data.length);
+ }
+}
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/IO.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/IO.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/IO.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.utils;
import java.io.ByteArrayOutputStream;
@@ -24,20 +23,18 @@
import java.io.InputStream;
/**
- * The <tt>IO</tt> class provides utility methods for handling I/O related
- * tasks such as reading from and writing to files, streams, and writers.
+ * The <tt>IO</tt> class provides utility methods for handling I/O related tasks such as reading
+ * from and writing to files, streams, and writers.
*
* @author Lasse Koskela
*/
public class IO {
- public static byte[] readToByteArray(File file)
- throws IOException {
+ public static byte[] readToByteArray(File file) throws IOException {
return readToByteArray(new FileInputStream(file));
}
- public static byte[] readToByteArray(InputStream in)
- throws IOException {
+ public static byte[] readToByteArray(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = new byte[8096];
int r = -1;
@@ -58,9 +55,7 @@
return new String(readToByteArray(file));
}
- public static String readToString(InputStream stream)
- throws IOException {
+ public static String readToString(InputStream stream) throws IOException {
return new String(readToByteArray(stream));
}
-
}
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/Path.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/Path.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/Path.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.utils;
import java.io.File;
@@ -27,75 +26,74 @@
*/
public class Path extends ArrayList {
- private static final String SEPARATOR = System
- .getProperty("path.separator");
+ private static final String SEPARATOR = System.getProperty("path.separator");
- public void addSystemProperty(String name) {
- String property = System.getProperty(name);
- if (property != null) {
- String[] systemClasspath = property.split(SEPARATOR);
- for (int i = 0; i < systemClasspath.length; i++) {
- String entry = systemClasspath[i];
- File file = new File(entry);
- if (file.exists()) {
- add(file.getAbsolutePath());
- } else {
- add(entry);
- }
- }
- }
- }
+ public void addSystemProperty(String name) {
+ String property = System.getProperty(name);
+ if (property != null) {
+ String[] systemClasspath = property.split(SEPARATOR);
+ for (int i = 0; i < systemClasspath.length; i++) {
+ String entry = systemClasspath[i];
+ File file = new File(entry);
+ if (file.exists()) {
+ add(file.getAbsolutePath());
+ } else {
+ add(entry);
+ }
+ }
+ }
+ }
- public boolean add(Object pathElement) {
- if (contains(pathElement)) {
- return false;
- }
- return super.add(pathElement);
- }
+ public boolean add(Object pathElement) {
+ if (contains(pathElement)) {
+ return false;
+ }
+ return super.add(pathElement);
+ }
- public boolean add(File file) {
- return add(file.getAbsolutePath());
- }
+ public boolean add(File file) {
+ return add(file.getAbsolutePath());
+ }
- public String[] toStringArray() {
- return (String[]) toArray(new String[size()]);
- }
+ public String[] toStringArray() {
+ return (String[]) toArray(new String[size()]);
+ }
- public void addContainer(Class klass) {
- String resource = resourcePathFor(klass);
- addJarFile(klass.getResource(resource));
- try {
- ClassLoader context = klass.getClassLoader();
- if (context != null) {
- Enumeration en = context.getResources(resource);
- while (en.hasMoreElements()) {
- addJarFile((URL) en.nextElement());
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
+ public void addContainer(Class klass) {
+ String resource = resourcePathFor(klass);
+ addJarFile(klass.getResource(resource));
+ try {
+ ClassLoader context = klass.getClassLoader();
+ if (context != null) {
+ Enumeration en = context.getResources(resource);
+ while (en.hasMoreElements()) {
+ addJarFile((URL) en.nextElement());
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
- private String resourcePathFor(Class klass) {
- String resource = klass.getName().replaceAll("\\.", "/");
- return "/" + resource + ".class";
- }
+ private String resourcePathFor(Class klass) {
+ String resource = klass.getName().replaceAll("\\.", "/");
+ return "/" + resource + ".class";
+ }
- private void addJarFile(URL url) {
- if (url != null) {
- addJarFile(url.toExternalForm());
- }
- }
+ private void addJarFile(URL url) {
+ if (url != null) {
+ addJarFile(url.toExternalForm());
+ }
+ }
- private void addJarFile(String url) {
- String prefix = "jar:file:";
- if (url.startsWith(prefix)) {
- String file = url.substring(prefix.length());
- if (file.indexOf("!") > -1) {
- file = file.substring(0, file.indexOf('!'));
- }
- add(new File(file));
- }
- }
+ private void addJarFile(String url) {
+ String prefix = "jar:file:";
+ if (url.startsWith(prefix)) {
+ String file = url.substring(prefix.length());
+ if (file.indexOf("!") > -1) {
+ file = file.substring(0, file.indexOf('!'));
+ }
+ add(new File(file));
+ }
+ }
}
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/StreamConsumer.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/StreamConsumer.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/StreamConsumer.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.utils;
import java.io.ByteArrayOutputStream;
@@ -27,13 +26,10 @@
public class StreamConsumer implements Runnable {
private final String outputPrefix;
-
private final InputStream stream;
-
private final PrintWriter log;
- public StreamConsumer(String streamName, InputStream stream,
- PrintWriter log) {
+ public StreamConsumer(String streamName, InputStream stream, PrintWriter log) {
this.outputPrefix = streamName + ":";
this.stream = stream;
this.log = log;
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/Strings.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/Strings.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/Strings.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,41 +13,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.utils;
/**
- * The <tt>Strings</tt> class provides utility methods for string
- * manipulation.
+ * The <tt>Strings</tt> class provides utility methods for string manipulation.
*
* @author Lasse Koskela
*/
public class Strings {
- /**
- * Replace instances of "what" from "fromWhere" with "withWhat". This is
- * essentially a replacement for not being able to use
- * {@link String#replace(String, String, String)} with JDK 1.4.
- *
- * @param fromWhere
- * The string to replace stuff from.
- * @param what
- * The string to replace.
- * @param withWhat
- * The string to replace with.
- * @return A new string with the replaced content.
- */
- public static String replace(String fromWhere, String what, String withWhat) {
- if (what.length() > 0) {
- int indexOfWhat = fromWhere.indexOf(what);
- if (indexOfWhat != -1) {
- String beforeMatch = fromWhere.substring(0, indexOfWhat);
- String afterMatch = fromWhere.substring(indexOfWhat
- + what.length());
- fromWhere = beforeMatch + withWhat
- + replace(afterMatch, what, withWhat);
- }
- }
- return fromWhere;
- }
+ /**
+ * Replace instances of "what" from "fromWhere" with "withWhat". This is essentially a
+ * replacement for not being able to use {@link String#replace(String, String, String)} with JDK
+ * 1.4.
+ *
+ * @param fromWhere
+ * The string to replace stuff from.
+ * @param what
+ * The string to replace.
+ * @param withWhat
+ * The string to replace with.
+ * @return A new string with the replaced content.
+ */
+ public static String replace(String fromWhere, String what, String withWhat) {
+ if (what.length() > 0) {
+ int indexOfWhat = fromWhere.indexOf(what);
+ if (indexOfWhat != -1) {
+ String beforeMatch = fromWhere.substring(0, indexOfWhat);
+ String afterMatch = fromWhere.substring(indexOfWhat + what.length());
+ fromWhere = beforeMatch + withWhat + replace(afterMatch, what, withWhat);
+ }
+ }
+ return fromWhere;
+ }
}
Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -13,61 +13,57 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package net.sf.jsptest.utils;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
-
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
- * The <tt>XML</tt> class provides utility methods for handling XML related
- * tasks.
+ * The <tt>XML</tt> class provides utility methods for handling XML related tasks.
*
* @author Lasse Koskela
*/
public class XML {
- private static final String APACHE_INDENTATION = "{http://xml.apache.org/xslt}indent-amount";
+ private static final String APACHE_INDENTATION = "{http://xml.apache.org/xslt}indent-amount";
- public static String toString(Node xml) {
- try {
- TransformerFactory f = TransformerFactory.newInstance();
- Transformer t = f.newTransformer();
- t.setOutputProperty(OutputKeys.INDENT, "yes");
- t.setOutputProperty(APACHE_INDENTATION, "2");
- OutputStream out = new ByteArrayOutputStream();
- t.transform(new DOMSource(xml), new StreamResult(out));
- return out.toString();
- } catch (TransformerException e) {
- throw new RuntimeException(e);
- }
- }
+ public static String toString(Node xml) {
+ try {
+ TransformerFactory f = TransformerFactory.newInstance();
+ Transformer t = f.newTransformer();
+ t.setOutputProperty(OutputKeys.INDENT, "yes");
+ t.setOutputProperty(APACHE_INDENTATION, "2");
+ OutputStream out = new ByteArrayOutputStream();
+ t.transform(new DOMSource(xml), new StreamResult(out));
+ return out.toString();
+ } catch (TransformerException e) {
+ throw new RuntimeException(e);
+ }
+ }
- public static String textContentOf(Element element) {
- StringBuffer textContent = new StringBuffer(100);
- NodeList children = element.getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- appendTextContentOf(children.item(i), textContent);
- }
- return textContent.toString();
- }
+ public static String textContentOf(Element element) {
+ StringBuffer textContent = new StringBuffer(100);
+ NodeList children = element.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ appendTextContentOf(children.item(i), textContent);
+ }
+ return textContent.toString();
+ }
- private static void appendTextContentOf(Node from, StringBuffer to) {
- if (from.getNodeType() == Node.ELEMENT_NODE) {
- to.append(textContentOf((Element) from));
- } else if (from.getNodeType() != Node.COMMENT_NODE) {
- to.append(from.getNodeValue().trim());
- }
- }
+ private static void appendTextContentOf(Node from, StringBuffer to) {
+ if (from.getNodeType() == Node.ELEMENT_NODE) {
+ to.append(textContentOf((Element) from));
+ } else if (from.getNodeType() != Node.COMMENT_NODE) {
+ to.append(from.getNodeValue().trim());
+ }
+ }
}
Modified: trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/CustomClassLoaderTest.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/CustomClassLoaderTest.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/CustomClassLoaderTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -1,60 +1,54 @@
package net.sf.jsptest.utils;
import java.io.File;
-
import junit.framework.TestCase;
public class CustomClassLoaderTest extends TestCase {
- private File baseDir;
- protected String definedName;
- protected byte[] definedData;
- private String fullyQualifiedClassName;
+ private File baseDir;
+ protected String definedName;
+ protected byte[] definedData;
+ private String fullyQualifiedClassName;
- protected void setUp() throws Exception {
- super.setUp();
- fullyQualifiedClassName = "pkg.Fake";
- baseDir = new File(System.getProperty("java.io.tmpdir"), "basedir");
- File packageDir = new File(baseDir, "pkg");
- packageDir.mkdirs();
- File classFile = new File(packageDir, "Fake.class");
- IO.write("Fake", classFile);
- }
+ protected void setUp() throws Exception {
+ super.setUp();
+ fullyQualifiedClassName = "pkg.Fake";
+ baseDir = new File(System.getProperty("java.io.tmpdir"), "basedir");
+ File packageDir = new File(baseDir, "pkg");
+ packageDir.mkdirs();
+ File classFile = new File(packageDir, "Fake.class");
+ IO.write("Fake", classFile);
+ }
- public void testClassesAreLoadedFromTheGivenBaseDirectory()
- throws Exception {
- CustomClassLoader cl = new CustomClassLoader(baseDir) {
- // override to avoid actual class loading
- protected Class defineClass(String name, byte[] data)
- throws ClassFormatError {
- definedName = name;
- definedData = data;
- return CustomClassLoaderTest.class;
- }
- };
+ public void testClassesAreLoadedFromTheGivenBaseDirectory() throws Exception {
+ CustomClassLoader cl = new CustomClassLoader(baseDir) {
- verifyClassLoading(cl);
- }
+ // override to avoid actual class loading
+ protected Class defineClass(String name, byte[] data) throws ClassFormatError {
+ definedName = name;
+ definedData = data;
+ return CustomClassLoaderTest.class;
+ }
+ };
+ verifyClassLoading(cl);
+ }
- public void testBaseDirectoryCanBeGivenAsAbsolutePathName()
- throws Exception {
- CustomClassLoader cl = new CustomClassLoader(baseDir.getAbsolutePath()) {
- // override to avoid actual class loading
- protected Class defineClass(String name, byte[] data)
- throws ClassFormatError {
- definedName = name;
- definedData = data;
- return CustomClassLoaderTest.class;
- }
- };
+ public void testBaseDirectoryCanBeGivenAsAbsolutePathName() throws Exception {
+ CustomClassLoader cl = new CustomClassLoader(baseDir.getAbsolutePath()) {
- verifyClassLoading(cl);
- }
+ // override to avoid actual class loading
+ protected Class defineClass(String name, byte[] data) throws ClassFormatError {
+ definedName = name;
+ definedData = data;
+ return CustomClassLoaderTest.class;
+ }
+ };
+ verifyClassLoading(cl);
+ }
- private void verifyClassLoading(CustomClassLoader classLoader)
- throws ClassNotFoundException {
- classLoader.loadClass(fullyQualifiedClassName);
- assertEquals(fullyQualifiedClassName, definedName);
- assertEquals("Fake", new String(definedData));
- }
+ private void verifyClassLoading(CustomClassLoader classLoader) throws ClassNotFoundException {
+ classLoader.loadClass(fullyQualifiedClassName);
+ assertEquals(fullyQualifiedClassName, definedName);
+ assertEquals("Fake", new String(definedData));
+ }
}
Modified: trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/IOTest.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/IOTest.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/IOTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -1,7 +1,6 @@
package net.sf.jsptest.utils;
import java.io.File;
-
import junit.framework.TestCase;
public class IOTest extends TestCase {
Modified: trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/PathTest.java
===================================================================
--- trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/PathTest.java 2008-11-07 19:06:40 UTC (rev 238)
+++ trunk/jsptest-generic/jsptest-common/src/test/java/net/sf/jsptest/utils/PathTest.java 2008-11-07 20:14:01 UTC (rev 239)
@@ -4,77 +4,75 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-
import junit.framework.TestCase;
public class PathTest extends TestCase {
- private Path path;
- private File file1;
- private File file2;
+ private Path path;
+ private File file1;
+ private File file2;
- protected void setUp() throws Exception {
- super.setUp();
- path = new Path();
- file1 = File.createTempFile("test", ".tmp");
- file2 = File.createTempFile("test", ".tmp");
- }
+ protected void setUp() throws Exception {
+ super.setUp();
+ path = new Path();
+ file1 = File.createTempFile("test", ".tmp");
+ file2 = File.createTempFile("test", ".tmp");
+ }
- protected void tearDown() throws Exception ...
[truncated message content] |