Search in sources :

Example 1 with PersistenceMarshallerImpl

use of org.infinispan.marshall.persistence.impl.PersistenceMarshallerImpl in project infinispan by infinispan.

the class MultimapStoreBucketTest method testMultimapWithJavaSerializationMarshaller.

public void testMultimapWithJavaSerializationMarshaller() throws Exception {
    GlobalConfigurationBuilder globalBuilder = new GlobalConfigurationBuilder().nonClusteredDefault();
    globalBuilder.defaultCacheName("test");
    globalBuilder.serialization().marshaller(new JavaSerializationMarshaller()).allowList().addClass(SuperPerson.class.getName());
    ConfigurationBuilder config = new ConfigurationBuilder();
    config.persistence().addStore(DummyInMemoryStoreConfigurationBuilder.class);
    EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(globalBuilder, config);
    MultimapCacheManager<String, Person> multimapCacheManager = EmbeddedMultimapCacheManagerFactory.from(cm);
    MultimapCache<String, Person> multimapCache = multimapCacheManager.get("test");
    multimapCache.put("k1", new SuperPerson());
    PersistenceMarshallerImpl pm = TestingUtil.extractPersistenceMarshaller(cm);
    DelegatingUserMarshaller userMarshaller = (DelegatingUserMarshaller) pm.getUserMarshaller();
    assertTrue(userMarshaller.getDelegate() instanceof JavaSerializationMarshaller);
    assertTrue(pm.getSerializationContext().canMarshall(Bucket.class));
    assertTrue(multimapCache.containsKey("k1").get(1, TimeUnit.SECONDS));
}
Also used : GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) DummyInMemoryStoreConfigurationBuilder(org.infinispan.persistence.dummy.DummyInMemoryStoreConfigurationBuilder) DelegatingUserMarshaller(org.infinispan.marshall.core.impl.DelegatingUserMarshaller) PersistenceMarshallerImpl(org.infinispan.marshall.persistence.impl.PersistenceMarshallerImpl) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) Person(org.infinispan.test.data.Person) JavaSerializationMarshaller(org.infinispan.commons.marshall.JavaSerializationMarshaller)

Aggregations

JavaSerializationMarshaller (org.infinispan.commons.marshall.JavaSerializationMarshaller)1 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)1 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 DelegatingUserMarshaller (org.infinispan.marshall.core.impl.DelegatingUserMarshaller)1 PersistenceMarshallerImpl (org.infinispan.marshall.persistence.impl.PersistenceMarshallerImpl)1 DummyInMemoryStoreConfigurationBuilder (org.infinispan.persistence.dummy.DummyInMemoryStoreConfigurationBuilder)1 Person (org.infinispan.test.data.Person)1