// Path: src/main/java/io/undertow/jsp/JspServletBuilder.java
// public class JspServletBuilder {
// 
// 
//     public static void setupDeployment(final DeploymentInfo deploymentInfo, final Map<String, ? extends JspPropertyGroupDescriptor> propertyGroups, final Map<String, TagLibraryInfo> tagLibraries, final InstanceManager instanceManager) {
//         deploymentInfo.addServletContextAttribute(SERVLET_VERSION, deploymentInfo.getMajorVersion() + "." + deploymentInfo.getMinorVersion());
//         deploymentInfo.addServletContextAttribute(JSP_PROPERTY_GROUPS, propertyGroups);
//         deploymentInfo.addServletContextAttribute(JSP_TAG_LIBRARIES, tagLibraries);
//         deploymentInfo.addServletContextAttribute(InstanceManager.class.getName(), instanceManager);
//         deploymentInfo.setJspConfigDescriptor(new JspConfigDescriptor() {
//             @Override
//             public Collection<TaglibDescriptor> getTaglibs() {
//                 return null;
//             }
// 
//             @Override
//             public Collection<JspPropertyGroupDescriptor> getJspPropertyGroups() {
//                 return (Collection<JspPropertyGroupDescriptor>) propertyGroups.values();
//             }
//         });
//     }
// 
//     public static ServletInfo createServlet(final String name, final String path) {
//         ServletInfo servlet = new ServletInfo(name, JspServlet.class);
//         servlet.addMapping(path);
//         //if the JSP servlet is mapped to a path that ends in /*
//         //we want to perform welcome file matches if the directory is requested
//         servlet.setRequireWelcomeFileMapping(true);
//         return servlet;
//     }
// 
// 
// }
// 
// Path: src/test/java/org/apache/tomcat/util/buf/ByteChunk.java
// public final class ByteChunk {
// 
//     private final StringBuilder content;
// 
// 
//     public ByteChunk(String content) {
//         this.content = new StringBuilder(content);
//     }
// 
//     public ByteChunk() {
//         this.content = new StringBuilder();
//     }
// 
//     @Override
//     public String toString() {
//         return content.toString();
//     }
// 
//     public void write(String content) {
//         this.content.append(content);
//     }
// 
//     public void recycle() {
//         content.setLength(0);
//     }
// 
//     public String toStringInternal() {
//         return toString();
//     }
// 
// }


import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import io.undertow.jsp.HackInstanceManager;
import io.undertow.jsp.JspServletBuilder;
import io.undertow.server.handlers.PathHandler;
import io.undertow.server.handlers.resource.PathResourceManager;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.DeploymentManager;
import io.undertow.servlet.api.ServletContainer;
import io.undertow.servlet.test.util.TestClassIntrospector;
import io.undertow.testutils.AjpIgnore;
import io.undertow.testutils.DefaultServer;
import io.undertow.testutils.HttpClientUtils;
import io.undertow.testutils.HttpOneOnly;
import io.undertow.testutils.HttpsIgnore;
import io.undertow.testutils.TestHttpClient;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.jasper.deploy.FunctionInfo;
import org.apache.jasper.deploy.JspPropertyGroup;
import org.apache.jasper.deploy.TagAttributeInfo;
import org.apache.jasper.deploy.TagFileInfo;
import org.apache.jasper.deploy.TagInfo;
import org.apache.jasper.deploy.TagLibraryInfo;
import org.apache.jasper.deploy.TagLibraryValidatorInfo;
import org.apache.jasper.deploy.TagVariableInfo;
import org.apache.tomcat.util.buf.ByteChunk;
import org.jboss.annotation.javaee.Icon;
import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData;
import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.parser.jsp.TldMetaDataParser;
import org.jboss.metadata.web.spec.AttributeMetaData;
import org.jboss.metadata.web.spec.FunctionMetaData;
import org.jboss.metadata.web.spec.TagFileMetaData;
import org.jboss.metadata.web.spec.TagMetaData;
import org.jboss.metadata.web.spec.TldMetaData;
import org.jboss.metadata.web.spec.VariableMetaData;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
package io.undertow.test;



/**
 * @author Tomaz Cerar (c) 2017 Red Hat Inc.
 * This class is just a substition class for TomcatBaseTest from tomcat codebase but adapted to work with undertow & jastow.
 */
@RunWith(DefaultServer.class)
@HttpOneOnly
@HttpsIgnore
@AjpIgnore
public abstract class TomcatBaseTest {

    @BeforeClass
    public static void setUp() throws Exception {

        final PathHandler servletPath = new PathHandler();
        final ServletContainer container = ServletContainer.Factory.newInstance();

        Path root = Paths.get(Thread.currentThread().getContextClassLoader().getResource("webapp").toURI());
        DeploymentInfo builder = new DeploymentInfo()
                .setClassLoader(TomcatBaseTest.class.getClassLoader())
                .setContextPath("/test")
                .setClassIntrospecter(TestClassIntrospector.INSTANCE)
                .setDeploymentName("test.war")
                .setResourceManager(new PathResourceManager(root))
// Path: src/main/java/io/undertow/jsp/JspServletBuilder.java
// public class JspServletBuilder {
// 
// 
//     public static void setupDeployment(final DeploymentInfo deploymentInfo, final Map<String, ? extends JspPropertyGroupDescriptor> propertyGroups, final Map<String, TagLibraryInfo> tagLibraries, final InstanceManager instanceManager) {
//         deploymentInfo.addServletContextAttribute(SERVLET_VERSION, deploymentInfo.getMajorVersion() + "." + deploymentInfo.getMinorVersion());
//         deploymentInfo.addServletContextAttribute(JSP_PROPERTY_GROUPS, propertyGroups);
//         deploymentInfo.addServletContextAttribute(JSP_TAG_LIBRARIES, tagLibraries);
//         deploymentInfo.addServletContextAttribute(InstanceManager.class.getName(), instanceManager);
//         deploymentInfo.setJspConfigDescriptor(new JspConfigDescriptor() {
//             @Override
//             public Collection<TaglibDescriptor> getTaglibs() {
//                 return null;
//             }
// 
//             @Override
//             public Collection<JspPropertyGroupDescriptor> getJspPropertyGroups() {
//                 return (Collection<JspPropertyGroupDescriptor>) propertyGroups.values();
//             }
//         });
//     }
// 
//     public static ServletInfo createServlet(final String name, final String path) {
//         ServletInfo servlet = new ServletInfo(name, JspServlet.class);
//         servlet.addMapping(path);
//         //if the JSP servlet is mapped to a path that ends in /*
//         //we want to perform welcome file matches if the directory is requested
//         servlet.setRequireWelcomeFileMapping(true);
//         return servlet;
//     }
// 
// 
// }
// 
// Path: src/test/java/org/apache/tomcat/util/buf/ByteChunk.java
// public final class ByteChunk {
// 
//     private final StringBuilder content;
// 
// 
//     public ByteChunk(String content) {
//         this.content = new StringBuilder(content);
//     }
// 
//     public ByteChunk() {
//         this.content = new StringBuilder();
//     }
// 
//     @Override
//     public String toString() {
//         return content.toString();
//     }
// 
//     public void write(String content) {
//         this.content.append(content);
//     }
// 
//     public void recycle() {
//         content.setLength(0);
//     }
// 
//     public String toStringInternal() {
//         return toString();
//     }
// 
// }


// Path: src/test/java/io/undertow/test/TomcatBaseTest.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.descriptor.JspPropertyGroupDescriptor;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import io.undertow.jsp.HackInstanceManager;
import io.undertow.jsp.JspServletBuilder;
import io.undertow.server.handlers.PathHandler;
import io.undertow.server.handlers.resource.PathResourceManager;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.servlet.api.DeploymentManager;
import io.undertow.servlet.api.ServletContainer;
import io.undertow.servlet.test.util.TestClassIntrospector;
import io.undertow.testutils.AjpIgnore;
import io.undertow.testutils.DefaultServer;
import io.undertow.testutils.HttpClientUtils;
import io.undertow.testutils.HttpOneOnly;
import io.undertow.testutils.HttpsIgnore;
import io.undertow.testutils.TestHttpClient;
import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.jasper.deploy.FunctionInfo;
import org.apache.jasper.deploy.JspPropertyGroup;
import org.apache.jasper.deploy.TagAttributeInfo;
import org.apache.jasper.deploy.TagFileInfo;
import org.apache.jasper.deploy.TagInfo;
import org.apache.jasper.deploy.TagLibraryInfo;
import org.apache.jasper.deploy.TagLibraryValidatorInfo;
import org.apache.jasper.deploy.TagVariableInfo;
import org.apache.tomcat.util.buf.ByteChunk;
import org.jboss.annotation.javaee.Icon;
import org.jboss.metadata.javaee.spec.DescriptionGroupMetaData;
import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.parser.jsp.TldMetaDataParser;
import org.jboss.metadata.web.spec.AttributeMetaData;
import org.jboss.metadata.web.spec.FunctionMetaData;
import org.jboss.metadata.web.spec.TagFileMetaData;
import org.jboss.metadata.web.spec.TagMetaData;
import org.jboss.metadata.web.spec.TldMetaData;
import org.jboss.metadata.web.spec.VariableMetaData;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;

package io.undertow.test;



/**
 * @author Tomaz Cerar (c) 2017 Red Hat Inc.
 * This class is just a substition class for TomcatBaseTest from tomcat codebase but adapted to work with undertow & jastow.
 */
@RunWith(DefaultServer.class)
@HttpOneOnly
@HttpsIgnore
@AjpIgnore
public abstract class TomcatBaseTest {

    @BeforeClass
    public static void setUp() throws Exception {

        final PathHandler servletPath = new PathHandler();
        final ServletContainer container = ServletContainer.Factory.newInstance();

        Path root = Paths.get(Thread.currentThread().getContextClassLoader().getResource("webapp").toURI());
        DeploymentInfo builder = new DeploymentInfo()
                .setClassLoader(TomcatBaseTest.class.getClassLoader())
                .setContextPath("/test")
                .setClassIntrospecter(TestClassIntrospector.INSTANCE)
                .setDeploymentName("test.war")
                .setResourceManager(new PathResourceManager(root))
                .addServlet(JspServletBuilder.createServlet("Default Jsp Servlet", "*.jsp").addMapping("*.jspx"));