JUnit 的扩展 NoSQLUnit 0.4.0 发布,支持 Cassandra
openkk 12年前
<p><em>NoSQLUnit</em> 是一个 <em>JUnit</em> 的扩展,用来为那些使用了 NoSQL 后端的应用提供单元测试和集成测试的工具。<br /> <br /> NoSQLUnit 0.4.0 发布了,该版本主要是增加对 <a href="http://www.open-open.com/lib/view/open1322706580499.html" target="_blank">Cassandra</a> 的支持,包括:</p> <ul> <li>Embedded: <em>com.lordofthejars.nosqlunit.cassandra.EmbeddedCassandra</em></li> <li>Managed: <em>com.lordofthejars.nosqlunit.cassandra.ManagedCassandra</em></li> </ul> <p>使用示例:</p> <pre class="brush:java; toolbar: true; auto-links: false;">package com.lordofthejars.nosqlunit.demo.mongodb; public class WhenANewBookIsCreated { @ClassRule public static ManagedMongoDb managedMongoDb = newManagedMongoDbRule().mongodPath("/opt/mongo").build(); @Rule public MongoDbRule remoteMongoDbRule = new MongoDbRule(mongoDb().databaseName("test").build()); @Test @UsingDataSet(locations="initialData.json", loadStrategy=LoadStrategyEnum.CLEAN_INSERT) @ShouldMatchDataSet(location="expectedData.json") public void book_should_be_inserted_into_repository() { BookManager bookManager = new BookManager(MongoDbUtil.getCollection(Book.class.getSimpleName())); Book book = new Book("The Lord Of The Rings", 1299); bookManager.create(book); } }</pre> <p></p>