Ok the problem of the HsqlServer approach was that it was far too heavy for 
testing purposes so, as I knew there is a in-memory configuration for HSQKDB I 
managed to get a working database access for my tests with the following 
dataSource bean configuration :



<beans>

&nbsp; &nbsp; <bean id="dataSource" 
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

&nbsp; &nbsp; &nbsp; &nbsp; <property name="driverClassName">

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>org.hsqldb.jdbcDriver</value>

&nbsp; &nbsp; &nbsp; &nbsp; </property>

&nbsp; &nbsp; &nbsp; &nbsp; <property name="url">

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
<value>jdbc&#58;hsqldb&#58;mem&#58;testdb</value>

&nbsp; &nbsp; &nbsp; &nbsp; </property>

&nbsp; &nbsp; &nbsp; &nbsp; <property name="username">

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>sa</value>

&nbsp; &nbsp; &nbsp; &nbsp; </property>

&nbsp; &nbsp; &nbsp; &nbsp; <property name="password">

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value/>

&nbsp; &nbsp; &nbsp; &nbsp; </property>

&nbsp; &nbsp; &nbsp; &nbsp; <property name="defaultAutoCommit">

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <value>false</value>

&nbsp; &nbsp; &nbsp; &nbsp; </property>

&nbsp; &nbsp; </bean>

</beans>



This configuration has the enormous advantage it creates no file at all and 
with the following hibernate.properties file in my test classpath, it doesn't 
even require me to create the database schema as it is created dynamically from 
mapping files :



hibernate.hbm2ddl.auto=update





This works for the first simple database access but the problem is that I get a 
lazy loading exception when I access the first Collection.



public void testHandleInitialize&#40;&#41; &#123;

&nbsp; &nbsp;&nbsp; &nbsp;Schaman schaman = serviceLocator.getSchaman&#40;&#41;;

&nbsp; &nbsp;&nbsp; 
&nbsp;schaman.initialize&#40;"test","http&#58;//test.com","[EMAIL 
PROTECTED]","admin","password"&#41;;

&nbsp; &nbsp;&nbsp; 
&nbsp;assertNotNull&#40;schaman.getRepository&#40;&#41;&#41;;

&nbsp; &nbsp;&nbsp; 
&nbsp;assertEquals&#40;schaman.getRepository&#40;&#41;.getUsers&#40;&#41;.size&#40;&#41;,1&#41;;

&nbsp; &nbsp;&nbsp; 
&nbsp;assertEquals&#40;schaman.getRepository&#40;&#41;.getRoles&#40;&#41;.size&#40;&#41;,1&#41;;

&nbsp; &nbsp;&nbsp; 
&nbsp;assertEquals&#40;schaman.getRepository&#40;&#41;.getPrivileges&#40;&#41;.size&#40;&#41;,1&#41;;

&nbsp; &nbsp;&nbsp; 
&nbsp;assertEquals&#40;schaman.getRepository&#40;&#41;.getModules&#40;&#41;.size&#40;&#41;,0&#41;;

&nbsp; &nbsp;&nbsp; 
&nbsp;assertEquals&#40;schaman.getRepository&#40;&#41;.getName&#40;&#41;,"test"&#41;;

&nbsp; &nbsp;&nbsp; 
&nbsp;assertEquals&#40;schaman.getRepository&#40;&#41;.getUri&#40;&#41;,"http&#58;//test.com"&#41;;

&nbsp; &nbsp;&nbsp; &nbsp;User admin = 
&#40;User&#41;schaman.getAllUsers&#40;&#41;.get&#40;0&#41;;

&nbsp; &nbsp;&nbsp; &nbsp;assertEquals&#40;admin.getName&#40;&#41;,"admin"&#41;;

&nbsp; &nbsp;&nbsp; &nbsp;assertEquals&#40;admin.getEmail&#40;&#41;,"[EMAIL 
PROTECTED]"&#41;;

&nbsp; &nbsp;&nbsp; 
&nbsp;assertEquals&#40;admin.getPassword&#40;&#41;,"password"&#41;;

&nbsp; &nbsp;&#125;





This test fails on the 3rd line of the method, when I try to access the users 
of the repository, with the following exception



Testcase&#58; 
testHandleInitialize&#40;ca.polymtl.larim.schaman.business.SchamanImplTest&#41;&#58;&nbsp;
 &nbsp;Caused an ERROR

Failed to lazily initialize a collection - no session or session was closed

net.sf.hibernate.LazyInitializationException&#58; Failed to lazily initialize a 
collection - no session or session was closed

&nbsp; &nbsp;at 
net.sf.hibernate.collection.PersistentCollection.initialize&#40;PersistentCollection.java&#58;209&#41;

&nbsp; &nbsp;at 
net.sf.hibernate.collection.PersistentCollection.read&#40;PersistentCollection.java&#58;71&#41;

&nbsp; &nbsp;at net.sf.hibernate.collection.Set.size&#40;Set.java&#58;106&#41;

&nbsp; &nbsp;at 
ca.polymtl.larim.schaman.business.SchamanImplTest.testHandleInitialize&#40;SchamanImplTest.java&#58;33&#41;

&nbsp; &nbsp;at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native 
Method&#41;

&nbsp; &nbsp;at 
sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;

&nbsp; &nbsp;at 
sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;

&nbsp; &nbsp;at 
org.apache.commons.jelly.tags.ant.AntTag.doTag&#40;AntTag.java&#58;185&#41;

&nbsp; &nbsp;at 
org.apache.commons.jelly.impl.TagScript.run&#40;TagScript.java&#58;279&#41;

&nbsp; &nbsp;at 
org.apache.commons.jelly.impl.ScriptBlock.run&#40;ScriptBlock.java&#58;135&#41;

&nbsp; &nbsp;at 
org.apache.commons.jelly.TagSupport.invokeBody&#40;TagSupport.java&#58;233&#41;

&nbsp; &nbsp;at 
org.apache.commons.jelly.tags.core.IfTag.doTag&#40;IfTag.java&#58;88&#41;

&nbsp; &nbsp;at 
org.apache.commons.jelly.impl.TagScript.run&#40;TagScript.java&#58;279&#41;

&nbsp; &nbsp;at 
org.apache.commons.jelly.impl.ScriptBlock.run&#40;ScriptBlock.java&#58;135&#41;

&nbsp; &nbsp;at 
org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag&#40;MavenGoalTag.java&#58;79&#41;

&nbsp; &nbsp;at 
org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction&#40;MavenGoalTag.java&#58;110&#41;

&nbsp; &nbsp;at com.werken.werkz.Goal.fire&#40;Goal.java&#58;639&#41;

&nbsp; &nbsp;at com.werken.werkz.Goal.attain&#40;Goal.java&#58;575&#41;

&nbsp; &nbsp;at 
com.werken.werkz.Goal.attainPrecursors&#40;Goal.java&#58;488&#41;

&nbsp; &nbsp;at com.werken.werkz.Goal.attain&#40;Goal.java&#58;573&#41;

&nbsp; &nbsp;at 
com.werken.werkz.Goal.attainPrecursors&#40;Goal.java&#58;488&#41;

&nbsp; &nbsp;at com.werken.werkz.Goal.attain&#40;Goal.java&#58;573&#41;

&nbsp; &nbsp;at 
com.werken.werkz.WerkzProject.attainGoal&#40;WerkzProject.java&#58;193&#41;

&nbsp; &nbsp;at 
org.apache.maven.jelly.tags.werkz.MavenAttainGoalTag.doTag&#40;MavenAttainGoalTag.java&#58;127&#41;

&nbsp; &nbsp;at 
org.apache.commons.jelly.impl.TagScript.run&#40;TagScript.java&#58;279&#41;

&nbsp; &nbsp;at 
org.apache.commons.jelly.impl.ScriptBlock.run&#40;ScriptBlock.java&#58;135&#41;

&nbsp; &nbsp;at 
org.apache.maven.jelly.tags.werkz.MavenGoalTag.runBodyTag&#40;MavenGoalTag.java&#58;79&#41;

&nbsp; &nbsp;at 
org.apache.maven.jelly.tags.werkz.MavenGoalTag$MavenGoalAction.performAction&#40;MavenGoalTag.java&#58;110&#41;

&nbsp; &nbsp;at com.werken.werkz.Goal.fire&#40;Goal.java&#58;639&#41;

&nbsp; &nbsp;at com.werken.werkz.Goal.attain&#40;Goal.java&#58;575&#41;

&nbsp; &nbsp;at 
org.apache.maven.plugin.PluginManager.attainGoals&#40;PluginManager.java&#58;671&#41;

&nbsp; &nbsp;at 
org.apache.maven.MavenSession.attainGoals&#40;MavenSession.java&#58;263&#41;

&nbsp; &nbsp;at org.apache.maven.cli.App.doMain&#40;App.java&#58;488&#41;

&nbsp; &nbsp;at org.apache.maven.cli.App.main&#40;App.java&#58;1239&#41;

&nbsp; &nbsp;at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native 
Method&#41;

&nbsp; &nbsp;at 
sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;

&nbsp; &nbsp;at 
sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;

&nbsp; &nbsp;at com.werken.forehead.Forehead.run&#40;Forehead.java&#58;551&#41;

&nbsp; &nbsp;at 
com.werken.forehead.Forehead.main&#40;Forehead.java&#58;581&#41; 





Any idea of where it comes from and how I can do to keep my session opened?



Thx in advance.
--
S�bastien Arbogast
_________________________________________________________
Reply to the post : http://galaxy.andromda.org/forum/viewtopic.php?p=250#250
Posting to http://forum.andromda.org/ is preferred over posting to the mailing 
list!


-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
Andromda-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/andromda-user

Reply via email to