Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 47996 invoked from network); 21 Jul 2009 00:06:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Jul 2009 00:06:37 -0000 Received: (qmail 45532 invoked by uid 500); 21 Jul 2009 00:07:39 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 45467 invoked by uid 500); 21 Jul 2009 00:07:39 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 45457 invoked by uid 99); 21 Jul 2009 00:07:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jul 2009 00:07:39 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of dimi.chr@gmail.com designates 209.85.221.201 as permitted sender) Received: from [209.85.221.201] (HELO mail-qy0-f201.google.com) (209.85.221.201) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jul 2009 00:07:31 +0000 Received: by qyk39 with SMTP id 39so2267486qyk.23 for ; Mon, 20 Jul 2009 17:07:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=xgI2x86Kz0gdpR1RwNbYmKPr3KF4dFKsQVCw+Nk9UhE=; b=u2PCy7nOx+IpoiRQBo/TDz3PyB2ThoGCwfTQFAa0mtGivAnCfVM+CQL299dKdk3MaY 2nFJhoh54MXirg0TTK92FFEH8mRpAYQN6KzZkykBA8m0zzng257cLfOiN3BkCOjLPdMt 0CovqirTaSuXECreYPTym24Q0R5QAQmSvYp+c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=IEIu6oNb4RC0W5ROQ7pHZzxzBYVU7so8k9DbNUoZW+pDLYExJM5C3A9tvZP8nFquDA KV5K2TM2KEp8TFI4exl4Z+RW4CaBIZdPPCc36W+NFFgocG5W1Y2oxAT4bDxMf471OZmr RRSmSorXuAE5dFl66gy3i0CvVbh/0Ht3cWjyw= MIME-Version: 1.0 Received: by 10.229.89.202 with SMTP id f10mr926095qcm.71.1248134829972; Mon, 20 Jul 2009 17:07:09 -0700 (PDT) In-Reply-To: References: <8CBD67217B2C7AF-D74-3BF8@webmail-mf15.sysops.aol.com> <5e5424000907190342h48347659vb5d53b716b8aa215@mail.gmail.com> <4A631223.2070900@yahoo.com> <5e5424000907191326q39b9cee5y3eac797f4ec83f5e@mail.gmail.com> <4A639194.1070001@yahoo.com> Date: Mon, 20 Jul 2009 19:07:09 -0500 Message-ID: Subject: Re: unit testing Struts2 application (with Spring and Hibernate) From: Dimitrios Christodoulakis To: Struts Users Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Thanks for clarifying Haroon, Actually the additions you are mentioning sum up the original testing code pretty well. Like I said, from an educational point of view, I think one can learn a lot about the framework itself by studying that article and the comments. Thanks for the "preparable" bit too. As other folks here mentioned, it depends on the testing requirements of the project when it comes which test strategy to take, or which tool to use. As a learner, I found it very useful to experiment with that code. I haven't tried Selenium yet, but I would be interested to see how it catches the same errors in the same test cases. On Mon, Jul 20, 2009 at 5:02 PM, Haroon Rafique wrote: > On Today at 4:32pm, DC=3D>Dimitrios Christodoulakis = wrote: > > DC> Thanks Haroon for the handy advice. That seems to do the trick as far > DC> as the session object is concerned. The test passes now. > DC> > > Glad it worked out. > > DC> > DC> Would it be easy for someone to extend your code to include actions > DC> that implement the -aware interfaces? If I wanted to take a shot at > DC> that, is there a particular point you would suggest I start with? > DC> > > Did you add that code in your Test class? I was actually suggesting that > you modify the code inside BaseStrutsTestCase. So, I would recommend > adding a private static HashMap variable called sessionMap in > BaseStrutsTestCase. And then in the createAction method, issue the > statement: > =A0 =A0proxy.getInvocation().getInvocationContext().setSession(sessionMap= ); > > Hope that helps. > > The only other fringe case that I have dealth with in our code, is when w= e > have actions that implement Preparable and are used with a > ParamsPrepareParams interceptor. I created a method to allow action > parameters to be set. > > /** > =A0* Sets the action parameters > =A0* @param parameters Parameters to set > =A0*/ > protected void setActionParameters(Map > parameters) { > =A0 proxy.getInvocation().getInvocationContext(). > =A0 =A0 =A0 =A0 =A0 setParameters(parameters); > } > > Then inside my Action Test class, I can issue: > =A0proxy.setActionParameters(...); > before: > =A0proxy.execute(); > > Cheers, > -- > Haroon Rafique > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org