use of org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache in project legend-pure by finos.
the class TestGraphIsSerialized method testInitializedFromGraphLoaderSerialization.
@Test
public void testInitializedFromGraphLoaderSerialization() {
PureRuntime runtime = new PureRuntimeBuilder(getCodeStorage()).buildAndInitialize();
PureGraphCache cache = new MemoryGraphLoaderPureGraphCache();
cache.setPureRuntime(runtime);
cache.cacheRepoAndSources();
runtime = new PureRuntimeBuilder(getCodeStorage()).withCache(cache).buildAndTryToInitializeFromCache();
new FunctionExecutionCompiledBuilder().build().init(runtime, new Message(""));
Assert.assertTrue(cache.getCacheState().getLastStackTrace(), runtime.isInitialized());
assertAllInstancesMarkedSerialized(runtime);
}
use of org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache in project legend-pure by finos.
the class TestGraphIsSerialized method testInitializedFromM4Serialization.
@Test
public void testInitializedFromM4Serialization() {
PureRuntime runtime = new PureRuntimeBuilder(getCodeStorage()).buildAndInitialize();
PureGraphCache cache = new MemoryPureGraphCache();
cache.setPureRuntime(runtime);
cache.cacheRepoAndSources();
runtime = new PureRuntimeBuilder(getCodeStorage()).withCache(cache).buildAndTryToInitializeFromCache();
new FunctionExecutionCompiledBuilder().build().init(runtime, new Message(""));
Assert.assertTrue(cache.getCacheState().getLastStackTrace(), runtime.isInitialized());
assertAllInstancesMarkedSerialized(runtime);
}
use of org.finos.legend.pure.m3.serialization.runtime.cache.PureGraphCache in project legend-pure by finos.
the class TestPureRuntime method testInstancesInContextDuringCaching.
@Test
public void testInstancesInContextDuringCaching() {
MutableCodeStorage codeStorage = new PureCodeStorage(Paths.get("..", "pure-code", "local"), new ClassLoaderCodeStorage(CodeRepository.newPlatformCodeRepository()));
PureGraphCache cache = new CompressedMemoryPureGraphCache();
Assert.assertFalse(cache.getCacheState().isCached());
PureRuntime runtime = new PureRuntimeBuilder(codeStorage).withCache(cache).buildAndTryToInitializeFromCache();
runtime.loadAndCompileCore();
cache.cacheRepoAndSources();
Assert.assertTrue(cache.getCacheState().isCached());
Assert.assertTrue(cache.getCacheState().getCurrentCacheSize() > 0);
PureRuntime newRuntime = new PureRuntimeBuilder(codeStorage).withCache(cache).buildAndTryToInitializeFromCache();
Assert.assertEquals(runtime.getContext().getAllInstances().collect(CoreInstance.GET_NAME).toSortedList(), newRuntime.getContext().getAllInstances().collect(CoreInstance.GET_NAME).toSortedList());
}
Aggregations