Nice one! TemporaryFolder is a standard Java class or your custom one?
Cheers, /peter neubauer GTalk: neubauer.peter Skype peter.neubauer Phone +46 704 106975 LinkedIn http://www.linkedin.com/in/neubauer Twitter http://twitter.com/peterneubauer http://www.neo4j.org - Your high performance graph database. http://startupbootcamp.org/ - Ă–resund - Innovation happens HERE. http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. On Mon, Aug 29, 2011 at 9:51 PM, Alexander Smirnov <[email protected]>wrote: > I use jUnit MethodRule that starts embedded server in temporary folder > and cleans up transaction after the test: > public class Neo4jRule extends TemporaryFolder { > > private GraphDatabaseService graphDatabase; > private Transaction transaction; > > @Override > protected void before() throws Throwable { > super.before(); > graphDatabase = new > EmbeddedGraphDatabase(newFolder("neo4j").getAbsolutePath()); > transaction = graphDatabase.beginTx(); > } > > @Override > protected void after() { > transaction.finish(); > graphDatabase.shutdown(); > super.after(); > } > > public GraphDatabaseService getGraphDatabase() { > return graphDatabase; > } > > public Transaction getTransaction() { > return transaction; > } > } > > On Thu, Aug 25, 2011 at 7:18 AM, Jim Webber <[email protected]> wrote: > > If you're using the standard try/catch/finally idiom in Neo4j then > consider using Nat Pryce/Steve Freeman's transactor pattern. > > > > We have an example of this in the neo4j server code here: > > > > > https://github.com/neo4j/community/blob/master/server/src/functionaltest/java/org/neo4j/server/helpers/Transactor.java > > > > It's not always appropriate, but it the general case it can keep your > code a bit terser and more intent-ful. > > > > Jim > > > > _______________________________________________ > > Neo4j mailing list > > [email protected] > > https://lists.neo4j.org/mailman/listinfo/user > > > > > > -- > _________________ > entia non sunt multiplicanda praeter necessitatem, > (entities should not be multiplied beyond necessity.) > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

