Return-Path: Delivered-To: apmail-jakarta-cactus-user-archive@apache.org Received: (qmail 79902 invoked from network); 19 Sep 2002 17:23:09 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 19 Sep 2002 17:23:09 -0000 Received: (qmail 12648 invoked by uid 97); 19 Sep 2002 17:23:48 -0000 Delivered-To: qmlist-jakarta-archive-cactus-user@jakarta.apache.org Received: (qmail 12627 invoked by uid 97); 19 Sep 2002 17:23:47 -0000 Mailing-List: contact cactus-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Cactus Users List" Reply-To: "Cactus Users List" Delivered-To: mailing list cactus-user@jakarta.apache.org Received: (qmail 12574 invoked by uid 98); 19 Sep 2002 17:23:46 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) X-Sent: 19 Sep 2002 17:23:06 GMT Message-ID: <3D8A07FB.2020307@ehatchersolutions.com> Date: Thu, 19 Sep 2002 13:23:07 -0400 From: Erik Hatcher User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Cactus Users List Subject: Re: StrutsTestCase / Struts 1.1b2 / Cactus - ConcurrentModificationException References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Are you using StrutsTestCase? The bug was there and I built the latest from its CVS HEAD and the problem went away. But, for the record - I *always* run with fork="true" :)) Erik Nicholas Lesiecki wrote: > Erik, > > I encountered some odd threading behavior in Cactus as well. Got a question > for you, are you running from Ant with fork=true? > > Cheers, > > Nick > > >>-----Original Message----- >>From: Erik Hatcher [mailto:lists@ehatchersolutions.com] >>Sent: Friday, September 13, 2002 4:15 PM >>To: cactus-user@jakarta.apache.org; deryl@acm.org >>Subject: StrutsTestCase / Struts 1.1b2 / Cactus - >>ConcurrentModificationException >> >> >>Deryl or others that may have encountered this.... >> >>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: > > > For additional commands, e-mail: > > > > -- > To unsubscribe, e-mail: > For additional commands, e-mail: > > > -- To unsubscribe, e-mail: For additional commands, e-mail: