Re: PageState in unit testing

Emmanuel Gaillot <[email protected]>
Newsgroups gmane.linux.redhat.ccm.general
Organization Open Wide / Paris
Message-ID <1080645034.22104.8.camel@devpt04>
Vadim,


> The simplest way to do this is to do what our unit tests do.  For
> example, take a look at
> test/src/com/arsdigita/bebop/FormDataTest.java and notice that it
> extends com.arsdigita.tools.junit.framework.BaseTestCase.  The latter
> is responsible for setting up a transaction context for you.  If you
> extend BaseTestCase, your error should go away.

Thank you for the pointer.  I had my tests extends BaseTestCase, but
unfortunately I still run into an error at execution.  I instanciated my
page state much like the way it is done in FormDataTest :

PageState pageState = 
  page.process(new MockHttpRequest(), new MockHttpResponse());

... and I get the following error stack trace :

java.lang.IllegalStateException: SessionManager has not been
initialized: 
  url is null
  username is null
  password is null
	at
com.arsdigita.persistence.SessionManager$1.initialValue(SessionManager.java:159)
	at java.lang.ThreadLocal.get(ThreadLocal.java:98)
	at
com.arsdigita.persistence.SessionManager.getSession(SessionManager.java:74)
	at
com.arsdigita.tools.junit.framework.BaseTestCase.baseSetUp(BaseTestCase.java:66)
	at
com.arsdigita.tools.junit.framework.BaseTestCase.runBare(BaseTestCase.java:43)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:410)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:294)
	at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:182)



Am I missing something?


Also:
> In theory, Bebop should not depend on persistence.  You shouldn't be
> forced to deal with the problem you've run into.  In practice, the
> dependency is there and you have to satisfy it.  

I would be happy to work on this dependency to make it go away.  Any
idea where I should start?

-- Emmanuel.


-- 
Redhat-ccm-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/redhat-ccm-list
Archives: https://www.redhat.com/pipermail/redhat-ccm-list/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.