-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-3926 Allow internal registry caches to be marked as persistent
- Loading branch information
1 parent
456dd14
commit db66ab8
Showing
6 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...va/org/infinispan/query/remote/impl/ProtobufMetadataCachePreserveStateAcrossRestarts.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.infinispan.query.remote.impl; | ||
|
||
import static org.testng.AssertJUnit.assertTrue; | ||
import org.infinispan.Cache; | ||
import org.infinispan.configuration.cache.ConfigurationBuilder; | ||
import org.infinispan.configuration.global.GlobalConfigurationBuilder; | ||
import org.infinispan.manager.EmbeddedCacheManager; | ||
import org.infinispan.test.AbstractInfinispanTest; | ||
import org.infinispan.test.CacheManagerCallable; | ||
import org.infinispan.test.TestingUtil; | ||
import org.infinispan.test.fwk.TestCacheManagerFactory; | ||
import org.testng.annotations.Test; | ||
import org.infinispan.query.remote.client.ProtobufMetadataManagerConstants; | ||
|
||
@Test(groups = "functional", testName = "query.remote.impl.ProtobufMetadataCachePreserveStateAcrossRestarts") | ||
public class ProtobufMetadataCachePreserveStateAcrossRestarts extends AbstractInfinispanTest { | ||
|
||
protected EmbeddedCacheManager createCacheManager(String persistentStateLocation) throws Exception { | ||
GlobalConfigurationBuilder global = new GlobalConfigurationBuilder(); | ||
global.statePersistence().enable().location(persistentStateLocation); | ||
EmbeddedCacheManager cacheManager = TestCacheManagerFactory.createCacheManager(global, new ConfigurationBuilder()); | ||
cacheManager.getCache(); | ||
return cacheManager; | ||
} | ||
|
||
public void testStatePreserved() throws Exception { | ||
String persistentStateLocation = TestingUtil.tmpDirectory(this.getClass()); | ||
TestingUtil.recursiveFileRemove(persistentStateLocation); | ||
|
||
TestingUtil.withCacheManager(new CacheManagerCallable(createCacheManager(persistentStateLocation)) { | ||
@Override | ||
public void call() throws Exception { | ||
Cache<String, String> protoBufMetadaCache = cm.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME); | ||
protoBufMetadaCache.put("test.proto", "package X;"); | ||
} | ||
}); | ||
|
||
TestingUtil.withCacheManager(new CacheManagerCallable(createCacheManager(persistentStateLocation)) { | ||
@Override | ||
public void call() throws Exception { | ||
Cache<String, String> protoBufMetadaCache = cm.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME); | ||
assertTrue(protoBufMetadaCache.containsKey("test.proto")); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
scripting/src/test/java/org/infinispan/scripting/ScriptCachePreserveStateAcrossRestarts.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.infinispan.scripting; | ||
|
||
import static org.testng.AssertJUnit.assertTrue; | ||
import java.io.InputStream; | ||
|
||
import org.infinispan.Cache; | ||
import org.infinispan.configuration.cache.ConfigurationBuilder; | ||
import org.infinispan.configuration.global.GlobalConfigurationBuilder; | ||
import org.infinispan.manager.EmbeddedCacheManager; | ||
import org.infinispan.scripting.impl.ScriptingManagerImpl; | ||
import org.infinispan.test.AbstractInfinispanTest; | ||
import org.infinispan.test.CacheManagerCallable; | ||
import org.infinispan.test.TestingUtil; | ||
import org.infinispan.test.fwk.TestCacheManagerFactory; | ||
import org.testng.annotations.Test; | ||
|
||
|
||
@Test(groups = "functional", testName = "scripting.ScriptCachePreserveStateAcrossRestarts") | ||
public class ScriptCachePreserveStateAcrossRestarts extends AbstractInfinispanTest { | ||
|
||
protected EmbeddedCacheManager createCacheManager(String persistentStateLocation) throws Exception { | ||
GlobalConfigurationBuilder global = new GlobalConfigurationBuilder(); | ||
global.statePersistence().enable().location(persistentStateLocation); | ||
EmbeddedCacheManager cacheManager = TestCacheManagerFactory.createCacheManager(global, new ConfigurationBuilder()); | ||
cacheManager.getCache(); | ||
return cacheManager; | ||
} | ||
|
||
public void testStatePreserved() throws Exception { | ||
String persistentStateLocation = TestingUtil.tmpDirectory(this.getClass()); | ||
TestingUtil.recursiveFileRemove(persistentStateLocation); | ||
|
||
TestingUtil.withCacheManager(new CacheManagerCallable(createCacheManager(persistentStateLocation)) { | ||
@Override | ||
public void call() throws Exception { | ||
Cache<String, String> scriptCache = cm.getCache(ScriptingManagerImpl.SCRIPT_CACHE); | ||
try (InputStream is = this.getClass().getResourceAsStream("/test.js")) { | ||
String script = TestingUtil.loadFileAsString(is); | ||
scriptCache.put("test.js", script); | ||
} | ||
} | ||
}); | ||
|
||
TestingUtil.withCacheManager(new CacheManagerCallable(createCacheManager(persistentStateLocation)) { | ||
@Override | ||
public void call() throws Exception { | ||
Cache<String, String> scriptCache = cm.getCache(ScriptingManagerImpl.SCRIPT_CACHE); | ||
assertTrue(scriptCache.containsKey("test.js")); | ||
} | ||
}); | ||
} | ||
} |