test/jdk/java/net/httpclient/whitebox/jdk.incubator.httpclient/jdk/incubator/http/AbstractSSLTubeTest.java
branchhttp-client-branch
changeset 55968 11a97b370db0
parent 55947 c4f314605d28
child 55970 261d4d2f77e2
equal deleted inserted replaced
55965:2911b5fbc229 55968:11a97b370db0
    71 import java.util.concurrent.atomic.AtomicInteger;
    71 import java.util.concurrent.atomic.AtomicInteger;
    72 import java.util.concurrent.atomic.AtomicLong;
    72 import java.util.concurrent.atomic.AtomicLong;
    73 import java.util.concurrent.atomic.AtomicReference;
    73 import java.util.concurrent.atomic.AtomicReference;
    74 import java.util.function.Consumer;
    74 import java.util.function.Consumer;
    75 
    75 
    76 public class AbstractSSLTubeTest {
    76 public class AbstractSSLTubeTest extends AbstractRandomTest {
    77 
    77 
    78     public static final long COUNTER = 600;
    78     public static final long COUNTER = 600;
    79     public static final int LONGS_PER_BUF = 800;
    79     public static final int LONGS_PER_BUF = 800;
    80     public static final long TOTAL_LONGS = COUNTER * LONGS_PER_BUF;
    80     public static final long TOTAL_LONGS = COUNTER * LONGS_PER_BUF;
    81     public static final ByteBuffer SENTINEL = ByteBuffer.allocate(0);
    81     public static final ByteBuffer SENTINEL = ByteBuffer.allocate(0);
    82     public static final Random rand = new Random();
       
    83 
       
    84     protected static int randomRange(int lower, int upper) {
       
    85         if (lower > upper)
       
    86             throw new IllegalArgumentException("lower > upper");
       
    87         int diff = upper - lower;
       
    88         int r = lower + rand.nextInt(diff);
       
    89         return r - (r % 8); // round down to multiple of 8 (align for longs)
       
    90     }
       
    91 
    82 
    92     protected static ByteBuffer getBuffer(long startingAt) {
    83     protected static ByteBuffer getBuffer(long startingAt) {
    93         ByteBuffer buf = ByteBuffer.allocate(LONGS_PER_BUF * 8);
    84         ByteBuffer buf = ByteBuffer.allocate(LONGS_PER_BUF * 8);
    94         for (int j = 0; j < LONGS_PER_BUF; j++) {
    85         for (int j = 0; j < LONGS_PER_BUF; j++) {
    95             buf.putLong(startingAt++);
    86             buf.putLong(startingAt++);