#: Alexandru Popescu changed the world a bit at a time by saying (astral date: 2/4/2006 1:01 PM) :# > Hi! > > I have a set of tests (more or less unit tests). Considering that I want to be able to run some of > them individually or all of them I have each TestCase returning a RepositoryLifecycleTestSetup (that > is registering/unregistering the test repository). > > [code] > public class MyTestClass extends TestCase { > public static Test suite() { > return new RepositoryLifecycleTestSetup(new TestSuite(MyTestClass.class)); > } > > [...] > } > [/code] > > [code] > package org.apache.portals.graffito.jcr; > > import org.apache.portals.graffito.jcr.repository.RepositoryUtil; > > import junit.extensions.TestSetup; > import junit.framework.Test; > > > /** > * This class/interface > */ > public class RepositoryLifecycleTestSetup extends TestSetup { > public RepositoryLifecycleTestSetup(Test test) { > super(test); > } > > /** > * @see junit.extensions.TestSetup#setUp() > */ > protected void setUp() throws Exception { > super.setUp(); > RepositoryUtil.registerRepository("repositoryTest", > "./src/test-config/repository-derby.xml", "./target/repository"); > } > > /** > * @see junit.extensions.TestSetup#tearDown() > */ > protected void tearDown() throws Exception { > RepositoryUtil.unRegisterRepository("repositoryTest"); > super.tearDown(); > } > > > } > [/code] > > While running test by test this works as expected, when trying to run all tests in the package I hit > quite soon an OutOfMemory problem: > > [stacktrace] > javax.jcr.RepositoryException: failed to write node state: 86d66b84-96c3-434c-bf0c-5bd7630cb254: > Java exception: 'Java heap space: java.lang.OutOfMemoryError'.: failed to write node state: > 86d66b84-96c3-434c-bf0c-5bd7630cb254: Java exception: 'Java heap space: java.lang.OutOfMemoryError'. > at > org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:273) > at > org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:193) > at org.apache.jackrabbit.core.ItemImpl.initVersionHistories(ItemImpl.java:736) > at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1150) > at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:758) > at > org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl.save(PersistenceManagerImpl.java:894) > at > org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerTest.testClassA(PersistenceManagerTest.java:112) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at junit.framework.TestCase.runTest(TestCase.java:154) > at junit.framework.TestCase.runBare(TestCase.java:127) > 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.extensions.TestDecorator.basicRun(TestDecorator.java:22) > at junit.extensions.TestSetup$1.protect(TestSetup.java:19) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.extensions.TestSetup.run(TestSetup.java:23) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) > Caused by: org.apache.jackrabbit.core.state.ItemStateException: failed to write node state: > 86d66b84-96c3-434c-bf0c-5bd7630cb254: Java exception: 'Java heap space: java.lang.OutOfMemoryError'. > at > org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:592) > at > org.apache.jackrabbit.core.state.AbstractPersistenceManager.store(AbstractPersistenceManager.java:78) > at > org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:446) > at org.apache.jackrabbit.core.state.SharedItemStateManager.store(SharedItemStateManager.java:514) > at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:344) > at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:306) > at > org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:266) > ... 25 more > Caused by: SQL Exception: Java exception: 'Java heap space: java.lang.OutOfMemoryError'. > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source) > at > org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:585) > ... 31 more > org.apache.jackrabbit.core.state.ItemStateException: failed to write node state: > 86d66b84-96c3-434c-bf0c-5bd7630cb254: Java exception: 'Java heap space: java.lang.OutOfMemoryError'. > at > org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:592) > at > org.apache.jackrabbit.core.state.AbstractPersistenceManager.store(AbstractPersistenceManager.java:78) > at > org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:446) > at org.apache.jackrabbit.core.state.SharedItemStateManager.store(SharedItemStateManager.java:514) > at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:344) > at org.apache.jackrabbit.core.state.LocalItemStateManager.update(LocalItemStateManager.java:306) > at > org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:266) > at > org.apache.jackrabbit.core.version.VersionManagerImpl.createVersionHistory(VersionManagerImpl.java:193) > at org.apache.jackrabbit.core.ItemImpl.initVersionHistories(ItemImpl.java:736) > at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:1150) > at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:758) > at > org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl.save(PersistenceManagerImpl.java:894) > at > org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerTest.testClassA(PersistenceManagerTest.java:112) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:585) > at junit.framework.TestCase.runTest(TestCase.java:154) > at junit.framework.TestCase.runBare(TestCase.java:127) > 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.extensions.TestDecorator.basicRun(TestDecorator.java:22) > at junit.extensions.TestSetup$1.protect(TestSetup.java:19) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.extensions.TestSetup.run(TestSetup.java:23) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) > Caused by: SQL Exception: Java exception: 'Java heap space: java.lang.OutOfMemoryError'. > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source) > at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source) > at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source) > at > org.apache.jackrabbit.core.state.db.SimpleDbPersistenceManager.store(SimpleDbPersistenceManager.java:585) > ... 31 more > java.lang.OutOfMemoryError: Java heap space > [/stacktrace] > > Now my question is: am I doing something stupid with these tests or is it what I imagine it can be > (derby is not able to handle anymore connections). > > thanks in advance, > > ./alex > -- > .w( the_mindstorm )p. > Some more details about this: the jackrabbit version against which the tests are run is: r367360. Between that moment and the current head there where no changes to the SimpleDbPersistenceManager. Another very interesting result is that if I switch the PersistenceManager to BerkleyDb I am not hitting this problem, so I start to think that my assumption about SimpleDbPersistenceManager is true. thanks in advance for any comments, ideas, suggestions, ./alex -- .w( the_mindstorm )p.