Search in sources :

Example 1 with CacheState

use of org.infinispan.globalstate.impl.CacheState in project infinispan by infinispan.

the class CacheResourceV2Test method assertPersistence.

private void assertPersistence(String name, boolean persisted) {
    EmbeddedCacheManager cm = cacheManagers.iterator().next();
    Cache<ScopedState, CacheState> configCache = cm.getCache(CONFIG_STATE_CACHE_NAME);
    assertEquals(persisted, configCache.entrySet().stream().anyMatch(e -> e.getKey().getName().equals(name) && !e.getValue().getFlags().contains(VOLATILE)));
}
Also used : ResponseAssertion.assertThat(org.infinispan.rest.assertion.ResponseAssertion.assertThat) CompletionStages.join(org.infinispan.util.concurrent.CompletionStages.join) ResponseAssertion(org.infinispan.rest.assertion.ResponseAssertion) APPLICATION_XML(org.infinispan.commons.dataconversion.MediaType.APPLICATION_XML) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HTTP_20(org.infinispan.client.rest.configuration.Protocol.HTTP_20) RestClient(org.infinispan.client.rest.RestClient) GlobalConfigurationManager(org.infinispan.globalstate.GlobalConfigurationManager) PartitionHandling(org.infinispan.partitionhandling.PartitionHandling) Test(org.testng.annotations.Test) Cache(org.infinispan.Cache) AssertJUnit.assertTrue(org.testng.AssertJUnit.assertTrue) CONFIG_STATE_CACHE_NAME(org.infinispan.globalstate.GlobalConfigurationManager.CONFIG_STATE_CACHE_NAME) APPLICATION_XML_TYPE(org.infinispan.commons.dataconversion.MediaType.APPLICATION_XML_TYPE) ByteArrayInputStream(java.io.ByteArrayInputStream) Document(org.w3c.dom.Document) Map(java.util.Map) TestingUtil(org.infinispan.test.TestingUtil) Util.getResourceAsString(org.infinispan.commons.util.Util.getResourceAsString) TEXT_PLAIN_TYPE(org.infinispan.commons.dataconversion.MediaType.TEXT_PLAIN_TYPE) APPLICATION_OCTET_STREAM(org.infinispan.commons.dataconversion.MediaType.APPLICATION_OCTET_STREAM) Collection(java.util.Collection) HTTP_11(org.infinispan.client.rest.configuration.Protocol.HTTP_11) Set(java.util.Set) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) List(java.util.List) PROTOBUF_METADATA_CACHE_NAME(org.infinispan.query.remote.client.ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME) CompletionStage(java.util.concurrent.CompletionStage) RestRawClient(org.infinispan.client.rest.RestRawClient) ResponseHeader(org.infinispan.rest.ResponseHeader) ConfigurationStorage(org.infinispan.globalstate.ConfigurationStorage) LocalTopologyManager(org.infinispan.topology.LocalTopologyManager) SKIP_CACHE_LOAD(org.infinispan.context.Flag.SKIP_CACHE_LOAD) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) SKIP_INDEXING(org.infinispan.context.Flag.SKIP_INDEXING) IntStream(java.util.stream.IntStream) Assert.assertNull(org.testng.Assert.assertNull) APPLICATION_YAML_TYPE(org.infinispan.commons.dataconversion.MediaType.APPLICATION_YAML_TYPE) KEY_CONTENT_TYPE_HEADER(org.infinispan.rest.RequestHeader.KEY_CONTENT_TYPE_HEADER) HashMap(java.util.HashMap) Yaml(org.yaml.snakeyaml.Yaml) MediaType(org.infinispan.commons.dataconversion.MediaType) ScopedState(org.infinispan.globalstate.ScopedState) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) VOLATILE(org.infinispan.commons.api.CacheContainerAdmin.AdminFlag.VOLATILE) CacheState(org.infinispan.globalstate.impl.CacheState) NodeList(org.w3c.dom.NodeList) RestResponse(org.infinispan.client.rest.RestResponse) APPLICATION_JSON(org.infinispan.commons.dataconversion.MediaType.APPLICATION_JSON) Assert.fail(org.testng.Assert.fail) Util(org.infinispan.commons.util.Util) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ACCEPT_HEADER(org.infinispan.rest.RequestHeader.ACCEPT_HEADER) AssertJUnit.assertFalse(org.testng.AssertJUnit.assertFalse) IOException(java.io.IOException) Json(org.infinispan.commons.dataconversion.internal.Json) TEXT_PLAIN(org.infinispan.commons.dataconversion.MediaType.TEXT_PLAIN) RestCacheClient(org.infinispan.client.rest.RestCacheClient) TimeUnit(java.util.concurrent.TimeUnit) DummyInMemoryStoreConfigurationBuilder(org.infinispan.persistence.dummy.DummyInMemoryStoreConfigurationBuilder) APPLICATION_JSON_TYPE(org.infinispan.commons.dataconversion.MediaType.APPLICATION_JSON_TYPE) CommonsTestingUtil.tmpDirectory(org.infinispan.commons.test.CommonsTestingUtil.tmpDirectory) CacheMode(org.infinispan.configuration.cache.CacheMode) ProtobufMetadataManagerConstants(org.infinispan.query.remote.client.ProtobufMetadataManagerConstants) Element(org.w3c.dom.Element) Paths(java.nio.file.Paths) Closeable(java.io.Closeable) RestEntity(org.infinispan.client.rest.RestEntity) Configuration(org.infinispan.configuration.cache.Configuration) ParserRegistry(org.infinispan.configuration.parsing.ParserRegistry) LOCAL_HEAP(org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) ProtoStreamMarshaller(org.infinispan.commons.marshall.ProtoStreamMarshaller) Collections(java.util.Collections) CacheState(org.infinispan.globalstate.impl.CacheState) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) ScopedState(org.infinispan.globalstate.ScopedState)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Paths (java.nio.file.Paths)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 CompletionStage (java.util.concurrent.CompletionStage)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Cache (org.infinispan.Cache)1 RestCacheClient (org.infinispan.client.rest.RestCacheClient)1 RestClient (org.infinispan.client.rest.RestClient)1