[Blueprints] Better TestCase handling.

27 views
Skip to first unread message

Marko Rodriguez

unread,
Jun 7, 2012, 1:19:46 PM6/7/12
to gremli...@googlegroups.com
Hi,

I read this:

And updated the JUnit tests in Blueprints so that target/test-data holds the databases and database files. This way, no more C:/temp or /tmp.

That one is for you Luca,
Marko.

Luca Garulli

unread,
Jun 7, 2012, 2:33:20 PM6/7/12
to gremli...@googlegroups.com
Hi,
have you changed the OrientDB test?

Lvc@

Marko Rodriguez

unread,
Jun 7, 2012, 4:59:11 PM6/7/12
to gremli...@googlegroups.com
Yes. Stephen was saying that OrientGraphTest was acting weird on Windows.

Can you have a looksy, please? .... Its pretty basic what I did, just changed the directory to use target/ instead of temp/.


Marko.

Joshua Shinavier

unread,
Jun 7, 2012, 5:18:45 PM6/7/12
to gremli...@googlegroups.com
Out of curiosity, what was the issue with temp files? It was a little
awkward the way some of the tests were building the temp file
directory, but Java actually makes this pretty easy. E.g. see
Neo4jGraphSailTest:

File dir = File.createTempFile("blueprints", "-neo4j-test");
String path = dir.getPath();
dir.delete();
dir.mkdir();

Josh

Jeff Ramsdale

unread,
Jun 7, 2012, 5:34:21 PM6/7/12
to gremli...@googlegroups.com
It's not a big deal to do try/catch to clean up temp files/dirs in
case of exceptions, but it does add a bit of boilerplate code to a
test.

I liked the 8th comment on the initial blog post that points to JUnit
4.7+ and its support for auto-cleanup of temp resources:
http://weblogs.java.net/blog/johnsmart/archive/2009/09/29/working-temporary-files-junit-47

Seems like that'd be the cleanest approach.

-jeff

Alfredo Serafini

unread,
Jun 7, 2012, 7:58:26 PM6/7/12
to gremli...@googlegroups.com
yes the cleanup by an annotated post (or sometimes pre, it depends) condition it's more clear.
Please consider that dir.delete() does not always return immediatly what we expected, especially on windows it sometimes has some delay, and this could introduce some weird result in the test

this is another idea:
Reply all
Reply to author
Forward
0 new messages