func (suite *DynamicObjPropStoreSuite) TestSwapReplacesWrapped(c *check.C) {
	objId0 := res.MakeObjectID(res.ObjectClass(0), res.ObjectSubclass(0), res.ObjectType(0))
	objId1 := res.MakeObjectID(res.ObjectClass(0), res.ObjectSubclass(0), res.ObjectType(1))
	secondData := suite.testData(6)
	provider0 := suite.createProvider(func(consumer objprop.Consumer) {
		consumer.Consume(objId0, suite.testData(3))
		consumer.Consume(objId1, suite.testData(3))
	})
	provider1 := suite.createProvider(func(consumer objprop.Consumer) {
		consumer.Consume(objId0, suite.testData(5))
		consumer.Consume(objId1, secondData)
	})

	testStore := NewDynamicObjPropStore(store.NewProviderBacked(provider0, func() {}))
	testStore.Swap(func(oldStore objprop.Store) objprop.Store {
		return store.NewProviderBacked(provider1, func() {})
	})

	retrievedData := testStore.Get(objId1)

	c.Check(retrievedData.Common, check.DeepEquals, secondData.Common)
	c.Check(retrievedData.Generic, check.DeepEquals, secondData.Generic)
	c.Check(retrievedData.Specific, check.DeepEquals, secondData.Specific)
}
func (library *ReleaseStoreLibrary) createSavingObjpropStore(provider objprop.Provider, path string, name string, closer func()) objprop.Store {
	storeChanged := make(chan interface{})
	onStoreChanged := func() { storeChanged <- nil }
	chunkStore := NewDynamicObjPropStore(storeObjprop.NewProviderBacked(provider, onStoreChanged))

	closeLastReader := closer
	saveAndSwap := func() {
		chunkStore.Swap(func(oldStore objprop.Store) objprop.Store {
			log.Printf("Saving resource <%s>/<%s>\n", path, name)
			data := library.serializeObjpropStore(oldStore)
			log.Printf("Serialized previous data, closing old reader")
			closeLastReader()

			log.Printf("Recreating new reader for new data")
			newProvider, newReader := library.saveAndReloadObjpropData(data, path, name)
			closeLastReader = func() { newReader.Close() }

			return storeObjprop.NewProviderBacked(newProvider, onStoreChanged)
		})
	}
	library.startSaverRoutine(storeChanged, saveAndSwap)

	return chunkStore
}
func (suite *DynamicObjPropStoreSuite) TestGetReturnsBlockFromWrapped(c *check.C) {
	objId := res.MakeObjectID(res.ObjectClass(0), res.ObjectSubclass(0), res.ObjectType(0))
	initData := suite.testData(4)
	provider := suite.createProvider(func(consumer objprop.Consumer) {
		consumer.Consume(objId, initData)
	})

	wrappedStore := store.NewProviderBacked(provider, func() {})
	testStore := NewDynamicObjPropStore(wrappedStore)

	retrievedData := testStore.Get(objId)

	c.Check(retrievedData.Common, check.DeepEquals, initData.Common)
	c.Check(retrievedData.Generic, check.DeepEquals, initData.Generic)
	c.Check(retrievedData.Specific, check.DeepEquals, initData.Specific)
}
func (suite *DynamicObjPropStoreSuite) TestPutInsertsToWrapped(c *check.C) {
	objId := res.MakeObjectID(res.ObjectClass(0), res.ObjectSubclass(0), res.ObjectType(0))
	provider := suite.createProvider(func(consumer objprop.Consumer) {
		consumer.Consume(objId, suite.testData(0))
	})

	wrappedStore := store.NewProviderBacked(provider, func() {})
	testStore := NewDynamicObjPropStore(wrappedStore)
	newData := suite.testData(1)

	testStore.Put(objId, newData)

	wrappedData := wrappedStore.Get(objId)

	c.Check(wrappedData.Common, check.DeepEquals, newData.Common)
	c.Check(wrappedData.Generic, check.DeepEquals, newData.Generic)
	c.Check(wrappedData.Specific, check.DeepEquals, newData.Specific)
}