// Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/OutputAssertion.java
// public class OutputAssertion extends AbstractAssertion {
// 
//     private final String content;
// 
//     /**
//      * @param content
//      *            The raw output to perform assertions on.
//      */
//     public OutputAssertion(String content) {
//         this.content = content;
//     }
// 
//     /**
//      * Assert that the output should contain the given text.
//      * 
//      * @param text
//      *            The (partial) content that should be found from the output.
//      */
//     public void shouldContain(String text) {
//         String msg = "Rendered output did not contain the expected text <" + text + ">:\n"
//                 + content;
//         assertContains(msg, content, text);
//     }
// 
//     /**
//      * Assert that the output should not contain the given text.
//      * 
//      * @param text
//      *            The (partial) content that shouldn't be found from the output.
//      */
//     public void shouldNotContain(String text) {
//         String msg = "Rendered output contained unexpected text <" + text + ">:\n" + content;
//         assertDoesNotContain(msg, content, text);
//     }
// }
// 
// Path: jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/Jsp.java
// public interface Jsp {
// 
//     JspExecution request(String httpMethod, Map requestAttributes, Map sessionAttributes, Map requestParameters);
// }
// 
// Path: jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/JspCompiler.java
// public interface JspCompiler {
// 
//     Jsp compile(String path, Map taglibs);
// 
//     void setWebRoot(String directory);
// 
//     void setOutputDirectory(String directory);
// }
// 
// Path: jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/JspCompilerFactory.java
// public class JspCompilerFactory {
// 
//     private static final Logger log = Logger.getLogger(JspCompilerFactory.class);
//     private static final String RESOURCE_PATH = "jsptest.properties";
//     private static final String CONFIGURATION_KEY = "jsptest.compiler.implementation";
// 
//     public static JspCompiler newInstance() {
//         RuntimeException exception = new RuntimeException(
//                 "No JSP compiler implementation configured: " + "(configuration file "
//                         + RESOURCE_PATH + " not found from class path.");
//         try {
//             printConfigurationFiles();
//             Enumeration resources = getClassLoader().getResources(RESOURCE_PATH);
//             while (resources.hasMoreElements()) {
//                 URL resource = (URL) resources.nextElement();
//                 if (resources.hasMoreElements()
//                         && resource.toString().indexOf("test-classes") != -1) {
//                     log.debug("Ignoring " + resource + " because it's from 'test-classes' "
//                             + "and there's another matching resource available");
//                     continue;
//                 }
//                 try {
//                     return loadCompilerFrom(resource);
//                 } catch (RuntimeException invalidConfig) {
//                     exception = invalidConfig;
//                 } catch (Exception invalidConfig) {
//                     exception = new RuntimeException(invalidConfig);
//                 }
//             }
//             throw exception;
//         } catch (Exception e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     private static void printConfigurationFiles() throws Exception {
//         Enumeration enumeration = getClassLoader().getResources(RESOURCE_PATH);
//         List resources = new ArrayList();
//         while (enumeration.hasMoreElements()) {
//             resources.add(enumeration.nextElement());
//         }
//         log.debug("Found " + resources.size() + " resources matching '" + RESOURCE_PATH + "':");
//         for (Iterator i = resources.iterator(); i.hasNext();) {
//             log.debug("  " + ((URL) i.next()));
//         }
//     }
// 
//     private static JspCompiler loadCompilerFrom(URL resource) throws Exception {
//         Properties properties = new Properties();
//         properties.load(resource.openStream());
//         if (!properties.containsKey(CONFIGURATION_KEY)) {
//             throw new RuntimeException("Property " + CONFIGURATION_KEY + " not found from "
//                     + resource);
//         }
//         String klass = properties.getProperty(CONFIGURATION_KEY);
//         return (JspCompiler) Class.forName(klass).newInstance();
//     }
// 
//     private static ClassLoader getClassLoader() {
//         return Thread.currentThread().getContextClassLoader();
//     }
// }
// 
// Path: jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/JspExecution.java
// public interface JspExecution {
// 
//     String getRenderedResponse();
// }


import java.io.File;
import java.util.HashMap;
import java.util.Map;
import junit.framework.TestCase;
import net.sf.jsptest.assertion.OutputAssertion;
import net.sf.jsptest.compiler.api.Jsp;
import net.sf.jsptest.compiler.api.JspCompiler;
import net.sf.jsptest.compiler.api.JspCompilerFactory;
import net.sf.jsptest.compiler.api.JspExecution;
import org.apache.log4j.Logger;
/*
 * Copyright 2007 Lasse Koskela.
 * 
 * Licensed 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 net.sf.jsptest;


/**
 * An abstract base class to be extended by the user. The <tt>JspTestCase</tt> class provides a
 * facility for rendering a JSP and a set of assertion methods for verifying that the JSP under test
 * renders the expected kind of output.
 * 
 * @author Lasse Koskela
 * @author Meinert Schwartau (scwar32)
 * @author Ronaldo Webb
 */
public abstract class JspTestCase extends TestCase {

    private Logger log;
    private Map requestParameters;
    private Map requestAttributes;
    private Map sessionAttributes;
    private Map substituteTaglibs;
// Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/assertion/OutputAssertion.java
// public class OutputAssertion extends AbstractAssertion {
// 
//     private final String content;
// 
//     /**
//      * @param content
//      *            The raw output to perform assertions on.
//      */
//     public OutputAssertion(String content) {
//         this.content = content;
//     }
// 
//     /**
//      * Assert that the output should contain the given text.
//      * 
//      * @param text
//      *            The (partial) content that should be found from the output.
//      */
//     public void shouldContain(String text) {
//         String msg = "Rendered output did not contain the expected text <" + text + ">:\n"
//                 + content;
//         assertContains(msg, content, text);
//     }
// 
//     /**
//      * Assert that the output should not contain the given text.
//      * 
//      * @param text
//      *            The (partial) content that shouldn't be found from the output.
//      */
//     public void shouldNotContain(String text) {
//         String msg = "Rendered output contained unexpected text <" + text + ">:\n" + content;
//         assertDoesNotContain(msg, content, text);
//     }
// }
// 
// Path: jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/Jsp.java
// public interface Jsp {
// 
//     JspExecution request(String httpMethod, Map requestAttributes, Map sessionAttributes, Map requestParameters);
// }
// 
// Path: jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/JspCompiler.java
// public interface JspCompiler {
// 
//     Jsp compile(String path, Map taglibs);
// 
//     void setWebRoot(String directory);
// 
//     void setOutputDirectory(String directory);
// }
// 
// Path: jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/JspCompilerFactory.java
// public class JspCompilerFactory {
// 
//     private static final Logger log = Logger.getLogger(JspCompilerFactory.class);
//     private static final String RESOURCE_PATH = "jsptest.properties";
//     private static final String CONFIGURATION_KEY = "jsptest.compiler.implementation";
// 
//     public static JspCompiler newInstance() {
//         RuntimeException exception = new RuntimeException(
//                 "No JSP compiler implementation configured: " + "(configuration file "
//                         + RESOURCE_PATH + " not found from class path.");
//         try {
//             printConfigurationFiles();
//             Enumeration resources = getClassLoader().getResources(RESOURCE_PATH);
//             while (resources.hasMoreElements()) {
//                 URL resource = (URL) resources.nextElement();
//                 if (resources.hasMoreElements()
//                         && resource.toString().indexOf("test-classes") != -1) {
//                     log.debug("Ignoring " + resource + " because it's from 'test-classes' "
//                             + "and there's another matching resource available");
//                     continue;
//                 }
//                 try {
//                     return loadCompilerFrom(resource);
//                 } catch (RuntimeException invalidConfig) {
//                     exception = invalidConfig;
//                 } catch (Exception invalidConfig) {
//                     exception = new RuntimeException(invalidConfig);
//                 }
//             }
//             throw exception;
//         } catch (Exception e) {
//             throw new RuntimeException(e);
//         }
//     }
// 
//     private static void printConfigurationFiles() throws Exception {
//         Enumeration enumeration = getClassLoader().getResources(RESOURCE_PATH);
//         List resources = new ArrayList();
//         while (enumeration.hasMoreElements()) {
//             resources.add(enumeration.nextElement());
//         }
//         log.debug("Found " + resources.size() + " resources matching '" + RESOURCE_PATH + "':");
//         for (Iterator i = resources.iterator(); i.hasNext();) {
//             log.debug("  " + ((URL) i.next()));
//         }
//     }
// 
//     private static JspCompiler loadCompilerFrom(URL resource) throws Exception {
//         Properties properties = new Properties();
//         properties.load(resource.openStream());
//         if (!properties.containsKey(CONFIGURATION_KEY)) {
//             throw new RuntimeException("Property " + CONFIGURATION_KEY + " not found from "
//                     + resource);
//         }
//         String klass = properties.getProperty(CONFIGURATION_KEY);
//         return (JspCompiler) Class.forName(klass).newInstance();
//     }
// 
//     private static ClassLoader getClassLoader() {
//         return Thread.currentThread().getContextClassLoader();
//     }
// }
// 
// Path: jsptest-generic/jsptest-compiler-api/src/main/java/net/sf/jsptest/compiler/api/JspExecution.java
// public interface JspExecution {
// 
//     String getRenderedResponse();
// }


// Path: jsptest-generic/jsptest-framework/src/main/java/net/sf/jsptest/JspTestCase.java
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import junit.framework.TestCase;
import net.sf.jsptest.assertion.OutputAssertion;
import net.sf.jsptest.compiler.api.Jsp;
import net.sf.jsptest.compiler.api.JspCompiler;
import net.sf.jsptest.compiler.api.JspCompilerFactory;
import net.sf.jsptest.compiler.api.JspExecution;
import org.apache.log4j.Logger;

/*
 * Copyright 2007 Lasse Koskela.
 * 
 * Licensed 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 net.sf.jsptest;


/**
 * An abstract base class to be extended by the user. The <tt>JspTestCase</tt> class provides a
 * facility for rendering a JSP and a set of assertion methods for verifying that the JSP under test
 * renders the expected kind of output.
 * 
 * @author Lasse Koskela
 * @author Meinert Schwartau (scwar32)
 * @author Ronaldo Webb
 */
public abstract class JspTestCase extends TestCase {

    private Logger log;
    private Map requestParameters;
    private Map requestAttributes;
    private Map sessionAttributes;
    private Map substituteTaglibs;
    private JspExecution execution;