Skip to content

Commit 40755af

Browse files
committed
8373808: Refactor java/net/httpclient qpack and hpack tests to use JUnit
Reviewed-by: djelinski
1 parent e1d81c0 commit 40755af

31 files changed

+427
-398
lines changed

test/jdk/java/net/httpclient/http2/HpackBinaryTestDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,6 @@
2929
* @compile/module=java.net.http jdk/internal/net/http/hpack/SpecHelper.java
3030
* @compile/module=java.net.http jdk/internal/net/http/hpack/TestHelper.java
3131
* @compile/module=java.net.http jdk/internal/net/http/hpack/BuffersTestingKit.java
32-
* @run testng/othervm/timeout=240 java.net.http/jdk.internal.net.http.hpack.BinaryPrimitivesTest
32+
* @run junit/othervm/timeout=240 java.net.http/jdk.internal.net.http.hpack.BinaryPrimitivesTest
3333
*/
3434
public class HpackBinaryTestDriver { }

test/jdk/java/net/httpclient/http2/HpackCircularBufferDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,6 @@
2929
* @compile/module=java.net.http jdk/internal/net/http/hpack/SpecHelper.java
3030
* @compile/module=java.net.http jdk/internal/net/http/hpack/TestHelper.java
3131
* @compile/module=java.net.http jdk/internal/net/http/hpack/BuffersTestingKit.java
32-
* @run testng/othervm java.net.http/jdk.internal.net.http.hpack.CircularBufferTest
32+
* @run junit/othervm java.net.http/jdk.internal.net.http.hpack.CircularBufferTest
3333
*/
3434
public class HpackCircularBufferDriver { }

test/jdk/java/net/httpclient/http2/HpackDecoderDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,6 @@
2929
* @compile/module=java.net.http jdk/internal/net/http/hpack/SpecHelper.java
3030
* @compile/module=java.net.http jdk/internal/net/http/hpack/TestHelper.java
3131
* @compile/module=java.net.http jdk/internal/net/http/hpack/BuffersTestingKit.java
32-
* @run testng/othervm java.net.http/jdk.internal.net.http.hpack.DecoderTest
32+
* @run junit/othervm java.net.http/jdk.internal.net.http.hpack.DecoderTest
3333
*/
3434
public class HpackDecoderDriver { }

test/jdk/java/net/httpclient/http2/HpackEncoderDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,6 @@
2929
* @compile/module=java.net.http jdk/internal/net/http/hpack/SpecHelper.java
3030
* @compile/module=java.net.http jdk/internal/net/http/hpack/TestHelper.java
3131
* @compile/module=java.net.http jdk/internal/net/http/hpack/BuffersTestingKit.java
32-
* @run testng/othervm java.net.http/jdk.internal.net.http.hpack.EncoderTest
32+
* @run junit/othervm java.net.http/jdk.internal.net.http.hpack.EncoderTest
3333
*/
3434
public class HpackEncoderDriver { }

test/jdk/java/net/httpclient/http2/HpackHeaderTableDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,6 @@
3030
* @compile/module=java.net.http jdk/internal/net/http/hpack/SpecHelper.java
3131
* @compile/module=java.net.http jdk/internal/net/http/hpack/TestHelper.java
3232
* @compile/module=java.net.http jdk/internal/net/http/hpack/BuffersTestingKit.java
33-
* @run testng/othervm java.net.http/jdk.internal.net.http.hpack.HeaderTableTest
33+
* @run junit/othervm java.net.http/jdk.internal.net.http.hpack.HeaderTableTest
3434
*/
3535
public class HpackHeaderTableDriver { }

test/jdk/java/net/httpclient/http2/HpackHuffmanDriver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,6 @@
2929
* @compile/module=java.net.http jdk/internal/net/http/hpack/SpecHelper.java
3030
* @compile/module=java.net.http jdk/internal/net/http/hpack/TestHelper.java
3131
* @compile/module=java.net.http jdk/internal/net/http/hpack/BuffersTestingKit.java
32-
* @run testng/othervm/timeout=300 java.net.http/jdk.internal.net.http.hpack.HuffmanTest
32+
* @run junit/othervm/timeout=300 java.net.http/jdk.internal.net.http.hpack.HuffmanTest
3333
*/
3434
public class HpackHuffmanDriver { }

test/jdk/java/net/httpclient/http2/HpackTestHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,6 @@
2929
* @compile/module=java.net.http jdk/internal/net/http/hpack/SpecHelper.java
3030
* @compile/module=java.net.http jdk/internal/net/http/hpack/TestHelper.java
3131
* @compile/module=java.net.http jdk/internal/net/http/hpack/BuffersTestingKit.java
32-
* @run testng/othervm java.net.http/jdk.internal.net.http.hpack.TestHelper
32+
* @run junit/othervm java.net.http/jdk.internal.net.http.hpack.TestHelper
3333
*/
3434
public class HpackTestHelperDriver { }

test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/BinaryPrimitivesTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,6 @@
2222
*/
2323
package jdk.internal.net.http.hpack;
2424

25-
import org.testng.annotations.Test;
2625

2726
import java.io.IOException;
2827
import java.io.UncheckedIOException;
@@ -33,10 +32,11 @@
3332
import java.util.List;
3433
import java.util.Random;
3534

36-
import static org.testng.Assert.assertEquals;
37-
import static org.testng.Assert.fail;
35+
import static org.junit.jupiter.api.Assertions.assertEquals;
36+
import static org.junit.jupiter.api.Assertions.fail;
3837
import static jdk.internal.net.http.hpack.BuffersTestingKit.*;
3938
import static jdk.internal.net.http.hpack.TestHelper.newRandom;
39+
import org.junit.jupiter.api.Test;
4040

4141
//
4242
// Some of the tests below overlap in what they test. This allows to diagnose
@@ -96,7 +96,7 @@ public void integerIdentity() throws IOException {
9696
totalCases++;
9797
maxFilling = Math.max(maxFilling, buf.remaining());
9898
r.reset().configure(N).read(buf);
99-
assertEquals(r.get(), expected);
99+
assertEquals(expected, r.get());
100100
buf.clear();
101101
}
102102
}
@@ -127,7 +127,7 @@ public void integerReadChunked() {
127127
throw new UncheckedIOException(e);
128128
}
129129
}
130-
assertEquals(r.get(), expected);
130+
assertEquals(expected, r.get());
131131
r.reset();
132132
});
133133
bb.clear();
@@ -167,7 +167,7 @@ public void integerWriteChunked() {
167167
throw new UncheckedIOException(e);
168168
}
169169
// TODO: check payload here
170-
assertEquals(r.get(), expected);
170+
assertEquals(expected, r.get());
171171
w.reset();
172172
r.reset();
173173
bb.clear();
@@ -209,7 +209,7 @@ public void stringIdentity() throws IOException {
209209
bytes.flip();
210210
reader.read(bytes, chars);
211211
chars.flip();
212-
assertEquals(chars.toString(), expected);
212+
assertEquals(expected, chars.toString());
213213
reader.reset();
214214
writer.reset();
215215
}
@@ -257,7 +257,7 @@ public void stringWriteChunked() {
257257
throw new UncheckedIOException(e);
258258
}
259259
chars.flip();
260-
assertEquals(chars.toString(), expected);
260+
assertEquals(expected, chars.toString());
261261
reader.reset();
262262
writer.reset();
263263
chars.clear();
@@ -301,7 +301,7 @@ public void stringReadChunked() {
301301
buf.position(p0);
302302
}
303303
chars.flip();
304-
assertEquals(chars.toString(), expected);
304+
assertEquals(expected, chars.toString());
305305
reader.reset();
306306
chars.clear();
307307
});
@@ -356,14 +356,14 @@ private static void verifyRead(byte[] data, int expected, int N) {
356356
} catch (IOException e) {
357357
throw new UncheckedIOException(e);
358358
}
359-
assertEquals(reader.get(), expected);
359+
assertEquals(expected, reader.get());
360360
}
361361

362362
private void verifyWrite(byte[] expected, int data, int N) {
363363
IntegerWriter w = new IntegerWriter();
364364
ByteBuffer buf = ByteBuffer.allocate(2 * expected.length);
365365
w.configure(data, N, 1).write(buf);
366366
buf.flip();
367-
assertEquals(buf, ByteBuffer.wrap(expected));
367+
assertEquals(ByteBuffer.wrap(expected), buf);
368368
}
369369
}

test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/CircularBufferTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,6 @@
2222
*/
2323
package jdk.internal.net.http.hpack;
2424

25-
import org.testng.annotations.Test;
2625
import jdk.internal.net.http.hpack.SimpleHeaderTable.CircularBuffer;
2726

2827
import java.util.Arrays;
@@ -31,10 +30,11 @@
3130
import java.util.concurrent.ArrayBlockingQueue;
3231

3332
import static jdk.internal.net.http.common.Utils.pow2Size;
34-
import static org.testng.Assert.assertEquals;
33+
import static org.junit.jupiter.api.Assertions.assertEquals;
3534
import static jdk.internal.net.http.hpack.TestHelper.assertVoidThrows;
3635
import static jdk.internal.net.http.hpack.TestHelper.newRandom;
37-
import static org.testng.Assert.assertTrue;
36+
import static org.junit.jupiter.api.Assertions.assertTrue;
37+
import org.junit.jupiter.api.Test;
3838

3939
public final class CircularBufferTest {
4040

@@ -143,7 +143,7 @@ private void queueOnce(int capacity, int numWraps) {
143143
for (int i = 0; i < gets; i++) {
144144
Integer expected = referenceQueue.poll();
145145
Integer actual = buffer.remove();
146-
assertEquals(actual, expected);
146+
assertEquals(expected, actual);
147147
}
148148
}
149149
}

test/jdk/java/net/httpclient/http2/java.net.http/jdk/internal/net/http/hpack/DecoderTest.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,6 @@
2222
*/
2323
package jdk.internal.net.http.hpack;
2424

25-
import org.testng.annotations.Test;
2625

2726
import java.io.IOException;
2827
import java.io.UncheckedIOException;
@@ -33,9 +32,9 @@
3332
import java.util.function.Supplier;
3433
import java.util.stream.Collectors;
3534

36-
import static org.testng.Assert.assertEquals;
37-
import static org.testng.Assert.assertNotNull;
35+
import static org.junit.jupiter.api.Assertions.assertEquals;
3836
import static jdk.internal.net.http.hpack.TestHelper.*;
37+
import org.junit.jupiter.api.Test;
3938

4039
//
4140
// Tests whose names start with "testX" are the ones captured from real HPACK
@@ -402,9 +401,9 @@ public void testX1() {
402401
@Test
403402
public void sizeUpdate() throws IOException {
404403
Decoder d = new Decoder(4096);
405-
assertEquals(d.getTable().maxSize(), 4096);
404+
assertEquals(4096, d.getTable().maxSize());
406405
d.decode(ByteBuffer.wrap(new byte[]{0b00111110}), true, nopCallback()); // newSize = 30
407-
assertEquals(d.getTable().maxSize(), 30);
406+
assertEquals(30, d.getTable().maxSize());
408407
}
409408

410409
@Test
@@ -650,8 +649,8 @@ private static void testAllSplits(Supplier<Decoder> supplier,
650649
throw new UncheckedIOException(e);
651650
}
652651
} while (i.hasNext());
653-
assertEquals(d.getTable().getStateString(), expectedHeaderTable);
654-
assertEquals(actual.stream().collect(Collectors.joining("\n")), expectedHeaderList);
652+
assertEquals(expectedHeaderTable, d.getTable().getStateString());
653+
assertEquals(expectedHeaderList, actual.stream().collect(Collectors.joining("\n")));
655654
});
656655

657656
// Now introduce last ByteBuffer which is empty and EOF (mimics idiom
@@ -690,8 +689,8 @@ private static void testAllSplits(Supplier<Decoder> supplier,
690689
throw new UncheckedIOException(e);
691690
}
692691

693-
assertEquals(d.getTable().getStateString(), expectedHeaderTable);
694-
assertEquals(actual.stream().collect(Collectors.joining("\n")), expectedHeaderList);
692+
assertEquals(expectedHeaderTable, d.getTable().getStateString());
693+
assertEquals(expectedHeaderList, actual.stream().collect(Collectors.joining("\n")));
695694
});
696695
}
697696

@@ -717,8 +716,8 @@ private static void test(Decoder d, String hexdump,
717716
throw new UncheckedIOException(e);
718717
}
719718

720-
assertEquals(d.getTable().getStateString(), expectedHeaderTable);
721-
assertEquals(actual.stream().collect(Collectors.joining("\n")), expectedHeaderList);
719+
assertEquals(expectedHeaderTable, d.getTable().getStateString());
720+
assertEquals(expectedHeaderList, actual.stream().collect(Collectors.joining("\n")));
722721
}
723722

724723
private static DecodingCallback nopCallback() {

0 commit comments

Comments
 (0)