Search in sources :

Example 46 with ByteChunk

use of org.apache.tomcat.util.buf.ByteChunk in project tomcat by apache.

the class TestELInJsp method testBug51544.

@Test
public void testBug51544() throws Exception {
    getTomcatInstanceTestWebapp(false, true);
    ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug51544.jsp");
    String result = res.toString();
    assertEcho(result, "Empty list: true");
}
Also used : ByteChunk(org.apache.tomcat.util.buf.ByteChunk) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Example 47 with ByteChunk

use of org.apache.tomcat.util.buf.ByteChunk in project tomcat by apache.

the class TestELInJsp method testBug45451.

@Test
public void testBug45451() throws Exception {
    getTomcatInstanceTestWebapp(false, true);
    ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45451a.jsp");
    String result = res.toString();
    // Warning: JSP attribute escaping != Java String escaping
    assertEcho(result, "00-\\'hello world\\'");
    assertEcho(result, "01-\\'hello world\\'");
    assertEcho(result, "02-\\'hello world\\'");
    assertEcho(result, "03-\\'hello world\\'");
    res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45451b.jsp");
    result = res.toString();
    // Warning: JSP attribute escaping != Java String escaping
    // Warning: Attributes are always unescaped before passing to the EL
    //          processor
    assertEcho(result, "00-2");
    assertEcho(result, "01-${1+1}");
    assertEcho(result, "02-\\${1+1}");
    assertEcho(result, "03-\\\\${1+1}");
    assertEcho(result, "04-$500");
    // Inside an EL literal '\' is only used to escape '\', ''' and '"'
    assertEcho(result, "05-\\$");
    assertEcho(result, "06-\\${");
    assertEcho(result, "10-2");
    assertEcho(result, "11-${1+1}");
    assertEcho(result, "12-\\2");
    assertEcho(result, "13-\\${1+1}");
    assertEcho(result, "14-\\\\2");
    assertEcho(result, "15-$500");
    assertEcho(result, "16-\\$");
    assertEcho(result, "17-\\${");
    assertEcho(result, "20-2");
    assertEcho(result, "21-#{1+1}");
    assertEcho(result, "22-\\2");
    assertEcho(result, "23-\\#{1+1}");
    assertEcho(result, "24-\\\\2");
    assertEcho(result, "25-\\#");
    assertEcho(result, "26-\\#{");
    res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45451c.jsp");
    result = res.toString();
    // Warning: JSP attribute escaping != Java String escaping
    // TODO - Currently we allow a single unescaped \ in attribute values
    //        Review if this should cause a warning/error
    assertEcho(result, "00-${1+1}");
    assertEcho(result, "01-\\${1+1}");
    assertEcho(result, "02-\\\\${1+1}");
    assertEcho(result, "03-\\\\\\${1+1}");
    assertEcho(result, "04-\\$500");
    assertEcho(result, "10-${1+1}");
    assertEcho(result, "11-\\${1+1}");
    assertEcho(result, "12-\\${1+1}");
    assertEcho(result, "13-\\\\${1+1}");
    assertEcho(result, "14-\\\\${1+1}");
    assertEcho(result, "15-\\$500");
    assertEcho(result, "20-#{1+1}");
    assertEcho(result, "21-\\#{1+1}");
    assertEcho(result, "22-\\#{1+1}");
    assertEcho(result, "23-\\\\#{1+1}");
    assertEcho(result, "24-\\\\#{1+1}");
    res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45451d.jspx");
    result = res.toString();
    // Warning: JSP attribute escaping != Java String escaping
    // \\ Is *not* an escape sequence in XML attributes
    assertEcho(result, "00-2");
    assertEcho(result, "01-${1+1}");
    assertEcho(result, "02-\\${1+1}");
    assertEcho(result, "03-\\\\${1+1}");
    assertEcho(result, "04-$500");
    assertEcho(result, "10-2");
    assertEcho(result, "11-${1+1}");
    assertEcho(result, "12-\\${1+1}");
    assertEcho(result, "13-\\\\${1+1}");
    assertEcho(result, "14-\\\\\\${1+1}");
    assertEcho(result, "15-$500");
    assertEcho(result, "20-2");
    assertEcho(result, "21-#{1+1}");
    assertEcho(result, "22-\\#{1+1}");
    assertEcho(result, "23-\\\\#{1+1}");
    assertEcho(result, "24-\\\\\\#{1+1}");
    res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45451e.jsp");
    result = res.toString();
    // Warning: JSP attribute escaping != Java String escaping
    // Warning: Attributes are always unescaped before passing to the EL
    //          processor
    assertEcho(result, "00-2");
    assertEcho(result, "01-${1+1}");
    assertEcho(result, "02-\\${1+1}");
    assertEcho(result, "03-\\\\${1+1}");
    assertEcho(result, "04-$500");
    assertEcho(result, "10-2");
    assertEcho(result, "11-${1+1}");
    assertEcho(result, "12-\\2");
    assertEcho(result, "13-\\${1+1}");
    assertEcho(result, "14-\\\\2");
    assertEcho(result, "15-$500");
    assertEcho(result, "20-#{1+1}");
    assertEcho(result, "21-\\#{1+1}");
    assertEcho(result, "22-\\#{1+1}");
    assertEcho(result, "23-\\\\#{1+1}");
    assertEcho(result, "24-\\\\#{1+1}");
}
Also used : ByteChunk(org.apache.tomcat.util.buf.ByteChunk) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Example 48 with ByteChunk

use of org.apache.tomcat.util.buf.ByteChunk in project tomcat by apache.

the class TestELInJsp method testBug57141.

/*
     * java.lang should be imported by default
     */
@Test
public void testBug57141() throws Exception {
    getTomcatInstanceTestWebapp(false, true);
    ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug57141.jsp");
    String result = res.toString();
    assertEcho(result, "00-true");
    assertEcho(result, "01-false");
    assertEcho(result, "02-2147483647");
}
Also used : ByteChunk(org.apache.tomcat.util.buf.ByteChunk) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Example 49 with ByteChunk

use of org.apache.tomcat.util.buf.ByteChunk in project tomcat by apache.

the class TestELInJsp method testScriptingExpression.

@Test
public void testScriptingExpression() throws Exception {
    getTomcatInstanceTestWebapp(false, true);
    ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/script-expr.jsp");
    String result = res.toString();
    assertEcho(result, "00-hello world");
    assertEcho(result, "01-hello \"world");
    assertEcho(result, "02-hello \\\"world");
    assertEcho(result, "03-hello ${world");
    assertEcho(result, "04-hello \\${world");
    assertEcho(result, "05-hello world");
    assertEcho(result, "06-hello \"world");
    assertEcho(result, "07-hello \\\"world");
    assertEcho(result, "08-hello ${world");
    assertEcho(result, "09-hello \\${world");
    assertEcho(result, "10-hello <% world");
    assertEcho(result, "11-hello %> world");
}
Also used : ByteChunk(org.apache.tomcat.util.buf.ByteChunk) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Example 50 with ByteChunk

use of org.apache.tomcat.util.buf.ByteChunk in project tomcat by apache.

the class TestELInJsp method testBug45511.

@Test
public void testBug45511() throws Exception {
    getTomcatInstanceTestWebapp(false, true);
    ByteChunk res = getUrl("http://localhost:" + getPort() + "/test/bug45nnn/bug45511.jsp");
    String result = res.toString();
    assertEcho(result, "00-true");
    assertEcho(result, "01-false");
}
Also used : ByteChunk(org.apache.tomcat.util.buf.ByteChunk) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Aggregations

ByteChunk (org.apache.tomcat.util.buf.ByteChunk)274 Test (org.junit.Test)201 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)180 Tomcat (org.apache.catalina.startup.Tomcat)129 Context (org.apache.catalina.Context)98 File (java.io.File)49 List (java.util.List)48 AsyncContext (javax.servlet.AsyncContext)40 HashMap (java.util.HashMap)35 Wrapper (org.apache.catalina.Wrapper)22 StandardContext (org.apache.catalina.core.StandardContext)21 ArrayList (java.util.ArrayList)20 TesterContext (org.apache.tomcat.unittest.TesterContext)18 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)16 ServletRequestWrapper (javax.servlet.ServletRequestWrapper)13 ServletResponseWrapper (javax.servlet.ServletResponseWrapper)13 ServletContext (javax.servlet.ServletContext)10 WsContextListener (org.apache.tomcat.websocket.server.WsContextListener)10 TesterAccessLogValve (org.apache.catalina.valves.TesterAccessLogValve)9 InitialContext (javax.naming.InitialContext)8