You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Amit Bhaskar <am...@jalvamedia.com> on 2002/05/09 10:43:58 UTC

Junit Testing with TDK

Hi,
       I am facing one problem while using Junit test framework with Tdk om classes.The problem discription is as below:--

For testing our database classes we are required to set the classpath explicitely which requires all jar files present in ..web-inf/lib directory. All these things were resolved.I tested a simple function which does not do any database calls & is working fine with TestRunner.
But I am getting error for the function which does database access using OM classes during run time.
 
java.lang.ExceptionInInitializerError: org.apache.turbine.services.InstantiationException: ServiceBroker: unknown service LoggingService requested
 at org.apache.turbine.services.BaseServiceBroker.getServiceInstance(BaseServiceBroker.java:356)
 at org.apache.turbine.services.BaseServiceBroker.getService(BaseServiceBroker.java:298)
 at org.apache.turbine.util.Log.error(Log.java:449)
 at org.apache.turbine.om.peer.BasePeer.getMapBuilder(BasePeer.java:1863)
 at com.sawyermedia.mam.om.BaseCompanyPeer.<clinit>(BaseCompanyPeer.java:34)
 at com.sawyermedia.mam.business.company.MyCompaniesManager.getAllCompanies(MyCompaniesManager.java:31)
 at com.sawyermedia.mam.business.company.MyCompaniesManagerTest.testXyz(MyCompaniesManagerTest.java:106)
 at java.lang.reflect.Method.invoke(Native Method)
 at junit.framework.TestCase.runTest(TestCase.java:155)
 at junit.framework.TestCase.runBare(TestCase.java:129)
 at junit.framework.TestResult$1.protect(TestResult.java:100)
 at junit.framework.TestResult.runProtected(TestResult.java:117)
 at junit.framework.TestResult.run(TestResult.java:103)
 at junit.framework.TestCase.run(TestCase.java:120)
 at junit.framework.TestSuite.run(TestSuite.java:144)
 at junit.swingui.TestRunner$18.run(TestRunner.java:709)
 
This error message is from TestRunner window.
.
Since TestRunner is a stand alone application.And from this application i am trying to access the database method for testing,so I am getting the above error.
This is the issue of using Junit with tdk (OM classes). 

>From the above description it seems that we should have some way to initialize the  required service in the testcase class we define.
I have gone through the servlet class named Turbine ,which is the framework class for the turbine. In this class in init method the services are initialized passing the configuration object. I have to see if there is any way to initialize the required service in an stand alone application.So my problem may be solved.

Hoping for the solution of the problem.

Thanks in advance!

With Regards
Amit