Just to followup and report success: The CVS version of StrutsTestCase 
fixed the problem.

Thanks Deryl and Donald!

        Erik


Erik Hatcher wrote:
> All the necessary troubleshooting details were in my original e-mail. If 
> you have specific questions about it, by all means ask.  It would be 
> very time prohibitive for me to zip up my entire development environment 
> on this one.
> 
> The question is: does Struts or StrutsTestCase maintain an 
> Iterator/Enumeration that is active?  If so, where and why?
> 
>     Erik
> 
> 
> micael wrote:
> 
>> Can you zip up your code and the stack trace?  I wouldn't mind looking 
>> at this anyway, aside from the pressing issue.
>>
>> At 09:25 PM 9/13/2002 -0400, you wrote:
>>
>>> If you look at the stack trace though, its in the StrutsTestCase 
>>> code, not mine.  It happens when looping through the application 
>>> scope keys to   initialize the ActionServlet somehow.
>>>
>>> So, is Struts storing an interator somewhere that its leaving open?  
>>> Or is StrutsTestCase?  I haven't dug that far yet, and figured 
>>> soliciting input from the list would be a good way to get more eyes 
>>> looking into this.
>>>
>>>         Erik
>>>
>>>
>>> micael wrote:
>>>
>>>> Concurrent modification exceptions are thrown when A LIST IS 
>>>> MODIFIED WHILE AN INTERATOR IS IN USE.  You can get some good 
>>>> information on this at pp. 133 ff. of John Zukowski's "Java 
>>>> Collections".  I did not look at your code closely, but I am sure 
>>>> you will see it right away.  A gross example John offers is:
>>>> List list = new ArrayList(Arrays.asList(args));  // args from main()
>>>> Iterator i = list.iterator();
>>>> while(i.hasNext()) {
>>>>   System.out.println(i.next());
>>>>   list.add("Add");
>>>> }
>>>> Hope this helps.
>>>> At 07:47 PM 9/13/2002 -0400, you wrote:
>>>>
>>>>
>>>>> Erik -
>>>>>
>>>>> I'm not sure what may be causing the error, but I was wondering - 
>>>>> have you
>>>>> used this code in the past or are you just developing it now? It looks
>>>>> great.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Erik Hatcher <[EMAIL PROTECTED]> on 09/13/2002 
>>>>> 07:16:36
>>>>> PM
>>>>>
>>>>> Please respond to "Struts Developers List" 
>>>>> <[EMAIL PROTECTED]>
>>>>>
>>>>> To:    [EMAIL PROTECTED]
>>>>> cc:     (bcc: Kevin Bedell/Systems/USHO/SunLife)
>>>>> Subject:    StrutsTestCase / Struts 1.1b2 / Cactus -
>>>>>        ConcurrentModificationException
>>>>>
>>>>>
>>>>> I'm using Struts 1.1b2 and StrutsTestCase 1.1 for Servlet 2.3 spec.
>>>>>
>>>>> Trying to run a second test case I'm getting whats immediately below.
>>>>> Any ideas on what is going wrong?  I'm fairly certain its not my test
>>>>> case code or base test case additions to StrutsTestCase, but perhaps
>>>>> some nasty interaction with StrutsTestCase and Struts?
>>>>>
>>>>>
>>>>> 15:27:09,353 ERROR [STDERR] java.util.ConcurrentModificationException
>>>>> 15:27:09,363 ERROR [STDERR]     at
>>>>> java.util.HashMap$HashIterator.next(HashMap.j
>>>>> ava:731)
>>>>> 15:27:09,363 ERROR [STDERR]     at
>>>>> org.apache.catalina.util.Enumerator.nextEleme
>>>>> nt(Enumerator.java:166)
>>>>> 15:27:09,373 ERROR [STDERR]     at
>>>>> servletunit.struts.CactusStrutsTestCase.getAc
>>>>> tionServlet(CactusStrutsTestCase.java:285)
>>>>> 15:27:09,373 ERROR [STDERR]     at
>>>>> servletunit.struts.CactusStrutsTestCase.actio
>>>>> nPerform(CactusStrutsTestCase.java:349)
>>>>> 15:27:09,383 ERROR [STDERR]     at
>>>>> edu.darden.alumni.contactinfo.ContactInfoTest
>>>>> .testSaveContactInfo(ContactInfoTest.java:17)
>>>>> 15:27:09,393 ERROR [STDERR]     at
>>>>> java.lang.reflect.Method.invoke(Native Method
>>>>> )
>>>>> 15:27:09,403 ERROR [STDERR]     at
>>>>> org.apache.cactus.AbstractTestCase.runServerT
>>>>> est(AbstractTestCase.java:332)
>>>>>
>>>>> My test case looks like this:
>>>>>
>>>>> public class ContactInfoTest extends StrutsFormTestCase {
>>>>>       public void beginSaveContactInfo(WebRequest theRequest) {
>>>>>           theRequest.setAuthentication(
>>>>>                   new BasicAuthentication("alumni", "alumni"));
>>>>>       }
>>>>>       public void testSaveContactInfo() throws Exception {
>>>>>           setRequestPathInfo("/alumni/updateContactInfo");
>>>>>           ContactInfoForm form = new ContactInfoForm();
>>>>>           form.reset();  // my ValidatorForm subclass forces this 
>>>>> method
>>>>> to exist
>>>>>           addToParameters(form);
>>>>>           actionPerform();
>>>>>           verifyForward("success");
>>>>>       }
>>>>>
>>>>>       public ContactInfoTest(String s) {
>>>>>           super(s);
>>>>>       }
>>>>> }
>>>>>
>>>>>
>>>>> And my base test case is below.  This could be considered a donation to
>>>>> the StrutsTestCase project, actually, although it needs to be
>>>>> generalized a bit more.  It adds the ability to just set up a form bean
>>>>> rather than HTTP request parameters (and convert a bean to request
>>>>> parameters under the covers).  One note: I have a BaseForm that all my
>>>>> Struts forms extend from and I've hidden the original method (made it
>>>>> final) and proxy that to the reset() method that all our forms are
>>>>> required to implement (I've yet to need the request or mapping in a
>>>>> reset method, so I took it away from implementers for now).
>>>>>
>>>>>
>>>>>
>>>>> package edu.darden.alumni.cactus;
>>>>>
>>>>> import servletunit.struts.CactusStrutsTestCase;
>>>>>
>>>>> import java.util.List;
>>>>> import java.util.ArrayList;
>>>>> import java.util.Map;
>>>>> import java.util.HashMap;
>>>>> import java.util.Iterator;
>>>>> import java.lang.reflect.InvocationTargetException;
>>>>>
>>>>> import org.apache.commons.beanutils.PropertyUtils;
>>>>> import org.apache.struts.action.ActionForm;
>>>>>
>>>>> abstract public class StrutsFormTestCase extends CactusStrutsTestCase {
>>>>>       private static final List invisibleFields = new ArrayList();
>>>>>       private static final List basicFields = new ArrayList();
>>>>>
>>>>>       static {
>>>>>           invisibleFields.add("multipartRequestHandler");
>>>>>           invisibleFields.add("resultValueMap");
>>>>>           invisibleFields.add("class");
>>>>>           invisibleFields.add("validatorResults");
>>>>>           invisibleFields.add("servletWrapper");
>>>>>
>>>>>           basicFields.add("java.lang.Integer");
>>>>>           basicFields.add("java.lang.String");
>>>>>           basicFields.add("java.lang.Boolean");
>>>>>       }
>>>>>
>>>>>       private final Map getBeanMap(Object bean, String prefix) throws
>>>>> IllegalAccessException, InvocationTargetException, 
>>>>> NoSuchMethodException
>>>>> {
>>>>>           String thisPrefix = prefix == null ? "" : prefix + ".";
>>>>>           Map map = new HashMap();
>>>>>           Map flatFields = PropertyUtils.describe(bean);
>>>>>           Iterator iterator = flatFields.keySet().iterator();
>>>>>           while (iterator.hasNext()) {
>>>>>               String key = (String) iterator.next();
>>>>>               if (invisibleFields.contains(key)) {
>>>>>                   continue;
>>>>>               }
>>>>>
>>>>>               Object value = flatFields.get(key);
>>>>>
>>>>>               if ((value != null) && !
>>>>> basicFields.contains(value.getClass().getName())) {
>>>>>                   map.putAll(getBeanMap(value, thisPrefix + key));
>>>>>               }
>>>>>               else {
>>>>>                   map.put(thisPrefix + key, value);
>>>>>               }
>>>>>           }
>>>>>           return map;
>>>>>       }
>>>>>
>>>>>       /**
>>>>>        * @todo Add checks for boolean/Boolean and set to "on" or 
>>>>> omit if
>>>>> false
>>>>>        */
>>>>>       private final void addToParameters(Map map) {
>>>>>           Iterator iterator = map.keySet().iterator();
>>>>>           while (iterator.hasNext()) {
>>>>>               String key = (String) iterator.next();
>>>>>               Object value = map.get(key);
>>>>>               String paramValue = "";
>>>>>               if (value != null) {
>>>>>                   paramValue = value.toString();
>>>>>               }
>>>>>               System.out.println("key = " + key + " value = " +
>>>>> paramValue);
>>>>>               addRequestParameter(key, paramValue);
>>>>>           }
>>>>>       }
>>>>>
>>>>>       protected final void addToParameters(ActionForm form) throws
>>>>> Exception {
>>>>>           addToParameters(getBeanMap(form, null));
>>>>>       }
>>>>>
>>>>>       public StrutsFormTestCase(String name) {
>>>>>           super(name);
>>>>>       }
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> To unsubscribe, e-mail:
>>>>> <mailto:[EMAIL PROTECTED]>
>>>>> For additional commands, e-mail: 
>>>>> <mailto:[EMAIL PROTECTED]>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------------
>>>>> This e-mail message (including attachments, if any) is intended for 
>>>>> the use
>>>>> of the individual or entity to which it is addressed and may contain
>>>>> information that is privileged, proprietary , confidential and 
>>>>> exempt from
>>>>> disclosure.  If you are not the intended recipient, you are 
>>>>> notified that
>>>>> any dissemination, distribution or copying of this communication is
>>>>> strictly prohibited.  If you have received this communication in error,
>>>>> please notify the sender and erase this e-mail message immediately.
>>>>> ---------------------------------------------------------------------------
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> To unsubscribe, e-mail:
>>>>> <mailto:[EMAIL PROTECTED]>
>>>>> For additional commands, e-mail: 
>>>>> <mailto:[EMAIL PROTECTED]>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> To unsubscribe, e-mail:   
>>>> <mailto:[EMAIL PROTECTED]>
>>>> For additional commands, e-mail: 
>>>> <mailto:[EMAIL PROTECTED]>
>>>>
>>>
>>>
>>> --
>>> To unsubscribe, e-mail:   
>>> <mailto:[EMAIL PROTECTED]>
>>> For additional commands, e-mail: 
>>> <mailto:[EMAIL PROTECTED]>
>>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:   
>> <mailto:[EMAIL PROTECTED]>
>> For additional commands, e-mail: 
>> <mailto:[EMAIL PROTECTED]>
>>
>>
>>
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to