ASF Bugzilla – Attachment 29710 Details for
Bug 54242
NPE in tagPlugins:ForEach
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Test case for "ForEach"
TestForEach.java (text/plain), 2.96 KB, created by
Sheldon Shao
on 2012-12-06 06:23:05 UTC
(
hide
)
Description:
Test case for "ForEach"
Filename:
MIME Type:
Creator:
Sheldon Shao
Created:
2012-12-06 06:23:05 UTC
Size:
2.96 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.*; > >import org.apache.catalina.startup.TomcatBaseTest; >import org.junit.Test; > >public class TestForEach extends TomcatBaseTest { > > @Test > public void testBug54242() throws Exception { > ForEach forEach = new ForEach(); > > SimpleTagPluginContext context = new SimpleTagPluginContext(); > context.addAttribute("var", "testVar"); > context.addAttribute("begin", "${begin}"); > context.addAttribute("end", "${end}"); > forEach.doTag(context); > > assertEquals( > "for (int _jspx_temp0 = ${begin}; _jspx_temp0 <= ${end}; _jspx_temp0++) {_jspx_page_context.setAttribute(testVar, String.valueOf(_jspx_temp0));}", > context.getCode()); > > context = new SimpleTagPluginContext(); > context.addAttribute("items", "${items}"); > forEach.doTag(context); > > assertEquals( > "Object _jspx_temp0= ${items};Iterator _jspx_temp1 = null;if (_jspx_temp0 instanceof Object[])_jspx_temp1=toIterator((Object[])_jspx_temp0);else if (_jspx_temp0 instanceof boolean[])_jspx_temp1=toIterator((boolean[])_jspx_temp0);else if (_jspx_temp0 instanceof byte[])_jspx_temp1=toIterator((byte[])_jspx_temp0);else if (_jspx_temp0 instanceof char[])_jspx_temp1=toIterator((char[])_jspx_temp0);else if (_jspx_temp0 instanceof short[])_jspx_temp1=toIterator((short[])_jspx_temp0);else if (_jspx_temp0 instanceof int[])_jspx_temp1=toIterator((int[])_jspx_temp0);else if (_jspx_temp0 instanceof long[])_jspx_temp1=toIterator((long[])_jspx_temp0);else if (_jspx_temp0 instanceof float[])_jspx_temp1=toIterator((float[])_jspx_temp0);else if (_jspx_temp0 instanceof double[])_jspx_temp1=toIterator((double[])_jspx_temp0);else if (_jspx_temp0 instanceof Collection)_jspx_temp1=((Collection)_jspx_temp0).iterator();else if (_jspx_temp0 instanceof Iterator)_jspx_temp1=(Iterator)_jspx_temp0;else if (_jspx_temp0 instanceof Enumeration)_jspx_temp1=toIterator((Enumeration)_jspx_temp0);else if (_jspx_temp0 instanceof Map)_jspx_temp1=((Map)_jspx_temp0).entrySet().iterator();if (_jspx_temp1 != null) {while (_jspx_temp1.hasNext()){}}", > context.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 54242
:
29689
|
29709
| 29710 |
29711
|
29772