Code example for Random

0
 
import org.junit.Test; 
 
 
public class TransactionIdUnitTest { 
    private final Random rand = new Random();
 
 
    private byte[] randomBytes() { 
        final byte[] bytes = new byte[this.rand.nextInt(100)];
        this.rand.nextBytes(bytes);
        return bytes;
    } 
 
 
    @Test 
    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);