~james-page/ubuntu/natty/tomcat6/fix-662588

« back to all changes in this revision

Viewing changes to test/org/apache/jasper/compiler/TestAttributeParser.java

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2010-05-21 13:51:15 UTC
  • mfrom: (2.2.12 sid)
  • Revision ID: james.westby@ubuntu.com-20100521135115-qfwnf24lzvi3644v
Tags: 6.0.26-2
* debian/tomcat6.{postinst,prerm}: Respect TOMCAT6_USER and TOMCAT6_GROUP
  as defined in /etc/default/tomcat6 when setting directory permissions and
  authbind configuration (Closes: #581018, LP: #557300)
* debian/tomcat6.postinst: Use group "tomcat6" instead of "adm" for
  permissions in /var/lib/tomcat6, so that group "adm" doesn't get write
  permissions over /var/lib/tomcat6/webapps (LP: #569118)

Show diffs side-by-side

added added

removed removed

Lines of Context:
134
134
        // Quoting <% and %>
135
135
        assertEquals("hello <% world", evalAttr("hello <\\% world", '\"'));
136
136
        assertEquals("hello %> world", evalAttr("hello %> world", '\"'));
 
137
 
 
138
        // Test that the end of literal in EL expression is recognized in
 
139
        // parseEL(), be it quoted with single or double quotes. That is, that
 
140
        // AttributeParser correctly switches between parseLiteral and parseEL
 
141
        // methods.
 
142
        //
 
143
        // The test is based on the difference in how the '\' character is printed:
 
144
        // when in parseLiteral \\${ will be printed as ${'\'}${, but if we are still
 
145
        // inside of parseEL it will be printed as \${, thus preventing the EL
 
146
        // expression that follows from being evaluated.
 
147
        //
 
148
        assertEquals("foo\\bar\\baz", evalAttr("${\'foo\'}\\\\${\'bar\'}\\\\${\'baz\'}", '\"'));
 
149
        assertEquals("foo\\bar\\baz", evalAttr("${\'foo\'}\\\\${\\\"bar\\\"}\\\\${\'baz\'}", '\"'));
 
150
        assertEquals("foo\\bar\\baz", evalAttr("${\\\"foo\\\"}\\\\${\'bar\'}\\\\${\\\"baz\\\"}", '\"'));
 
151
        assertEquals("foo\\bar\\baz", evalAttr("${\"foo\"}\\\\${\\\'bar\\\'}\\\\${\"baz\"}", '\''));
137
152
    }
138
153
 
139
 
    public void testScriptExpressiinLiterals() {
 
154
    public void testScriptExpressionLiterals() {
140
155
        assertEquals(" \"hello world\" ", parseScriptExpression(
141
156
                " \"hello world\" ", (char) 0));
142
157
        assertEquals(" \"hello \\\"world\" ", parseScriptExpression(
149
164
        ctx.setFunctionMapper(new FMapper());
150
165
        ExpressionFactoryImpl exprFactory = new ExpressionFactoryImpl();
151
166
        ValueExpression ve = exprFactory.createValueExpression(ctx,
152
 
                AttributeParser.getUnquoted(expression, quote, false, false),
 
167
                AttributeParser.getUnquoted(expression, quote, false, false,
 
168
                        false),
153
169
                String.class);
154
170
        return (String) ve.getValue(ctx);
155
171
    }
156
172
    
157
173
    private String parseScriptExpression(String expression, char quote) {
158
 
        return AttributeParser.getUnquoted(expression, quote, false, false);
 
174
        return AttributeParser.getUnquoted(expression, quote, false, false,
 
175
                false);
159
176
    }
160
177
 
161
178
    public static class FMapper extends FunctionMapper {