Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A2F3670C9 for ; Thu, 22 Sep 2011 07:57:14 +0000 (UTC) Received: (qmail 20558 invoked by uid 500); 22 Sep 2011 07:57:12 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 20534 invoked by uid 500); 22 Sep 2011 07:57:12 -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 20525 invoked by uid 99); 22 Sep 2011 07:57:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Sep 2011 07:57:12 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of carlballantyne@gmail.com designates 209.85.216.48 as permitted sender) Received: from [209.85.216.48] (HELO mail-qw0-f48.google.com) (209.85.216.48) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Sep 2011 07:57:03 +0000 Received: by qwh5 with SMTP id 5so5892900qwh.7 for ; Thu, 22 Sep 2011 00:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=oDhNglXyA+CRE4knWs7SejFegPPF1O4YZ7fb6qmjc/k=; b=iBmBy5rhjI6LhQZAIxFSmPVHPdE9VCyq3+q8aKflPJmTG1OKrZfG+jKBPxilTLn1mM IwwkqMNtT2asdk1NeEQv+Hnay6z732OAfXECuT4ZCx7p3svzt4HJN5QI0qF1k+pB5FEe mqzuTzX0VrNKvYQEUN8HHkq8gxSA9cdhYfGvg= MIME-Version: 1.0 Received: by 10.229.176.40 with SMTP id bc40mr1348024qcb.240.1316678202698; Thu, 22 Sep 2011 00:56:42 -0700 (PDT) Received: by 10.229.43.19 with HTTP; Thu, 22 Sep 2011 00:56:42 -0700 (PDT) In-Reply-To: References: Date: Thu, 22 Sep 2011 09:56:42 +0200 Message-ID: Subject: Re: Unit Test Struts2 Action - Custom type converters not being run? From: Carl Ballantyne To: Struts Users Mailing List Content-Type: multipart/alternative; boundary=0016e6d369e18e2c0f04ad83087e X-Virus-Checked: Checked by ClamAV on apache.org --0016e6d369e18e2c0f04ad83087e Content-Type: text/plain; charset=ISO-8859-1 It seems to have fixed itself overnight without me changing anything. I can in this morning and now the converters are being run for the unit tests. Hmmmmm as long as it is passing all good. On Wed, Sep 21, 2011 at 7:25 PM, Maurizio Cucchiara wrote: > Does Maven Snapshot section [1] answer your question? > [1] http://struts.apache.org/dev/builds.html#MavenSnapshots > > Maurizio Cucchiara > > > > On 21 September 2011 17:55, Carl Ballantyne > wrote: > > I am using 2.2.3. > > > > How can I try the nightly build if using Maven? I do not see it listed as > an > > option. > > > > I also noticed I am using spring beans as the converters. Not sure if > this > > makes a difference. So for example in the conversion properties file I > have > > something like roles=rolesConverter. And rolesConverter is a spring bean. > > > > I will try some more tomorrow and see what I can come up with. I am sure > it > > is something silly I am doing. > > > > > > > > On Wed, Sep 21, 2011 at 5:47 PM, Maurizio Cucchiara > > wrote: > > > >> What Struts version are you using? > >> Could you give a try to the nightly version [1] and tell me if it > >> works as you expect? > >> Be aware that you can write your test as follow: > >> > >> public void testValidationRequired() throws Exception { > >> request.setParameter("user.roles", ""); > >> executeAction("/your_package/your_action.action"); > >> > >> // asserts to check errors etc...... > >> } > >> } > >> > >> > >> > >> [1] > >> > https://builds.apache.org/job/Struts2/lastStableBuild/org.apache.struts$struts2-assembly/ > >> > >> Maurizio Cucchiara > >> > >> > >> > >> On 21 September 2011 17:31, Carl Ballantyne > >> wrote: > >> > Hi All, > >> > > >> > I have an action that I am trying to unit test. However it seems the > >> > converters I have set for the User object that is being create by the > >> action > >> > are not being applied at all when running the unit test. The > converters > >> are > >> > run when running the application. > >> > > >> > For example I have a test class: > >> > > >> > public class UserCreateTest extends StrutsSpringTestCase { > >> > > >> > > >> > public void testValidationRequired() throws Exception { > >> > request.setParameter("user.roles", ""); > >> > > >> > ActionProxy proxy = getActionProxy("/createUser.action"); > >> > > >> > ActionSupport action = (ActionSupport)proxy.getAction(); > >> > > >> > proxy.setExecuteResult(false); // Do not execute view > >> > (JSP/Tiles) > >> > proxy.execute(); > >> > > >> > // asserts to check errors etc...... > >> > } > >> > } > >> > > >> > > >> > > >> > And then for that test class I have getUser and setUser methods that > >> return > >> > a User object. This object has an attribute roles that has a converter > >> > applied by puting a User-conversion.properties file in the same folder > as > >> > the User class. All this works fine when running the app. It is just > when > >> > running the unit test it does not seem to get run. Or at least it is > not > >> > getting run before the Validation interceptor which seems odd to me. > >> > > >> > Anyone have any ideas? Anyone testing validation for actions that > involve > >> > custom convertors? > >> > > >> > Cheers, > >> > Carl. > >> > > >> > >> --------------------------------------------------------------------- > >> 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 > > --0016e6d369e18e2c0f04ad83087e--