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 C30381085C for ; Thu, 28 Nov 2013 07:19:43 +0000 (UTC) Received: (qmail 49790 invoked by uid 500); 28 Nov 2013 07:19:40 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 49164 invoked by uid 500); 28 Nov 2013 07:19:33 -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 49156 invoked by uid 99); 28 Nov 2013 07:19:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Nov 2013 07:19:31 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of damian.blazejewski@gmail.com designates 209.85.212.181 as permitted sender) Received: from [209.85.212.181] (HELO mail-wi0-f181.google.com) (209.85.212.181) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Nov 2013 07:19:27 +0000 Received: by mail-wi0-f181.google.com with SMTP id hq4so413445wib.2 for ; Wed, 27 Nov 2013 23:19:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=mCgzd3RtzfUVkFtThbwq1BLO8myjfc4No7m+MHIzdxM=; b=orEwm8xNlXGTjNkLkrOSX3bIP1eAGOJJKEXOSQucWwxUmPx2gIQbB+jE7yj43xfD67 kyvZ/hJz9+zI7TKtIppjzfPe1QLMpi5h0u5hmXi2DKfcY0EBiG+liTb1Bu+vpdlTyVYZ TJv2UbbT4ykfjoBLdvJg3VQyxYHWi1+IMrqbv4InACiPLXYjINofLyLdVcrbDUkdnJCz piLYEo6ZrulJs1CVh+U9sewsgcbwT+gFcA2uZ+NRPOJyHQ8h23Nlkuo3ymUMJ1OUEGXW 8Ec3oI5zOcoN0YnTsn7WN3CjnPEuwqPyLbkicqjmp0qh7c2eaTY0cOw/vJOSzBlU5IG7 R++g== X-Received: by 10.180.101.197 with SMTP id fi5mr1100928wib.46.1385623146017; Wed, 27 Nov 2013 23:19:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.166.138 with HTTP; Wed, 27 Nov 2013 23:18:45 -0800 (PST) In-Reply-To: References: From: Damian Blazejewski Date: Thu, 28 Nov 2013 08:18:45 +0100 Message-ID: Subject: Re: Struts 2 Testing Actions To: Struts Users Mailing List Content-Type: multipart/alternative; boundary=f46d0444e8d7693c8704ec378736 X-Virus-Checked: Checked by ClamAV on apache.org --f46d0444e8d7693c8704ec378736 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Lukasz, Mockito is what I am going to use. But how to deal with those Spring dependencies in the action? As I said before, when I extend StrutsJUnit4TestCase I get the following error: "Looks like the Spring listener was not configured for your web app! " On the other hand, extending StrutsSpringJUnit4TestCase I have to provide Spring context. No I am thinking about using this: https://bitbucket.org/kubek2k/springockito/wiki/Home It should solve my problem. Pozdrawiam/Best regards, Damian B=C5=82a=C5=BCejewski dblazejewski.com 2013/11/28 Lukasz Lenart > Yes, use mocks -> Mockito > > > Regards > -- > =C5=81ukasz > + 48 606 323 122 http://www.lenart.org.pl/ > > 2013/11/28 Damian Blazejewski : > > I don't want to extend StrutsSpringJUnit4TestCase as it enforces me to > > provide all Spring dependencies required by the action itself. > > Although the Struts Action I want to test is dependent only on two Spri= ng > > beans, those beans have a lot of other dependencies and so on. > > What I would like to do is mocking all Struts Action dependencies and > then > > doing some tests. > > Is it possible to do it that way? > > > > > > Pozdrawiam/Best regards, > > Damian B=C5=82a=C5=BCejewski > > dblazejewski.com > > > > > > 2013/11/27 Lukasz Lenart > > > >> 2013/11/26 Damian Blazejewski : > >> > I have managed to sort it out. My project has two maven modules and > one > >> > parent pom common for those modules. > >> > Tests are located in on of the submodules. > >> > As turns out, when I add servlet-api and jsp-api dependencies to the > >> parent > >> > pom, the error is present. > >> > However, when I move those two dependencies to the module's pom whic= h > >> tests > >> > are located in, error disappears. > >> > So that problem is solved. > >> > Unfortunately, there is another issue. I have almost given up but my > >> desire > >> > to start automatically testing Struts actions is stronger so I still > >> > struggle :) > >> > I have Spring dependencies in the actions itself. It would be perfec= t > if > >> I > >> > could mock them. But as far as I know I can't but I should provide > spring > >> > application context > >> > defining those dependencies. > >> > > >> > When I try to extend StrutsJUnit4TestCase in my test I get the > following > >> > error: > >> > > >> > "Looks like the Spring listener was not configured for your web app!= " > >> > > >> > When I extend StrutsSpringJUnit4TestCase, I have to provide Spring > >> > dependencies as I said earlier. > >> > > >> > Is there any way to mock those Spring dependencies in my Struts > action? > >> > >> I'm not sure if I understand you - why don't you use > >> StrutsSpringJUnit4TestCase? > >> > >> > >> > http://struts.apache.org/release/2.3.x/docs/struts-2-junit-plugin-tutoria= l.html > >> http://struts.apache.org/release/2.3.x/docs/testing-actions.html > >> > >> > >> Regards > >> -- > >> =C5=81ukasz > >> + 48 606 323 122 http://www.lenart.org.pl/ > >> > >> --------------------------------------------------------------------- > >> 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 > > --f46d0444e8d7693c8704ec378736--