Code example for Random

Methods: nextBytesnextInt

public class TransactionIdUnitTest { 
    private final Random rand = new Random();
    private byte[] randomBytes() { 
        final byte[] bytes = new byte[this.rand.nextInt(100)];
        return bytes;
    public void testValueOf() { 
        final byte[] branchQualifier = this.randomBytes();
        final byte[] globalTransactionId = this.randomBytes();
        final XATransactionId xid = new XATransactionId(100, branchQualifier, globalTransactionId, "unique-qualifier");
        final LocalTransactionId id = new LocalTransactionId("sessionId", -99);
        final String key1 = xid.getTransactionKey();
        final String key2 = id.getTransactionKey();
Connect your IDE to all the code out there  Get Codota for Java