use of org.apache.ignite.internal.util.io.GridByteArrayInputStream in project ignite by apache.
the class GridCacheReplicatedQueueRemoveSelfTest method testQueueRemovalProcessor.
/**
* This a unit test of Ignite queue's RemoveProcessor process() method.
*
* @throws Exception If failed.
*/
@Test
@SuppressWarnings("unchecked")
public void testQueueRemovalProcessor() throws Exception {
GridCacheContext cctx = grid(0).context().cache().cache("ignite-sys-cache").context();
IgniteUuid id = IgniteUuid.randomUuid();
CacheInvokeEntry entry = new CacheInvokeEntry<>(null, null, null, false, new GridDhtCacheEntry(cctx, null, new KeyCacheObjectImpl(1, BigInteger.valueOf(1).toByteArray(), 1)));
entry.setValue(new GridCacheQueueHeader(id, 2147483647, false, 0L, 10000L, Collections.singleton(1L)));
GridCacheQueueAdapter.RemoveProcessor rp = new GridCacheQueueAdapter.RemoveProcessor(id, 1L);
rp.process(entry);
GridCacheQueueAdapter.RemoveProcessor externalRP = new GridCacheQueueAdapter.RemoveProcessor();
GridByteArrayOutputStream output = new GridByteArrayOutputStream();
rp.writeExternal(new ObjectOutputStream(output));
externalRP.readExternal(new ObjectInputStream(new GridByteArrayInputStream(output.toByteArray())));
assertEquals(id, GridTestUtils.getFieldValue(externalRP, "id"));
// idx should be null, cause entry was already removed, see GridCacheQueueAdapter.RemoveProcessor.code
// for more details.
assertNull(GridTestUtils.getFieldValue(externalRP, "idx"));
}
Aggregations