Make methods 'static' where it possible
Motivation: Even if it's a super micro-optimization (most JVM could optimize such cases in runtime), in theory (and according to some perf tests) it may help a bit. It also makes a code more clear and allows you to access such methods in the test scope directly, without instance of the class. Modifications: Add 'static' modifier for all methods, where it possible. Mostly in test scope. Result: Cleaner code with proper 'static' modifiers.
This commit is contained in:
parent
17e1a26d64
commit
50a067a8f7
@ -202,7 +202,7 @@ public class ReadOnlyByteBufTest {
|
|||||||
ensureWritableIntStatusShouldFailButNotThrow(true);
|
ensureWritableIntStatusShouldFailButNotThrow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureWritableIntStatusShouldFailButNotThrow(boolean force) {
|
private static void ensureWritableIntStatusShouldFailButNotThrow(boolean force) {
|
||||||
ByteBuf buf = buffer(1);
|
ByteBuf buf = buffer(1);
|
||||||
ByteBuf readOnly = buf.asReadOnly();
|
ByteBuf readOnly = buf.asReadOnly();
|
||||||
int result = readOnly.ensureWritable(1, force);
|
int result = readOnly.ensureWritable(1, force);
|
||||||
|
@ -159,7 +159,7 @@ public class HttpObjectAggregator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object continueResponse(HttpMessage start, int maxContentLength, ChannelPipeline pipeline) {
|
private static Object continueResponse(HttpMessage start, int maxContentLength, ChannelPipeline pipeline) {
|
||||||
if (HttpUtil.isUnsupportedExpectation(start)) {
|
if (HttpUtil.isUnsupportedExpectation(start)) {
|
||||||
// if the request contains an unsupported expectation, we return 417
|
// if the request contains an unsupported expectation, we return 417
|
||||||
pipeline.fireUserEventTriggered(HttpExpectationFailedEvent.INSTANCE);
|
pipeline.fireUserEventTriggered(HttpExpectationFailedEvent.INSTANCE);
|
||||||
|
@ -215,7 +215,7 @@ public class HttpUtilTest {
|
|||||||
run100ContinueTest(message, false);
|
run100ContinueTest(message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run100ContinueTest(final HttpVersion version, final String expectations, boolean expect) {
|
private static void run100ContinueTest(final HttpVersion version, final String expectations, boolean expect) {
|
||||||
final HttpMessage message = new DefaultFullHttpRequest(version, HttpMethod.GET, "/");
|
final HttpMessage message = new DefaultFullHttpRequest(version, HttpMethod.GET, "/");
|
||||||
if (expectations != null) {
|
if (expectations != null) {
|
||||||
message.headers().set(HttpHeaderNames.EXPECT, expectations);
|
message.headers().set(HttpHeaderNames.EXPECT, expectations);
|
||||||
@ -223,7 +223,7 @@ public class HttpUtilTest {
|
|||||||
run100ContinueTest(message, expect);
|
run100ContinueTest(message, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run100ContinueTest(final HttpMessage message, final boolean expected) {
|
private static void run100ContinueTest(final HttpMessage message, final boolean expected) {
|
||||||
assertEquals(expected, HttpUtil.is100ContinueExpected(message));
|
assertEquals(expected, HttpUtil.is100ContinueExpected(message));
|
||||||
ReferenceCountUtil.release(message);
|
ReferenceCountUtil.release(message);
|
||||||
}
|
}
|
||||||
@ -242,7 +242,8 @@ public class HttpUtilTest {
|
|||||||
runUnsupportedExpectationTest(message, false);
|
runUnsupportedExpectationTest(message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runUnsupportedExpectationTest(final HttpVersion version, final String expectations, boolean expect) {
|
private static void runUnsupportedExpectationTest(final HttpVersion version,
|
||||||
|
final String expectations, boolean expect) {
|
||||||
final HttpMessage message = new DefaultFullHttpRequest(version, HttpMethod.GET, "/");
|
final HttpMessage message = new DefaultFullHttpRequest(version, HttpMethod.GET, "/");
|
||||||
if (expectations != null) {
|
if (expectations != null) {
|
||||||
message.headers().set("Expect", expectations);
|
message.headers().set("Expect", expectations);
|
||||||
@ -250,7 +251,7 @@ public class HttpUtilTest {
|
|||||||
runUnsupportedExpectationTest(message, expect);
|
runUnsupportedExpectationTest(message, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runUnsupportedExpectationTest(final HttpMessage message, final boolean expected) {
|
private static void runUnsupportedExpectationTest(final HttpMessage message, final boolean expected) {
|
||||||
assertEquals(expected, HttpUtil.isUnsupportedExpectation(message));
|
assertEquals(expected, HttpUtil.isUnsupportedExpectation(message));
|
||||||
ReferenceCountUtil.release(message);
|
ReferenceCountUtil.release(message);
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ public class DefaultHttp2FrameReaderTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writePriorityFrame(
|
private static void writePriorityFrame(
|
||||||
ByteBuf output, int streamId, int streamDependency, int weight) {
|
ByteBuf output, int streamId, int streamDependency, int weight) {
|
||||||
writeFrameHeader(output, 5, PRIORITY, new Http2Flags(), streamId);
|
writeFrameHeader(output, 5, PRIORITY, new Http2Flags(), streamId);
|
||||||
output.writeInt(streamDependency);
|
output.writeInt(streamDependency);
|
||||||
|
@ -265,7 +265,7 @@ public class DefaultHttp2FrameWriterTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Http2Headers dummyHeaders(Http2Headers headers, int times) {
|
private static Http2Headers dummyHeaders(Http2Headers headers, int times) {
|
||||||
final String largeValue = repeat("dummy-value", 100);
|
final String largeValue = repeat("dummy-value", 100);
|
||||||
for (int i = 0; i < times; i++) {
|
for (int i = 0; i < times; i++) {
|
||||||
headers.add(String.format("dummy-%d", i), largeValue);
|
headers.add(String.format("dummy-%d", i), largeValue);
|
||||||
@ -273,7 +273,7 @@ public class DefaultHttp2FrameWriterTest {
|
|||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String repeat(String str, int count) {
|
private static String repeat(String str, int count) {
|
||||||
return String.format(String.format("%%%ds", count), " ").replace(" ", str);
|
return String.format(String.format("%%%ds", count), " ").replace(" ", str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,39 +198,39 @@ public class ReadOnlyHttp2HeadersTest {
|
|||||||
assertFalse(itr.hasNext());
|
assertFalse(itr.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testValueIteratorSingleValue(Http2Headers headers, CharSequence name, CharSequence value) {
|
private static void testValueIteratorSingleValue(Http2Headers headers, CharSequence name, CharSequence value) {
|
||||||
Iterator<CharSequence> itr = headers.valueIterator(name);
|
Iterator<CharSequence> itr = headers.valueIterator(name);
|
||||||
assertTrue(itr.hasNext());
|
assertTrue(itr.hasNext());
|
||||||
assertTrue(AsciiString.contentEqualsIgnoreCase(value, itr.next()));
|
assertTrue(AsciiString.contentEqualsIgnoreCase(value, itr.next()));
|
||||||
assertFalse(itr.hasNext());
|
assertFalse(itr.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testIteratorReadOnly(Http2Headers headers) {
|
private static void testIteratorReadOnly(Http2Headers headers) {
|
||||||
Iterator<Map.Entry<CharSequence, CharSequence>> itr = headers.iterator();
|
Iterator<Map.Entry<CharSequence, CharSequence>> itr = headers.iterator();
|
||||||
assertTrue(itr.hasNext());
|
assertTrue(itr.hasNext());
|
||||||
itr.remove();
|
itr.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testIteratorEntryReadOnly(Http2Headers headers) {
|
private static void testIteratorEntryReadOnly(Http2Headers headers) {
|
||||||
Iterator<Map.Entry<CharSequence, CharSequence>> itr = headers.iterator();
|
Iterator<Map.Entry<CharSequence, CharSequence>> itr = headers.iterator();
|
||||||
assertTrue(itr.hasNext());
|
assertTrue(itr.hasNext());
|
||||||
itr.next().setValue("foo");
|
itr.next().setValue("foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReadOnlyHttp2Headers newServerHeaders() {
|
private static ReadOnlyHttp2Headers newServerHeaders() {
|
||||||
return ReadOnlyHttp2Headers.serverHeaders(false, new AsciiString("200"), otherHeaders());
|
return ReadOnlyHttp2Headers.serverHeaders(false, new AsciiString("200"), otherHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReadOnlyHttp2Headers newClientHeaders() {
|
private static ReadOnlyHttp2Headers newClientHeaders() {
|
||||||
return ReadOnlyHttp2Headers.clientHeaders(false, new AsciiString("meth"), new AsciiString("/foo"),
|
return ReadOnlyHttp2Headers.clientHeaders(false, new AsciiString("meth"), new AsciiString("/foo"),
|
||||||
new AsciiString("schemer"), new AsciiString("respect_my_authority"), otherHeaders());
|
new AsciiString("schemer"), new AsciiString("respect_my_authority"), otherHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReadOnlyHttp2Headers newTrailers() {
|
private static ReadOnlyHttp2Headers newTrailers() {
|
||||||
return ReadOnlyHttp2Headers.trailers(false, otherHeaders());
|
return ReadOnlyHttp2Headers.trailers(false, otherHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
private AsciiString[] otherHeaders() {
|
private static AsciiString[] otherHeaders() {
|
||||||
return new AsciiString[] {
|
return new AsciiString[] {
|
||||||
new AsciiString("name1"), new AsciiString("value1"),
|
new AsciiString("name1"), new AsciiString("value1"),
|
||||||
new AsciiString("name2"), new AsciiString("value2"),
|
new AsciiString("name2"), new AsciiString("value2"),
|
||||||
|
@ -45,7 +45,7 @@ public class DefaultHeadersTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestDefaultHeaders newInstance() {
|
private static TestDefaultHeaders newInstance() {
|
||||||
return new TestDefaultHeaders();
|
return new TestDefaultHeaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public class LineEncoderTest {
|
|||||||
testLineEncode(LineSeparator.UNIX, "abc");
|
testLineEncode(LineSeparator.UNIX, "abc");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testLineEncode(LineSeparator lineSeparator, String msg) {
|
private static void testLineEncode(LineSeparator lineSeparator, String msg) {
|
||||||
EmbeddedChannel channel = new EmbeddedChannel(new LineEncoder(lineSeparator, CharsetUtil.UTF_8));
|
EmbeddedChannel channel = new EmbeddedChannel(new LineEncoder(lineSeparator, CharsetUtil.UTF_8));
|
||||||
assertTrue(channel.writeOutbound(msg));
|
assertTrue(channel.writeOutbound(msg));
|
||||||
ByteBuf buf = channel.readOutbound();
|
ByteBuf buf = channel.readOutbound();
|
||||||
|
@ -98,7 +98,7 @@ public class NettyRuntimeTests {
|
|||||||
assertNull(secondRefernce.get());
|
assertNull(secondRefernce.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Runnable getRunnable(
|
private static Runnable getRunnable(
|
||||||
final NettyRuntime.AvailableProcessorsHolder holder,
|
final NettyRuntime.AvailableProcessorsHolder holder,
|
||||||
final CyclicBarrier barrier,
|
final CyclicBarrier barrier,
|
||||||
final AtomicReference<IllegalStateException> reference) {
|
final AtomicReference<IllegalStateException> reference) {
|
||||||
|
@ -241,8 +241,8 @@ public class DefaultPromiseTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testStackOverFlowChainedFuturesA(int promiseChainLength, final EventExecutor executor,
|
private static void testStackOverFlowChainedFuturesA(int promiseChainLength, final EventExecutor executor,
|
||||||
boolean runTestInExecutorThread)
|
boolean runTestInExecutorThread)
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
final Promise<Void>[] p = new DefaultPromise[promiseChainLength];
|
final Promise<Void>[] p = new DefaultPromise[promiseChainLength];
|
||||||
final CountDownLatch latch = new CountDownLatch(promiseChainLength);
|
final CountDownLatch latch = new CountDownLatch(promiseChainLength);
|
||||||
@ -264,8 +264,8 @@ public class DefaultPromiseTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testStackOverFlowChainedFuturesA(EventExecutor executor, final Promise<Void>[] p,
|
private static void testStackOverFlowChainedFuturesA(EventExecutor executor, final Promise<Void>[] p,
|
||||||
final CountDownLatch latch) {
|
final CountDownLatch latch) {
|
||||||
for (int i = 0; i < p.length; i ++) {
|
for (int i = 0; i < p.length; i ++) {
|
||||||
final int finalI = i;
|
final int finalI = i;
|
||||||
p[i] = new DefaultPromise<Void>(executor);
|
p[i] = new DefaultPromise<Void>(executor);
|
||||||
@ -283,8 +283,8 @@ public class DefaultPromiseTest {
|
|||||||
p[0].setSuccess(null);
|
p[0].setSuccess(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testStackOverFlowChainedFuturesB(int promiseChainLength, final EventExecutor executor,
|
private static void testStackOverFlowChainedFuturesB(int promiseChainLength, final EventExecutor executor,
|
||||||
boolean runTestInExecutorThread)
|
boolean runTestInExecutorThread)
|
||||||
throws InterruptedException {
|
throws InterruptedException {
|
||||||
final Promise<Void>[] p = new DefaultPromise[promiseChainLength];
|
final Promise<Void>[] p = new DefaultPromise[promiseChainLength];
|
||||||
final CountDownLatch latch = new CountDownLatch(promiseChainLength);
|
final CountDownLatch latch = new CountDownLatch(promiseChainLength);
|
||||||
@ -306,8 +306,8 @@ public class DefaultPromiseTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testStackOverFlowChainedFuturesB(EventExecutor executor, final Promise<Void>[] p,
|
private static void testStackOverFlowChainedFuturesB(EventExecutor executor, final Promise<Void>[] p,
|
||||||
final CountDownLatch latch) {
|
final CountDownLatch latch) {
|
||||||
for (int i = 0; i < p.length; i ++) {
|
for (int i = 0; i < p.length; i ++) {
|
||||||
final int finalI = i;
|
final int finalI = i;
|
||||||
p[i] = new DefaultPromise<Void>(executor);
|
p[i] = new DefaultPromise<Void>(executor);
|
||||||
|
@ -186,7 +186,7 @@ public class DefaultThreadFactoryTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runStickyThreadGroupTest(
|
private static void runStickyThreadGroupTest(
|
||||||
final Callable<DefaultThreadFactory> callable,
|
final Callable<DefaultThreadFactory> callable,
|
||||||
final ThreadGroup expected) throws InterruptedException {
|
final ThreadGroup expected) throws InterruptedException {
|
||||||
final AtomicReference<ThreadGroup> captured = new AtomicReference<ThreadGroup>();
|
final AtomicReference<ThreadGroup> captured = new AtomicReference<ThreadGroup>();
|
||||||
|
@ -116,7 +116,7 @@ public class DefaultPriorityQueueTest {
|
|||||||
testRemoval(true);
|
testRemoval(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testRemoval(boolean typed) {
|
private static void testRemoval(boolean typed) {
|
||||||
PriorityQueue<TestElement> queue = new DefaultPriorityQueue<TestElement>(TestElementComparator.INSTANCE, 4);
|
PriorityQueue<TestElement> queue = new DefaultPriorityQueue<TestElement>(TestElementComparator.INSTANCE, 4);
|
||||||
assertEmptyQueue(queue);
|
assertEmptyQueue(queue);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class PlatformDependentTest {
|
|||||||
boolean equals(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length);
|
boolean equals(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testEquals(EqualityChecker equalsChecker) {
|
private static void testEquals(EqualityChecker equalsChecker) {
|
||||||
byte[] bytes1 = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};
|
byte[] bytes1 = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};
|
||||||
byte[] bytes2 = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};
|
byte[] bytes2 = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'};
|
||||||
assertNotSame(bytes1, bytes2);
|
assertNotSame(bytes1, bytes2);
|
||||||
|
@ -440,7 +440,7 @@ public class StringUtilTest {
|
|||||||
assertEscapeCsvAndUnEscapeCsv("\n");
|
assertEscapeCsvAndUnEscapeCsv("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertEscapeCsvAndUnEscapeCsv(String value) {
|
private static void assertEscapeCsvAndUnEscapeCsv(String value) {
|
||||||
assertEquals(value, unescapeCsv(StringUtil.escapeCsv(value)));
|
assertEquals(value, unescapeCsv(StringUtil.escapeCsv(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class Http2RequestHandler extends SimpleChannelInboundHandler<FullHttpReq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendBadRequest(ChannelHandlerContext ctx, String streamId) {
|
private static void sendBadRequest(ChannelHandlerContext ctx, String streamId) {
|
||||||
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST, EMPTY_BUFFER);
|
FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST, EMPTY_BUFFER);
|
||||||
streamId(response, streamId);
|
streamId(response, streamId);
|
||||||
ctx.writeAndFlush(response);
|
ctx.writeAndFlush(response);
|
||||||
|
@ -307,14 +307,14 @@ public class CipherSuiteConverterTest {
|
|||||||
testUnknownJavaCiphersToOpenSSL("");
|
testUnknownJavaCiphersToOpenSSL("");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testUnknownOpenSSLCiphersToJava(String openSslCipherSuite) {
|
private static void testUnknownOpenSSLCiphersToJava(String openSslCipherSuite) {
|
||||||
CipherSuiteConverter.clearCache();
|
CipherSuiteConverter.clearCache();
|
||||||
|
|
||||||
assertNull(CipherSuiteConverter.toJava(openSslCipherSuite, "TLS"));
|
assertNull(CipherSuiteConverter.toJava(openSslCipherSuite, "TLS"));
|
||||||
assertNull(CipherSuiteConverter.toJava(openSslCipherSuite, "SSL"));
|
assertNull(CipherSuiteConverter.toJava(openSslCipherSuite, "SSL"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testUnknownJavaCiphersToOpenSSL(String javaCipherSuite) {
|
private static void testUnknownJavaCiphersToOpenSSL(String javaCipherSuite) {
|
||||||
CipherSuiteConverter.clearCache();
|
CipherSuiteConverter.clearCache();
|
||||||
|
|
||||||
assertNull(CipherSuiteConverter.toOpenSsl(javaCipherSuite));
|
assertNull(CipherSuiteConverter.toOpenSsl(javaCipherSuite));
|
||||||
|
@ -99,7 +99,7 @@ public class OcspTest {
|
|||||||
testClientOcspNotEnabled(SslProvider.OPENSSL_REFCNT);
|
testClientOcspNotEnabled(SslProvider.OPENSSL_REFCNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testClientOcspNotEnabled(SslProvider sslProvider) throws Exception {
|
private static void testClientOcspNotEnabled(SslProvider sslProvider) throws Exception {
|
||||||
SslContext context = SslContextBuilder.forClient()
|
SslContext context = SslContextBuilder.forClient()
|
||||||
.sslProvider(sslProvider)
|
.sslProvider(sslProvider)
|
||||||
.build();
|
.build();
|
||||||
@ -126,7 +126,7 @@ public class OcspTest {
|
|||||||
testServerOcspNotEnabled(SslProvider.OPENSSL_REFCNT);
|
testServerOcspNotEnabled(SslProvider.OPENSSL_REFCNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void testServerOcspNotEnabled(SslProvider sslProvider) throws Exception {
|
private static void testServerOcspNotEnabled(SslProvider sslProvider) throws Exception {
|
||||||
SelfSignedCertificate ssc = new SelfSignedCertificate();
|
SelfSignedCertificate ssc = new SelfSignedCertificate();
|
||||||
try {
|
try {
|
||||||
SslContext context = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
|
SslContext context = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey())
|
||||||
@ -161,7 +161,7 @@ public class OcspTest {
|
|||||||
/**
|
/**
|
||||||
* The Server provides an OCSP staple and the Client accepts it.
|
* The Server provides an OCSP staple and the Client accepts it.
|
||||||
*/
|
*/
|
||||||
private void testClientAcceptingOcspStaple(SslProvider sslProvider) throws Exception {
|
private static void testClientAcceptingOcspStaple(SslProvider sslProvider) throws Exception {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
ChannelInboundHandlerAdapter serverHandler = new ChannelInboundHandlerAdapter() {
|
ChannelInboundHandlerAdapter serverHandler = new ChannelInboundHandlerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
@ -207,7 +207,7 @@ public class OcspTest {
|
|||||||
/**
|
/**
|
||||||
* The Server provides an OCSP staple and the Client rejects it.
|
* The Server provides an OCSP staple and the Client rejects it.
|
||||||
*/
|
*/
|
||||||
private void testClientRejectingOcspStaple(SslProvider sslProvider) throws Exception {
|
private static void testClientRejectingOcspStaple(SslProvider sslProvider) throws Exception {
|
||||||
final AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
|
final AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ public class OcspTest {
|
|||||||
/**
|
/**
|
||||||
* The server has OCSP stapling enabled but doesn't provide a staple.
|
* The server has OCSP stapling enabled but doesn't provide a staple.
|
||||||
*/
|
*/
|
||||||
private void testServerHasNoStaple(SslProvider sslProvider) throws Exception {
|
private static void testServerHasNoStaple(SslProvider sslProvider) throws Exception {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
ChannelInboundHandlerAdapter serverHandler = new ChannelInboundHandlerAdapter() {
|
ChannelInboundHandlerAdapter serverHandler = new ChannelInboundHandlerAdapter() {
|
||||||
@Override
|
@Override
|
||||||
@ -297,7 +297,7 @@ public class OcspTest {
|
|||||||
*
|
*
|
||||||
* The exception should bubble up on the client side and the connection should get closed.
|
* The exception should bubble up on the client side and the connection should get closed.
|
||||||
*/
|
*/
|
||||||
private void testClientException(SslProvider sslProvider) throws Exception {
|
private static void testClientException(SslProvider sslProvider) throws Exception {
|
||||||
final AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
|
final AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class IdleStateHandlerTest {
|
|||||||
IdleStateEvent.ALL_IDLE_STATE_EVENT, IdleStateEvent.ALL_IDLE_STATE_EVENT);
|
IdleStateEvent.ALL_IDLE_STATE_EVENT, IdleStateEvent.ALL_IDLE_STATE_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void anyIdle(TestableIdleStateHandler idleStateHandler, Object... expected) throws Exception {
|
private static void anyIdle(TestableIdleStateHandler idleStateHandler, Object... expected) throws Exception {
|
||||||
|
|
||||||
assertTrue("The number of expected events must be >= 1", expected.length >= 1);
|
assertTrue("The number of expected events must be >= 1", expected.length >= 1);
|
||||||
|
|
||||||
@ -159,8 +159,8 @@ public class IdleStateHandlerTest {
|
|||||||
anyNotIdle(idleStateHandler, writer, IdleStateEvent.FIRST_ALL_IDLE_STATE_EVENT);
|
anyNotIdle(idleStateHandler, writer, IdleStateEvent.FIRST_ALL_IDLE_STATE_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void anyNotIdle(TestableIdleStateHandler idleStateHandler,
|
private static void anyNotIdle(TestableIdleStateHandler idleStateHandler,
|
||||||
Action action, Object expected) throws Exception {
|
Action action, Object expected) throws Exception {
|
||||||
|
|
||||||
final List<Object> events = new ArrayList<Object>();
|
final List<Object> events = new ArrayList<Object>();
|
||||||
ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() {
|
ChannelInboundHandlerAdapter handler = new ChannelInboundHandlerAdapter() {
|
||||||
@ -205,7 +205,7 @@ public class IdleStateHandlerTest {
|
|||||||
observeOutputIdle(false);
|
observeOutputIdle(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void observeOutputIdle(boolean writer) throws Exception {
|
private static void observeOutputIdle(boolean writer) throws Exception {
|
||||||
|
|
||||||
long writerIdleTime = 0L;
|
long writerIdleTime = 0L;
|
||||||
long allIdleTime = 0L;
|
long allIdleTime = 0L;
|
||||||
|
@ -767,7 +767,7 @@ abstract class DnsNameResolverContext<T> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DnsQuestion newQuestion(String hostname, DnsRecordType type) {
|
private static DnsQuestion newQuestion(String hostname, DnsRecordType type) {
|
||||||
try {
|
try {
|
||||||
return new DefaultDnsQuestion(hostname, type);
|
return new DefaultDnsQuestion(hostname, type);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -246,25 +246,26 @@ public class SearchDomainTest {
|
|||||||
assertNotResolve(resolver, "host2");
|
assertNotResolve(resolver, "host2");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertNotResolve(DnsNameResolver resolver, String inetHost) throws InterruptedException {
|
private static void assertNotResolve(DnsNameResolver resolver, String inetHost) throws InterruptedException {
|
||||||
Future<InetAddress> fut = resolver.resolve(inetHost);
|
Future<InetAddress> fut = resolver.resolve(inetHost);
|
||||||
assertTrue(fut.await(10, TimeUnit.SECONDS));
|
assertTrue(fut.await(10, TimeUnit.SECONDS));
|
||||||
assertFalse(fut.isSuccess());
|
assertFalse(fut.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertNotResolveAll(DnsNameResolver resolver, String inetHost) throws InterruptedException {
|
private static void assertNotResolveAll(DnsNameResolver resolver, String inetHost) throws InterruptedException {
|
||||||
Future<List<InetAddress>> fut = resolver.resolveAll(inetHost);
|
Future<List<InetAddress>> fut = resolver.resolveAll(inetHost);
|
||||||
assertTrue(fut.await(10, TimeUnit.SECONDS));
|
assertTrue(fut.await(10, TimeUnit.SECONDS));
|
||||||
assertFalse(fut.isSuccess());
|
assertFalse(fut.isSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String assertResolve(DnsNameResolver resolver, String inetHost) throws InterruptedException {
|
private static String assertResolve(DnsNameResolver resolver, String inetHost) throws InterruptedException {
|
||||||
Future<InetAddress> fut = resolver.resolve(inetHost);
|
Future<InetAddress> fut = resolver.resolve(inetHost);
|
||||||
assertTrue(fut.await(10, TimeUnit.SECONDS));
|
assertTrue(fut.await(10, TimeUnit.SECONDS));
|
||||||
return fut.getNow().getHostAddress();
|
return fut.getNow().getHostAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> assertResolveAll(DnsNameResolver resolver, String inetHost) throws InterruptedException {
|
private static List<String> assertResolveAll(DnsNameResolver resolver,
|
||||||
|
String inetHost) throws InterruptedException {
|
||||||
Future<List<InetAddress>> fut = resolver.resolveAll(inetHost);
|
Future<List<InetAddress>> fut = resolver.resolveAll(inetHost);
|
||||||
assertTrue(fut.await(10, TimeUnit.SECONDS));
|
assertTrue(fut.await(10, TimeUnit.SECONDS));
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
|
@ -238,7 +238,7 @@ abstract class AbstractEpollChannel extends AbstractChannel implements UnixChann
|
|||||||
return socket.isInputShutdown() && (inputClosedSeenErrorOnRead || !isAllowHalfClosure(config));
|
return socket.isInputShutdown() && (inputClosedSeenErrorOnRead || !isAllowHalfClosure(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isAllowHalfClosure(ChannelConfig config) {
|
private static boolean isAllowHalfClosure(ChannelConfig config) {
|
||||||
return config instanceof EpollSocketChannelConfig &&
|
return config instanceof EpollSocketChannelConfig &&
|
||||||
((EpollSocketChannelConfig) config).isAllowHalfClosure();
|
((EpollSocketChannelConfig) config).isAllowHalfClosure();
|
||||||
}
|
}
|
||||||
|
@ -63,11 +63,11 @@ public class EpollSocketChannelConfigTest {
|
|||||||
ch.close().syncUninterruptibly();
|
ch.close().syncUninterruptibly();
|
||||||
}
|
}
|
||||||
|
|
||||||
private long randLong(long min, long max) {
|
private static long randLong(long min, long max) {
|
||||||
return min + nextLong(max - min + 1);
|
return min + nextLong(max - min + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private long nextLong(long n) {
|
private static long nextLong(long n) {
|
||||||
long bits, val;
|
long bits, val;
|
||||||
do {
|
do {
|
||||||
bits = (rand.nextLong() << 1) >>> 1;
|
bits = (rand.nextLong() << 1) >>> 1;
|
||||||
|
@ -351,7 +351,7 @@ abstract class AbstractKQueueChannel extends AbstractChannel implements UnixChan
|
|||||||
return socket.isInputShutdown() && (inputClosedSeenErrorOnRead || !isAllowHalfClosure(config));
|
return socket.isInputShutdown() && (inputClosedSeenErrorOnRead || !isAllowHalfClosure(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isAllowHalfClosure(ChannelConfig config) {
|
private static boolean isAllowHalfClosure(ChannelConfig config) {
|
||||||
return config instanceof KQueueSocketChannelConfig &&
|
return config instanceof KQueueSocketChannelConfig &&
|
||||||
((KQueueSocketChannelConfig) config).isAllowHalfClosure();
|
((KQueueSocketChannelConfig) config).isAllowHalfClosure();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user