It looks like context.refresh() does get called twice - on two different application contexts. But since the H2 database is in memory, it has already been initialized.
So it looks like the issue is that the context gets initialized twice with the jbehave-spring archetype.
Here's the first initialization:

main@1, prio=5, in group 'main', status: 'RUNNING'
	  at org.jbehave.core.steps.spring.SpringApplicationContextFactory.createApplicationContext(SpringApplicationContextFactory.java:72)
	  at com.ften.rx.jbehave.MyStories.stepsFactory(MyStories.java:77)
	  at org.jbehave.core.ConfigurableEmbedder.configuredEmbedder(ConfigurableEmbedder.java:88)
	  at com.ften.rx.jbehave.MyStories.<init>(MyStories.java:50)
	  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeConstructorAccessorImpl.java:-1)
	  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	  at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
	  at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:209)
	  at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:258)

here's the second call to refresh()

main@1, prio=5, in group 'main', status: 'RUNNING'
	  at org.jbehave.core.steps.spring.SpringApplicationContextFactory.createApplicationContext(SpringApplicationContextFactory.java:72)
	  at com.ften.rx.jbehave.MyStories.stepsFactory(MyStories.java:77)
	  at org.jbehave.core.ConfigurableEmbedder.configuredEmbedder(ConfigurableEmbedder.java:88)
	  at org.jbehave.core.junit.JUnitStories.run(JUnitStories.java:18)
	  at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
	  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	  at java.lang.reflect.Method.invoke(Method.java:601)
	  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	  at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

Perhaps the MyStories<init> shouldn't be calling configuredEmbedder, but it would appear that JUnitStories.run calls configuredEmbedder for each story, so this will probably be an issue once I get past the first story.
The Spring test framework has solutions around this, including using the same ApplicationContext across tests unless you call @DirtiesContext. And when the context is shut down, the in-memory database is disposed.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to