Re: [Neo4j] Test and try/catch block

2011-09-01 Thread Peter Neubauer
I like.
Thanks for sharing it!

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 Tue, Aug 30, 2011 at 2:31 PM, Benjamin Gehrels 
neo4j-mailingl...@gehrels.info wrote:

 TemporaryFolder is a Junit-Rule coming with JUnit 4.7

 The TemporaryFolder Rule allows creation of files and folders that are
 guaranteed to be deleted when the test method finishes (whether it
 passes or fails)


 http://kentbeck.github.com/junit/javadoc/latest/org/junit/rules/TemporaryFolder.html

 Best Regards,
 Benjamin

 Am Dienstag, 30. August 2011 10:34:23, Peter Neubauer schrieb:
  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 Smirnovalsmirn...@gmail.com
 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 Webberj...@neotechnology.com
  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
  User@lists.neo4j.org
  https://lists.neo4j.org/mailman/listinfo/user
 
 
 
 
  --
  _
  entia non sunt multiplicanda praeter necessitatem,
  (entities should not be multiplied beyond necessity.)
  ___
  Neo4j mailing list
  User@lists.neo4j.org
  https://lists.neo4j.org/mailman/listinfo/user
 
  ___
  Neo4j mailing list
  User@lists.neo4j.org
  https://lists.neo4j.org/mailman/listinfo/user
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Test and try/catch block

2011-08-30 Thread Peter Neubauer
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 alsmirn...@gmail.comwrote:

 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 j...@neotechnology.com 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
  User@lists.neo4j.org
  https://lists.neo4j.org/mailman/listinfo/user
 



 --
 _
 entia non sunt multiplicanda praeter necessitatem,
 (entities should not be multiplied beyond necessity.)
 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Test and try/catch block

2011-08-29 Thread Alexander Smirnov
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 j...@neotechnology.com 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
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user




-- 
_
entia non sunt multiplicanda praeter necessitatem,
(entities should not be multiplied beyond necessity.)
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Test and try/catch block

2011-08-25 Thread Jim Webber
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
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user