Skip to content

Instantly share code, notes, and snippets.

@eyalgo
Created September 11, 2014 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyalgo/26ecf2cc1c021d67c5db to your computer and use it in GitHub Desktop.
Save eyalgo/26ecf2cc1c021d67c5db to your computer and use it in GitHub Desktop.
public class DbConnectionRule extends ExternalResource {
private DbConnectionManager connection;
public DbConnectionRule() {
}
@Override
protected void before() throws Throwable {
ClassPathXmlApplicationContext ctx = null;
try {
ctx = new ClassPathXmlApplicationContext("/META-INF/my-db-connection-TEST-ctx.xml");
mongoDb = (DbConnectionManager) ctx.getBean("myDbConnection");
} finally {
if (ctx != null) {
ctx.close();
}
}
}
@Override
protected void after() {
}
public DbConnectionManager getDbConnecttion() {
return connection;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment