ASF Bugzilla – Attachment 29774 Details for
Bug 54314
Code generation of TagPlugins: When and Otherwise error when they are used without <c:choose> outside
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Test case for Choose.java, When.java & Otherwise.java
TestWhen.java (text/plain), 3.25 KB, created by
Sheldon Shao
on 2012-12-17 07:06:22 UTC
(
hide
)
Description:
Test case for Choose.java, When.java & Otherwise.java
Filename:
MIME Type:
Creator:
Sheldon Shao
Created:
2012-12-17 07:06:22 UTC
Size:
3.25 KB
patch
obsolete
>/* > * Licensed to the Apache Software Foundation (ASF) under one or more > * contributor license agreements. See the NOTICE file distributed with > * this work for additional information regarding copyright ownership. > * The ASF licenses this file to You under the Apache License, Version 2.0 > * (the "License"); you may not use this file except in compliance with > * the License. You may obtain a copy of the License at > * > * http://www.apache.org/licenses/LICENSE-2.0 > * > * Unless required by applicable law or agreed to in writing, software > * distributed under the License is distributed on an "AS IS" BASIS, > * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > * See the License for the specific language governing permissions and > * limitations under the License. > */ >package org.apache.jasper.tagplugins.jstl.core; > >import static org.junit.Assert.assertEquals; > >import org.junit.Test; > >/** > * Test case for <c:when> & <c:otherwise> > * > * @author Sheldon Shao <xshao@ebay.com> > */ >public class TestWhen { > @Test > public void testWhen() throws Exception { > //Test no <c:choose> outside > SimpleTagPluginContext context1 = new SimpleTagPluginContext(); > > When when = new When(); > > SimpleTagPluginContext context = new SimpleTagPluginContext(); > context.setParentContext(context1); > context.addAttribute("test", "${true}"); > when.doTag(context); > > assertEquals("", context.getCode()); // "if(${true}){" before fix > > //Test with <c:choose> outside > Choose choose = new Choose(); > > SimpleTagPluginContext chooseContext = new SimpleTagPluginContext(); > context = new SimpleTagPluginContext(); > context.setParentContext(chooseContext); > context.addAttribute("test", "${true}"); > > chooseContext.addBody(when, context); > choose.doTag(chooseContext); > > assertEquals("if(${true}){}", chooseContext.getCode()); > } > > @Test > public void testOtherwise() throws Exception { > //Test no <c:choose> outside > When when = new When(); > SimpleTagPluginContext context1 = new SimpleTagPluginContext(); > context1.addAttribute("test", "${true}"); > when.doTag(context1); > > Otherwise otherwise = new Otherwise(); > SimpleTagPluginContext context2 = new SimpleTagPluginContext(); > otherwise.doTag(context2); > > assertEquals("", context1.getCode()); > assertEquals("", context2.getCode()); // "} else {" before fix > > //Test with <c:choose> outside > Choose choose = new Choose(); > > SimpleTagPluginContext chooseContext = new SimpleTagPluginContext(); > SimpleTagPluginContext whenContext = new SimpleTagPluginContext(); > > whenContext.setParentContext(chooseContext); > whenContext.addAttribute("test", "${true}"); > chooseContext.addBody(when, whenContext); > > otherwise = new Otherwise(); > SimpleTagPluginContext otherwiseContext = new SimpleTagPluginContext(); > otherwiseContext.setParentContext(chooseContext); > chooseContext.addBody(otherwise, otherwiseContext); > > choose.doTag(chooseContext); > assertEquals("if(${true}){} else {}", chooseContext.getCode()); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 54314
:
29773
| 29774