[opencms-dev] Unit Testing
Hernán Leoni
hernan.leoni at globant.com
Wed Mar 5 15:25:52 CET 2008
Hi Bobi,
I have not used OpenCmsTestCase, so, I don't really know too much about
which advantages it give. Sorry
Regards
Hernán
-----Original Message-----
From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Bozidar Ilievski
Sent: Martes, 04 de Marzo de 2008 09:02 p.m.
To: The OpenCms mailing list
Subject: Re: [opencms-dev] Unit Testing
Hi.
I solved this problem. It was somehow related to the log4j.properties
file. I copied the log4j.properties from the OpenCms web application,
and now I can instantiate the CmsShell class without problems.
I have another question related to Unit Testing with OpenCms.
Looking into the opencms sources (after checking out from their
repository) I see that almost all of their unit test classes inherit the
org.opencms.test.OpenCmsTestCase class.
But this class, and others in the org.opencms.test package, are not part
of the opencms.jar, so using them is not so easy, I guess.
My question is, am I as a module developer supposed to extend this class
(OpenCmsTestCase) for my test cases? If so, what is the easiest way to
do that?
Thanks, and
Best Regards.
Bobi.
Bozidar Ilievski wrote:
> Thanks for your reply Hernan.
>
> I'm trying to create new CmsShell as you suggested.
> But after hundreds of LOG messages, new CmsShell(...) statement starts
> to throw Exceptions.
> I tried with started and stoped Tomcat, but no success in either case.
>
> This is the Exception that is printed again and again:
>
> 21:36:09,969 DEBUG CmsVfsDriver:1793 - SELECT DISTINCT
>
CMS_ONLINE_RESOURCE_RELATIONS.RELATION_SOURCE_ID,CMS_ONLINE_RESOURCE_RELATIO
NS.RELATION_SOURCE_PATH,CMS_ONLINE_RESOURCE_RELATIONS.RELATION_TARGET_ID,CMS
_ONLINE_RESOURCE_RELATIONS.RELATION_TARGET_PATH,CMS_ONLINE_RESOURCE_RELATION
S.RELATION_TYPE
> FROM CMS_ONLINE_RESOURCE_RELATIONS WHERE
> (CMS_ONLINE_RESOURCE_RELATIONS.RELATION_SOURCE_ID = ?)
> 21:36:09,969 DEBUG CmsSqlManager:179 - Already closed
> java.sql.SQLException: Already closed
> at
>
org.apache.commons.dbcp.PoolablePreparedStatement.close(PoolablePreparedStat
ement.java:76)
> at
>
org.apache.commons.dbcp.DelegatingStatement.close(DelegatingStatement.java:1
68)
> at
org.opencms.db.generic.CmsSqlManager.closeAll(CmsSqlManager.java:176)
> at
> org.opencms.db.generic.CmsVfsDriver.readRelations(CmsVfsDriver.java:1811)
> at
>
org.opencms.db.CmsDriverManager.getRelationsForResource(CmsDriverManager.jav
a:3921)
> at
>
org.opencms.db.generic.CmsUserDriver.internalResourcesForOrgUnit(CmsUserDriv
er.java:2436)
> at
>
org.opencms.db.generic.CmsUserDriver.getResourcesForOrganizationalUnit(CmsUs
erDriver.java:854)
> at
>
org.opencms.db.CmsDriverManager.getResourcesForOrganizationalUnit(CmsDriverM
anager.java:3941)
> at
>
org.opencms.db.CmsSecurityManager.hasRoleForResource(CmsSecurityManager.java
:2483)
> at
>
org.opencms.security.CmsDefaultPermissionHandler.hasPermissions(CmsDefaultPe
rmissionHandler.java:114)
> at
>
org.opencms.db.CmsSecurityManager.hasPermissions(CmsSecurityManager.java:556
0)
> at
>
org.opencms.db.CmsDriverManager.filterPermissions(CmsDriverManager.java:8436
)
> at
>
org.opencms.db.CmsDriverManager.readResourcesWithProperty(CmsDriverManager.j
ava:6465)
> at
>
org.opencms.db.CmsSecurityManager.readResourcesWithProperty(CmsSecurityManag
er.java:4067)
> at
> org.opencms.file.CmsObject.readResourcesWithProperty(CmsObject.java:3589)
> at
> org.opencms.file.CmsObject.readResourcesWithProperty(CmsObject.java:3565)
> at
>
org.opencms.workplace.tools.CmsToolManager.configureToolRoot(CmsToolManager.
java:595)
> at
>
org.opencms.workplace.tools.CmsToolManager.configure(CmsToolManager.java:200
)
> at
>
org.opencms.workplace.CmsWorkplaceManager.initialize(CmsWorkplaceManager.jav
a:1174)
> at
org.opencms.main.OpenCmsCore.initConfiguration(OpenCmsCore.java:1184)
> at
org.opencms.main.OpenCmsCore.upgradeRunlevel(OpenCmsCore.java:1692)
> at org.opencms.main.CmsShell.<init>(CmsShell.java:450)
> .
> .
> .
>
>
> Hernán Leoni wrote:
>> Hi, you can connect to the instance using CmsShell,
>>
>>
>> // tomcat folder, (or servlet container folder)
>> String tomcatDir = properties.getProperty("tomcat.dir");
>> // web app name, opencms by default
>> String webAppName = properties.getProperty("tomcat.app.name");
>>
>> new CmsShell(tomcatDir + "/webapps/" + webAppName + "/WEB-INF/",
null,
>> null, "${user}@${project}>", null);
>> cms = OpenCms.initCmsObject("Guest");
>> cms.loginUser("Admin", "admin");
>>
>> so, you yave a CmsObject to use with your opencms instance
>>
>> Regards,
>>
>> Hernan
>>
>> -----Original Message-----
>> From: opencms-dev-bounces at opencms.org
>> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Bozidar Ilievski
>> Sent: Lunes, 03 de Marzo de 2008 05:03 p.m.
>> To: The OpenCms mailing list
>> Subject: [opencms-dev] Unit Testing
>>
>> Hi.
>>
>> I'm trying to write some unit test for an OpenCms Module that I'm
>> developing.
>> These test should be run independently from the webapp, in another JVM.
>> But the problem is how to connect to the running instance of OpenCms and
>> read/write to its VFS.
>>
>> Simple example: how can I read some resource from the VFS, and print it
>> to standard output.
>>
>> Regards,
>> Bobi.
>>
>
--
Bozidar Ilievski | bozidar.ilievski at netcetera.com.mk
phone +389 -2- 30 64 532 | fax +389 -2- 30 79 495
Netcetera | 1000 Skopje | Macedonia | http://netcetera.com.mk
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list