// 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;
//     }
// 
// 
// }


import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import io.undertow.jsp.HackInstanceManager;
import io.undertow.jsp.JspServletBuilder;
import io.undertow.server.handlers.PathHandler;
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.servlet.test.util.TestResourceLoader;
import io.undertow.testutils.DefaultServer;
import io.undertow.testutils.HttpClientUtils;
import io.undertow.testutils.TestHttpClient;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.jasper.deploy.FunctionInfo;
import org.apache.jasper.deploy.JspPropertyGroup;
import org.apache.jasper.deploy.TagLibraryInfo;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
        bugTld.setTlibversion("1.1");
        FunctionInfo functionInfo = new FunctionInfo();
        functionInfo.setName("dummy");
        functionInfo.setFunctionSignature("java.lang.Runtime getRuntime()");
        functionInfo.setFunctionClass("java.lang.Runtime");
        bugTld.addFunctionInfo(functionInfo);
        tags.put("/bug.tld", bugTld);

        JspServletBuilder.setupDeployment(builder, new HashMap<String, JspPropertyGroup>(), tags, new HackInstanceManager());

        DeploymentManager manager = container.addDeployment(builder);
        manager.deploy();
        servletPath.addPrefixPath(builder.getContextPath(), manager.start());

        DefaultServer.setRootHandler(servletPath);
    }



    @Test
    public void testSimpleHttpServlet() throws IOException {
        TestHttpClient client = new TestHttpClient();
        try {
            HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/test.jsp");
            get.setConfig(RequestConfig.custom().setConnectTimeout(5* 60 * 1000)
                    .setSocketTimeout(5 * 60 * 1000).build());
            HttpResponse result = client.execute(get);
            Assert.assertEquals(200, result.getStatusLine().getStatusCode());
            final String response = HttpClientUtils.readResponse(result);
            Assert.assertTrue(response.contains("java.lang.Runtime"));
// 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/io/undertow/test/jsp/taglib/TagLibJspTestCase.java
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import io.undertow.jsp.HackInstanceManager;
import io.undertow.jsp.JspServletBuilder;
import io.undertow.server.handlers.PathHandler;
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.servlet.test.util.TestResourceLoader;
import io.undertow.testutils.DefaultServer;
import io.undertow.testutils.HttpClientUtils;
import io.undertow.testutils.TestHttpClient;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.jasper.deploy.FunctionInfo;
import org.apache.jasper.deploy.JspPropertyGroup;
import org.apache.jasper.deploy.TagLibraryInfo;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;

        bugTld.setTlibversion("1.1");
        FunctionInfo functionInfo = new FunctionInfo();
        functionInfo.setName("dummy");
        functionInfo.setFunctionSignature("java.lang.Runtime getRuntime()");
        functionInfo.setFunctionClass("java.lang.Runtime");
        bugTld.addFunctionInfo(functionInfo);
        tags.put("/bug.tld", bugTld);

        JspServletBuilder.setupDeployment(builder, new HashMap<String, JspPropertyGroup>(), tags, new HackInstanceManager());

        DeploymentManager manager = container.addDeployment(builder);
        manager.deploy();
        servletPath.addPrefixPath(builder.getContextPath(), manager.start());

        DefaultServer.setRootHandler(servletPath);
    }



    @Test
    public void testSimpleHttpServlet() throws IOException {
        TestHttpClient client = new TestHttpClient();
        try {
            HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/test.jsp");
            get.setConfig(RequestConfig.custom().setConnectTimeout(5* 60 * 1000)
                    .setSocketTimeout(5 * 60 * 1000).build());
            HttpResponse result = client.execute(get);
            Assert.assertEquals(200, result.getStatusLine().getStatusCode());
            final String response = HttpClientUtils.readResponse(result);
            Assert.assertTrue(response.contains("java.lang.Runtime"));
        } finally {