@Override public void assemble( ModuleAssembly module ) { super.assemble( module ); assembleCachePool( module ); }
@After @Override public void tearDown() throws Exception { super.tearDown(); // TODO : delete test data } }
@Override public void setUp() throws Exception { super.setUp(); }
@Test public void entityStatesSPI() { EntityStore entityStore = serviceFinder.findService( EntityStore.class ).get(); try( Stream<EntityState> states = entityStore.entityStates( module ) ) { assertThat( states.count(), is( 0L ) ); } UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork(); TestEntity newInstance = createEntity( unitOfWork ); unitOfWork.complete(); try( Stream<EntityState> states = entityStore.entityStates( module ) ) { assertThat( states.count(), is( 1L ) ); } unitOfWork = unitOfWorkFactory.newUnitOfWork(); TestEntity instance = unitOfWork.get( newInstance ); unitOfWork.remove( instance ); unitOfWork.complete(); try( Stream<EntityState> states = entityStore.entityStates( module ) ) { assertThat( states.count(), is( 0L ) ); } }
@Test @Override public void givenConcurrentUnitOfWorksWhenUoWCompletesThenCheckConcurrentModification() throws UnitOfWorkCompletionException { super.givenConcurrentUnitOfWorksWhenUoWCompletesThenCheckConcurrentModification(); }
@Test public void entityStatesSPI() { EntityStore entityStore = serviceFinder.findService( EntityStore.class ).get(); try( Stream<EntityState> states = entityStore.entityStates( module ) ) { assertThat( states.count(), is( 0L ) ); } UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork(); TestEntity newInstance = createEntity( unitOfWork ); unitOfWork.complete(); try( Stream<EntityState> states = entityStore.entityStates( module ) ) { assertThat( states.count(), is( 1L ) ); } unitOfWork = unitOfWorkFactory.newUnitOfWork(); TestEntity instance = unitOfWork.get( newInstance ); unitOfWork.remove( instance ); unitOfWork.complete(); try( Stream<EntityState> states = entityStore.entityStates( module ) ) { assertThat( states.count(), is( 0L ) ); } }
@Test public void givenConcurrentUnitOfWorksWhenUoWCompletesThenCheckConcurrentModification() throws UnitOfWorkCompletionException { super.givenConcurrentUnitOfWorksWhenUoWCompletesThenCheckConcurrentModification(); if( cachePool != null ) { MemoryCacheImpl<?> cache = cachePool.singleCache(); assertThat( cache.size(), is( 1 ) ); assertThat( cache.gets(), is( 4 ) ); assertThat( cache.puts(), is( 2 ) ); assertThat( cache.removes(), is( 0 ) ); assertThat( cache.exists(), is( 0 ) ); } }
@Override public void assemble( ModuleAssembly module ) { super.assemble( module ); assembleCachePool( module ); }
@Override public void tearDown() throws Exception { riakFixture.deleteTestData(); super.tearDown(); }
@Override public void setUp() throws Exception { super.setUp(); RedisEntityStoreService es = serviceFinder.findService( RedisEntityStoreService.class ).get(); jedisPool = es.jedisPool(); }
@Test public void givenEntityStoredLoadedChangedWhenUnitOfWorkDiscardsThenDontStoreState() throws UnitOfWorkCompletionException { UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork(); try { Identity identity = createEntity( unitOfWork ).identity().get(); unitOfWork.complete(); unitOfWork = unitOfWorkFactory.newUnitOfWork(); TestEntity entity = unitOfWork.get( TestEntity.class, identity ); assertThat( entity.intValue().get(), is( 42 ) ); entity.intValue().set( 23 ); unitOfWork.discard(); unitOfWork = unitOfWorkFactory.newUnitOfWork(); entity = unitOfWork.get( TestEntity.class, identity ); assertThat( entity.intValue().get(), is( 42 ) ); } finally { unitOfWork.discard(); } }
@Test public void givenConcurrentUnitOfWorksWhenUoWCompletesThenCheckConcurrentModification() throws UnitOfWorkCompletionException { super.givenConcurrentUnitOfWorksWhenUoWCompletesThenCheckConcurrentModification(); if( cachePool != null ) { MemoryCacheImpl<?> cache = cachePool.singleCache(); assertThat( cache.size(), is( 1 ) ); assertThat( cache.gets(), is( 4 ) ); assertThat( cache.puts(), is( 2 ) ); assertThat( cache.removes(), is( 0 ) ); assertThat( cache.exists(), is( 0 ) ); } }
@Override public void assemble( ModuleAssembly module ) { new MemoryEntityStoreAssembler().assemble( module ); // END SNIPPET: assembly super.assemble( module ); module.defaultServices(); // START SNIPPET: assembly } // END SNIPPET: assembly
@Override public void tearDown() throws Exception { try( Jedis jedis = jedisPool.getResource() ) { jedis.flushDB(); } super.tearDown(); } }
@Override public void setUp() throws Exception { super.setUp(); MongoDBEntityStoreService es = serviceFinder.findService( MongoDBEntityStoreService.class ).get(); mongo = es.mongoInstanceUsed(); dbName = es.dbInstanceUsed().getName(); }
@Test public void givenEntityStoredLoadedChangedWhenUnitOfWorkDiscardsThenDontStoreState() throws UnitOfWorkCompletionException { UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork(); try { Identity identity = createEntity( unitOfWork ).identity().get(); unitOfWork.complete(); unitOfWork = unitOfWorkFactory.newUnitOfWork(); TestEntity entity = unitOfWork.get( TestEntity.class, identity ); assertThat( entity.intValue().get(), is( 42 ) ); entity.intValue().set( 23 ); unitOfWork.discard(); unitOfWork = unitOfWorkFactory.newUnitOfWork(); entity = unitOfWork.get( TestEntity.class, identity ); assertThat( entity.intValue().get(), is( 42 ) ); } finally { unitOfWork.discard(); } }
@Override public void assemble( ModuleAssembly module ) throws AssemblyException { module.layer().application().setName( "PreferencesTest" ); super.assemble( module ); ClassLoader cl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader( null ); Preferences node = Preferences.userNodeForPackage( getClass() ) .node( "integtest" ) .node( tmpDir.getRoot().getName() ) .node( "PreferencesEntityStoreTest" ); PreferencesEntityStoreInfo metaInfo = new PreferencesEntityStoreInfo( node ); Thread.currentThread().setContextClassLoader( cl ); module.services( PreferencesEntityStoreService.class ).setMetaInfo( metaInfo ).instantiateOnStartup(); module.defaultServices(); } }
@Override public void tearDown() throws Exception { mongo.dropDatabase( dbName ); super.tearDown(); } }
@Override public void setUp() throws Exception { super.setUp(); RiakEntityStoreService es = serviceFinder.findService( RiakEntityStoreService.class ).get(); riakFixture = new RiakFixture( es.riakClient(), es.riakNamespace() ); riakFixture.waitUntilReady(); }
try( UnitOfWork unitOfWork = unitOfWorkFactory.newUnitOfWork() ) instance = createEntity( unitOfWork ); unitOfWork.complete();