use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class BaseStoreTest method testLoadAndStoreBytesValues.
public void testLoadAndStoreBytesValues() throws PersistenceException, IOException, InterruptedException {
assertIsEmpty();
SerializationContext ctx = ProtobufUtil.newSerializationContext();
SerializationContextInitializer sci = TestDataSCI.INSTANCE;
sci.registerSchema(ctx);
sci.registerMarshallers(ctx);
Marshaller userMarshaller = new ProtoStreamMarshaller(ctx);
WrappedBytes key = new WrappedByteArray(userMarshaller.objectToByteBuffer(new Key("key")));
WrappedBytes key2 = new WrappedByteArray(userMarshaller.objectToByteBuffer(new Key("key2")));
WrappedBytes value = new WrappedByteArray(userMarshaller.objectToByteBuffer(new Person()));
assertFalse(cl.contains(key));
PersistenceMarshaller persistenceMarshaller = getMarshaller();
cl.write(MarshalledEntryUtil.create(key, value, persistenceMarshaller));
assertEquals(value, cl.loadEntry(key).getValue());
MarshallableEntry entry = cl.loadEntry(key);
assertTrue("Expected an immortalEntry", entry.getMetadata() == null || entry.expiryTime() == -1 || entry.getMetadata().maxIdle() == -1);
assertContains(key, true);
assertFalse(cl.delete(key2));
assertTrue(cl.delete(key));
}
use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class MultimapTestUtils method assertContaisKeyValue.
public static void assertContaisKeyValue(MultimapCache<String, Person> multimapCache, String key, Person value) {
Address address = ((EmbeddedMultimapCache) multimapCache).getCache().getCacheManager().getAddress();
await(multimapCache.get(key).thenAccept(v -> {
assertTrue(format("get method call : multimap '%s' must contain key '%s' value '%s' pair", address, key, value), v.contains(value));
}));
await(multimapCache.containsEntry(key, value).thenAccept(v -> {
assertTrue(format("containsEntry method call : multimap '%s' must contain key '%s' value '%s' pair", address, key, value), v);
}));
}
use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class TxDistributedMultimapCacheTest method testExplicitTx.
public void testExplicitTx() throws SystemException, NotSupportedException {
initAndTest();
MultimapCache<String, Person> multimapCache = getMultimapCacheMember(NAMES_KEY);
TransactionManager tm1 = MultimapTestUtils.getTransactionManager(multimapCache);
assertMultimapCacheSize(multimapCache, 1);
tm1.begin();
try {
putValuesOnMultimapCache(multimapCache, NAMES_KEY, JULIEN);
if (fromOwner) {
assertContaisKeyValue(multimapCache, NAMES_KEY, JULIEN);
}
tm1.commit();
} catch (Exception e) {
fail(e.getMessage());
}
assertValuesAndOwnership(NAMES_KEY, JULIEN);
assertMultimapCacheSize(multimapCache, 2);
}
use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class EagerKeyValueConverterTest method testWriteMap.
public void testWriteMap() throws InterruptedException {
BlockingQueue<KeyValuePair<String, Person>> eventsQueue = new LinkedBlockingQueue<>();
RemoteCache<String, Person> cache = remoteCacheManager.getCache();
cache.addClientListener(new EventListener(eventsQueue, cache.getDataFormat()));
Map<String, Person> data = new HashMap<>();
data.put("1", new Person("John"));
data.put("2", new Person("Mary"));
data.put("3", new Person("George"));
cache.putAll(data);
KeyValuePair<String, Person> event = eventsQueue.poll(5, TimeUnit.SECONDS);
assertNotNull(event);
}
use of org.infinispan.test.data.Person in project infinispan by infinispan.
the class EventWithStorageTypeTest method testReceiveKeyValues.
@Test
public void testReceiveKeyValues() throws InterruptedException {
RemoteCache<String, Person> cache = remoteCacheManager.getCache();
EventListener listener = new EventListener();
cache.addClientListener(listener);
cache.put("1", new Person("John"));
Object key = listener.getEventKey();
assertNotNull(key);
assertEquals("1", key);
}
Aggregations