Skip to content

Commit

Permalink
OGM-300 Re-creating session factory in OgmTestCase if it has been dis…
Browse files Browse the repository at this point in the history
…posed in earlier tests
  • Loading branch information
gunnarmorling committed Jul 12, 2013
1 parent 943ecee commit 7069ae5
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,18 @@ public abstract class OgmTestCase extends TestCase {
protected SessionFactory sessions;
private Session session;

@Override
@Before
public void setUp() throws Exception {
if ( cfg == null || lastTestClass != getClass() ) {
buildConfiguration();
lastTestClass = getClass();
}

// OGM-300: re-build session factory if it has been discarded by a previous test method
if ( sessions == null ) {
rebuildSessionFactory();
}
}

protected String[] getXmlFiles() {
Expand All @@ -100,6 +106,7 @@ protected static Configuration getCfg() {
protected void configure(Configuration cfg) {
}

@Override
@After
public void tearDown() throws Exception {
handleUnclosedResources();
Expand Down Expand Up @@ -339,7 +346,6 @@ protected void buildConfiguration() throws Exception {
setSessions( getCfg().buildSessionFactory( /* new TestInterceptor() */) );
}
catch ( Exception e ) {
e.printStackTrace();
throw e;
}
}
Expand Down

0 comments on commit 7069ae5

Please sign in to comment.