Java Code Examples for org.apache.catalina.core.StandardContext#setAliases()

The following examples show how to use org.apache.catalina.core.StandardContext#setAliases() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestELInJsp.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug56029() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(
            null, "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56029.jspx");

    String result = res.toString();

    Assert.assertTrue(result.contains("[1]:[1]"));
}
 
Example 2
Source File: TestELInJsp.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug56147() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctx = (StandardContext) tomcat.addWebapp(
            null, "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctx.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56147.jsp");

    String result = res.toString();
    assertEcho(result, "00-OK");
}
 
Example 3
Source File: TestGenerator.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug48701Fail() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir =
        new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
            "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    int rc = getUrl("http://localhost:" + getPort() +
            "/test/bug48nnn/bug48701-fail.jsp", new ByteChunk(), null);

    assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, rc);
}
 
Example 4
Source File: TestCompositeELResolver.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug50408() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir =  new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
            "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    int rc = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug50408.jsp", new ByteChunk(), null);

    assertEquals(HttpServletResponse.SC_OK, rc);
}
 
Example 5
Source File: TestELInJsp.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug56029() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(
            null, "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56029.jspx");

    String result = res.toString();

    Assert.assertTrue(result.contains("[1]:[1]"));
}
 
Example 6
Source File: TestELInJsp.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug56147() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctx = (StandardContext) tomcat.addWebapp(
            null, "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctx.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56147.jsp");

    String result = res.toString();
    assertEcho(result, "00-OK");
}
 
Example 7
Source File: TestGenerator.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug48701Fail() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir =
        new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
            "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    int rc = getUrl("http://localhost:" + getPort() +
            "/test/bug48nnn/bug48701-fail.jsp", new ByteChunk(), null);

    assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, rc);
}
 
Example 8
Source File: TestCompositeELResolver.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
@Test
public void testBug50408() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir =  new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
            "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    int rc = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug50408.jsp", new ByteChunk(), null);

    assertEquals(HttpServletResponse.SC_OK, rc);
}
 
Example 9
Source File: TestParser.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
@Test
public void testBug56265() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
            "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56265.jsp");

    String result = res.toString();

    Assert.assertTrue(result,
            result.contains("[1: [data-test]: [window.alert('Hello World <&>!')]]"));
    Assert.assertTrue(result,
            result.contains("[2: [data-test]: [window.alert('Hello World <&>!')]]"));
    Assert.assertTrue(result,
            result.contains("[3: [data-test]: [window.alert('Hello 'World <&>'!')]]"));
    Assert.assertTrue(result,
            result.contains("[4: [data-test]: [window.alert('Hello 'World <&>'!')]]"));
}
 
Example 10
Source File: TestParser.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
@Test
public void testBug56265() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
            "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56265.jsp");

    String result = res.toString();

    Assert.assertTrue(result,
            result.contains("[1: [data-test]: [window.alert('Hello World <&>!')]]"));
    Assert.assertTrue(result,
            result.contains("[2: [data-test]: [window.alert('Hello World <&>!')]]"));
    Assert.assertTrue(result,
            result.contains("[3: [data-test]: [window.alert('Hello 'World <&>'!')]]"));
    Assert.assertTrue(result,
            result.contains("[4: [data-test]: [window.alert('Hello 'World <&>'!')]]"));
}
 
Example 11
Source File: TestJspContextWrapper.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Test
public void testELTagFilePageContext() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(
            null, "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();
    
    ByteChunk out = new ByteChunk();

    int rc = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug58178.jsp", out, null);

    Assert.assertEquals(HttpServletResponse.SC_OK, rc);

    String result = out.toString();

    Assert.assertTrue(result, result.contains("PASS"));
}
 
Example 12
Source File: TestParser.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Test
public void testBug56334And56561() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
            "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56334and56561.jspx");

    String result = res.toString();

    // NOTE: The expected values must themselves be \ escaped below
    Assert.assertTrue(result, result.contains("01a\\?resize01a"));
    Assert.assertTrue(result, result.contains("01b\\\\x\\?resize01b"));
    Assert.assertTrue(result, result.contains("<set data-value=\"02a\\\\?resize02a\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"02b\\\\\\\\x\\\\?resize02b\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"03a\\?resize03a\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"03b\\\\x\\?resize03b\"/>"));
    Assert.assertTrue(result, result.contains("<04a\\?resize04a/>"));
    Assert.assertTrue(result, result.contains("<04b\\\\x\\?resize04b/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"05a$${&amp;\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"05b$${&amp;2\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"05c##{&gt;hello&lt;\"/>"));
    Assert.assertTrue(result, result.contains("05x:<set data-value=\"\"/>"));
    Assert.assertTrue(result, result.contains("<set xmlns:foo=\"urn:06a\\bar\\baz\"/>"));
    Assert.assertTrue(result, result.contains("07a:<set data-value=\"\\?resize\"/>"));
    Assert.assertTrue(result, result.contains("07b:<set data-content=\"\\?resize=.+\"/>"));
    Assert.assertTrue(result, result.contains("07c:<set data-content=\"\\?resize=.+\"/>"));
    Assert.assertTrue(result, result.contains("07d:<set data-content=\"false\"/>"));
    Assert.assertTrue(result, result.contains("07e:<set data-content=\"false\"/>"));
    Assert.assertTrue(result, result.contains("07f:<set data-content=\"\\\'something\'\"/>"));
    Assert.assertTrue(result, result.contains("07g:<set data-content=\"\\\'something\'\"/>"));
}
 
Example 13
Source File: TestJspContextWrapper.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Test
public void testELTagFilePageContext() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(
            null, "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();
    
    ByteChunk out = new ByteChunk();

    int rc = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug58178.jsp", out, null);

    Assert.assertEquals(HttpServletResponse.SC_OK, rc);

    String result = out.toString();

    Assert.assertTrue(result, result.contains("PASS"));
}
 
Example 14
Source File: TestParser.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Test
public void testBug56334And56561() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
            "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56334and56561.jspx");

    String result = res.toString();

    // NOTE: The expected values must themselves be \ escaped below
    Assert.assertTrue(result, result.contains("01a\\?resize01a"));
    Assert.assertTrue(result, result.contains("01b\\\\x\\?resize01b"));
    Assert.assertTrue(result, result.contains("<set data-value=\"02a\\\\?resize02a\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"02b\\\\\\\\x\\\\?resize02b\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"03a\\?resize03a\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"03b\\\\x\\?resize03b\"/>"));
    Assert.assertTrue(result, result.contains("<04a\\?resize04a/>"));
    Assert.assertTrue(result, result.contains("<04b\\\\x\\?resize04b/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"05a$${&amp;\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"05b$${&amp;2\"/>"));
    Assert.assertTrue(result, result.contains("<set data-value=\"05c##{&gt;hello&lt;\"/>"));
    Assert.assertTrue(result, result.contains("05x:<set data-value=\"\"/>"));
    Assert.assertTrue(result, result.contains("<set xmlns:foo=\"urn:06a\\bar\\baz\"/>"));
    Assert.assertTrue(result, result.contains("07a:<set data-value=\"\\?resize\"/>"));
    Assert.assertTrue(result, result.contains("07b:<set data-content=\"\\?resize=.+\"/>"));
    Assert.assertTrue(result, result.contains("07c:<set data-content=\"\\?resize=.+\"/>"));
    Assert.assertTrue(result, result.contains("07d:<set data-content=\"false\"/>"));
    Assert.assertTrue(result, result.contains("07e:<set data-content=\"false\"/>"));
    Assert.assertTrue(result, result.contains("07f:<set data-content=\"\\\'something\'\"/>"));
    Assert.assertTrue(result, result.contains("07g:<set data-content=\"\\\'something\'\"/>"));
}