martes, agosto 07, 2012

NoSQLUnit 0.3.2 Released


Yo no te pido la luna, tan solo quiero amarte. Quiero ser esa locura que vibra muy dentro de tí (Yo No Te Pido La Luna - Sergio Dalma)

Update: 0.3.3 version has been released providing In-Memory Neo4j lifecycle support.

NoSQLUnit is a JUnit extension to make writing unit and integration tests of systems that use NoSQL backend easier. Visit official page for more information.

In 0.3.2 release, one new NoSQL system is supported and is Neo4j.

Neo4j is a high-performance, NoSQL graph database with all the features of a mature and robust database.

As all databases supported by NoSQLUnit, two set of rules are provided to write Neo4j tests:

First set of JUnit Rules are those responsible of managing database lifecycle; basically starting and stopping Neo4j.
  • Embedded: com.lordofthejars.nosqlunit.neo4j.EmbeddedNeo4j
  • Managed Wrapping: com.lordofthejars.nosqlunit.neo4j.ManagedWrappingNeoServer
  • Managed: com.lordofthejars.nosqlunit.neo4j.ManagedNeoServer
Depending on kind of test you are implementing (unit test, integration test, deployment test, ...) you will require an embedded approach, managed approach or  remote approach. Note that for now I have not implementated of a Neo4j in-memory database at this time (0.3.3 will do), but embedded strategy for unit tests will be the better one. As Neo4j developers will know, you can start remote Neo4j server by calling start/stop scripts (Managed way) or by using an embedded database wrapper by a server (Managed Wrapping way), both of them are supported by NoSQLUnit.

Second set of rules are those responsible of maintaining database into known state;
  • NoSQLUnit Management: com.lordofthejars.nosqlunit.neo4j.Neo4jRule
And finally default dataset file format in Neo4j is GraphML. GraphML is a comprehensive and easy-to-use file format for graphs.


We will use the example of finding Neo's friends as an example of how to write unit tests for systems that uses Neo4j databases as backend.

First of all dataset used to maintain Neo4j into known state:


and finally the test case:

Next release will support Cassandra. Stay in touch with the project and of course I am opened to any ideas that you think that could make NoSQLUnit better.

2 comentarios:

Michael Hunger dijo...

Hi Alex,

thanks so much for integrating Neo4j, thats really awesome.

Just wanted to point out one thing. Neo4j has a in-memory version of the database which works exactly as the real one.

Please see this chapter of the docs for dependency and usage: http://docs.neo4j.org/chunked/milestone/tutorials-java-unit-testing.html

Cheers

Michael

Alex Soto dijo...

Hi thank you very much for reading my blog and also helping me to improve NoSQLUnit. I read Neo4j documentation and I read about embedded way, and ImpermanentGraphDatabase but I do not understand that was only in-memory, but can be used for unit testing. Thank again and this afternoon I will release 0.3.3 version with in-memory approach supported.
Regards,
Alex.