jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicholas Dierauf" <nicholas.dier...@autodesk.com>
Subject RE: Where do I put code to be executed only once for entire testclass
Date Wed, 21 Feb 2007 17:05:50 GMT
TestSetup is a standard JUnit class, so you shouldn't have any problem
importing this class. You generally have to extend this class or create
an anonymous instance of the class as shown below. It is for exercising
code before and/or after running a suite of test cases.

You can use TestSetup in Cactus, but it is very tricky. This is because
TestSetup is executed on the client-side of Cactus' client-server
architecture. I use it to persist users to a database prior to running a
test on my server against these users (TestSetup.setUp()), and then for
removing these users once the test is completed (TestSetup.tearDown()). 

I am no sure how you would use it for performing server-side
authentication, perhaps you can call a special server-side servlet (or
.jsp page) from TestSetup.setUp() that performs this authentication for
you. Have the servlet return an errorCode indicating whether the single
authentication was successful or not.

Good luck,
Nick.



-----Original Message-----
From: Tejaswini Yardi [mailto:tejaswini.yardi@gmail.com] 
Sent: Wednesday, February 21, 2007 4:09 AM
To: cactus-user@jakarta.apache.org
Subject: Re: Where do I put code to be executed only once for entire
testclass


What is TestSetup class? I am not being able to execute it since i am
not
sure from where to import this class. Also i have one suite class which
calls test methods for my different test classes - would the
authenticated
details remain in the request object when the control gets passed to
these
classes ?


Shay Thompson wrote:
> 
> 
> For JUnit I do the following.. I think it would work with Cactus.. not

> positive as I haven't tried it.  There's probably something similar if
> not.
> 
>     public static Test suite() {
> 
>         TestSuite suite = new TestSuite();
>         suite.addTestSuite(MyTestClass.class);
> 
>         TestSetup wrapper = new TestSetup(suite) {
> 
>             public void setUp() throws Exception {
>                 init();
>             }
> 
>             public void tearDown() throws Exception {
>                 cleanUp();
>             }
>         };
> 
>         return wrapper;
>     }
> 
> Then in your init() you do the authentication.
> 
> 
> Tejaswini Yardi wrote:
>> Hi
>>
>> I need to put a code to authenticate the user into the application
which
>> loads user cache and should be executed only once for the entire
>> testclass
>> instead of executing once for each testcase. Can anyone tell me where
can
>> i
>> put this code in my test class. 
>> Please let me know this as soon as possible.
>>   
> 
> -- 
> 
> If you apply Ohms Law, e=mc2, to the hypotenuse and add to that a
catalyst
> consisting of a set of struts and a gigahertz, you will theoretically
> arrive at an answer yesterday...
> 
> Shay Thompson - Lead Computer Scientist
> Adobe Systems, Inc. - Titan Core QE 
> Voice: x34728 or 612.251.5415
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org
> 
> 
> 

-- 
View this message in context:
http://www.nabble.com/Where-do-I-put-code-to-be-executed-only-once-for-e
ntire-testclass-tf3200579.html#a9079700
Sent from the Cactus - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-user-help@jakarta.apache.org




Mime
View raw message