Skip to content

Instantly share code, notes, and snippets.

@debop
Created July 20, 2013 03:11
Show Gist options
  • Select an option

  • Save debop/6043701 to your computer and use it in GitHub Desktop.

Select an option

Save debop/6043701 to your computer and use it in GitHub Desktop.
@Test
@SuppressWarnings("unchecked")
public void configurationTest() throws InterruptedException {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.loaders().addStore(MongoDBCacheStoreConfigurationBuilder.class)
.host("localhost")
.port(27017)
.timeout(2000)
.acknowledgment(0)
.database("infinispan_cachestore")
.collection("entries");
final Configuration config = builder.build(true);
MongoDBCacheStoreConfiguration store = (MongoDBCacheStoreConfiguration) config.loaders().cacheLoaders().get(0);
DefaultCacheManager manager = new DefaultCacheManager();
manager.defineConfiguration("entries", config);
Cache cache = manager.getCache("entry");
assertThat(cache).isNotNull();
for (int i = 0; i < 5000; i++) {
cache.put("Element-" + i, "Value-" + i);
}
Thread.sleep(100);
assertThat(cache.get("Element-0")).isEqualTo("Value-0");
manager.stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment