[opencms-dev] Unit Testing

Bozidar Ilievski bozidar.ilievski at netcetera.com.mk
Mon Mar 3 21:45:39 CET 2008


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_RELATIONS.RELATION_SOURCE_PATH,CMS_ONLINE_RESOURCE_RELATIONS.RELATION_TARGET_ID,CMS_ONLINE_RESOURCE_RELATIONS.RELATION_TARGET_PATH,CMS_ONLINE_RESOURCE_RELATIONS.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(PoolablePreparedStatement.java:76)
	at 
org.apache.commons.dbcp.DelegatingStatement.close(DelegatingStatement.java:168)
	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.java:3921)
	at 
org.opencms.db.generic.CmsUserDriver.internalResourcesForOrgUnit(CmsUserDriver.java:2436)
	at 
org.opencms.db.generic.CmsUserDriver.getResourcesForOrganizationalUnit(CmsUserDriver.java:854)
	at 
org.opencms.db.CmsDriverManager.getResourcesForOrganizationalUnit(CmsDriverManager.java:3941)
	at 
org.opencms.db.CmsSecurityManager.hasRoleForResource(CmsSecurityManager.java:2483)
	at 
org.opencms.security.CmsDefaultPermissionHandler.hasPermissions(CmsDefaultPermissionHandler.java:114)
	at 
org.opencms.db.CmsSecurityManager.hasPermissions(CmsSecurityManager.java:5560)
	at 
org.opencms.db.CmsDriverManager.filterPermissions(CmsDriverManager.java:8436)
	at 
org.opencms.db.CmsDriverManager.readResourcesWithProperty(CmsDriverManager.java:6465)
	at 
org.opencms.db.CmsSecurityManager.readResourcesWithProperty(CmsSecurityManager.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.java: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



More information about the opencms-dev mailing list