struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Loschen" <>
Subject RE: Junit tests on remote Struts application in Eclipse
Date Mon, 10 Jul 2006 18:42:05 GMT
Yes, it does help -- thank you! I'll look into cactus and (probably better) if there's some
way I can rearrange my testing strategy. TPTP seems to have some sort of datapooling arrangement
which might help me.

Eventually, I'm going to need to set up some multiple thread tests and confirm that correct
values get written to the DB, so I do need to have some of the persistence layer strategies
you mention. I'm not sure I'll be able to get away from running it in the container, though
-- some of what I'm concerned about is the interaction of multiple threads with Hibernate,
Spring, ThreadLocal, etc. -- is there a way to look at all that without being in the container?

More specifically, we had a problem where we were using a ThreadLocal variable to store the
operator id in a Spring-enabled stateless class. The operator id was (potentially at least)
getting saved back to the thread pool where it could be applied to another thread picking
up the same class. Instead, we've saved the operator id to a stateful class and passed it
to the original class as method arguments. Now we want to test that multiple threads with
different operator ids persist the correct operator id back to the DB. 

I have a pretty good idea how to write up that test. What I'm less clear about is how to actually
run the test once it's set up. I had assumed that I needed to be in the container that the
application normally runs in so that I wouldn't have to reproduce all of the configuration
details. Is that a wrong assumption?


-----Original Message-----
From: [] 
Sent: Monday, July 10, 2006 2:11 PM
Subject: RE: Junit tests on remote Struts application in Eclipse


It sounds like you're trying to run the tests inside the container.  If so, JUnit can't do
that on it's own.  You can use Cactus to proxy from the testrunner (outside the container)
to the tests (inside the container).

I've always found Cactus to be a bit of a PITA, however, and have changed my testing strategy
to avoid it.  My tests are split into three

 - POJO JUnit tests which test the java code and run very fast.  These drive most of my development
via TDD.
 - Tests that involve other systems, principally the database.  I substitute a DAO factory
that uses a local JDBC Connection instead of getting a datasource from the container.  These
tests check the Persistence layer.  They're much slower than the ordinary JUnit tests (particulary
because they use DBUnit to set up test data), but they're still faster and easier than in-container
 - Acceptance or System tests that test the application as a whole, running in the container,
through the normal web interface (using HttpUnit).  These don't have to test the edge conditions,
because those are tested in the other tests, above.

Hope that helps.

 - George

> -----Original Message-----
> From: Chris Loschen []
> Sent: Monday, July 10, 2006 1:25 PM
> To: Struts Users Mailing List
> Subject: Junit tests on remote Struts application in Eclipse
> Hi all,
> This is admittedly tangential to our topic, but some other questions 
> on Eclipse came up last week, and people here seem knowledgeable on 
> all sorts of subjects... If you know of a better list on which I could 
> ask this question, please let me
> know: I should probably be on it.
> I have a struts application deployed on a localhost app server (the 
> stack is Windows/Oracle/WebLogic), and I'm using the new Eclipse 3.2 
> IDE (downloaded last week, at least partly to try to solve the current 
> problem). I've set up the project as a regular Java project, which I 
> did before WTP came out. I haven't yet been able to figure out how to 
> use the WTP tools, or if there's something I need to do with my 
> project to enable those, but that's another issue. I've been able to 
> debug the application in Eclipse just fine for several months by 
> connecting to my localhost app and setting breakpoints in my source 
> code etc.
> Now I'm trying to get some Junit tests running. The tests themselves 
> already exist, though eventually I'll be writing some new ones to test 
> some new functionality I'm working on.
> But I haven't been able to run the tests at all yet. I keep getting a 
> null pointer exception on the tests which try to actually connect to 
> the DB. All the DB connections are handled in my app server setup, so 
> I think the difficulty is that I'm just connecting to the code but not 
> to the running application.
> I've got TPTP in this new version of Eclipse but haven't totally 
> figured it out yet. Does anyone have any suggestions to get me started 
> or for some references on how to make this work?
> Thanks for your help!
> Chris
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message