Unit Testing Struts 2 Action

2009-01-17 Thread Doug Pham
Hi All,
    I am putting together Struts 2, Hibernate  Sitemesh.  Where can I find 
information on how to unit test my new application actions?

Thanks,
Doug



  

Re: Unit Testing Struts 2 Action

2009-01-17 Thread Nils-Helge Garli Hegvik
One of the things I really like about Struts 2 is how easy it is to
unit test actions. Using the proper mechanisms for injecting what you
need, unit testing the action should be as simple as instantiating the
action, set the appropriate dependencies, and then execute it.

Nils-H

On Sat, Jan 17, 2009 at 10:21 AM, Doug Pham dougtp...@yahoo.com wrote:
 Hi All,
 I am putting together Struts 2, Hibernate  Sitemesh.  Where can I find 
 information on how to unit test my new application actions?

 Thanks,
 Doug





-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Unit Testing Struts 2 Action

2009-01-17 Thread Robert Harrison
Here's http://www.rkcole.com/articles/struts/crudTutorial/step1.html the
first step of a nice, three-part tutorial (I have no connection to author)

Bob

Sure you can trust the government.  Just ask any Indian - anonymous



On Sat, Jan 17, 2009 at 6:21 AM, Nils-Helge Garli Hegvik
nil...@gmail.comwrote:

 One of the things I really like about Struts 2 is how easy it is to
 unit test actions. Using the proper mechanisms for injecting what you
 need, unit testing the action should be as simple as instantiating the
 action, set the appropriate dependencies, and then execute it.

 Nils-H

 On Sat, Jan 17, 2009 at 10:21 AM, Doug Pham dougtp...@yahoo.com wrote:
  Hi All,
  I am putting together Struts 2, Hibernate  Sitemesh.  Where can I
 find information on how to unit test my new application actions?
 
  Thanks,
  Doug
 
 
 
 

 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org




Re: Unit Testing Struts 2 Action

2009-01-17 Thread Dave Newton

Doug Pham wrote:
 [...] information on how to unit test my new application actions?

When you hit reply and change the subject this is what happens in 
threaded view:


http://tinypic.com/view.php?pic=n5mog5s=5

Please consider starting new threads.

Dave


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Unit testing Struts 2 systems in multiple projects

2008-09-18 Thread Peter Butler
We are doing web development using Struts 2, building using Maven. Our
system is made up of two projects: a war project and a core project. The
war project contains all web resources, jsps, etc. The core project
contains all of our struts actions, service layer and data access layer.

 

We split our system up like this because of the Maven restriction on
generating one artifact per project. The problem is that this makes
automated testing difficult. The web project contains the struts.xml
file that defines all of our actions but the action source code is in
the core project.

 

How can we set things up so that the test code can pick up the
struts.xml file from the web project while testing the code in the core
project? I have been thinking about putting the tests in the web
project, but this means that the test code is in a different project
from the code that is being tested, which is not ideal. The other
alternative is to have separate struts.xml files for testing and
deployment, which is also not ideal.

 

How have other people handled this?

 

Cheers

 

Peter

 

 

 


___
The information contained in this e-mail is confidential and may be privileged. 
It is intended for the addressee only. If you are not the intended recipient, 
please delete this e-mail immediately. The contents of this e-mail must not be 
disclosed or copied without the sender's consent. The statements and opinions 
expressed in this message are those of the author and do not necessarily 
reflect those of the company. The company does not take any responsibility for 
the views of the author.

Registered Office: IT-Freedom Limited, 9 Minster Court, Tuscam Way, Camberley, 
Surrey GU15 3YY 
Registered in England, Number: 04500346
___

Re: Unit testing Struts 2 systems in multiple projects

2008-09-18 Thread Dave Newton
--- On Thu, 9/18/08, Peter Butler wrote:
 The war project contains all web resources, jsps, etc. 
 The core project contains all of our struts actions, 
 service layer and data access layer.

IMO that's broken--the S2 actions should be part of the web project because... 
that's what S2 is--the web layer. That solves your problem and (to me, anyway) 
seems a more logical approach.

Dave


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



RE: Unit testing Struts 2 systems in multiple projects

2008-09-18 Thread Peter Butler
 The war project contains all web resources, jsps, etc. 
 The core project contains all of our struts actions, 
 service layer and data access layer.

 IMO that's broken--the S2 actions should be part of the web
 project because... that's what S2 is--the web layer. That
 solves your problem and (to me, anyway) seems a more logical approach.

Ordinarily I would agree with you, but we have a constraint that I
forgot to mention: our actions have to be usable in more than one web
project. The system we are building is deployed to more than one
customer. We customise the web project by overlaying customer-specific
files in separate projects.

I was thinking that another approach to this might be to keep all
actions in the core project, along with the struts.xml file, then
package these into a jar file. This page:

http://struts.apache.org/2.0.11.2/docs/can-we-break-up-a-large-strutsxml
-file-into-smaller-pieces.html

says that this is possible, but doesn't give any details. Does anyone
have any more details on getting this to work?

Cheers

Peter


___
The information contained in this e-mail is confidential and may be privileged. 
It is intended for the addressee only. If you are not the intended recipient, 
please delete this e-mail immediately. The contents of this e-mail must not be 
disclosed or copied without the sender's consent. The statements and opinions 
expressed in this message are those of the author and do not necessarily 
reflect those of the company. The company does not take any responsibility for 
the views of the author.

Registered Office: IT-Freedom Limited, 9 Minster Court, Tuscam Way, Camberley, 
Surrey GU15 3YY 
Registered in England, Number: 04500346
___

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



Re: Unit Testing Struts 2

2008-09-12 Thread Greg Lindholm

Here is a blog writeup of what I'm using. It allows you to test interceptors.

http://glindholm.wordpress.com/2008/06/30/unit-testing-struts-2-actions/


Mark-413 wrote:
 
 Hi all:
 
 Does anyone have a working example of unit testing a Struts 2 app?   
 I've been looking around for awhile know and found the following  
 resources.  However, I've not been able to get any of them to work.
 
 http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing- 
 struts-2-actions-spring-junit/
 http://www.soft-gems.net/index.php? 
 option=com_contenttask=viewid=47Itemid=33
 http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html
 
 I'm using Struts 2.1.3 and want to test Interceptors and result  
 types, not just the Action POJO's.
 
 Any help or resources are greatly appreciated!
 Mark
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Unit-Testing-Struts-2-tp19428146p19451533.html
Sent from the Struts - User mailing list archive at Nabble.com.


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



Re: Unit Testing Struts 2

2008-09-11 Thread Nils-Helge Garli Hegvik
Not in particular. Basically, they all more or less do the same
(although sometime with different approaches to mocking): Set up the
action context, create a mock invocation and invoke intercept on the
interceptor with the mock invocation.

I think this is the smallest and simplest interceptor test:
http://svn.apache.org/repos/asf/struts/struts2/trunk/core/src/test/java/org/apache/struts2/interceptor/ClearSessionInterceptorTest.java

Nils-H

On Thu, Sep 11, 2008 at 7:48 AM, Mark [EMAIL PROTECTED] wrote:
 I had a look at a few in the 2.0.11.1 source tree.  I couldn't understand
 how they were structured.  I haven't looked at the 2.1.3 source tree.  Is
 there a particular one you would suggest?

 Mark

 On 11/09/2008, at 3:40 PM, Nils-Helge Garli Hegvik wrote:

 Have you looked at the tests in the source repository?

 Nils-H

 On Thu, Sep 11, 2008 at 7:31 AM, Mark [EMAIL PROTECTED] wrote:

 Hi all:

 Does anyone have a working example of unit testing a Struts 2 app?  I've
 been looking around for awhile know and found the following resources.
  However, I've not been able to get any of them to work.


 http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/

 http://www.soft-gems.net/index.php?option=com_contenttask=viewid=47Itemid=33
 http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html

 I'm using Struts 2.1.3 and want to test Interceptors and result types,
 not
 just the Action POJO's.

 Any help or resources are greatly appreciated!
 Mark

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



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

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



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



Unit Testing Struts 2

2008-09-10 Thread Mark

Hi all:

Does anyone have a working example of unit testing a Struts 2 app?   
I've been looking around for awhile know and found the following  
resources.  However, I've not been able to get any of them to work.


http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing- 
struts-2-actions-spring-junit/
http://www.soft-gems.net/index.php? 
option=com_contenttask=viewid=47Itemid=33

http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html

I'm using Struts 2.1.3 and want to test Interceptors and result  
types, not just the Action POJO's.


Any help or resources are greatly appreciated!
Mark

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



Re: Unit Testing Struts 2

2008-09-10 Thread Nils-Helge Garli Hegvik
Have you looked at the tests in the source repository?

Nils-H

On Thu, Sep 11, 2008 at 7:31 AM, Mark [EMAIL PROTECTED] wrote:
 Hi all:

 Does anyone have a working example of unit testing a Struts 2 app?  I've
 been looking around for awhile know and found the following resources.
  However, I've not been able to get any of them to work.

 http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
 http://www.soft-gems.net/index.php?option=com_contenttask=viewid=47Itemid=33
 http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html

 I'm using Struts 2.1.3 and want to test Interceptors and result types, not
 just the Action POJO's.

 Any help or resources are greatly appreciated!
 Mark

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



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



Re: Unit Testing Struts 2

2008-09-10 Thread Mark
I had a look at a few in the 2.0.11.1 source tree.  I couldn't  
understand how they were structured.  I haven't looked at the 2.1.3  
source tree.  Is there a particular one you would suggest?


Mark

On 11/09/2008, at 3:40 PM, Nils-Helge Garli Hegvik wrote:


Have you looked at the tests in the source repository?

Nils-H

On Thu, Sep 11, 2008 at 7:31 AM, Mark [EMAIL PROTECTED] wrote:

Hi all:

Does anyone have a working example of unit testing a Struts 2  
app?  I've
been looking around for awhile know and found the following  
resources.

 However, I've not been able to get any of them to work.

http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing- 
struts-2-actions-spring-junit/
http://www.soft-gems.net/index.php? 
option=com_contenttask=viewid=47Itemid=33

http://struts.apache.org/2.0.8/docs/how-can-we-test-actions.html

I'm using Struts 2.1.3 and want to test Interceptors and result  
types, not

just the Action POJO's.

Any help or resources are greatly appreciated!
Mark

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




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


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



Unit Testing Struts 2 Actions

2008-06-30 Thread Greg Lindholm
I've spent a lot of time in the debugger over the last few days trying to 
figure out how to unit test struts 2 actions with the Interceptor stack so that 
validation and results configuration etc. were also tested.

I wrote a unit test helper class and posted it and a description here Unit 
Testing Struts 2 Actions [1] hopefully others will find this helpful.

[1] http://glindholm.wordpress.com/2008/06/30/unit-testing-struts-2-actions/




  

[S2][ANN] Unit Testing Struts 2 Actions wired with Spring using JUnit article

2007-06-20 Thread Ted Husted

[arenselist] Hopefully this entry serves as some search engine
friendly documentation on how one might unit test Struts 2 actions
configured using Spring, something I would think many, many people
want to do.  This used to be done using StrutsTestCase in the Struts
1.x days but Webwork/Struts provides enough flexibility in its
architecture to accommodate unit testing fairly easily.

More ... 
http://arsenalist.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/

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