Skip to content

Instantly share code, notes, and snippets.

@gscheibel
Created December 26, 2013 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gscheibel/8138722 to your computer and use it in GitHub Desktop.
Save gscheibel/8138722 to your computer and use it in GitHub Desktop.
MongoDB cachestore standalone test
@Test
public void testCreateCacheStore() throws Exception {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.loaders().addStore(MongoDBCacheStoreConfigurationBuilder.class)
.host(hostname)
.port(port)
.acknowledgment(0)
.database(DATABASE)
.collection(COLLECTION).async().disable();
Configuration configuration = builder.build();
DefaultCacheManager cacheManager = new DefaultCacheManager();
cacheManager.defineConfiguration("default", configuration);
Cache<Object, Object> cache = cacheManager.getCache("default");
cache.put("key", "value");
System.out.println(cache.values());
assertThat(collection.count(), is(1L));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment