Re: WOUnitTest and sessions and EditingContexts
Re: WOUnitTest and sessions and EditingContexts
- Subject: Re: WOUnitTest and sessions and EditingContexts
- From: Christian Pekeler <email@hidden>
- Date: Mon, 13 Dec 2004 16:59:44 -0700
I'm attempting to use WOUnitTest. I have been somewhat thrown in at
the deep end, however, as pretty much the first tests I've been
attempting to write are testing our project subclass of
EOEditingContext (lets call it OurEditingContext), and I'm not quite
sure what to do.
In our Application.java, we have overloaded
NewEOEditingContext(Session session) so that it returns
OurEditingContext, but this doesn't work with TestCases, so I need to
do something like
protected void setUp() throws Exception {
super.setUp();
OurEditingContext editingContext = new OurEditingContext(session());
}
Only that is not working, because its not finding session() (which
confuses me, because it should be able to find session() from
WOComponent, shouldn't it?
Your test case inherits from TestCase or WOUTTestCase. These classes
have nothing to do with WOComponent and don't implement session(). I
think what you want is something like
public class OurEditingContextTest extends WOUTTestCase {
OurEditingContext ourEditingContext;
protected void setUp() throws Exception {
super.setUp();
ourEditingContext = new OurEditingContext(new Session());
}
public void testSomething() {
assertSomething(ourEditingContext);
...
}
However...
We are overloading EOEditingContext so it also keeps session
information, because we want to put creationdate and modificationdate
logging into our subclass of EOGenericRecord, and EOGenericRecord has
no direct access to the session (but does have access to the editing
context).
Why do you need the session to get the creationdate and
modificationdate? It doesn't seem very clean to me to give an editing
context subclass access to a WOSession.
Christian
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden