Java Code Examples for javax.cache.event.CacheEntryEvent#getOldValue()

The following examples show how to use javax.cache.event.CacheEntryEvent#getOldValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CacheContinuousQueryVariationsTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param evtsQueues Event queue.
 * @param key Key.
 * @param val Value.
 * @param oldVal Old value.
 * @param keepBinary Keep binary.
 * @param withFilter With filter.
 * @throws Exception If failed.
 */
private void waitAndCheckEvent(List<BlockingQueue<CacheEntryEvent<?, ?>>> evtsQueues,
    Object key,
    Object val,
    Object oldVal,
    boolean keepBinary, boolean withFilter)
    throws Exception {
    if (val == null && oldVal == null || (withFilter && val != null && !isAccepted(val, false, dataMode))) {
        checkNoEvent(evtsQueues);

        return;
    }

    for (BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue : evtsQueues) {
        CacheEntryEvent<?, ?> evt = evtsQueue.poll(5, SECONDS);

        assertNotNull("Failed to wait for event [key=" + key + ", val=" + val + ", oldVal=" + oldVal + ']', evt);

        Object actKey = evt.getKey();
        Object actVal = evt.getValue();
        Object actOldVal = evt.getOldValue();

        if (keepBinary) {
            actKey = checkAndGetObject(actKey);
            actVal = checkAndGetObject(actVal);
            actOldVal = checkAndGetObject(actOldVal);
        }

        assertEquals(key, actKey);
        assertEquals(val, actVal);
        assertEquals(oldVal, actOldVal);
    }
}
 
Example 2
Source File: CacheContinuousQueryFailoverAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param e Event
 * @param expVals expected value
 * @return {@code True} if entries has the same key, value and oldValue. If cache start without backups
 * than oldValue ignoring in comparison.
 */
private boolean equalOldValue(CacheEntryEvent<?, ?> e, T3<Object, Object, Object> expVals) {
    return (e.getOldValue() == null && expVals.get3() == null) // Both null
        || (e.getOldValue() != null && expVals.get3() != null  // Equals
        && e.getOldValue().equals(expVals.get3()))
        || (backups == 0); // If we start without backup than oldValue might be lose.
}
 
Example 3
Source File: CacheListenersTest.java    From blazingcache with Apache License 2.0 5 votes vote down vote up
@Override
public void onRemoved(Iterable<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException {            
    for (CacheEntryEvent<? extends K, ? extends V> event : events) {
        
        assertEquals(REMOVED.toString(), event.getEventType().toString());
        removed.incrementAndGet();
        event.getKey();
        if (event.isOldValueAvailable()) {
            event.getOldValue();
        }
    }
}
 
Example 4
Source File: CacheListenersTest.java    From blazingcache with Apache License 2.0 5 votes vote down vote up
@Override
public void onUpdated(Iterable<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException {
    for (CacheEntryEvent<? extends K, ? extends V> event : events) {
        assertEquals(UPDATED.toString(), event.getEventType().toString());
        updated.incrementAndGet();
        event.getKey();
        if (event.isOldValueAvailable()) {
            event.getOldValue();
        }
    }
}
 
Example 5
Source File: CacheTestSupport.java    From cache2k with Apache License 2.0 5 votes vote down vote up
@Override
public void onRemoved(Iterable<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException {
  for (CacheEntryEvent<? extends K, ? extends V> event : events) {
    assertEquals(REMOVED, event.getEventType());
    assertTrue("isOldValueAvailable() for onRemoved", event.isOldValueAvailable());
    assertNotNull("old value non-null for onRemoved", event.getOldValue());
    assertEquals("old value identical to value at onRemoved", event.getOldValue(), event.getValue());
    removed.incrementAndGet();
    event.getKey();
    if (event.isOldValueAvailable()) {
      event.getOldValue();
    }
  }
}
 
Example 6
Source File: CacheTestSupport.java    From cache2k with Apache License 2.0 5 votes vote down vote up
@Override
public void onUpdated(Iterable<CacheEntryEvent<? extends K, ? extends V>> events) throws CacheEntryListenerException {
  for (CacheEntryEvent<? extends K, ? extends V> event : events) {
    assertEquals(UPDATED, event.getEventType());
    assertTrue("isOldValueAvailable() for onUpdated", event.isOldValueAvailable());
    assertNotNull("old value non-null for onUpdated", event.getOldValue());
    updated.incrementAndGet();
    event.getKey();
    if (event.isOldValueAvailable()) {
      event.getOldValue();
    }
  }
}