private static void warnLegacy(String oldKey, String newKey) { if (log.isInfoEnabled()) log.infof("Could not find value for key %1$s, but did find value under deprecated key %2$s. Please use %1$s as support for %2$s will eventually be discontinued.", newKey, oldKey); }
@Test(expected = IllegalArgumentException.class) public void testInvalidBranch2() { long seed = System.currentTimeMillis(); log.infof("[testInvalidBranch2] seed: %s", seed); Random random = new Random(seed); byte[] branch = new byte[65]; //max is 64 random.nextBytes(branch); Xid xid = XidImpl.create(random.nextInt(), new byte[]{0}, branch); log.debugf("Invalid XID: %s", xid); }
@Test(expected = IllegalArgumentException.class) public void testInvalidGlobalTransaction2() { long seed = System.currentTimeMillis(); log.infof("[testInvalidGlobalTransaction2] seed: %s", seed); Random random = new Random(seed); byte[] globalTx = new byte[65]; //max is 64 random.nextBytes(globalTx); Xid xid = XidImpl.create(random.nextInt(), globalTx, new byte[]{0}); log.debugf("Invalid XID: %s", xid); }
/** * Registers the remote value wrapper interceptor in the cache before it gets started. */ @Override public void cacheStarting(ComponentRegistry cr, Configuration cfg, String cacheName) { if (!cacheName.equals(Support.AVRO_METADATA_CACHE_NAME)) { if (cfg.indexing().index().isEnabled() && !cfg.compatibility().enabled()) { log.infof("Registering RemoteAvroValueWrapperInterceptor for cache %s", cacheName); createRemoteIndexingInterceptor(cr, cfg); } } }
@Test(expected = IllegalArgumentException.class) public void testInvalidGlobalTransaction() { long seed = System.currentTimeMillis(); log.infof("[testInvalidGlobalTransaction] seed: %s", seed); Random random = new Random(seed); Xid xid = XidImpl.create(random.nextInt(), Util.EMPTY_BYTE_ARRAY, new byte[]{0}); log.debugf("Invalid XID: %s", xid); }
@Test(expected = IllegalArgumentException.class) public void testInvalidBranch() { long seed = System.currentTimeMillis(); log.infof("[testInvalidBranch] seed: %s", seed); Random random = new Random(seed); Xid xid = XidImpl.create(random.nextInt(), new byte[]{0}, Util.EMPTY_BYTE_ARRAY); log.debugf("Invalid XID: %s", xid); }
@Test public void testMarshalling() throws IOException, ClassNotFoundException { long seed = System.currentTimeMillis(); log.infof("[testMarshalling] seed: %s", seed); Random random = new Random(seed); int formatId = random.nextInt(); byte[] tx = new byte[random.nextInt(64) + 1]; byte[] branch = new byte[random.nextInt(64) + 1]; random.nextBytes(tx); random.nextBytes(branch); XidImpl xid = XidImpl.create(formatId, tx, branch); log.debugf("XID: %s", xid); ByteArrayOutputStream bos = new ByteArrayOutputStream(256); ObjectOutput oo = new ObjectOutputStream(bos); XidImpl.writeTo(oo, xid); oo.flush(); oo.close(); bos.close(); byte[] marshalled = bos.toByteArray(); log.debugf("Size: %s", marshalled.length); ByteArrayInputStream bis = new ByteArrayInputStream(marshalled); ObjectInput oi = new ObjectInputStream(bis); XidImpl otherXid = XidImpl.readFrom(oi); oi.close(); bis.close(); log.debugf("other XID: %s", xid); Assert.assertEquals(xid, otherXid); }
@Test public void testMarshallingMaxSize() throws IOException, ClassNotFoundException { long seed = System.currentTimeMillis(); log.infof("[testMarshallingMaxSize] seed: %s", seed); Random random = new Random(seed); int formatId = random.nextInt(); byte[] tx = new byte[Xid.MAXGTRIDSIZE]; byte[] branch = new byte[Xid.MAXBQUALSIZE]; random.nextBytes(tx); random.nextBytes(branch); XidImpl xid = XidImpl.create(formatId, tx, branch); log.debugf("XID: %s", xid); ByteArrayOutputStream bos = new ByteArrayOutputStream(256); ObjectOutput oo = new ObjectOutputStream(bos); XidImpl.writeTo(oo, xid); oo.flush(); oo.close(); bos.close(); byte[] marshalled = bos.toByteArray(); log.debugf("Size: %s", marshalled.length); ByteArrayInputStream bis = new ByteArrayInputStream(marshalled); ObjectInput oi = new ObjectInputStream(bis); XidImpl otherXid = XidImpl.readFrom(oi); oi.close(); bis.close(); log.debugf("other XID: %s", xid); Assert.assertEquals(xid, otherXid); }
@Test public void testCorrectDataStored() { long seed = System.currentTimeMillis(); log.infof("[testCorrectDataStored] seed: %s", seed); Random random = new Random(seed); int formatId = random.nextInt(); byte[] tx = new byte[random.nextInt(64) + 1]; byte[] branch = new byte[random.nextInt(64) + 1]; random.nextBytes(tx); random.nextBytes(branch); Xid xid = XidImpl.create(formatId, tx, branch); log.debugf("XID: %s", xid); Assert.assertEquals(formatId, xid.getFormatId()); Assert.assertArrayEquals(tx, xid.getGlobalTransactionId()); Assert.assertArrayEquals(branch, xid.getBranchQualifier()); Xid sameXid = XidImpl.create(formatId, tx, branch); log.debugf("same XID: %s", sameXid); Assert.assertEquals(xid, sameXid); }
@Test public void testCorrectDataStoredMaxSize() { long seed = System.currentTimeMillis(); log.infof("[testCorrectDataStoredMaxSize] seed: %s", seed); Random random = new Random(seed); int formatId = random.nextInt(); byte[] tx = new byte[Xid.MAXGTRIDSIZE]; byte[] branch = new byte[Xid.MAXBQUALSIZE]; random.nextBytes(tx); random.nextBytes(branch); Xid xid = XidImpl.create(formatId, tx, branch); log.debugf("XID: %s", xid); Assert.assertEquals(formatId, xid.getFormatId()); Assert.assertArrayEquals(tx, xid.getGlobalTransactionId()); Assert.assertArrayEquals(branch, xid.getBranchQualifier()); Xid sameXid = XidImpl.create(formatId, tx, branch); log.debugf("same XID: %s", sameXid); Assert.assertEquals(xid, sameXid); }