From 3c9e2a1a44acf2a1c7074fa3bb5eac15512b7b5a Mon Sep 17 00:00:00 2001 From: strangelookingnerd <49242855+strangelookingnerd@users.noreply.github.com> Date: Thu, 27 Jun 2024 09:36:37 +0200 Subject: [PATCH 1/3] Test classes and methods should have default package visibility --- .../http/cache/TestHttpCacheEntry.java | 44 +-- .../http/cache/TestHttpCacheEntryFactory.java | 30 +- .../impl/cache/CacheControlGeneratorTest.java | 6 +- .../impl/cache/CacheControlParserTest.java | 48 ++-- .../impl/cache/ConsumableInputStream.java | 2 +- .../impl/cache/SimpleHttpCacheStorage.java | 6 +- ...tAbstractSerializingAsyncCacheStorage.java | 26 +- .../TestAbstractSerializingCacheStorage.java | 26 +- .../impl/cache/TestBasicHttpAsyncCache.java | 62 ++-- .../http/impl/cache/TestBasicHttpCache.java | 62 ++-- .../TestByteArrayCacheEntrySerializer.java | 76 ++--- .../impl/cache/TestCacheKeyGenerator.java | 64 ++--- .../impl/cache/TestCacheRevalidatorBase.java | 14 +- .../http/impl/cache/TestCacheSupport.java | 4 +- .../impl/cache/TestCacheValidityPolicy.java | 58 ++-- .../cache/TestCacheableRequestPolicy.java | 14 +- .../TestCachedHttpResponseGenerator.java | 18 +- .../TestCachedResponseSuitabilityChecker.java | 52 ++-- .../http/impl/cache/TestCachingExecChain.java | 86 +++--- .../http/impl/cache/TestCombinedEntity.java | 4 +- .../cache/TestConditionalRequestBuilder.java | 44 ++- .../impl/cache/TestFileResourceFactory.java | 6 +- ...TestHttpByteArrayCacheEntrySerializer.java | 30 +- .../cache/TestHttpCacheJiraNumber1147.java | 8 +- .../impl/cache/TestInternalCacheStorage.java | 6 +- .../cache/TestProtocolAllowedBehavior.java | 6 +- .../cache/TestProtocolRecommendations.java | 138 ++++----- .../impl/cache/TestProtocolRequirements.java | 268 +++++++++--------- .../impl/cache/TestRFC5861Compliance.java | 18 +- .../cache/TestResponseCacheConformance.java | 14 +- .../impl/cache/TestResponseCachingPolicy.java | 170 +++++------ .../impl/cache/TestViaCacheGenerator.java | 8 +- .../memcached/TestPrefixKeyHashingScheme.java | 6 +- .../memcached/TestSHA256HashingScheme.java | 4 +- ...ponentialBackingOffSchedulingStrategy.java | 6 +- .../TestImmediateSchedulingStrategy.java | 6 +- .../http/schedule/TestConcurrentCountMap.java | 4 +- .../hc/client5/http/fluent/TestRequest.java | 8 +- ...ractHttpAsyncClientAuthenticationTest.java | 26 +- .../AbstractHttpAsyncFundamentalsTest.java | 14 +- .../async/AbstractHttpAsyncRedirectsTest.java | 42 +-- .../AbstractHttpReactiveFundamentalsTest.java | 4 +- .../async/AbstractIntegrationTestBase.java | 2 +- .../testing/async/HttpIntegrationTests.java | 66 ++--- .../async/HttpMinimalIntegrationTests.java | 18 +- .../async/ReactiveIntegrationTests.java | 18 +- .../ReactiveMinimalIntegrationTests.java | 18 +- .../hc/client5/testing/async/TestH2Async.java | 2 +- .../testing/async/TestH2AsyncMinimal.java | 2 +- .../testing/async/TestH2AsyncRedirect.java | 2 +- .../async/TestH2ClientAuthentication.java | 2 +- .../client5/testing/async/TestH2Reactive.java | 2 +- .../testing/async/TestH2ReactiveMinimal.java | 2 +- .../client5/testing/async/TestHttp1Async.java | 6 +- .../testing/async/TestHttp1AsyncMinimal.java | 4 +- .../async/TestHttp1AsyncRedirects.java | 8 +- .../TestHttp1AsyncStatefulConnManagement.java | 10 +- .../async/TestHttp1ClientAuthentication.java | 4 +- .../testing/async/TestHttp1Reactive.java | 2 +- .../async/TestHttp1ReactiveMinimal.java | 4 +- .../async/TestHttp1RequestReExecution.java | 8 +- .../TestHttpAsyncMinimalTlsHandshake.java | 6 +- .../async/TestHttpAsyncProtocolPolicy.java | 4 +- .../extension/async/TestAsyncResources.java | 2 +- .../extension/sync/TestClientResources.java | 2 +- .../hc/client5/testing/fluent/TestFluent.java | 22 +- .../sync/AbstractIntegrationTestBase.java | 2 +- .../testing/sync/HttpIntegrationTests.java | 34 +-- .../sync/HttpMinimalIntegrationTests.java | 10 +- .../sync/TestBasicConnectionManager.java | 6 +- .../sync/TestClientAuthentication.java | 44 +-- .../sync/TestClientRequestExecution.java | 14 +- .../sync/TestConnectionManagement.java | 12 +- .../testing/sync/TestConnectionReuse.java | 16 +- .../testing/sync/TestContentCodings.java | 26 +- .../testing/sync/TestCookieVirtualHost.java | 6 +- .../sync/TestDefaultClientTlsStrategy.java | 26 +- .../TestFutureRequestExecutionService.java | 18 +- .../TestHttpClientBuilderInterceptors.java | 6 +- .../sync/TestIdleConnectionEviction.java | 4 +- .../sync/TestMalformedServerResponse.java | 6 +- .../TestMinimalClientRequestExecution.java | 8 +- .../client5/testing/sync/TestRedirects.java | 40 +-- .../sync/TestStatefulConnManagement.java | 8 +- .../http/ConnectExceptionSupportTest.java | 18 +- .../http/SystemDefaultDnsResolverTest.java | 2 +- .../apache/hc/client5/http/TestHttpRoute.java | 24 +- .../methods/TestSimpleMessageBuilders.java | 14 +- .../client5/http/auth/TestAuthChallenge.java | 6 +- .../hc/client5/http/auth/TestAuthScope.java | 18 +- .../hc/client5/http/auth/TestCredentials.java | 24 +- .../http/classic/methods/TestHttpOptions.java | 4 +- .../classic/methods/TestHttpRequestBase.java | 38 +-- .../http/classic/methods/TestHttpTrace.java | 4 +- .../http/config/TestRequestConfig.java | 8 +- .../client5/http/cookie/TestCookieOrigin.java | 14 +- .../http/cookie/TestCookiePathComparator.java | 14 +- .../cookie/TestCookiePriorityComparator.java | 16 +- .../hc/client5/http/entity/TestBrotli.java | 4 +- .../http/entity/TestDecompressingEntity.java | 8 +- .../hc/client5/http/entity/TestDeflate.java | 4 +- .../http/entity/TestEntityBuilder.java | 20 +- .../hc/client5/http/entity/TestGZip.java | 10 +- .../http/entity/mime/FormBodyPartTest.java | 4 +- .../entity/mime/HttpRFC7578MultipartTest.java | 4 +- .../entity/mime/TestFormBodyPartBuilder.java | 8 +- .../http/entity/mime/TestMimeField.java | 4 +- .../entity/mime/TestMultipartContentBody.java | 6 +- .../mime/TestMultipartEntityBuilder.java | 30 +- .../http/entity/mime/TestMultipartForm.java | 20 +- .../mime/TestMultipartFormHttpEntity.java | 10 +- .../http/entity/mime/TestMultipartFormat.java | 6 +- .../http/entity/mime/TestMultipartMixed.java | 18 +- .../entity/mime/TestMultipartPartBuilder.java | 8 +- .../AsyncClientFullDuplexExchange.java | 2 +- .../AsyncClientH2FullDuplexExchange.java | 2 +- .../examples/AsyncClientH2ServerPush.java | 10 +- .../AsyncClientHttpExchangeStreaming.java | 6 +- .../examples/AsyncClientInterceptors.java | 2 +- .../http/examples/ClientInterceptors.java | 2 +- .../hc/client5/http/impl/ExecSupportTest.java | 4 +- .../http/impl/InMemoryDnsResolverTest.java | 2 +- .../http/impl/PrefixedIncrementingIdTest.java | 4 +- .../http/impl/TestAuthenticationStrategy.java | 10 +- .../TestDefaultConnKeepAliveStrategy.java | 12 +- .../TestDefaultHttpRequestRetryStrategy.java | 30 +- .../impl/TestDefaultRedirectStrategy.java | 40 +-- .../http/impl/TestIdleConnectionEvictor.java | 6 +- .../http/impl/TestProtocolSwitchStrategy.java | 8 +- .../client5/http/impl/TestRequestSupport.java | 4 +- .../impl/auth/TestAuthChallengeParser.java | 44 +-- .../http/impl/auth/TestBasicAuthCache.java | 8 +- .../http/impl/auth/TestBasicScheme.java | 24 +- .../http/impl/auth/TestBearerScheme.java | 8 +- .../impl/auth/TestCredentialsProviders.java | 24 +- .../http/impl/auth/TestDigestScheme.java | 64 ++--- .../http/impl/auth/TestHttpAuthenticator.java | 48 ++-- .../http/impl/auth/TestNTLMEngineImpl.java | 29 +- .../http/impl/auth/TestNTLMScheme.java | 4 +- .../TestSystemDefaultCredentialsProvider.java | 6 +- .../impl/classic/TestAIMDBackoffManager.java | 30 +- ...TestAbstractHttpClientResponseHandler.java | 8 +- .../classic/TestBasicResponseHandler.java | 6 +- .../impl/classic/TestCloseableHttpClient.java | 16 +- .../http/impl/classic/TestConnectExec.java | 22 +- .../classic/TestContentCompressionExec.java | 24 +- .../classic/TestCookieIdentityComparator.java | 12 +- .../classic/TestDefaultBackoffStrategy.java | 16 +- .../TestExponentialBackoffManager.java | 22 +- .../classic/TestHttpAsyncClientBuilder.java | 10 +- .../impl/classic/TestHttpClientBuilder.java | 6 +- .../classic/TestHttpRequestRetryExec.java | 22 +- .../impl/classic/TestInternalExecRuntime.java | 24 +- .../impl/classic/TestInternalHttpClient.java | 18 +- .../classic/TestLinearBackoffManager.java | 20 +- .../http/impl/classic/TestMainClientExec.java | 24 +- .../impl/classic/TestNullBackoffStrategy.java | 8 +- .../http/impl/classic/TestProtocolExec.java | 18 +- .../http/impl/classic/TestRedirectExec.java | 22 +- .../impl/classic/TestResponseEntityProxy.java | 10 +- .../classic/TestResponseEntityWrapper.java | 18 +- .../impl/cookie/TestBasicClientCookie.java | 8 +- .../cookie/TestBasicCookieAttribHandlers.java | 66 ++--- .../impl/cookie/TestBasicCookieStore.java | 8 +- .../cookie/TestLaxCookieAttribHandlers.java | 66 ++--- .../cookie/TestPublicSuffixListParser.java | 10 +- .../impl/cookie/TestRFC6265CookieSpec.java | 36 +-- .../TestBasicHttpClientConnectionManager.java | 34 +-- .../io/TestHttpClientConnectionOperator.java | 22 +- ...estPoolingHttpClientConnectionManager.java | 28 +- .../routing/TestDefaultProxyRoutePlanner.java | 8 +- .../impl/routing/TestDefaultRoutePlanner.java | 16 +- .../http/impl/routing/TestRouteDirector.java | 16 +- .../http/impl/routing/TestRouteTracker.java | 18 +- .../http/impl/routing/TestRoutingSupport.java | 8 +- .../TestSystemDefaultRoutePlanner.java | 10 +- .../http/protocol/TestRedirectLocation.java | 4 +- .../http/protocol/TestRequestAddCookies.java | 36 +-- .../TestRequestClientConnControl.java | 14 +- .../protocol/TestRequestDefaultHeaders.java | 8 +- .../protocol/TestRequestExpectContinue.java | 14 +- .../protocol/TestResponseProcessCookies.java | 16 +- .../http/psl/TestPublicSuffixListParser.java | 6 +- .../http/psl/TestPublicSuffixMatcher.java | 14 +- .../http/ssl/CertificatesToPlayWith.java | 2 +- .../http/ssl/TestDefaultHostnameVerifier.java | 32 +-- .../http/ssl/TestDistinguishedNameParser.java | 24 +- .../hc/client5/http/utils/TestBase64.java | 2 +- .../http/utils/TestByteArrayBuilder.java | 18 +- .../hc/client5/http/utils/TestDateUtils.java | 16 +- .../hc/client5/http/utils/TestDnsUtils.java | 4 +- .../hc/client5/http/utils/TestURIUtils.java | 16 +- .../hc/client5/http/validator/TestETag.java | 10 +- 193 files changed, 1873 insertions(+), 1884 deletions(-) diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java index 52036fa20..b5d9f559c 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java @@ -56,7 +56,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestHttpCacheEntry { +class TestHttpCacheEntry { private Instant now; private Instant elevenSecondsAgo; @@ -65,7 +65,7 @@ public class TestHttpCacheEntry { private HttpCacheEntry entry; @BeforeEach - public void setUp() { + void setUp() { now = Instant.now(); elevenSecondsAgo = now.minusSeconds(11); nineSecondsAgo = now.minusSeconds(9); @@ -99,7 +99,7 @@ private HttpCacheEntry makeEntry(final Instant requestDate, } @Test - public void testGetHeadersReturnsCorrectHeaders() { + void testGetHeadersReturnsCorrectHeaders() { entry = makeEntry( new BasicHeader("bar", "barValue1"), new BasicHeader("bar", "barValue2")); @@ -107,7 +107,7 @@ public void testGetHeadersReturnsCorrectHeaders() { } @Test - public void testGetFirstHeaderReturnsCorrectHeader() { + void testGetFirstHeaderReturnsCorrectHeader() { entry = makeEntry( new BasicHeader("bar", "barValue1"), new BasicHeader("bar", "barValue2")); @@ -115,7 +115,7 @@ public void testGetFirstHeaderReturnsCorrectHeader() { } @Test - public void testGetHeadersReturnsEmptyArrayIfNoneMatch() { + void testGetHeadersReturnsEmptyArrayIfNoneMatch() { entry = makeEntry( new BasicHeader("foo", "fooValue"), new BasicHeader("bar", "barValue1"), @@ -124,7 +124,7 @@ public void testGetHeadersReturnsEmptyArrayIfNoneMatch() { } @Test - public void testGetFirstHeaderReturnsNullIfNoneMatch() { + void testGetFirstHeaderReturnsNullIfNoneMatch() { entry = makeEntry( new BasicHeader("foo", "fooValue"), new BasicHeader("bar", "barValue1"), @@ -133,7 +133,7 @@ public void testGetFirstHeaderReturnsNullIfNoneMatch() { } @Test - public void testGetMethodReturnsCorrectRequestMethod() { + void testGetMethodReturnsCorrectRequestMethod() { entry = makeEntry( new BasicHeader("foo", "fooValue"), new BasicHeader("bar", "barValue1"), @@ -142,33 +142,33 @@ public void testGetMethodReturnsCorrectRequestMethod() { } @Test - public void statusCodeComesFromOriginalStatusLine() { + void statusCodeComesFromOriginalStatusLine() { entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK); assertEquals(HttpStatus.SC_OK, entry.getStatus()); } @Test - public void canGetOriginalRequestDate() { + void canGetOriginalRequestDate() { final Instant requestDate = Instant.now(); entry = makeEntry(requestDate, Instant.now(), HttpStatus.SC_OK); assertEquals(requestDate, entry.getRequestInstant()); } @Test - public void canGetOriginalResponseDate() { + void canGetOriginalResponseDate() { final Instant responseDate = Instant.now(); entry = makeEntry(Instant.now(), responseDate, HttpStatus.SC_OK); assertEquals(responseDate, entry.getResponseInstant()); } @Test - public void canGetOriginalResource() { + void canGetOriginalResource() { entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK); assertSame(mockResource, entry.getResource()); } @Test - public void canGetOriginalHeaders() { + void canGetOriginalHeaders() { final Header[] headers = { new BasicHeader("Server", "MockServer/1.0"), new BasicHeader("Date", DateUtils.formatStandardDate(now)) @@ -182,7 +182,7 @@ public void canGetOriginalHeaders() { } @Test - public void canRetrieveOriginalVariantMap() { + void canRetrieveOriginalVariantMap() { final Set variants = new HashSet<>(); variants.add("A"); variants.add("B"); @@ -199,7 +199,7 @@ public void canRetrieveOriginalVariantMap() { } @Test - public void retrievedVariantMapIsNotModifiable() { + void retrievedVariantMapIsNotModifiable() { final Set variants = new HashSet<>(); variants.add("A"); variants.add("B"); @@ -213,27 +213,27 @@ public void retrievedVariantMapIsNotModifiable() { } @Test - public void canConvertToString() { + void canConvertToString() { entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK); assertNotNull(entry.toString()); assertNotEquals("", entry.toString()); } @Test - public void testMissingDateHeaderIsIgnored() { + void testMissingDateHeaderIsIgnored() { entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK); assertNull(entry.getInstant()); } @Test - public void testMalformedDateHeaderIsIgnored() { + void testMalformedDateHeaderIsIgnored() { entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK, new BasicHeader("Date", "asdf")); assertNull(entry.getInstant()); } @Test - public void testValidDateHeaderIsParsed() { + void testValidDateHeaderIsParsed() { final Instant date = Instant.now().with(ChronoField.MILLI_OF_SECOND, 0); entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK, new BasicHeader("Date", DateUtils.formatStandardDate(date))); @@ -243,7 +243,7 @@ public void testValidDateHeaderIsParsed() { } @Test - public void testEpochDateHeaderIsParsed() { + void testEpochDateHeaderIsParsed() { entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK, new BasicHeader("Date", DateUtils.formatStandardDate(Instant.EPOCH))); final Instant dateHeaderValue = entry.getInstant(); @@ -252,7 +252,7 @@ public void testEpochDateHeaderIsParsed() { } @Test - public void testDateParsedOnce() { + void testDateParsedOnce() { final Instant date = Instant.now().with(ChronoField.MILLI_OF_SECOND, 0); entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK, new BasicHeader("Date", DateUtils.formatStandardDate(date))); @@ -263,7 +263,7 @@ public void testDateParsedOnce() { } @Test - public void testExpiresParsedOnce() { + void testExpiresParsedOnce() { final Instant date = Instant.now().with(ChronoField.MILLI_OF_SECOND, 0); entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK, new BasicHeader("Last-Modified", DateUtils.formatStandardDate(date))); @@ -278,7 +278,7 @@ private static Instant createInstant(final int year, final Month month, final in } @Test - public void testIsCacheEntryNewer() throws Exception { + void testIsCacheEntryNewer() { assertFalse(HttpCacheEntry.isNewer(null, null)); entry = makeEntry(); final HeaderGroup message = new HeaderGroup(); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntryFactory.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntryFactory.java index 2f1bdcb71..46092c24d 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntryFactory.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntryFactory.java @@ -52,7 +52,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestHttpCacheEntryFactory { +class TestHttpCacheEntryFactory { private Instant requestDate; private Instant responseDate; @@ -69,7 +69,7 @@ public class TestHttpCacheEntryFactory { private HttpCacheEntryFactory impl; @BeforeEach - public void setUp() throws Exception { + void setUp() { requestDate = Instant.now().minusSeconds(1); responseDate = Instant.now(); @@ -87,7 +87,7 @@ public void setUp() throws Exception { } @Test - public void testFilterHopByHopAndConnectionSpecificHeaders() { + void testFilterHopByHopAndConnectionSpecificHeaders() { response.setHeaders( new BasicHeader(HttpHeaders.CONNECTION, "blah, blah, this, that"), new BasicHeader("Blah", "huh?"), @@ -106,7 +106,7 @@ public void testFilterHopByHopAndConnectionSpecificHeaders() { } @Test - public void testHeadersAreMergedCorrectly() { + void testHeadersAreMergedCorrectly() { entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Date", DateUtils.formatStandardDate(responseDate)), new BasicHeader("ETag", "\"etag\"")); @@ -118,7 +118,7 @@ public void testHeadersAreMergedCorrectly() { } @Test - public void testNewerHeadersReplaceExistingHeaders() { + void testNewerHeadersReplaceExistingHeaders() { entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Date", DateUtils.formatStandardDate(requestDate)), new BasicHeader("Cache-Control", "private"), @@ -139,7 +139,7 @@ public void testNewerHeadersReplaceExistingHeaders() { } @Test - public void testNewHeadersAreAddedByMerge() { + void testNewHeadersAreAddedByMerge() { entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Date", DateUtils.formatStandardDate(requestDate)), new BasicHeader("ETag", "\"etag\"")); @@ -156,7 +156,7 @@ public void testNewHeadersAreAddedByMerge() { } @Test - public void entryWithMalformedDateIsStillUpdated() throws Exception { + void entryWithMalformedDateIsStillUpdated() { entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo, new BasicHeader("ETag", "\"old\""), new BasicHeader("Date", "bad-date")); @@ -169,7 +169,7 @@ public void entryWithMalformedDateIsStillUpdated() throws Exception { } @Test - public void entryIsStillUpdatedByResponseWithMalformedDate() throws Exception { + void entryIsStillUpdatedByResponseWithMalformedDate() { entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo, new BasicHeader("ETag", "\"old\""), new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -182,14 +182,14 @@ public void entryIsStillUpdatedByResponseWithMalformedDate() throws Exception { } @Test - public void testUpdateCacheEntryReturnsDifferentEntryInstance() { + void testUpdateCacheEntryReturnsDifferentEntryInstance() { entry = HttpTestUtils.makeCacheEntry(); final HttpCacheEntry newEntry = impl.createUpdated(requestDate, responseDate, host, request, response, entry); Assertions.assertNotSame(newEntry, entry); } @Test - public void testCreateRootVariantEntry() { + void testCreateRootVariantEntry() { request.setHeaders( new BasicHeader("Keep-Alive", "timeout, max=20"), new BasicHeader("X-custom", "my stuff"), @@ -241,7 +241,7 @@ public void testCreateRootVariantEntry() { } @Test - public void testCreateResourceEntry() { + void testCreateResourceEntry() { request.setHeaders( new BasicHeader("Keep-Alive", "timeout, max=20"), new BasicHeader("X-custom", "my stuff"), @@ -285,7 +285,7 @@ public void testCreateResourceEntry() { } @Test - public void testCreateUpdatedResourceEntry() { + void testCreateUpdatedResourceEntry() { final Resource resource = HttpTestUtils.makeRandomResource(128); final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry( tenSecondsAgo, @@ -347,7 +347,7 @@ public void testCreateUpdatedResourceEntry() { } @Test - public void testUpdateNotModifiedIfResponseOlder() { + void testUpdateNotModifiedIfResponseOlder() { entry = HttpTestUtils.makeCacheEntry(twoSecondsAgo, now, new BasicHeader("Date", DateUtils.formatStandardDate(oneSecondAgo)), new BasicHeader("ETag", "\"new-etag\"")); @@ -360,7 +360,7 @@ public void testUpdateNotModifiedIfResponseOlder() { } @Test - public void testUpdateHasLatestRequestAndResponseDates() { + void testUpdateHasLatestRequestAndResponseDates() { entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, eightSecondsAgo); final HttpCacheEntry updated = impl.createUpdated(twoSecondsAgo, oneSecondAgo, host, request, response, entry); @@ -369,7 +369,7 @@ public void testUpdateHasLatestRequestAndResponseDates() { } @Test - public void cannotUpdateFromANon304OriginResponse() throws Exception { + void cannotUpdateFromANon304OriginResponse() { entry = HttpTestUtils.makeCacheEntry(); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); Assertions.assertThrows(IllegalArgumentException.class, () -> diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/CacheControlGeneratorTest.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/CacheControlGeneratorTest.java index 0efa6dad3..058ecd89d 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/CacheControlGeneratorTest.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/CacheControlGeneratorTest.java @@ -33,12 +33,12 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class CacheControlGeneratorTest { +class CacheControlGeneratorTest { private final CacheControlHeaderGenerator generator = CacheControlHeaderGenerator.INSTANCE; @Test - public void testGenerateRequestCacheControlHeader() { + void testGenerateRequestCacheControlHeader() { assertThat(generator.generate( RequestCacheControl.builder() .setMaxAge(12) @@ -77,7 +77,7 @@ public void testGenerateRequestCacheControlHeader() { } @Test - public void testGenerateRequestCacheControlHeaderNoDirectives() { + void testGenerateRequestCacheControlHeaderNoDirectives() { final RequestCacheControl cacheControl = RequestCacheControl.builder() .build(); Assertions.assertNull(generator.generate(cacheControl)); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/CacheControlParserTest.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/CacheControlParserTest.java index 640402ecb..d4ad63919 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/CacheControlParserTest.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/CacheControlParserTest.java @@ -40,74 +40,74 @@ import org.apache.hc.core5.http.message.BasicHeader; import org.junit.jupiter.api.Test; -public class CacheControlParserTest { +class CacheControlParserTest { private final CacheControlHeaderParser parser = CacheControlHeaderParser.INSTANCE; @Test - public void testParseMaxAgeZero() { + void testParseMaxAgeZero() { final Header header = new BasicHeader("Cache-Control", "max-age=0 , this = stuff;"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertEquals(0L, cacheControl.getMaxAge()); } @Test - public void testParseSMaxAge() { + void testParseSMaxAge() { final Header header = new BasicHeader("Cache-Control", "s-maxage=3600"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertEquals(3600L, cacheControl.getSharedMaxAge()); } @Test - public void testParseInvalidCacheValue() { + void testParseInvalidCacheValue() { final Header header = new BasicHeader("Cache-Control", "max-age=invalid"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertEquals(0L, cacheControl.getMaxAge()); } @Test - public void testParseInvalidHeader() { + void testParseInvalidHeader() { final Header header = new BasicHeader("Cache-Control", "max-age"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertEquals(-1L, cacheControl.getMaxAge()); } @Test - public void testParseNullHeader() { + void testParseNullHeader() { final Header header = null; assertThrows(NullPointerException.class, () -> parser.parseResponse(Collections.singletonList(header).iterator())); } @Test - public void testParseEmptyHeader() { + void testParseEmptyHeader() { final Header header = new BasicHeader("Cache-Control", ""); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertEquals(-1L, cacheControl.getMaxAge()); } @Test - public void testParseCookieEmptyValue() { + void testParseCookieEmptyValue() { final Header header = new BasicHeader("Cache-Control", "max-age=,"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertEquals(-1L, cacheControl.getMaxAge()); } @Test - public void testParseNoCache() { + void testParseNoCache() { final Header header = new BasicHeader(" Cache-Control", "no-cache"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertEquals(-1L, cacheControl.getMaxAge()); } @Test - public void testParseNoDirective() { + void testParseNoDirective() { final Header header = new BasicHeader(" Cache-Control", ""); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertEquals(-1L, cacheControl.getMaxAge()); } @Test - public void testGarbage() { + void testGarbage() { final Header header = new BasicHeader("Cache-Control", ",,= blah,"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertEquals(-1L, cacheControl.getMaxAge()); @@ -115,7 +115,7 @@ public void testGarbage() { @Test - public void testParseMultipleDirectives() { + void testParseMultipleDirectives() { final Header header = new BasicHeader("Cache-Control", "max-age=604800, stale-while-revalidate=86400, s-maxage=3600, must-revalidate, private"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); @@ -128,7 +128,7 @@ public void testParseMultipleDirectives() { } @Test - public void testParseMultipleDirectives2() { + void testParseMultipleDirectives2() { final Header header = new BasicHeader("Cache-Control", "max-age=604800, stale-while-revalidate=86400, must-revalidate, private, s-maxage=3600"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); @@ -141,7 +141,7 @@ public void testParseMultipleDirectives2() { } @Test - public void testParsePublic() { + void testParsePublic() { final Header header = new BasicHeader("Cache-Control", "public"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); @@ -149,7 +149,7 @@ public void testParsePublic() { } @Test - public void testParsePrivate() { + void testParsePrivate() { final Header header = new BasicHeader("Cache-Control", "private"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); @@ -157,7 +157,7 @@ public void testParsePrivate() { } @Test - public void testParseNoStore() { + void testParseNoStore() { final Header header = new BasicHeader("Cache-Control", "no-store"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); @@ -165,7 +165,7 @@ public void testParseNoStore() { } @Test - public void testParseStaleWhileRevalidate() { + void testParseStaleWhileRevalidate() { final Header header = new BasicHeader("Cache-Control", "max-age=3600, stale-while-revalidate=120"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); @@ -173,7 +173,7 @@ public void testParseStaleWhileRevalidate() { } @Test - public void testParseNoCacheFields() { + void testParseNoCacheFields() { final Header header = new BasicHeader("Cache-Control", "no-cache=\"Set-Cookie, Content-Language\", stale-while-revalidate=120"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); @@ -185,7 +185,7 @@ public void testParseNoCacheFields() { } @Test - public void testParseNoCacheFieldsNoQuote() { + void testParseNoCacheFieldsNoQuote() { final Header header = new BasicHeader("Cache-Control", "no-cache=Set-Cookie, Content-Language, stale-while-revalidate=120"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); @@ -196,7 +196,7 @@ public void testParseNoCacheFieldsNoQuote() { } @Test - public void testParseNoCacheFieldsMessy() { + void testParseNoCacheFieldsMessy() { final Header header = new BasicHeader("Cache-Control", "no-cache=\" , , ,,, Set-Cookie , , Content-Language , \", stale-while-revalidate=120"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); @@ -209,7 +209,7 @@ public void testParseNoCacheFieldsMessy() { @Test - public void testParseMultipleHeaders() { + void testParseMultipleHeaders() { // Create headers final Header header1 = new BasicHeader("Cache-Control", "max-age=3600, no-store"); final Header header2 = new BasicHeader("Cache-Control", "private, must-revalidate"); @@ -230,7 +230,7 @@ public void testParseMultipleHeaders() { } @Test - public void testParseRequestMultipleDirectives() { + void testParseRequestMultipleDirectives() { final Header header = new BasicHeader("Cache-Control", "blah, max-age=1111, max-stale=2222, " + "min-fresh=3333, no-cache, no-store, no-cache, no-stuff, only-if-cached, only-if-cached-or-maybe-not"); final RequestCacheControl cacheControl = parser.parseRequest(Collections.singletonList(header).iterator()); @@ -246,14 +246,14 @@ public void testParseRequestMultipleDirectives() { } @Test - public void testParseIsImmutable() { + void testParseIsImmutable() { final Header header = new BasicHeader("Cache-Control", "max-age=0 , immutable"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertTrue(cacheControl.isImmutable()); } @Test - public void testParseMultipleIsImmutable() { + void testParseMultipleIsImmutable() { final Header header = new BasicHeader("Cache-Control", "immutable, nmax-age=0 , immutable"); final ResponseCacheControl cacheControl = parser.parseResponse(Collections.singletonList(header).iterator()); assertTrue(cacheControl.isImmutable()); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java index a6de12aa0..1cd8c3490 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java @@ -42,7 +42,7 @@ public ConsumableInputStream(final ByteArrayInputStream buf) { } @Override - public int read() throws IOException { + public int read() { return buf.read(); } diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/SimpleHttpCacheStorage.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/SimpleHttpCacheStorage.java index 8dcfad757..0b51b730f 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/SimpleHttpCacheStorage.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/SimpleHttpCacheStorage.java @@ -44,17 +44,17 @@ public SimpleHttpCacheStorage() { } @Override - public void putEntry(final String key, final HttpCacheEntry entry) throws ResourceIOException { + public void putEntry(final String key, final HttpCacheEntry entry) { map.put(key, entry); } @Override - public HttpCacheEntry getEntry(final String key) throws ResourceIOException { + public HttpCacheEntry getEntry(final String key) { return map.get(key); } @Override - public void removeEntry(final String key) throws ResourceIOException { + public void removeEntry(final String key) { map.remove(key); } diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java index aefbe66ea..56891428d 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java @@ -54,7 +54,7 @@ import org.mockito.MockitoAnnotations; import org.mockito.stubbing.Answer; -public class TestAbstractSerializingAsyncCacheStorage { +class TestAbstractSerializingAsyncCacheStorage { @Mock private Cancellable cancellable; @@ -80,7 +80,7 @@ public void setUp() { } @Test - public void testCachePut() throws Exception { + void testCachePut() throws Exception { final String key = "foo"; final HttpCacheEntry value = HttpTestUtils.makeCacheEntry(); @@ -103,7 +103,7 @@ public void testCachePut() throws Exception { } @Test - public void testCacheGetNullEntry() throws Exception { + void testCacheGetNullEntry() { final String key = "foo"; Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar"); @@ -121,7 +121,7 @@ public void testCacheGetNullEntry() throws Exception { } @Test - public void testCacheGet() throws Exception { + void testCacheGet() { final String key = "foo"; final HttpCacheEntry value = HttpTestUtils.makeCacheEntry(); @@ -141,7 +141,7 @@ public void testCacheGet() throws Exception { } @Test - public void testCacheGetKeyMismatch() throws Exception { + void testCacheGetKeyMismatch() { final String key = "foo"; final HttpCacheEntry value = HttpTestUtils.makeCacheEntry(); Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar"); @@ -159,7 +159,7 @@ public void testCacheGetKeyMismatch() throws Exception { } @Test - public void testCacheRemove() throws Exception{ + void testCacheRemove() { final String key = "foo"; Mockito.when(impl.digestToStorageKey(key)).thenReturn("bar"); @@ -177,7 +177,7 @@ public void testCacheRemove() throws Exception{ } @Test - public void testCacheUpdateNullEntry() throws Exception { + void testCacheUpdateNullEntry() { final String key = "foo"; final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -207,7 +207,7 @@ public void testCacheUpdateNullEntry() throws Exception { } @Test - public void testCacheCASUpdate() throws Exception { + void testCacheCASUpdate() throws Exception { final String key = "foo"; final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry(); final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -238,7 +238,7 @@ public void testCacheCASUpdate() throws Exception { } @Test - public void testCacheCASUpdateKeyMismatch() throws Exception { + void testCacheCASUpdateKeyMismatch() throws Exception { final String key = "foo"; final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry(); final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -274,7 +274,7 @@ public void testCacheCASUpdateKeyMismatch() throws Exception { } @Test - public void testSingleCacheUpdateRetry() throws Exception { + void testSingleCacheUpdateRetry() throws Exception { final String key = "foo"; final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry(); final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -312,7 +312,7 @@ public void testSingleCacheUpdateRetry() throws Exception { } @Test - public void testCacheUpdateFail() throws Exception { + void testCacheUpdateFail() throws Exception { final String key = "foo"; final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry(); final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -351,7 +351,7 @@ public void testCacheUpdateFail() throws Exception { @Test @SuppressWarnings("unchecked") - public void testBulkGet() throws Exception { + void testBulkGet() { final String key1 = "foo this"; final String key2 = "foo that"; final String storageKey1 = "bar this"; @@ -396,7 +396,7 @@ public void testBulkGet() throws Exception { @Test @SuppressWarnings("unchecked") - public void testBulkGetKeyMismatch() throws Exception { + void testBulkGetKeyMismatch() { final String key1 = "foo this"; final String key2 = "foo that"; final String storageKey1 = "bar this"; diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java index 618c7f183..7e37fd4de 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java @@ -51,7 +51,7 @@ import org.mockito.stubbing.Answer; @SuppressWarnings("boxing") // test code -public class TestAbstractSerializingCacheStorage { +class TestAbstractSerializingCacheStorage { public static byte[] serialize(final String key, final HttpCacheEntry value) throws ResourceIOException { return HttpByteArrayCacheEntrySerializer.INSTANCE.serialize(new HttpCacheStorageEntry(key, value)); @@ -67,7 +67,7 @@ public void setUp() { } @Test - public void testCachePut() throws Exception { + void testCachePut() throws Exception { final String key = "foo"; final HttpCacheEntry value = HttpTestUtils.makeCacheEntry(); @@ -81,7 +81,7 @@ public void testCachePut() throws Exception { } @Test - public void testCacheGetNullEntry() throws Exception { + void testCacheGetNullEntry() throws Exception { final String key = "foo"; when(impl.digestToStorageKey(key)).thenReturn("bar"); @@ -95,7 +95,7 @@ public void testCacheGetNullEntry() throws Exception { } @Test - public void testCacheGet() throws Exception { + void testCacheGet() throws Exception { final String key = "foo"; final HttpCacheEntry value = HttpTestUtils.makeCacheEntry(); @@ -110,7 +110,7 @@ public void testCacheGet() throws Exception { } @Test - public void testCacheGetKeyMismatch() throws Exception { + void testCacheGetKeyMismatch() throws Exception { final String key = "foo"; final HttpCacheEntry value = HttpTestUtils.makeCacheEntry(); @@ -125,7 +125,7 @@ public void testCacheGetKeyMismatch() throws Exception { } @Test - public void testCacheRemove() throws Exception{ + void testCacheRemove() throws Exception{ final String key = "foo"; when(impl.digestToStorageKey(key)).thenReturn("bar"); @@ -135,7 +135,7 @@ public void testCacheRemove() throws Exception{ } @Test - public void testCacheUpdateNullEntry() throws Exception { + void testCacheUpdateNullEntry() throws Exception { final String key = "foo"; final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -152,7 +152,7 @@ public void testCacheUpdateNullEntry() throws Exception { } @Test - public void testCacheCASUpdate() throws Exception { + void testCacheCASUpdate() throws Exception { final String key = "foo"; final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry(); final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -170,7 +170,7 @@ public void testCacheCASUpdate() throws Exception { } @Test - public void testCacheCASUpdateKeyMismatch() throws Exception { + void testCacheCASUpdateKeyMismatch() throws Exception { final String key = "foo"; final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry(); final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -191,7 +191,7 @@ public void testCacheCASUpdateKeyMismatch() throws Exception { } @Test - public void testSingleCacheUpdateRetry() throws Exception { + void testSingleCacheUpdateRetry() throws Exception { final String key = "foo"; final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry(); final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -209,7 +209,7 @@ public void testSingleCacheUpdateRetry() throws Exception { } @Test - public void testCacheUpdateFail() throws Exception { + void testCacheUpdateFail() throws Exception { final String key = "foo"; final HttpCacheEntry existingValue = HttpTestUtils.makeCacheEntry(); final HttpCacheEntry updatedValue = HttpTestUtils.makeCacheEntry(); @@ -228,7 +228,7 @@ public void testCacheUpdateFail() throws Exception { } @Test - public void testBulkGet() throws Exception { + void testBulkGet() throws Exception { final String key1 = "foo this"; final String key2 = "foo that"; final String storageKey1 = "bar this"; @@ -262,7 +262,7 @@ public void testBulkGet() throws Exception { } @Test - public void testBulkGetKeyMismatch() throws Exception { + void testBulkGetKeyMismatch() throws Exception { final String key1 = "foo this"; final String key2 = "foo that"; final String storageKey1 = "bar this"; diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpAsyncCache.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpAsyncCache.java index f8632e65d..068fadef2 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpAsyncCache.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpAsyncCache.java @@ -64,7 +64,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public class TestBasicHttpAsyncCache { +class TestBasicHttpAsyncCache { private HttpHost host; private Instant now; @@ -73,7 +73,7 @@ public class TestBasicHttpAsyncCache { private BasicHttpAsyncCache impl; @BeforeEach - public void setUp() { + void setUp() { host = new HttpHost("foo.example.com"); now = Instant.now(); tenSecondsAgo = now.minusSeconds(10); @@ -82,7 +82,7 @@ public void setUp() { } @Test - public void testGetCacheEntryReturnsNullOnCacheMiss() throws Exception { + void testGetCacheEntryReturnsNullOnCacheMiss() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest request = new HttpGet("http://foo.example.com/bar"); @@ -97,7 +97,7 @@ public void testGetCacheEntryReturnsNullOnCacheMiss() throws Exception { } @Test - public void testGetCacheEntryFetchesFromCacheOnCacheHitIfNoVariants() throws Exception { + void testGetCacheEntryFetchesFromCacheOnCacheHitIfNoVariants() throws Exception { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(); assertFalse(entry.hasVariants()); final HttpHost host = new HttpHost("foo.example.com"); @@ -121,7 +121,7 @@ public void testGetCacheEntryFetchesFromCacheOnCacheHitIfNoVariants() throws Exc } @Test - public void testGetCacheEntryReturnsNullIfNoVariantInCache() throws Exception { + void testGetCacheEntryReturnsNullIfNoVariantInCache() throws Exception { final HttpRequest origRequest = new HttpGet("http://foo.example.com/bar"); origRequest.setHeader("Accept-Encoding","gzip"); @@ -153,7 +153,7 @@ public void testGetCacheEntryReturnsNullIfNoVariantInCache() throws Exception { } @Test - public void testGetCacheEntryReturnsVariantIfPresentInCache() throws Exception { + void testGetCacheEntryReturnsVariantIfPresentInCache() throws Exception { final HttpRequest origRequest = new HttpGet("http://foo.example.com/bar"); origRequest.setHeader("Accept-Encoding","gzip"); @@ -186,7 +186,7 @@ public void testGetCacheEntryReturnsVariantIfPresentInCache() throws Exception { } @Test - public void testGetCacheEntryReturnsVariantWithMostRecentDateHeader() throws Exception { + void testGetCacheEntryReturnsVariantWithMostRecentDateHeader() throws Exception { final HttpRequest origRequest = new HttpGet("http://foo.example.com/bar"); origRequest.setHeader("Accept-Encoding", "gzip"); @@ -237,7 +237,7 @@ public void testGetCacheEntryReturnsVariantWithMostRecentDateHeader() throws Exc } @Test - public void testGetVariantsRootNoVariants() throws Exception { + void testGetVariantsRootNoVariants() throws Exception { final HttpCacheEntry root = HttpTestUtils.makeCacheEntry(); final CountDownLatch latch1 = new CountDownLatch(1); @@ -252,7 +252,7 @@ public void testGetVariantsRootNoVariants() throws Exception { } @Test - public void testGetVariantsRootNonExistentVariants() throws Exception { + void testGetVariantsRootNonExistentVariants() throws Exception { final Set varinats = new HashSet<>(); varinats.add("variant1"); varinats.add("variant2"); @@ -270,7 +270,7 @@ public void testGetVariantsRootNonExistentVariants() throws Exception { } @Test - public void testGetVariantCacheEntriesReturnsAllVariants() throws Exception { + void testGetVariantCacheEntriesReturnsAllVariants() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -332,7 +332,7 @@ public void testGetVariantCacheEntriesReturnsAllVariants() throws Exception { } @Test - public void testUpdateCacheEntry() throws Exception { + void testUpdateCacheEntry() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -386,7 +386,7 @@ public void testUpdateCacheEntry() throws Exception { } @Test - public void testUpdateVariantCacheEntry() throws Exception { + void testUpdateVariantCacheEntry() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -443,7 +443,7 @@ public void testUpdateVariantCacheEntry() throws Exception { } @Test - public void testUpdateCacheEntryTurnsVariant() throws Exception { + void testUpdateCacheEntryTurnsVariant() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -498,7 +498,7 @@ public void testUpdateCacheEntryTurnsVariant() throws Exception { } @Test - public void testStoreFromNegotiatedVariant() throws Exception { + void testStoreFromNegotiatedVariant() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -552,7 +552,7 @@ public void testStoreFromNegotiatedVariant() throws Exception { } @Test - public void testInvalidatesUnsafeRequests() throws Exception { + void testInvalidatesUnsafeRequests() throws Exception { final HttpRequest request = new BasicHttpRequest("POST", "/path"); final HttpResponse response = HttpTestUtils.make200Response(); @@ -571,7 +571,7 @@ public void testInvalidatesUnsafeRequests() throws Exception { } @Test - public void testDoesNotInvalidateSafeRequests() throws Exception { + void testDoesNotInvalidateSafeRequests() throws Exception { final HttpRequest request1 = new BasicHttpRequest("GET", "/"); final HttpResponse response1 = HttpTestUtils.make200Response(); final CountDownLatch latch1 = new CountDownLatch(1); @@ -594,7 +594,7 @@ public void testDoesNotInvalidateSafeRequests() throws Exception { } @Test - public void testInvalidatesUnsafeRequestsWithVariants() throws Exception { + void testInvalidatesUnsafeRequestsWithVariants() throws Exception { final HttpRequest request = new BasicHttpRequest("POST", "/path"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final Set variants = new HashSet<>(); @@ -625,7 +625,7 @@ public void testInvalidatesUnsafeRequestsWithVariants() throws Exception { } @Test - public void testInvalidateUriSpecifiedByContentLocationAndFresher() throws Exception { + void testInvalidateUriSpecifiedByContentLocationAndFresher() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final URI contentUri = new URIBuilder() @@ -657,7 +657,7 @@ public void testInvalidateUriSpecifiedByContentLocationAndFresher() throws Excep } @Test - public void testInvalidateUriSpecifiedByLocationAndFresher() throws Exception { + void testInvalidateUriSpecifiedByLocationAndFresher() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final URI contentUri = new URIBuilder() @@ -689,7 +689,7 @@ public void testInvalidateUriSpecifiedByLocationAndFresher() throws Exception { } @Test - public void testDoesNotInvalidateForUnsuccessfulResponse() throws Exception { + void testDoesNotInvalidateForUnsuccessfulResponse() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -709,7 +709,7 @@ public void testDoesNotInvalidateForUnsuccessfulResponse() throws Exception { } @Test - public void testInvalidateUriSpecifiedByContentLocationNonCanonical() throws Exception { + void testInvalidateUriSpecifiedByContentLocationNonCanonical() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final URI contentUri = new URIBuilder() @@ -744,7 +744,7 @@ public void testInvalidateUriSpecifiedByContentLocationNonCanonical() throws Exc } @Test - public void testInvalidateUriSpecifiedByContentLocationRelative() throws Exception { + void testInvalidateUriSpecifiedByContentLocationRelative() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final URI contentUri = new URIBuilder() @@ -779,7 +779,7 @@ public void testInvalidateUriSpecifiedByContentLocationRelative() throws Excepti } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationOtherOrigin() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationOtherOrigin() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/"); final URI contentUri = new URIBuilder() .setHost("bar.example.com") @@ -804,7 +804,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationOtherOrigin() thro } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationIfEtagsMatch() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationIfEtagsMatch() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -831,7 +831,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationIfEtagsMatch() thr } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationIfOlder() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationIfOlder() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -858,7 +858,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationIfOlder() throws E } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationIfResponseHasNoEtag() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationIfResponseHasNoEtag() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -885,7 +885,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationIfResponseHasNoEta } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationIfEntryHasNoEtag() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationIfEntryHasNoEtag() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -911,7 +911,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationIfEntryHasNoEtag() } @Test - public void testInvalidatesUriSpecifiedByContentLocationIfResponseHasNoDate() throws Exception { + void testInvalidatesUriSpecifiedByContentLocationIfResponseHasNoDate() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -938,7 +938,7 @@ public void testInvalidatesUriSpecifiedByContentLocationIfResponseHasNoDate() th } @Test - public void testInvalidatesUriSpecifiedByContentLocationIfEntryHasNoDate() throws Exception { + void testInvalidatesUriSpecifiedByContentLocationIfEntryHasNoDate() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -964,7 +964,7 @@ public void testInvalidatesUriSpecifiedByContentLocationIfEntryHasNoDate() throw } @Test - public void testInvalidatesUriSpecifiedByContentLocationIfResponseHasMalformedDate() throws Exception { + void testInvalidatesUriSpecifiedByContentLocationIfResponseHasMalformedDate() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -991,7 +991,7 @@ public void testInvalidatesUriSpecifiedByContentLocationIfResponseHasMalformedDa } @Test - public void testInvalidatesUriSpecifiedByContentLocationIfEntryHasMalformedDate() throws Exception { + void testInvalidatesUriSpecifiedByContentLocationIfEntryHasMalformedDate() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpCache.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpCache.java index 359188273..1fadffadd 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpCache.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpCache.java @@ -63,7 +63,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public class TestBasicHttpCache { +class TestBasicHttpCache { private HttpHost host; private Instant now; @@ -72,7 +72,7 @@ public class TestBasicHttpCache { private BasicHttpCache impl; @BeforeEach - public void setUp() throws Exception { + void setUp() { host = new HttpHost("foo.example.com"); now = Instant.now(); tenSecondsAgo = now.minusSeconds(10); @@ -81,7 +81,7 @@ public void setUp() throws Exception { } @Test - public void testGetCacheEntryReturnsNullOnCacheMiss() throws Exception { + void testGetCacheEntryReturnsNullOnCacheMiss() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest request = new HttpGet("http://foo.example.com/bar"); final CacheMatch result = impl.match(host, request); @@ -89,7 +89,7 @@ public void testGetCacheEntryReturnsNullOnCacheMiss() throws Exception { } @Test - public void testGetCacheEntryFetchesFromCacheOnCacheHitIfNoVariants() throws Exception { + void testGetCacheEntryFetchesFromCacheOnCacheHitIfNoVariants() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(); assertFalse(entry.hasVariants()); final HttpHost host = new HttpHost("foo.example.com"); @@ -106,7 +106,7 @@ public void testGetCacheEntryFetchesFromCacheOnCacheHitIfNoVariants() throws Exc } @Test - public void testGetCacheEntryReturnsNullIfNoVariantInCache() throws Exception { + void testGetCacheEntryReturnsNullIfNoVariantInCache() { final HttpRequest origRequest = new HttpGet("http://foo.example.com/bar"); origRequest.setHeader("Accept-Encoding","gzip"); @@ -127,7 +127,7 @@ public void testGetCacheEntryReturnsNullIfNoVariantInCache() throws Exception { } @Test - public void testGetCacheEntryReturnsVariantIfPresentInCache() throws Exception { + void testGetCacheEntryReturnsVariantIfPresentInCache() { final HttpRequest origRequest = new HttpGet("http://foo.example.com/bar"); origRequest.setHeader("Accept-Encoding","gzip"); @@ -149,7 +149,7 @@ public void testGetCacheEntryReturnsVariantIfPresentInCache() throws Exception { } @Test - public void testGetCacheEntryReturnsVariantWithMostRecentDateHeader() throws Exception { + void testGetCacheEntryReturnsVariantWithMostRecentDateHeader() { final HttpRequest origRequest = new HttpGet("http://foo.example.com/bar"); origRequest.setHeader("Accept-Encoding", "gzip"); @@ -189,7 +189,7 @@ public void testGetCacheEntryReturnsVariantWithMostRecentDateHeader() throws Exc } @Test - public void testGetVariantsRootNoVariants() throws Exception { + void testGetVariantsRootNoVariants() { final HttpCacheEntry root = HttpTestUtils.makeCacheEntry(); final List variants = impl.getVariants(new CacheHit("root-key", root)); @@ -198,7 +198,7 @@ public void testGetVariantsRootNoVariants() throws Exception { } @Test - public void testGetVariantsRootNonExistentVariants() throws Exception { + void testGetVariantsRootNonExistentVariants() { final Set varinats = new HashSet<>(); varinats.add("variant1"); varinats.add("variant2"); @@ -210,7 +210,7 @@ public void testGetVariantsRootNonExistentVariants() throws Exception { } @Test - public void testGetVariantCacheEntriesReturnsAllVariants() throws Exception { + void testGetVariantCacheEntriesReturnsAllVariants() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -255,7 +255,7 @@ public void testGetVariantCacheEntriesReturnsAllVariants() throws Exception { } @Test - public void testUpdateCacheEntry() throws Exception { + void testUpdateCacheEntry() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -295,7 +295,7 @@ public void testUpdateCacheEntry() throws Exception { } @Test - public void testUpdateVariantCacheEntry() throws Exception { + void testUpdateVariantCacheEntry() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -338,7 +338,7 @@ public void testUpdateVariantCacheEntry() throws Exception { } @Test - public void testUpdateCacheEntryTurnsVariant() throws Exception { + void testUpdateCacheEntryTurnsVariant() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -379,7 +379,7 @@ public void testUpdateCacheEntryTurnsVariant() throws Exception { } @Test - public void testStoreFromNegotiatedVariant() throws Exception { + void testStoreFromNegotiatedVariant() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final URI uri = new URI("http://foo.example.com/bar"); final HttpRequest req1 = new HttpGet(uri); @@ -420,7 +420,7 @@ public void testStoreFromNegotiatedVariant() throws Exception { } @Test - public void testInvalidatesUnsafeRequests() throws Exception { + void testInvalidatesUnsafeRequests() throws Exception { final HttpRequest request = new BasicHttpRequest("POST","/path"); final String key = CacheKeyGenerator.INSTANCE.generateKey(host, request); @@ -437,7 +437,7 @@ public void testInvalidatesUnsafeRequests() throws Exception { } @Test - public void testDoesNotInvalidateSafeRequests() throws Exception { + void testDoesNotInvalidateSafeRequests() { final HttpRequest request1 = new BasicHttpRequest("GET","/"); final HttpResponse response1 = HttpTestUtils.make200Response(); @@ -453,7 +453,7 @@ public void testDoesNotInvalidateSafeRequests() throws Exception { } @Test - public void testInvalidatesUnsafeRequestsWithVariants() throws Exception { + void testInvalidatesUnsafeRequestsWithVariants() throws Exception { final HttpRequest request = new BasicHttpRequest("POST","/path"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final Set variants = new HashSet<>(); @@ -481,7 +481,7 @@ public void testInvalidatesUnsafeRequestsWithVariants() throws Exception { } @Test - public void testInvalidateUriSpecifiedByContentLocationAndFresher() throws Exception { + void testInvalidateUriSpecifiedByContentLocationAndFresher() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final URI contentUri = new URIBuilder() @@ -510,7 +510,7 @@ public void testInvalidateUriSpecifiedByContentLocationAndFresher() throws Excep } @Test - public void testInvalidateUriSpecifiedByLocationAndFresher() throws Exception { + void testInvalidateUriSpecifiedByLocationAndFresher() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final URI contentUri = new URIBuilder() @@ -539,7 +539,7 @@ public void testInvalidateUriSpecifiedByLocationAndFresher() throws Exception { } @Test - public void testDoesNotInvalidateForUnsuccessfulResponse() throws Exception { + void testDoesNotInvalidateForUnsuccessfulResponse() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -556,7 +556,7 @@ public void testDoesNotInvalidateForUnsuccessfulResponse() throws Exception { } @Test - public void testInvalidateUriSpecifiedByContentLocationNonCanonical() throws Exception { + void testInvalidateUriSpecifiedByContentLocationNonCanonical() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final URI contentUri = new URIBuilder() @@ -588,7 +588,7 @@ public void testInvalidateUriSpecifiedByContentLocationNonCanonical() throws Exc } @Test - public void testInvalidateUriSpecifiedByContentLocationRelative() throws Exception { + void testInvalidateUriSpecifiedByContentLocationRelative() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final String rootKey = CacheKeyGenerator.INSTANCE.generateKey(host, request); final URI contentUri = new URIBuilder() @@ -620,7 +620,7 @@ public void testInvalidateUriSpecifiedByContentLocationRelative() throws Excepti } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationOtherOrigin() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationOtherOrigin() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/"); final URI contentUri = new URIBuilder() .setHost("bar.example.com") @@ -642,7 +642,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationOtherOrigin() thro } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationIfEtagsMatch() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationIfEtagsMatch() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -666,7 +666,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationIfEtagsMatch() thr } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationIfOlder() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationIfOlder() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -690,7 +690,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationIfOlder() throws E } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationIfResponseHasNoEtag() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationIfResponseHasNoEtag() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -714,7 +714,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationIfResponseHasNoEta } @Test - public void testDoesNotInvalidateUriSpecifiedByContentLocationIfEntryHasNoEtag() throws Exception { + void testDoesNotInvalidateUriSpecifiedByContentLocationIfEntryHasNoEtag() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -737,7 +737,7 @@ public void testDoesNotInvalidateUriSpecifiedByContentLocationIfEntryHasNoEtag() } @Test - public void testInvalidatesUriSpecifiedByContentLocationIfResponseHasNoDate() throws Exception { + void testInvalidatesUriSpecifiedByContentLocationIfResponseHasNoDate() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -761,7 +761,7 @@ public void testInvalidatesUriSpecifiedByContentLocationIfResponseHasNoDate() th } @Test - public void testInvalidatesUriSpecifiedByContentLocationIfEntryHasNoDate() throws Exception { + void testInvalidatesUriSpecifiedByContentLocationIfEntryHasNoDate() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -784,7 +784,7 @@ public void testInvalidatesUriSpecifiedByContentLocationIfEntryHasNoDate() throw } @Test - public void testInvalidatesUriSpecifiedByContentLocationIfResponseHasMalformedDate() throws Exception { + void testInvalidatesUriSpecifiedByContentLocationIfResponseHasMalformedDate() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) @@ -808,7 +808,7 @@ public void testInvalidatesUriSpecifiedByContentLocationIfResponseHasMalformedDa } @Test - public void testInvalidatesUriSpecifiedByContentLocationIfEntryHasMalformedDate() throws Exception { + void testInvalidatesUriSpecifiedByContentLocationIfEntryHasMalformedDate() throws Exception { final HttpRequest request = new BasicHttpRequest("PUT", "/foo"); final URI contentUri = new URIBuilder() .setHttpHost(host) diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestByteArrayCacheEntrySerializer.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestByteArrayCacheEntrySerializer.java index faba93f3b..57d2d64ad 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestByteArrayCacheEntrySerializer.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestByteArrayCacheEntrySerializer.java @@ -52,192 +52,192 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("deprecation") -public class TestByteArrayCacheEntrySerializer { +class TestByteArrayCacheEntrySerializer { private ByteArrayCacheEntrySerializer impl; @BeforeEach - public void setUp() { + void setUp() { impl = new ByteArrayCacheEntrySerializer(); } @Test - public void canSerializeEntriesWithVariantMapsDeprecatedConstructor() throws Exception { + void canSerializeEntriesWithVariantMapsDeprecatedConstructor() throws Exception { readWriteVerify(makeCacheEntryDeprecatedConstructorWithVariantMap("somekey")); } @Test - public void canSerializeEntriesWithVariantMapsAndInstant() throws Exception { + void canSerializeEntriesWithVariantMapsAndInstant() throws Exception { readWriteVerify(makeCacheEntryWithVariantMap("somekey")); } @Test - public void isAllowedClassNameStringTrue() { + void isAllowedClassNameStringTrue() { assertIsAllowedClassNameTrue(String.class.getName()); } @Test - public void isAllowedClassNameStringArrayTrue() { + void isAllowedClassNameStringArrayTrue() { assertIsAllowedClassNameTrue("[L" + String.class.getName()); } @Test - public void isAllowedClassNameStringArrayArrayTrue() { + void isAllowedClassNameStringArrayArrayTrue() { assertIsAllowedClassNameTrue("[[L" + String.class.getName()); } @Test - public void isAllowedClassNameDataTrue() { + void isAllowedClassNameDataTrue() { assertIsAllowedClassNameTrue(Date.class.getName()); } @Test - public void isAllowedClassNameInstantTrue() { + void isAllowedClassNameInstantTrue() { assertIsAllowedClassNameTrue(Instant.class.getName()); } @Test - public void isAllowedClassNameStatusLineTrue() { + void isAllowedClassNameStatusLineTrue() { assertIsAllowedClassNameTrue(StatusLine.class.getName()); } @Test - public void isAllowedClassNameResourceTrue() { + void isAllowedClassNameResourceTrue() { assertIsAllowedClassNameTrue(Resource.class.getName()); } @Test - public void isAllowedClassNameByteArrayTrue() { + void isAllowedClassNameByteArrayTrue() { assertIsAllowedClassNameTrue("[B"); } @Test - public void isAllowedClassNameByteArrayArrayTrue() { + void isAllowedClassNameByteArrayArrayTrue() { assertIsAllowedClassNameTrue("[[B"); } @Test - public void isAllowedClassNameCharArrayTrue() { + void isAllowedClassNameCharArrayTrue() { assertIsAllowedClassNameTrue("[C"); } @Test - public void isAllowedClassNameCharArrayArrayTrue() { + void isAllowedClassNameCharArrayArrayTrue() { assertIsAllowedClassNameTrue("[[C"); } @Test - public void isAllowedClassNameDoubleArrayTrue() { + void isAllowedClassNameDoubleArrayTrue() { assertIsAllowedClassNameTrue("[D"); } @Test - public void isAllowedClassNameDoubleArrayArrayTrue() { + void isAllowedClassNameDoubleArrayArrayTrue() { assertIsAllowedClassNameTrue("[[D"); } @Test - public void isAllowedClassNameFloatArrayTrue() { + void isAllowedClassNameFloatArrayTrue() { assertIsAllowedClassNameTrue("[F"); } @Test - public void isAllowedClassNameFloatArrayArrayTrue() { + void isAllowedClassNameFloatArrayArrayTrue() { assertIsAllowedClassNameTrue("[[F"); } @Test - public void isAllowedClassNameIntArrayTrue() { + void isAllowedClassNameIntArrayTrue() { assertIsAllowedClassNameTrue("[I"); } @Test - public void isAllowedClassNameIntArrayArrayTrue() { + void isAllowedClassNameIntArrayArrayTrue() { assertIsAllowedClassNameTrue("[[I"); } @Test - public void isAllowedClassNameLongArrayTrue() { + void isAllowedClassNameLongArrayTrue() { assertIsAllowedClassNameTrue("[J"); } @Test - public void isAllowedClassNameLongArrayArrayTrue() { + void isAllowedClassNameLongArrayArrayTrue() { assertIsAllowedClassNameTrue("[[J"); } @Test - public void isAllowedClassNameShortArrayTrue() { + void isAllowedClassNameShortArrayTrue() { assertIsAllowedClassNameTrue("[S"); } @Test - public void isAllowedClassNameShortArrayArrayTrue() { + void isAllowedClassNameShortArrayArrayTrue() { assertIsAllowedClassNameTrue("[[S"); } @Test - public void isAllowedClassNameCollectionsInvokerTransformerFalse() { + void isAllowedClassNameCollectionsInvokerTransformerFalse() { assertIsAllowedClassNameFalse("org.apache.commons.collections.functors.InvokerTransformer"); } @Test - public void isAllowedClassNameCollections4InvokerTransformerFalse() { + void isAllowedClassNameCollections4InvokerTransformerFalse() { assertIsAllowedClassNameFalse("org.apache.commons.collections4.functors.InvokerTransformer"); } @Test - public void isAllowedClassNameCollectionsInstantiateTransformerFalse() { + void isAllowedClassNameCollectionsInstantiateTransformerFalse() { assertIsAllowedClassNameFalse("org.apache.commons.collections.functors.InstantiateTransformer"); } @Test - public void isAllowedClassNameCollections4InstantiateTransformerFalse() { + void isAllowedClassNameCollections4InstantiateTransformerFalse() { assertIsAllowedClassNameFalse("org.apache.commons.collections4.functors.InstantiateTransformer"); } @Test - public void isAllowedClassNameGroovyConvertedClosureFalse() { + void isAllowedClassNameGroovyConvertedClosureFalse() { assertIsAllowedClassNameFalse("org.codehaus.groovy.runtime.ConvertedClosure"); } @Test - public void isAllowedClassNameGroovyMethodClosureFalse() { + void isAllowedClassNameGroovyMethodClosureFalse() { assertIsAllowedClassNameFalse("org.codehaus.groovy.runtime.MethodClosure"); } @Test - public void isAllowedClassNameSpringObjectFactoryFalse() { + void isAllowedClassNameSpringObjectFactoryFalse() { assertIsAllowedClassNameFalse("org.springframework.beans.factory.ObjectFactory"); } @Test - public void isAllowedClassNameCalanTemplatesImplFalse() { + void isAllowedClassNameCalanTemplatesImplFalse() { assertIsAllowedClassNameFalse("com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl"); } @Test - public void isAllowedClassNameCalanTemplatesImplArrayFalse() { + void isAllowedClassNameCalanTemplatesImplArrayFalse() { assertIsAllowedClassNameFalse("[Lcom.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl"); } @Test - public void isAllowedClassNameJavaRmiRegistryFalse() { + void isAllowedClassNameJavaRmiRegistryFalse() { assertIsAllowedClassNameFalse("java.rmi.registry.Registry"); } @Test - public void isAllowedClassNameJavaRmiServerRemoteObjectInvocationHandlerFalse() { + void isAllowedClassNameJavaRmiServerRemoteObjectInvocationHandlerFalse() { assertIsAllowedClassNameFalse("java.rmi.server.RemoteObjectInvocationHandler"); } @Test - public void isAllowedClassNameJavaxXmlTransformTemplatesFalse() { + void isAllowedClassNameJavaxXmlTransformTemplatesFalse() { assertIsAllowedClassNameFalse("javax.xml.transform.Templates"); } @Test - public void isAllowedClassNameJavaxManagementMBeanServerInvocationHandlerFalse() { + void isAllowedClassNameJavaxManagementMBeanServerInvocationHandlerFalse() { assertIsAllowedClassNameFalse("javax.management.MBeanServerInvocationHandler"); } diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheKeyGenerator.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheKeyGenerator.java index 8a27c4937..8fcb19553 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheKeyGenerator.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheKeyGenerator.java @@ -49,17 +49,17 @@ import org.junit.jupiter.api.Test; @SuppressWarnings({"boxing","static-access"}) // this is test code -public class TestCacheKeyGenerator { +class TestCacheKeyGenerator { private CacheKeyGenerator extractor; @BeforeEach - public void setUp() throws Exception { + void setUp() { extractor = CacheKeyGenerator.INSTANCE; } @Test - public void testGetRequestUri() { + void testGetRequestUri() { Assertions.assertEquals("http://foo.example.com/stuff?huh", CacheKeyGenerator.getRequestUri( new HttpHost("bar.example.com"), @@ -92,7 +92,7 @@ public void testGetRequestUri() { } @Test - public void testNormalizeRequestUri() throws URISyntaxException { + void testNormalizeRequestUri() throws URISyntaxException { Assertions.assertEquals(URI.create("http://bar.example.com:80/stuff?huh"), CacheKeyGenerator.normalize(URI.create("//bar.example.com/stuff?huh"))); @@ -107,14 +107,14 @@ public void testNormalizeRequestUri() throws URISyntaxException { } @Test - public void testExtractsUriFromAbsoluteUriInRequest() { + void testExtractsUriFromAbsoluteUriInRequest() { final HttpHost host = new HttpHost("bar.example.com"); final HttpRequest req = new HttpGet("http://foo.example.com/"); Assertions.assertEquals("http://foo.example.com:80/", extractor.generateKey(host, req)); } @Test - public void testGetURIWithDefaultPortAndScheme() { + void testGetURIWithDefaultPortAndScheme() { Assertions.assertEquals("http://www.comcast.net:80/", extractor.generateKey( new HttpHost("www.comcast.net"), new BasicHttpRequest("GET", "/"))); @@ -125,7 +125,7 @@ public void testGetURIWithDefaultPortAndScheme() { } @Test - public void testGetURIWithDifferentScheme() { + void testGetURIWithDifferentScheme() { Assertions.assertEquals("https://www.comcast.net:443/", extractor.generateKey( new HttpHost("https", "www.comcast.net", -1), new BasicHttpRequest("GET", "/"))); @@ -136,7 +136,7 @@ public void testGetURIWithDifferentScheme() { } @Test - public void testGetURIWithDifferentPort() { + void testGetURIWithDifferentPort() { Assertions.assertEquals("http://www.comcast.net:8080/", extractor.generateKey( new HttpHost("www.comcast.net", 8080), new BasicHttpRequest("GET", "/"))); @@ -147,7 +147,7 @@ public void testGetURIWithDifferentPort() { } @Test - public void testGetURIWithDifferentPortAndScheme() { + void testGetURIWithDifferentPortAndScheme() { Assertions.assertEquals("https://www.comcast.net:8080/", extractor.generateKey( new HttpHost("https", "www.comcast.net", 8080), new BasicHttpRequest("GET", "/"))); @@ -158,7 +158,7 @@ public void testGetURIWithDifferentPortAndScheme() { } @Test - public void testEmptyPortEquivalentToDefaultPortForHttp() { + void testEmptyPortEquivalentToDefaultPortForHttp() { final HttpHost host1 = new HttpHost("foo.example.com:"); final HttpHost host2 = new HttpHost("foo.example.com:80"); final HttpRequest req = new BasicHttpRequest("GET", "/"); @@ -166,7 +166,7 @@ public void testEmptyPortEquivalentToDefaultPortForHttp() { } @Test - public void testEmptyPortEquivalentToDefaultPortForHttps() { + void testEmptyPortEquivalentToDefaultPortForHttps() { final HttpHost host1 = new HttpHost("https", "foo.example.com", -1); final HttpHost host2 = new HttpHost("https", "foo.example.com", 443); final HttpRequest req = new BasicHttpRequest("GET", "/"); @@ -176,7 +176,7 @@ public void testEmptyPortEquivalentToDefaultPortForHttps() { } @Test - public void testEmptyPortEquivalentToDefaultPortForHttpsAbsoluteURI() { + void testEmptyPortEquivalentToDefaultPortForHttpsAbsoluteURI() { final HttpHost host = new HttpHost("https", "foo.example.com", -1); final HttpGet get1 = new HttpGet("https://bar.example.com:/"); final HttpGet get2 = new HttpGet("https://bar.example.com:443/"); @@ -186,7 +186,7 @@ public void testEmptyPortEquivalentToDefaultPortForHttpsAbsoluteURI() { } @Test - public void testNotProvidedPortEquivalentToDefaultPortForHttpsAbsoluteURI() { + void testNotProvidedPortEquivalentToDefaultPortForHttpsAbsoluteURI() { final HttpHost host = new HttpHost("https", "foo.example.com", -1); final HttpGet get1 = new HttpGet("https://bar.example.com/"); final HttpGet get2 = new HttpGet("https://bar.example.com:443/"); @@ -196,7 +196,7 @@ public void testNotProvidedPortEquivalentToDefaultPortForHttpsAbsoluteURI() { } @Test - public void testNotProvidedPortEquivalentToDefaultPortForHttp() { + void testNotProvidedPortEquivalentToDefaultPortForHttp() { final HttpHost host1 = new HttpHost("foo.example.com"); final HttpHost host2 = new HttpHost("foo.example.com:80"); final HttpRequest req = new BasicHttpRequest("GET", "/"); @@ -204,7 +204,7 @@ public void testNotProvidedPortEquivalentToDefaultPortForHttp() { } @Test - public void testHostNameComparisonsAreCaseInsensitive() { + void testHostNameComparisonsAreCaseInsensitive() { final HttpHost host1 = new HttpHost("foo.example.com"); final HttpHost host2 = new HttpHost("FOO.EXAMPLE.COM"); final HttpRequest req = new BasicHttpRequest("GET", "/"); @@ -212,7 +212,7 @@ public void testHostNameComparisonsAreCaseInsensitive() { } @Test - public void testSchemeNameComparisonsAreCaseInsensitive() { + void testSchemeNameComparisonsAreCaseInsensitive() { final HttpHost host1 = new HttpHost("http", "foo.example.com", -1); final HttpHost host2 = new HttpHost("HTTP", "foo.example.com", -1); final HttpRequest req = new BasicHttpRequest("GET", "/"); @@ -220,7 +220,7 @@ public void testSchemeNameComparisonsAreCaseInsensitive() { } @Test - public void testEmptyAbsPathIsEquivalentToSlash() { + void testEmptyAbsPathIsEquivalentToSlash() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest req1 = new BasicHttpRequest("GET", "/"); final HttpRequest req2 = new HttpGet("http://foo.example.com"); @@ -228,7 +228,7 @@ public void testEmptyAbsPathIsEquivalentToSlash() { } @Test - public void testExtraDotSegmentsAreIgnored() { + void testExtraDotSegmentsAreIgnored() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest req1 = new BasicHttpRequest("GET", "/"); final HttpRequest req2 = new HttpGet("http://foo.example.com/./"); @@ -236,7 +236,7 @@ public void testExtraDotSegmentsAreIgnored() { } @Test - public void testExtraDotDotSegmentsAreIgnored() { + void testExtraDotDotSegmentsAreIgnored() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest req1 = new BasicHttpRequest("GET", "/"); final HttpRequest req2 = new HttpGet("http://foo.example.com/.././../"); @@ -244,7 +244,7 @@ public void testExtraDotDotSegmentsAreIgnored() { } @Test - public void testIntermidateDotDotSegementsAreEquivalent() { + void testIntermidateDotDotSegementsAreEquivalent() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest req1 = new BasicHttpRequest("GET", "/home.html"); final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/../home.html"); @@ -252,7 +252,7 @@ public void testIntermidateDotDotSegementsAreEquivalent() { } @Test - public void testIntermidateEncodedDotDotSegementsAreEquivalent() { + void testIntermidateEncodedDotDotSegementsAreEquivalent() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest req1 = new BasicHttpRequest("GET", "/home.html"); final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/../home.html"); @@ -260,7 +260,7 @@ public void testIntermidateEncodedDotDotSegementsAreEquivalent() { } @Test - public void testIntermidateDotSegementsAreEquivalent() { + void testIntermidateDotSegementsAreEquivalent() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home.html"); final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/./home.html"); @@ -268,7 +268,7 @@ public void testIntermidateDotSegementsAreEquivalent() { } @Test - public void testEquivalentPathEncodingsAreEquivalent() { + void testEquivalentPathEncodingsAreEquivalent() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home.html"); final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/home.html"); @@ -276,7 +276,7 @@ public void testEquivalentPathEncodingsAreEquivalent() { } @Test - public void testEquivalentExtraPathEncodingsAreEquivalent() { + void testEquivalentExtraPathEncodingsAreEquivalent() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home.html"); final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/home.html"); @@ -284,7 +284,7 @@ public void testEquivalentExtraPathEncodingsAreEquivalent() { } @Test - public void testEquivalentExtraPathEncodingsWithPercentAreEquivalent() { + void testEquivalentExtraPathEncodingsWithPercentAreEquivalent() { final HttpHost host = new HttpHost("foo.example.com"); final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home%20folder.html"); final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/home%20folder.html"); @@ -292,7 +292,7 @@ public void testEquivalentExtraPathEncodingsWithPercentAreEquivalent() { } @Test - public void testGetURIWithQueryParameters() { + void testGetURIWithQueryParameters() { Assertions.assertEquals("http://www.comcast.net:80/?foo=bar", extractor.generateKey( new HttpHost("http", "www.comcast.net", -1), new BasicHttpRequest("GET", "/?foo=bar"))); Assertions.assertEquals("http://www.fancast.com:80/full_episodes?foo=bar", extractor.generateKey( @@ -305,7 +305,7 @@ private static Iterator
headers(final Header... headers) { } @Test - public void testNormalizeHeaderElements() { + void testNormalizeHeaderElements() { final List tokens = new ArrayList<>(); CacheKeyGenerator.normalizeElements(headers( new BasicHeader("Accept-Encoding", "gzip,zip,deflate") @@ -336,7 +336,7 @@ public void testNormalizeHeaderElements() { } @Test - public void testGetVariantKey() { + void testGetVariantKey() { final HttpRequest request = BasicRequestBuilder.get("/blah") .addHeader(HttpHeaders.USER_AGENT, "some-agent") .addHeader(HttpHeaders.ACCEPT_ENCODING, "gzip,zip") @@ -352,7 +352,7 @@ public void testGetVariantKey() { } @Test - public void testGetVariantKeyInputNormalization() { + void testGetVariantKeyInputNormalization() { final HttpRequest request = BasicRequestBuilder.get("/blah") .addHeader(HttpHeaders.USER_AGENT, "Some-Agent") .addHeader(HttpHeaders.ACCEPT_ENCODING, "gzip, ZIP,,") @@ -370,7 +370,7 @@ public void testGetVariantKeyInputNormalization() { } @Test - public void testGetVariantKeyInputNormalizationReservedChars() { + void testGetVariantKeyInputNormalizationReservedChars() { final HttpRequest request = BasicRequestBuilder.get("/blah") .addHeader(HttpHeaders.USER_AGENT, "*===some-agent===*") .build(); @@ -380,7 +380,7 @@ public void testGetVariantKeyInputNormalizationReservedChars() { } @Test - public void testGetVariantKeyInputNoMatchingHeaders() { + void testGetVariantKeyInputNoMatchingHeaders() { final HttpRequest request = BasicRequestBuilder.get("/blah") .build(); @@ -389,7 +389,7 @@ public void testGetVariantKeyInputNoMatchingHeaders() { } @Test - public void testGetVariantKeyFromCachedResponse() { + void testGetVariantKeyFromCachedResponse() { final HttpRequest request = BasicRequestBuilder.get("/blah") .addHeader("User-Agent", "agent1") .addHeader("Accept-Encoding", "text/plain") diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java index 9d6e974cb..0370e3a56 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheRevalidatorBase.java @@ -42,7 +42,7 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -public class TestCacheRevalidatorBase { +class TestCacheRevalidatorBase { @Mock private SchedulingStrategy mockSchedulingStrategy; @@ -55,13 +55,13 @@ public class TestCacheRevalidatorBase { @BeforeEach - public void setUp() { + void setUp() { MockitoAnnotations.openMocks(this); impl = new CacheRevalidatorBase(mockScheduledExecutor, mockSchedulingStrategy); } @Test - public void testRevalidateCacheEntrySchedulesExecutionAndPopulatesIdentifier() { + void testRevalidateCacheEntrySchedulesExecutionAndPopulatesIdentifier() { when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(1)); final String cacheKey = "blah"; @@ -74,7 +74,7 @@ public void testRevalidateCacheEntrySchedulesExecutionAndPopulatesIdentifier() { } @Test - public void testMarkCompleteRemovesIdentifier() { + void testMarkCompleteRemovesIdentifier() { when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(3)); final String cacheKey = "blah"; @@ -92,7 +92,7 @@ public void testMarkCompleteRemovesIdentifier() { } @Test - public void testRevalidateCacheEntryDoesNotPopulateIdentifierOnRejectedExecutionException() { + void testRevalidateCacheEntryDoesNotPopulateIdentifierOnRejectedExecutionException() { when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(2)); doThrow(new RejectedExecutionException()).when(mockScheduledExecutor).schedule(ArgumentMatchers.any(), ArgumentMatchers.any()); @@ -104,7 +104,7 @@ public void testRevalidateCacheEntryDoesNotPopulateIdentifierOnRejectedExecution } @Test - public void testRevalidateCacheEntryProperlyCollapsesRequest() { + void testRevalidateCacheEntryProperlyCollapsesRequest() { when(mockSchedulingStrategy.schedule(ArgumentMatchers.anyInt())).thenReturn(TimeValue.ofSeconds(2)); final String cacheKey = "blah"; @@ -119,7 +119,7 @@ public void testRevalidateCacheEntryProperlyCollapsesRequest() { } @Test - public void testShutdown() throws Exception { + void testShutdown() throws Exception { impl.close(); impl.awaitTermination(Timeout.ofMinutes(2)); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheSupport.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheSupport.java index 3be79ad2f..8572bba77 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheSupport.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheSupport.java @@ -33,10 +33,10 @@ /** * Unit tests for {@link CacheSupport}. */ -public class TestCacheSupport { +class TestCacheSupport { @Test - public void testParseDeltaSeconds() throws Exception { + void testParseDeltaSeconds() { Assertions.assertEquals(1234L, CacheSupport.deltaSeconds("1234")); Assertions.assertEquals(0L, CacheSupport.deltaSeconds("0")); Assertions.assertEquals(-1L, CacheSupport.deltaSeconds("-1")); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheValidityPolicy.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheValidityPolicy.java index 93a27f00c..fe42b5edb 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheValidityPolicy.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheValidityPolicy.java @@ -41,7 +41,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestCacheValidityPolicy { +class TestCacheValidityPolicy { private CacheValidityPolicy impl; private Instant now; @@ -51,7 +51,7 @@ public class TestCacheValidityPolicy { private Instant elevenSecondsAgo; @BeforeEach - public void setUp() { + void setUp() { impl = new CacheValidityPolicy(); now = Instant.now(); oneSecondAgo = now.minusSeconds(1); @@ -61,7 +61,7 @@ public void setUp() { } @Test - public void testApparentAgeIsMaxIntIfDateHeaderNotPresent() { + void testApparentAgeIsMaxIntIfDateHeaderNotPresent() { final Header[] headers = { new BasicHeader("Server", "MockServer/1.0") }; @@ -70,7 +70,7 @@ public void testApparentAgeIsMaxIntIfDateHeaderNotPresent() { } @Test - public void testApparentAgeIsResponseReceivedTimeLessDateHeader() { + void testApparentAgeIsResponseReceivedTimeLessDateHeader() { final Header[] headers = new Header[] { new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo)) }; final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, sixSecondsAgo, headers); @@ -78,14 +78,14 @@ public void testApparentAgeIsResponseReceivedTimeLessDateHeader() { } @Test - public void testNegativeApparentAgeIsBroughtUpToZero() { + void testNegativeApparentAgeIsBroughtUpToZero() { final Header[] headers = new Header[] { new BasicHeader("Date", DateUtils.formatStandardDate(sixSecondsAgo)) }; final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, tenSecondsAgo, headers); assertEquals(TimeValue.ofSeconds(0), impl.getApparentAge(entry)); } @Test - public void testCorrectedReceivedAgeIsAgeHeaderIfLarger() { + void testCorrectedReceivedAgeIsAgeHeaderIfLarger() { final Header[] headers = new Header[] { new BasicHeader("Age", "10"), }; final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers); impl = new CacheValidityPolicy() { @@ -98,20 +98,20 @@ protected TimeValue getApparentAge(final HttpCacheEntry ent) { } @Test - public void testGetCorrectedAgeValue() { + void testGetCorrectedAgeValue() { final Header[] headers = new Header[] { new BasicHeader("Age", "6"), }; final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers); assertEquals(TimeValue.ofSeconds(6), impl.getCorrectedAgeValue(entry)); } @Test - public void testResponseDelayIsDifferenceBetweenResponseAndRequestTimes() { + void testResponseDelayIsDifferenceBetweenResponseAndRequestTimes() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(tenSecondsAgo, sixSecondsAgo); assertEquals(TimeValue.ofSeconds(4), impl.getResponseDelay(entry)); } @Test - public void testCorrectedInitialAgeIsCorrectedReceivedAgePlusResponseDelay() { + void testCorrectedInitialAgeIsCorrectedReceivedAgePlusResponseDelay() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(); impl = new CacheValidityPolicy() { @Override @@ -128,13 +128,13 @@ protected TimeValue getResponseDelay(final HttpCacheEntry ent) { } @Test - public void testResidentTimeSecondsIsTimeSinceResponseTime() { + void testResidentTimeSecondsIsTimeSinceResponseTime() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, sixSecondsAgo); assertEquals(TimeValue.ofSeconds(6), impl.getResidentTime(entry, now)); } @Test - public void testCurrentAgeIsCorrectedInitialAgePlusResidentTime() { + void testCurrentAgeIsCorrectedInitialAgePlusResidentTime() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(); impl = new CacheValidityPolicy() { @Override @@ -150,7 +150,7 @@ protected TimeValue getResidentTime(final HttpCacheEntry ent, final Instant d) { } @Test - public void testFreshnessLifetimeIsSMaxAgeIfPresent() { + void testFreshnessLifetimeIsSMaxAgeIfPresent() { final ResponseCacheControl cacheControl = ResponseCacheControl.builder() .setSharedMaxAge(10) .setMaxAge(5) @@ -160,7 +160,7 @@ public void testFreshnessLifetimeIsSMaxAgeIfPresent() { } @Test - public void testSMaxAgeIsIgnoredWhenNotShared() { + void testSMaxAgeIsIgnoredWhenNotShared() { final CacheConfig cacheConfig = CacheConfig.custom() .setSharedCache(false) .build(); @@ -174,7 +174,7 @@ public void testSMaxAgeIsIgnoredWhenNotShared() { } @Test - public void testFreshnessLifetimeIsMaxAgeIfPresent() { + void testFreshnessLifetimeIsMaxAgeIfPresent() { final ResponseCacheControl cacheControl = ResponseCacheControl.builder() .setMaxAge(10) .build(); @@ -183,7 +183,7 @@ public void testFreshnessLifetimeIsMaxAgeIfPresent() { } @Test - public void testFreshnessLifetimeUsesSharedMaxAgeInSharedCache() { + void testFreshnessLifetimeUsesSharedMaxAgeInSharedCache() { // assuming impl represents a shared cache final ResponseCacheControl cacheControl = ResponseCacheControl.builder() .setMaxAge(10) @@ -194,7 +194,7 @@ public void testFreshnessLifetimeUsesSharedMaxAgeInSharedCache() { } @Test - public void testFreshnessLifetimeUsesMaxAgeWhenSharedMaxAgeNotPresent() { + void testFreshnessLifetimeUsesMaxAgeWhenSharedMaxAgeNotPresent() { // assuming impl represents a shared cache final ResponseCacheControl cacheControl = ResponseCacheControl.builder() .setMaxAge(10) @@ -204,7 +204,7 @@ public void testFreshnessLifetimeUsesMaxAgeWhenSharedMaxAgeNotPresent() { } @Test - public void testFreshnessLifetimeIsMaxAgeEvenIfExpiresIsPresent() { + void testFreshnessLifetimeIsMaxAgeEvenIfExpiresIsPresent() { final ResponseCacheControl cacheControl = ResponseCacheControl.builder() .setMaxAge(10) .build(); @@ -215,7 +215,7 @@ public void testFreshnessLifetimeIsMaxAgeEvenIfExpiresIsPresent() { } @Test - public void testFreshnessLifetimeIsSMaxAgeEvenIfExpiresIsPresent() { + void testFreshnessLifetimeIsSMaxAgeEvenIfExpiresIsPresent() { final ResponseCacheControl cacheControl = ResponseCacheControl.builder() .setSharedMaxAge(10) .build(); @@ -226,7 +226,7 @@ public void testFreshnessLifetimeIsSMaxAgeEvenIfExpiresIsPresent() { } @Test - public void testFreshnessLifetimeIsFromExpiresHeaderIfNoMaxAge() { + void testFreshnessLifetimeIsFromExpiresHeaderIfNoMaxAge() { final ResponseCacheControl cacheControl = ResponseCacheControl.builder() .build(); final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry( @@ -236,7 +236,7 @@ public void testFreshnessLifetimeIsFromExpiresHeaderIfNoMaxAge() { } @Test - public void testHeuristicFreshnessLifetime() { + void testHeuristicFreshnessLifetime() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Date", DateUtils.formatStandardDate(oneSecondAgo)), new BasicHeader("Last-Modified", DateUtils.formatStandardDate(elevenSecondsAgo))); @@ -244,14 +244,14 @@ public void testHeuristicFreshnessLifetime() { } @Test - public void testHeuristicFreshnessLifetimeDefaultsProperly() { + void testHeuristicFreshnessLifetimeDefaultsProperly() { final TimeValue defaultFreshness = TimeValue.ofSeconds(0); final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(); assertEquals(defaultFreshness, impl.getHeuristicFreshnessLifetime(entry)); } @Test - public void testHeuristicFreshnessLifetimeIsNonNegative() { + void testHeuristicFreshnessLifetimeIsNonNegative() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Date", DateUtils.formatStandardDate(elevenSecondsAgo)), new BasicHeader("Last-Modified", DateUtils.formatStandardDate(oneSecondAgo))); @@ -259,7 +259,7 @@ public void testHeuristicFreshnessLifetimeIsNonNegative() { } @Test - public void testHeuristicFreshnessLifetimeCustomProperly() { + void testHeuristicFreshnessLifetimeCustomProperly() { final CacheConfig cacheConfig = CacheConfig.custom().setHeuristicDefaultLifetime(TimeValue.ofSeconds(10)) .setHeuristicCoefficient(0.5f).build(); impl = new CacheValidityPolicy(cacheConfig); @@ -269,7 +269,7 @@ public void testHeuristicFreshnessLifetimeCustomProperly() { } @Test - public void testNegativeAgeHeaderValueReturnsZero() { + void testNegativeAgeHeaderValueReturnsZero() { final Header[] headers = new Header[] { new BasicHeader("Age", "-100") }; final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(headers); // in seconds @@ -277,7 +277,7 @@ public void testNegativeAgeHeaderValueReturnsZero() { } @Test - public void testMalformedAgeHeaderValueReturnsMaxAge() { + void testMalformedAgeHeaderValueReturnsMaxAge() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Age", "asdf")); // in seconds @@ -285,7 +285,7 @@ public void testMalformedAgeHeaderValueReturnsMaxAge() { } @Test - public void testMalformedAgeHeaderMultipleWellFormedAges() { + void testMalformedAgeHeaderMultipleWellFormedAges() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Age", "123,456,789")); // in seconds @@ -293,7 +293,7 @@ public void testMalformedAgeHeaderMultipleWellFormedAges() { } @Test - public void testMalformedAgeHeaderMultiplesMalformedAges() { + void testMalformedAgeHeaderMultiplesMalformedAges() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Age", "123 456 789")); // in seconds @@ -301,7 +301,7 @@ public void testMalformedAgeHeaderMultiplesMalformedAges() { } @Test - public void testMalformedAgeHeaderNegativeAge() { + void testMalformedAgeHeaderNegativeAge() { final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Age", "-123")); // in seconds @@ -309,7 +309,7 @@ public void testMalformedAgeHeaderNegativeAge() { } @Test - public void testMalformedAgeHeaderOverflow() { + void testMalformedAgeHeaderOverflow() { final String reallyOldAge = "1" + Long.MAX_VALUE; final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry( new BasicHeader("Age", reallyOldAge)); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheableRequestPolicy.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheableRequestPolicy.java index 3c5d88074..99b423e9a 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheableRequestPolicy.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheableRequestPolicy.java @@ -32,17 +32,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestCacheableRequestPolicy { +class TestCacheableRequestPolicy { private CacheableRequestPolicy policy; @BeforeEach - public void setUp() throws Exception { + void setUp() { policy = new CacheableRequestPolicy(); } @Test - public void testIsGetServableFromCache() { + void testIsGetServableFromCache() { final BasicHttpRequest request = new BasicHttpRequest("GET", "someUri"); final RequestCacheControl cacheControl = RequestCacheControl.builder().build(); @@ -50,7 +50,7 @@ public void testIsGetServableFromCache() { } @Test - public void testIsGetWithCacheControlServableFromCache() { + void testIsGetWithCacheControlServableFromCache() { final BasicHttpRequest request = new BasicHttpRequest("GET", "someUri"); final RequestCacheControl cacheControl = RequestCacheControl.builder() .setNoCache(true) @@ -67,7 +67,7 @@ public void testIsGetWithCacheControlServableFromCache() { } @Test - public void testIsHeadServableFromCache() { + void testIsHeadServableFromCache() { final BasicHttpRequest request = new BasicHttpRequest("HEAD", "someUri"); final RequestCacheControl cacheControl = RequestCacheControl.builder().build(); @@ -81,7 +81,7 @@ public void testIsHeadServableFromCache() { } @Test - public void testIsHeadWithCacheControlServableFromCache() { + void testIsHeadWithCacheControlServableFromCache() { final BasicHttpRequest request = new BasicHttpRequest("HEAD", "someUri"); final RequestCacheControl cacheControl = RequestCacheControl.builder() .setNoCache(true) @@ -100,7 +100,7 @@ public void testIsHeadWithCacheControlServableFromCache() { } @Test - public void testIsArbitraryMethodServableFromCache() { + void testIsArbitraryMethodServableFromCache() { final BasicHttpRequest request = new BasicHttpRequest("TRACE", "someUri"); final RequestCacheControl cacheControl = RequestCacheControl.builder() .build(); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedHttpResponseGenerator.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedHttpResponseGenerator.java index 3a9cc6ff8..59eca4b3a 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedHttpResponseGenerator.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedHttpResponseGenerator.java @@ -44,7 +44,7 @@ import org.junit.jupiter.api.Test; @SuppressWarnings({"boxing","static-access"}) // test code -public class TestCachedHttpResponseGenerator { +class TestCachedHttpResponseGenerator { private HttpCacheEntry entry; private ClassicHttpRequest request; @@ -52,7 +52,7 @@ public class TestCachedHttpResponseGenerator { private CachedHttpResponseGenerator impl; @BeforeEach - public void setUp() { + void setUp() { entry = HttpTestUtils.makeCacheEntry(); request = HttpTestUtils.makeDefaultRequest(); mockValidityPolicy = mock(CacheValidityPolicy.class); @@ -60,7 +60,7 @@ public void setUp() { } @Test - public void testResponseHasContentLength() throws Exception { + void testResponseHasContentLength() throws Exception { final byte[] buf = new byte[] { 1, 2, 3, 4, 5 }; final HttpCacheEntry entry1 = HttpTestUtils.makeCacheEntry(buf); @@ -73,14 +73,14 @@ public void testResponseHasContentLength() throws Exception { } @Test - public void testResponseStatusCodeMatchesCacheEntry() throws Exception { + void testResponseStatusCodeMatchesCacheEntry() throws Exception { final SimpleHttpResponse response = impl.generateResponse(request, entry); Assertions.assertEquals(entry.getStatus(), response.getCode()); } @Test - public void testAgeHeaderIsPopulatedWithCurrentAgeOfCacheEntryIfNonZero() throws Exception { + void testAgeHeaderIsPopulatedWithCurrentAgeOfCacheEntryIfNonZero() throws Exception { currentAge(TimeValue.ofSeconds(10L)); final SimpleHttpResponse response = impl.generateResponse(request, entry); @@ -93,7 +93,7 @@ public void testAgeHeaderIsPopulatedWithCurrentAgeOfCacheEntryIfNonZero() throws } @Test - public void testAgeHeaderIsNotPopulatedIfCurrentAgeOfCacheEntryIsZero() throws Exception { + void testAgeHeaderIsNotPopulatedIfCurrentAgeOfCacheEntryIsZero() throws Exception { currentAge(TimeValue.ofSeconds(0L)); final SimpleHttpResponse response = impl.generateResponse(request, entry); @@ -105,7 +105,7 @@ public void testAgeHeaderIsNotPopulatedIfCurrentAgeOfCacheEntryIsZero() throws E } @Test - public void testAgeHeaderIsPopulatedWithMaxAgeIfCurrentAgeTooBig() throws Exception { + void testAgeHeaderIsPopulatedWithMaxAgeIfCurrentAgeTooBig() throws Exception { currentAge(TimeValue.ofSeconds(CacheSupport.MAX_AGE.toSeconds() + 1L)); final SimpleHttpResponse response = impl.generateResponse(request, entry); @@ -124,14 +124,14 @@ private void currentAge(final TimeValue age) { } @Test - public void testResponseContainsEntityToServeGETRequestIfEntryContainsResource() throws Exception { + void testResponseContainsEntityToServeGETRequestIfEntryContainsResource() throws Exception { final SimpleHttpResponse response = impl.generateResponse(request, entry); Assertions.assertNotNull(response.getBody()); } @Test - public void testResponseDoesNotContainEntityToServeHEADRequestIfEntryContainsResource() throws Exception { + void testResponseDoesNotContainEntityToServeHEADRequestIfEntryContainsResource() throws Exception { final ClassicHttpRequest headRequest = HttpTestUtils.makeDefaultHEADRequest(); final SimpleHttpResponse response = impl.generateResponse(headRequest, entry); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java index 0219f3311..899dc5107 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java @@ -44,7 +44,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestCachedResponseSuitabilityChecker { +class TestCachedResponseSuitabilityChecker { private Instant now; private Instant elevenSecondsAgo; @@ -58,7 +58,7 @@ public class TestCachedResponseSuitabilityChecker { private CachedResponseSuitabilityChecker impl; @BeforeEach - public void setUp() { + void setUp() { now = Instant.now(); elevenSecondsAgo = now.minusSeconds(11); tenSecondsAgo = now.minusSeconds(10); @@ -104,7 +104,7 @@ private HttpCacheEntry makeEntry(final Method method, final String requestUri, f } @Test - public void testRequestMethodMatch() { + void testRequestMethodMatch() { request = new BasicHttpRequest("GET", "/foo"); entry = makeEntry(Method.GET, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -128,7 +128,7 @@ public void testRequestMethodMatch() { } @Test - public void testRequestUriMatch() { + void testRequestUriMatch() { request = new BasicHttpRequest("GET", "/foo"); entry = makeEntry(Method.GET, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -156,7 +156,7 @@ public void testRequestUriMatch() { } @Test - public void testRequestHeadersMatch() { + void testRequestHeadersMatch() { request = BasicRequestBuilder.get("/foo").build(); entry = makeEntry( Method.GET, "/foo", @@ -225,7 +225,7 @@ public void testRequestHeadersMatch() { } @Test - public void testResponseNoCache() { + void testResponseNoCache() { entry = makeEntry(new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); responseCacheControl = ResponseCacheControl.builder() .setNoCache(false) @@ -254,7 +254,7 @@ public void testResponseNoCache() { } @Test - public void testSuitableIfCacheEntryIsFresh() { + void testSuitableIfCacheEntryIsFresh() { entry = makeEntry(new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); responseCacheControl = ResponseCacheControl.builder() .setMaxAge(3600) @@ -263,7 +263,7 @@ public void testSuitableIfCacheEntryIsFresh() { } @Test - public void testNotSuitableIfCacheEntryIsNotFresh() { + void testNotSuitableIfCacheEntryIsNotFresh() { entry = makeEntry( new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); responseCacheControl = ResponseCacheControl.builder() @@ -273,7 +273,7 @@ public void testNotSuitableIfCacheEntryIsNotFresh() { } @Test - public void testNotSuitableIfRequestHasNoCache() { + void testNotSuitableIfRequestHasNoCache() { requestCacheControl = RequestCacheControl.builder() .setNoCache(true) .build(); @@ -286,7 +286,7 @@ public void testNotSuitableIfRequestHasNoCache() { } @Test - public void testNotSuitableIfAgeExceedsRequestMaxAge() { + void testNotSuitableIfAgeExceedsRequestMaxAge() { requestCacheControl = RequestCacheControl.builder() .setMaxAge(10) .build(); @@ -299,7 +299,7 @@ public void testNotSuitableIfAgeExceedsRequestMaxAge() { } @Test - public void testSuitableIfFreshAndAgeIsUnderRequestMaxAge() { + void testSuitableIfFreshAndAgeIsUnderRequestMaxAge() { requestCacheControl = RequestCacheControl.builder() .setMaxAge(15) .build(); @@ -312,7 +312,7 @@ public void testSuitableIfFreshAndAgeIsUnderRequestMaxAge() { } @Test - public void testSuitableIfFreshAndFreshnessLifetimeGreaterThanRequestMinFresh() { + void testSuitableIfFreshAndFreshnessLifetimeGreaterThanRequestMinFresh() { requestCacheControl = RequestCacheControl.builder() .setMinFresh(10) .build(); @@ -325,7 +325,7 @@ public void testSuitableIfFreshAndFreshnessLifetimeGreaterThanRequestMinFresh() } @Test - public void testNotSuitableIfFreshnessLifetimeLessThanRequestMinFresh() { + void testNotSuitableIfFreshnessLifetimeLessThanRequestMinFresh() { requestCacheControl = RequestCacheControl.builder() .setMinFresh(10) .build(); @@ -338,7 +338,7 @@ public void testNotSuitableIfFreshnessLifetimeLessThanRequestMinFresh() { } @Test - public void testSuitableEvenIfStaleButPermittedByRequestMaxStale() { + void testSuitableEvenIfStaleButPermittedByRequestMaxStale() { requestCacheControl = RequestCacheControl.builder() .setMaxStale(10) .build(); @@ -353,7 +353,7 @@ public void testSuitableEvenIfStaleButPermittedByRequestMaxStale() { } @Test - public void testNotSuitableIfStaleButTooStaleForRequestMaxStale() { + void testNotSuitableIfStaleButTooStaleForRequestMaxStale() { requestCacheControl = RequestCacheControl.builder() .setMaxStale(2) .build(); @@ -366,7 +366,7 @@ public void testNotSuitableIfStaleButTooStaleForRequestMaxStale() { } @Test - public void testSuitableIfCacheEntryIsHeuristicallyFreshEnough() { + void testSuitableIfCacheEntryIsHeuristicallyFreshEnough() { final Instant oneSecondAgo = now.minusSeconds(1); final Instant twentyOneSecondsAgo = now.minusSeconds(21); @@ -383,7 +383,7 @@ public void testSuitableIfCacheEntryIsHeuristicallyFreshEnough() { } @Test - public void testSuitableIfCacheEntryIsHeuristicallyFreshEnoughByDefault() { + void testSuitableIfCacheEntryIsHeuristicallyFreshEnoughByDefault() { entry = makeEntry( new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -397,7 +397,7 @@ public void testSuitableIfCacheEntryIsHeuristicallyFreshEnoughByDefault() { } @Test - public void testSuitableIfRequestMethodisHEAD() { + void testSuitableIfRequestMethodisHEAD() { final HttpRequest headRequest = new BasicHttpRequest("HEAD", "/foo"); entry = makeEntry( new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -409,7 +409,7 @@ public void testSuitableIfRequestMethodisHEAD() { } @Test - public void testSuitableForGETIfEntryDoesNotSpecifyARequestMethodButContainsEntity() { + void testSuitableForGETIfEntryDoesNotSpecifyARequestMethodButContainsEntity() { impl = new CachedResponseSuitabilityChecker(CacheConfig.custom().build()); entry = makeEntry(Method.GET, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -421,7 +421,7 @@ public void testSuitableForGETIfEntryDoesNotSpecifyARequestMethodButContainsEnti } @Test - public void testSuitableForGETIfHeadResponseCachingEnabledAndEntryDoesNotSpecifyARequestMethodButContains204Response() { + void testSuitableForGETIfHeadResponseCachingEnabledAndEntryDoesNotSpecifyARequestMethodButContains204Response() { impl = new CachedResponseSuitabilityChecker(CacheConfig.custom().build()); entry = makeEntry(Method.GET, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -433,7 +433,7 @@ public void testSuitableForGETIfHeadResponseCachingEnabledAndEntryDoesNotSpecify } @Test - public void testSuitableForHEADIfHeadResponseCachingEnabledAndEntryDoesNotSpecifyARequestMethod() { + void testSuitableForHEADIfHeadResponseCachingEnabledAndEntryDoesNotSpecifyARequestMethod() { final HttpRequest headRequest = new BasicHttpRequest("HEAD", "/foo"); impl = new CachedResponseSuitabilityChecker(CacheConfig.custom().build()); final Header[] headers = { @@ -449,7 +449,7 @@ public void testSuitableForHEADIfHeadResponseCachingEnabledAndEntryDoesNotSpecif } @Test - public void testNotSuitableIfGetRequestWithHeadCacheEntry() { + void testNotSuitableIfGetRequestWithHeadCacheEntry() { // Prepare a cache entry with HEAD method entry = makeEntry(Method.HEAD, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -461,7 +461,7 @@ public void testNotSuitableIfGetRequestWithHeadCacheEntry() { } @Test - public void testSuitableIfErrorRequestCacheControl() { + void testSuitableIfErrorRequestCacheControl() { // Prepare a cache entry with HEAD method entry = makeEntry(Method.GET, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -494,7 +494,7 @@ public void testSuitableIfErrorRequestCacheControl() { } @Test - public void testSuitableIfErrorResponseCacheControl() { + void testSuitableIfErrorResponseCacheControl() { // Prepare a cache entry with HEAD method entry = makeEntry(Method.GET, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -521,7 +521,7 @@ public void testSuitableIfErrorResponseCacheControl() { } @Test - public void testSuitableIfErrorRequestCacheControlTakesPrecedenceOverResponseCacheControl() { + void testSuitableIfErrorRequestCacheControlTakesPrecedenceOverResponseCacheControl() { // Prepare a cache entry with HEAD method entry = makeEntry(Method.GET, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); @@ -541,7 +541,7 @@ public void testSuitableIfErrorRequestCacheControlTakesPrecedenceOverResponseCac } @Test - public void testSuitableIfErrorConfigDefault() { + void testSuitableIfErrorConfigDefault() { // Prepare a cache entry with HEAD method entry = makeEntry(Method.GET, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java index e40ab6782..9a8592ec1 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java @@ -71,7 +71,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -public class TestCachingExecChain { +class TestCachingExecChain { @Mock ExecChain mockExecChain; @@ -93,7 +93,7 @@ public class TestCachingExecChain { ExecChain.Scope scope; @BeforeEach - public void setUp() { + void setUp() { MockitoAnnotations.openMocks(this); host = new HttpHost("foo.example.com", 80); route = new HttpRoute(host); @@ -115,7 +115,7 @@ public ClassicHttpResponse execute(final ClassicHttpRequest request) throws IOEx } @Test - public void testCacheableResponsesGoIntoCache() throws Exception { + void testCacheableResponsesGoIntoCache() throws Exception { final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Cache-Control", "max-age=3600"); @@ -133,7 +133,7 @@ public void testCacheableResponsesGoIntoCache() throws Exception { } @Test - public void testOlderCacheableResponsesDoNotGoIntoCache() throws Exception { + void testOlderCacheableResponsesDoNotGoIntoCache() throws Exception { final Instant now = Instant.now(); final Instant fiveSecondsAgo = now.minusSeconds(5); @@ -165,7 +165,7 @@ public void testOlderCacheableResponsesDoNotGoIntoCache() throws Exception { } @Test - public void testNewerCacheableResponsesReplaceExistingCacheEntry() throws Exception { + void testNewerCacheableResponsesReplaceExistingCacheEntry() throws Exception { final Instant now = Instant.now(); final Instant fiveSecondsAgo = now.minusSeconds(5); @@ -197,7 +197,7 @@ public void testNewerCacheableResponsesReplaceExistingCacheEntry() throws Except } @Test - public void testNonCacheableResponseIsNotCachedAndIsReturnedAsIs() throws Exception { + void testNonCacheableResponseIsNotCachedAndIsReturnedAsIs() throws Exception { final HttpCache cache = new BasicHttpCache(new HeapResourceFactory(), mockStorage); impl = new CachingExec(cache, null, CacheConfig.DEFAULT); @@ -216,7 +216,7 @@ public void testNonCacheableResponseIsNotCachedAndIsReturnedAsIs() throws Except } @Test - public void testSetsModuleGeneratedResponseContextForCacheOptionsResponse() throws Exception { + void testSetsModuleGeneratedResponseContextForCacheOptionsResponse() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("OPTIONS", "*"); req.setHeader("Max-Forwards", "0"); @@ -225,7 +225,7 @@ public void testSetsModuleGeneratedResponseContextForCacheOptionsResponse() thro } @Test - public void testSetsCacheMissContextIfRequestNotServableFromCache() throws Exception { + void testSetsCacheMissContextIfRequestNotServableFromCache() throws Exception { final ClassicHttpRequest req = new HttpGet("http://foo.example.com/"); req.setHeader("Cache-Control", "no-cache"); final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_NO_CONTENT, "No Content"); @@ -237,7 +237,7 @@ public void testSetsCacheMissContextIfRequestNotServableFromCache() throws Excep } @Test - public void testSetsCacheHitContextIfRequestServedFromCache() throws Exception { + void testSetsCacheHitContextIfRequestServedFromCache() throws Exception { final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com/"); final ClassicHttpRequest req2 = new HttpGet("http://foo.example.com/"); final ClassicHttpResponse resp1 = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK"); @@ -255,7 +255,7 @@ public void testSetsCacheHitContextIfRequestServedFromCache() throws Exception { } @Test - public void testReturns304ForIfModifiedSinceHeaderIfRequestServedFromCache() throws Exception { + void testReturns304ForIfModifiedSinceHeaderIfRequestServedFromCache() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com/"); @@ -277,7 +277,7 @@ public void testReturns304ForIfModifiedSinceHeaderIfRequestServedFromCache() thr } @Test - public void testReturns304ForIfModifiedSinceHeaderIf304ResponseInCache() throws Exception { + void testReturns304ForIfModifiedSinceHeaderIf304ResponseInCache() throws Exception { final Instant now = Instant.now(); final Instant oneHourAgo = now.minus(1, ChronoUnit.HOURS); final Instant inTenMinutes = now.plus(10, ChronoUnit.MINUTES); @@ -304,7 +304,7 @@ public void testReturns304ForIfModifiedSinceHeaderIf304ResponseInCache() throws } @Test - public void testReturns304ForIfModifiedSinceHeaderIf304ResponseInCacheWithLastModified() throws Exception { + void testReturns304ForIfModifiedSinceHeaderIf304ResponseInCacheWithLastModified() throws Exception { final Instant now = Instant.now(); final Instant oneHourAgo = now.minus(1, ChronoUnit.HOURS); final Instant inTenMinutes = now.plus(10, ChronoUnit.MINUTES); @@ -330,7 +330,7 @@ public void testReturns304ForIfModifiedSinceHeaderIf304ResponseInCacheWithLastMo } @Test - public void testReturns200ForIfModifiedSinceDateIsLess() throws Exception { + void testReturns200ForIfModifiedSinceDateIsLess() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com/"); @@ -360,7 +360,7 @@ public void testReturns200ForIfModifiedSinceDateIsLess() throws Exception { } @Test - public void testReturns200ForIfModifiedSinceDateIsInvalid() throws Exception { + void testReturns200ForIfModifiedSinceDateIsInvalid() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAfter = now.plusSeconds(10); final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com/"); @@ -387,7 +387,7 @@ public void testReturns200ForIfModifiedSinceDateIsInvalid() throws Exception { } @Test - public void testReturns304ForIfNoneMatchHeaderIfRequestServedFromCache() throws Exception { + void testReturns304ForIfNoneMatchHeaderIfRequestServedFromCache() throws Exception { final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com/"); final ClassicHttpRequest req2 = new HttpGet("http://foo.example.com/"); req2.addHeader("If-None-Match", "*"); @@ -407,7 +407,7 @@ public void testReturns304ForIfNoneMatchHeaderIfRequestServedFromCache() throws } @Test - public void testReturns200ForIfNoneMatchHeaderFails() throws Exception { + void testReturns200ForIfNoneMatchHeaderFails() throws Exception { final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com/"); final ClassicHttpRequest req2 = new HttpGet("http://foo.example.com/"); @@ -433,7 +433,7 @@ public void testReturns200ForIfNoneMatchHeaderFails() throws Exception { } @Test - public void testReturns304ForIfNoneMatchHeaderAndIfModifiedSinceIfRequestServedFromCache() throws Exception { + void testReturns304ForIfNoneMatchHeaderAndIfModifiedSinceIfRequestServedFromCache() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com/"); @@ -458,7 +458,7 @@ public void testReturns304ForIfNoneMatchHeaderAndIfModifiedSinceIfRequestServedF } @Test - public void testReturns200ForIfNoneMatchHeaderFailsIfModifiedSinceIgnored() throws Exception { + void testReturns200ForIfNoneMatchHeaderFailsIfModifiedSinceIgnored() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com/"); @@ -481,7 +481,7 @@ public void testReturns200ForIfNoneMatchHeaderFailsIfModifiedSinceIgnored() thro } @Test - public void testReturns200ForOptionsFollowedByGetIfAuthorizationHeaderAndSharedCache() throws Exception { + void testReturns200ForOptionsFollowedByGetIfAuthorizationHeaderAndSharedCache() throws Exception { impl = new CachingExec(cache, null, CacheConfig.custom().setSharedCache(true).build()); final Instant now = Instant.now(); final ClassicHttpRequest req1 = new HttpOptions("http://foo.example.com/"); @@ -512,7 +512,7 @@ public void testReturns200ForOptionsFollowedByGetIfAuthorizationHeaderAndSharedC } @Test - public void testSetsValidatedContextIfRequestWasSuccessfullyValidated() throws Exception { + void testSetsValidatedContextIfRequestWasSuccessfullyValidated() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -543,7 +543,7 @@ public void testSetsValidatedContextIfRequestWasSuccessfullyValidated() throws E } @Test - public void testSetsModuleResponseContextIfValidationRequiredButFailed() throws Exception { + void testSetsModuleResponseContextIfValidationRequiredButFailed() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -569,7 +569,7 @@ public void testSetsModuleResponseContextIfValidationRequiredButFailed() throws } @Test - public void testSetsModuleResponseContextIfValidationFailsButNotRequired() throws Exception { + void testSetsModuleResponseContextIfValidationFailsButNotRequired() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -594,7 +594,7 @@ public void testSetsModuleResponseContextIfValidationFailsButNotRequired() throw } @Test - public void testReturns304ForIfNoneMatchPassesIfRequestServedFromOrigin() throws Exception { + void testReturns304ForIfNoneMatchPassesIfRequestServedFromOrigin() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -626,7 +626,7 @@ public void testReturns304ForIfNoneMatchPassesIfRequestServedFromOrigin() throws } @Test - public void testReturns200ForIfNoneMatchFailsIfRequestServedFromOrigin() throws Exception { + void testReturns200ForIfNoneMatchFailsIfRequestServedFromOrigin() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -660,7 +660,7 @@ public void testReturns200ForIfNoneMatchFailsIfRequestServedFromOrigin() throws } @Test - public void testReturns304ForIfModifiedSincePassesIfRequestServedFromOrigin() throws Exception { + void testReturns304ForIfModifiedSincePassesIfRequestServedFromOrigin() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -694,7 +694,7 @@ public void testReturns304ForIfModifiedSincePassesIfRequestServedFromOrigin() th } @Test - public void testReturns200ForIfModifiedSinceFailsIfRequestServedFromOrigin() throws Exception { + void testReturns200ForIfModifiedSinceFailsIfRequestServedFromOrigin() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -730,7 +730,7 @@ public void testReturns200ForIfModifiedSinceFailsIfRequestServedFromOrigin() thr } @Test - public void testVariantMissServerIfReturns304CacheReturns200() throws Exception { + void testVariantMissServerIfReturns304CacheReturns200() throws Exception { final Instant now = Instant.now(); final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com"); @@ -792,7 +792,7 @@ public void testVariantMissServerIfReturns304CacheReturns200() throws Exception } @Test - public void testVariantsMissServerReturns304CacheReturns304() throws Exception { + void testVariantsMissServerReturns304CacheReturns304() throws Exception { final Instant now = Instant.now(); final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com"); @@ -853,7 +853,7 @@ public void testVariantsMissServerReturns304CacheReturns304() throws Exception { } @Test - public void testSocketTimeoutExceptionIsNotSilentlyCatched() throws Exception { + void testSocketTimeoutExceptionIsNotSilentlyCatched() throws Exception { final Instant now = Instant.now(); final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com"); @@ -863,7 +863,7 @@ public void testSocketTimeoutExceptionIsNotSilentlyCatched() throws Exception { private boolean closed; @Override - public void close() throws IOException { + public void close() { closed = true; } @@ -886,7 +886,7 @@ public int read() throws IOException { } @Test - public void testTooLargeResponsesAreNotCached() throws Exception { + void testTooLargeResponsesAreNotCached() throws Exception { final HttpHost host = new HttpHost("foo.example.com"); final ClassicHttpRequest request = new HttpGet("http://foo.example.com/bar"); @@ -908,7 +908,7 @@ public void testTooLargeResponsesAreNotCached() throws Exception { } @Test - public void testSmallEnoughResponsesAreCached() throws Exception { + void testSmallEnoughResponsesAreCached() throws Exception { final HttpCache mockCache = mock(HttpCache.class); impl = new CachingExec(mockCache, null, CacheConfig.DEFAULT); @@ -949,7 +949,7 @@ public void testSmallEnoughResponsesAreCached() throws Exception { } @Test - public void testIfOnlyIfCachedAndNoCacheEntryBackendNotCalled() throws Exception { + void testIfOnlyIfCachedAndNoCacheEntryBackendNotCalled() throws Exception { request.addHeader("Cache-Control", "only-if-cached"); final ClassicHttpResponse resp = execute(request); @@ -958,7 +958,7 @@ public void testIfOnlyIfCachedAndNoCacheEntryBackendNotCalled() throws Exception } @Test - public void testCanCacheAResponseWithoutABody() throws Exception { + void testCanCacheAResponseWithoutABody() throws Exception { final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_NO_CONTENT, "No Content"); response.setHeader("Date", DateUtils.formatStandardDate(Instant.now())); response.setHeader("Cache-Control", "max-age=300"); @@ -971,7 +971,7 @@ public void testCanCacheAResponseWithoutABody() throws Exception { } @Test - public void testNoEntityForIfNoneMatchRequestNotYetInCache() throws Exception { + void testNoEntityForIfNoneMatchRequestNotYetInCache() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -993,7 +993,7 @@ public void testNoEntityForIfNoneMatchRequestNotYetInCache() throws Exception { } @Test - public void testNotModifiedResponseUpdatesCacheEntryWhenNoEntity() throws Exception { + void testNotModifiedResponseUpdatesCacheEntryWhenNoEntity() throws Exception { final Instant now = Instant.now(); @@ -1027,7 +1027,7 @@ public void testNotModifiedResponseUpdatesCacheEntryWhenNoEntity() throws Except } @Test - public void testNotModifiedResponseWithVaryUpdatesCacheEntryWhenNoEntity() throws Exception { + void testNotModifiedResponseWithVaryUpdatesCacheEntryWhenNoEntity() throws Exception { final Instant now = Instant.now(); @@ -1064,7 +1064,7 @@ public void testNotModifiedResponseWithVaryUpdatesCacheEntryWhenNoEntity() throw } @Test - public void testDoesNotSend304ForNonConditionalRequest() throws Exception { + void testDoesNotSend304ForNonConditionalRequest() throws Exception { final Instant now = Instant.now(); final Instant inOneMinute = now.plus(1, ChronoUnit.MINUTES); @@ -1105,7 +1105,7 @@ public void testDoesNotSend304ForNonConditionalRequest() throws Exception { } @Test - public void testUsesVirtualHostForCacheKey() throws Exception { + void testUsesVirtualHostForCacheKey() throws Exception { final ClassicHttpResponse response = HttpTestUtils.make200Response(); response.setHeader("Cache-Control", "max-age=3600"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(response); @@ -1125,7 +1125,7 @@ public void testUsesVirtualHostForCacheKey() throws Exception { } @Test - public void testReturnssetStaleIfErrorNotEnabled() throws Exception { + void testReturnssetStaleIfErrorNotEnabled() throws Exception { // Create the first request and response final ClassicHttpRequest req1 = new HttpGet("http://foo.example.com/"); @@ -1156,7 +1156,7 @@ public void testReturnssetStaleIfErrorNotEnabled() throws Exception { @Test - public void testReturnssetStaleIfErrorEnabled() throws Exception { + void testReturnssetStaleIfErrorEnabled() throws Exception { final CacheConfig customConfig = CacheConfig.custom() .setMaxCacheEntries(100) .setMaxObjectSize(1024) @@ -1196,7 +1196,7 @@ public void testReturnssetStaleIfErrorEnabled() throws Exception { } @Test - public void testNotModifiedResponseUpdatesCacheEntry() throws Exception { + void testNotModifiedResponseUpdatesCacheEntry() throws Exception { final HttpCache mockCache = mock(HttpCache.class); impl = new CachingExec(mockCache, null, CacheConfig.DEFAULT); // Prepare request and host @@ -1251,7 +1251,7 @@ public void testNotModifiedResponseUpdatesCacheEntry() throws Exception { } @Test - public void testNoCacheFieldsRevalidation() throws Exception { + void testNoCacheFieldsRevalidation() throws Exception { final Instant now = Instant.now(); final Instant fiveSecondsAgo = now.minusSeconds(5); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCombinedEntity.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCombinedEntity.java index 3b35a11bf..abb6aa50b 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCombinedEntity.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCombinedEntity.java @@ -38,10 +38,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestCombinedEntity { +class TestCombinedEntity { @Test - public void testCombinedEntityBasics() throws Exception { + void testCombinedEntityBasics() throws Exception { final HttpEntity httpEntity = mock(HttpEntity.class); when(httpEntity.getContent()).thenReturn( new ByteArrayInputStream(new byte[] { 6, 7, 8, 9, 10 })); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java index 3daf75c51..3e1e08029 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestConditionalRequestBuilder.java @@ -51,19 +51,19 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestConditionalRequestBuilder { +class TestConditionalRequestBuilder { private ConditionalRequestBuilder impl; private HttpRequest request; @BeforeEach - public void setUp() throws Exception { + void setUp() { impl = new ConditionalRequestBuilder<>(request -> BasicRequestBuilder.copy(request).build()); request = new BasicHttpRequest("GET", "/"); } @Test - public void testBuildConditionalRequestWithLastModified() { + void testBuildConditionalRequestWithLastModified() { final String theMethod = "GET"; final String theUri = "/theuri"; final String lastModified = "this is my last modified date"; @@ -91,8 +91,7 @@ public void testBuildConditionalRequestWithLastModified() { } @Test - public void testConditionalRequestForEntryWithLastModifiedAndEtagIncludesBothAsValidators() - throws Exception { + void testConditionalRequestForEntryWithLastModifiedAndEtagIncludesBothAsValidators() { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final Instant twentySecondsAgo = now.plusSeconds(20); @@ -114,7 +113,7 @@ public void testConditionalRequestForEntryWithLastModifiedAndEtagIncludesBothAsV } @Test - public void testBuildConditionalRequestWithETag() { + void testBuildConditionalRequestWithETag() { final String theMethod = "GET"; final String theUri = "/theuri"; final String theETag = "\"this is my eTag\""; @@ -146,7 +145,7 @@ public void testBuildConditionalRequestWithETag() { } @Test - public void testCacheEntryWithMustRevalidateDoesEndToEndRevalidation() throws Exception { + void testCacheEntryWithMustRevalidateDoesEndToEndRevalidation() { final HttpRequest basicRequest = new BasicHttpRequest("GET","/"); final Instant now = Instant.now(); final Instant elevenSecondsAgo = now.minusSeconds(11); @@ -170,7 +169,7 @@ public void testCacheEntryWithMustRevalidateDoesEndToEndRevalidation() throws Ex } @Test - public void testCacheEntryWithProxyRevalidateDoesEndToEndRevalidation() throws Exception { + void testCacheEntryWithProxyRevalidateDoesEndToEndRevalidation() { final HttpRequest basicRequest = new BasicHttpRequest("GET", "/"); final Instant now = Instant.now(); final Instant elevenSecondsAgo = now.minusSeconds(11); @@ -194,15 +193,13 @@ public void testCacheEntryWithProxyRevalidateDoesEndToEndRevalidation() throws E } @Test - public void testBuildUnconditionalRequestUsesGETMethod() - throws Exception { + void testBuildUnconditionalRequestUsesGETMethod() { final HttpRequest result = impl.buildUnconditionalRequest(request); Assertions.assertEquals("GET", result.getMethod()); } @Test - public void testBuildUnconditionalRequestUsesRequestUri() - throws Exception { + void testBuildUnconditionalRequestUsesRequestUri() { final String uri = "/theURI"; request = new BasicHttpRequest("GET", uri); final HttpRequest result = impl.buildUnconditionalRequest(request); @@ -210,56 +207,49 @@ public void testBuildUnconditionalRequestUsesRequestUri() } @Test - public void testBuildUnconditionalRequestAddsCacheControlNoCache() - throws Exception { + void testBuildUnconditionalRequestAddsCacheControlNoCache() { final HttpRequest result = impl.buildUnconditionalRequest(request); final RequestCacheControl requestCacheControl = CacheControlHeaderParser.INSTANCE.parse(result); Assertions.assertTrue(requestCacheControl.isNoCache()); } @Test - public void testBuildUnconditionalRequestDoesNotUseIfRange() - throws Exception { + void testBuildUnconditionalRequestDoesNotUseIfRange() { request.addHeader("If-Range","\"etag\""); final HttpRequest result = impl.buildUnconditionalRequest(request); Assertions.assertNull(result.getFirstHeader("If-Range")); } @Test - public void testBuildUnconditionalRequestDoesNotUseIfMatch() - throws Exception { + void testBuildUnconditionalRequestDoesNotUseIfMatch() { request.addHeader("If-Match","\"etag\""); final HttpRequest result = impl.buildUnconditionalRequest(request); Assertions.assertNull(result.getFirstHeader("If-Match")); } @Test - public void testBuildUnconditionalRequestDoesNotUseIfNoneMatch() - throws Exception { + void testBuildUnconditionalRequestDoesNotUseIfNoneMatch() { request.addHeader("If-None-Match","\"etag\""); final HttpRequest result = impl.buildUnconditionalRequest(request); Assertions.assertNull(result.getFirstHeader("If-None-Match")); } @Test - public void testBuildUnconditionalRequestDoesNotUseIfUnmodifiedSince() - throws Exception { + void testBuildUnconditionalRequestDoesNotUseIfUnmodifiedSince() { request.addHeader("If-Unmodified-Since", DateUtils.formatStandardDate(Instant.now())); final HttpRequest result = impl.buildUnconditionalRequest(request); Assertions.assertNull(result.getFirstHeader("If-Unmodified-Since")); } @Test - public void testBuildUnconditionalRequestDoesNotUseIfModifiedSince() - throws Exception { + void testBuildUnconditionalRequestDoesNotUseIfModifiedSince() { request.addHeader("If-Modified-Since", DateUtils.formatStandardDate(Instant.now())); final HttpRequest result = impl.buildUnconditionalRequest(request); Assertions.assertNull(result.getFirstHeader("If-Modified-Since")); } @Test - public void testBuildUnconditionalRequestCarriesOtherRequestHeaders() - throws Exception { + void testBuildUnconditionalRequestCarriesOtherRequestHeaders() { request.addHeader("User-Agent","MyBrowser/1.0"); final HttpRequest result = impl.buildUnconditionalRequest(request); Assertions.assertEquals("MyBrowser/1.0", @@ -267,7 +257,7 @@ public void testBuildUnconditionalRequestCarriesOtherRequestHeaders() } @Test - public void testBuildConditionalRequestFromVariants() throws Exception { + void testBuildConditionalRequestFromVariants() { final ETag etag1 = new ETag("123"); final ETag etag2 = new ETag("456"); final ETag etag3 = new ETag("789"); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestFileResourceFactory.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestFileResourceFactory.java index 952f75712..ba814be0c 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestFileResourceFactory.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestFileResourceFactory.java @@ -33,17 +33,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestFileResourceFactory { +class TestFileResourceFactory { CacheKeyGenerator keyGenerator; @BeforeEach - public void setUp() { + void setUp() { keyGenerator = new CacheKeyGenerator(); } @Test - public void testViaValueLookup() throws Exception { + void testViaValueLookup() throws Exception { final String requestId = keyGenerator.generateKey(new URI("http://localhost/stuff")); Assertions.assertEquals( diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java index 4647ab038..7a60f31db 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java @@ -50,17 +50,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestHttpByteArrayCacheEntrySerializer { +class TestHttpByteArrayCacheEntrySerializer { private HttpCacheEntrySerializer httpCacheEntrySerializer; @BeforeEach - public void before() { + void before() { httpCacheEntrySerializer = HttpByteArrayCacheEntrySerializer.INSTANCE; } @Test - public void testSimpleSerializeAndDeserialize() throws Exception { + void testSimpleSerializeAndDeserialize() throws Exception { final String content = "Hello World"; final ContentType contentType = ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8); final HttpCacheEntry cacheEntry = new HttpCacheEntry(Instant.now(), Instant.now(), @@ -77,7 +77,7 @@ public void testSimpleSerializeAndDeserialize() throws Exception { } @Test - public void testSerializeAndDeserializeLargeContent() throws Exception { + void testSerializeAndDeserializeLargeContent() throws Exception { final ContentType contentType = ContentType.IMAGE_JPEG; final HeapResource resource = load(getClass().getResource("/ApacheLogo.png")); final HttpCacheEntry cacheEntry = new HttpCacheEntry(Instant.now(), Instant.now(), @@ -97,7 +97,7 @@ public void testSerializeAndDeserializeLargeContent() throws Exception { * Deserialize a cache entry in a bad format, expecting an exception. */ @Test - public void testInvalidCacheEntry() throws Exception { + void testInvalidCacheEntry() throws Exception { // This file is a JPEG not a cache entry, so should fail to deserialize final HeapResource resource = load(getClass().getResource("/ApacheLogo.png")); Assertions.assertThrows(ResourceIOException.class, () -> @@ -108,7 +108,7 @@ public void testInvalidCacheEntry() throws Exception { * Deserialize truncated cache entries. */ @Test - public void testTruncatedCacheEntry() throws Exception { + void testTruncatedCacheEntry() { final String content1 = HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" + "HC-Key: unique-cache-key\n" + "HC-Resource-Length: 11\n" + @@ -190,7 +190,7 @@ public void testTruncatedCacheEntry() throws Exception { * Deserialize cache entries with a missing mandatory header. */ @Test - public void testMissingHeaderCacheEntry() throws Exception { + void testMissingHeaderCacheEntry() { final String content1 = HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" + "HC-Key: unique-cache-key\n" + "HC-Resource-Length: 11\n" + @@ -230,7 +230,7 @@ public void testMissingHeaderCacheEntry() throws Exception { * Deserialize cache entries with an invalid header value. */ @Test - public void testInvalidHeaderCacheEntry() throws Exception { + void testInvalidHeaderCacheEntry() { final String content1 = HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" + "HC-Key: unique-cache-key\n" + "HC-Resource-Length: 11\n" + @@ -271,7 +271,7 @@ public void testInvalidHeaderCacheEntry() throws Exception { * Deserialize cache entries with an invalid request line. */ @Test - public void testInvalidRequestLineCacheEntry() throws Exception { + void testInvalidRequestLineCacheEntry() { final String content1 = HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" + "HC-Key: unique-cache-key\n" + "HC-Resource-Length: 11\n" + @@ -295,7 +295,7 @@ public void testInvalidRequestLineCacheEntry() throws Exception { * Deserialize cache entries with an invalid request line. */ @Test - public void testInvalidStatusLineCacheEntry() throws Exception { + void testInvalidStatusLineCacheEntry() { final String content1 = HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" + "HC-Key: unique-cache-key\n" + "HC-Resource-Length: 11\n" + @@ -319,7 +319,7 @@ public void testInvalidStatusLineCacheEntry() throws Exception { * Serialize and deserialize a cache entry with no headers. */ @Test - public void noHeadersTest() throws Exception { + void noHeadersTest() throws Exception { final String content = "Hello World"; final ContentType contentType = ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8); final HttpCacheEntry cacheEntry = new HttpCacheEntry(Instant.now(), Instant.now(), @@ -339,7 +339,7 @@ public void noHeadersTest() throws Exception { * Serialize and deserialize a cache entry with an empty body. */ @Test - public void emptyBodyTest() throws Exception { + void emptyBodyTest() throws Exception { final HttpCacheEntry cacheEntry = new HttpCacheEntry(Instant.now(), Instant.now(), "GET", "/stuff", HttpTestUtils.headers(), HttpStatus.SC_OK, HttpTestUtils.headers(), @@ -357,7 +357,7 @@ public void emptyBodyTest() throws Exception { * Serialize and deserialize a cache entry with no body. */ @Test - public void noBodyTest() throws Exception { + void noBodyTest() throws Exception { final HttpCacheEntry cacheEntry = new HttpCacheEntry(Instant.now(), Instant.now(), "GET", "/stuff", HttpTestUtils.headers(), HttpStatus.SC_OK, HttpTestUtils.headers(), @@ -375,7 +375,7 @@ public void noBodyTest() throws Exception { * Serialize and deserialize a cache entry with a variant map. */ @Test - public void testSimpleVariantMap() throws Exception { + void testSimpleVariantMap() throws Exception { final String content = "Hello World"; final ContentType contentType = ContentType.TEXT_PLAIN.withCharset(StandardCharsets.UTF_8); final Set variants = new HashSet<>(); @@ -398,7 +398,7 @@ public void testSimpleVariantMap() throws Exception { * Deserialize cache entries with trailing garbage. */ @Test - public void testDeserializeCacheEntryWithTrailingGarbage() throws Exception { + void testDeserializeCacheEntryWithTrailingGarbage() { final String content1 =HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" + "HC-Key: unique-cache-key\n" + "HC-Resource-Length: 11\n" + diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpCacheJiraNumber1147.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpCacheJiraNumber1147.java index 8452f9974..d165e3b34 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpCacheJiraNumber1147.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpCacheJiraNumber1147.java @@ -56,7 +56,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public class TestHttpCacheJiraNumber1147 { +class TestHttpCacheJiraNumber1147 { private File cacheDir; @@ -72,7 +72,7 @@ private void removeCache() { } @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { cacheDir = File.createTempFile("cachedir", ""); if (cacheDir.exists()) { cacheDir.delete(); @@ -81,12 +81,12 @@ public void setUp() throws Exception { } @AfterEach - public void cleanUp() { + void cleanUp() { removeCache(); } @Test - public void testIssue1147() throws Exception { + void testIssue1147() throws Exception { final CacheConfig cacheConfig = CacheConfig.custom() .setSharedCache(true) .setMaxObjectSize(262144) //256kb diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestInternalCacheStorage.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestInternalCacheStorage.java index 7e688c05b..4bf184aa8 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestInternalCacheStorage.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestInternalCacheStorage.java @@ -33,10 +33,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestInternalCacheStorage { +class TestInternalCacheStorage { @Test - public void testCacheBasics() { + void testCacheBasics() { final InternalCacheStorage storage = new InternalCacheStorage(); final String key1 = "some-key-1"; Assertions.assertNull(storage.get(key1)); @@ -61,7 +61,7 @@ public void testCacheBasics() { } @Test - public void testCacheEviction() { + void testCacheEviction() { final Queue evictedEntries = new LinkedList<>(); final InternalCacheStorage storage = new InternalCacheStorage(2, e -> evictedEntries.add(e.getContent())); final String key1 = "some-key-1"; diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolAllowedBehavior.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolAllowedBehavior.java index 81669953c..f40f318d1 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolAllowedBehavior.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolAllowedBehavior.java @@ -51,7 +51,7 @@ * This class tests behavior that is allowed (MAY) by the HTTP/1.1 protocol * specification and for which we have implemented the behavior in HTTP cache. */ -public class TestProtocolAllowedBehavior { +class TestProtocolAllowedBehavior { static final int MAX_BYTES = 1024; static final int MAX_ENTRIES = 100; @@ -73,7 +73,7 @@ public class TestProtocolAllowedBehavior { HttpCache cache; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { MockitoAnnotations.openMocks(this); host = new HttpHost("foo.example.com", 80); @@ -105,7 +105,7 @@ public ClassicHttpResponse execute(final ClassicHttpRequest request) throws IOEx } @Test - public void testNonSharedCacheMayCacheResponsesWithCacheControlPrivate() throws Exception { + void testNonSharedCacheMayCacheResponsesWithCacheControlPrivate() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET","/"); originResponse.setHeader("Cache-Control","private,max-age=3600"); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java index 607f35533..3bdcce722 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java @@ -68,7 +68,7 @@ * compliance with the HTTP/1.1 caching protocol (SHOULD, SHOULD NOT, * RECOMMENDED, and NOT RECOMMENDED behaviors). */ -public class TestProtocolRecommendations { +class TestProtocolRecommendations { static final int MAX_BYTES = 1024; static final int MAX_ENTRIES = 100; @@ -92,7 +92,7 @@ public class TestProtocolRecommendations { Instant twoMinutesAgo; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { MockitoAnnotations.openMocks(this); host = new HttpHost("foo.example.com", 80); @@ -164,85 +164,85 @@ private void cacheGenerated304ForStrongDateValidatorShouldNotContainEntityHeader } @Test - public void cacheGenerated304ForStrongEtagValidatorShouldNotContainAllow() throws Exception { + void cacheGenerated304ForStrongEtagValidatorShouldNotContainAllow() throws Exception { cacheGenerated304ForStrongETagValidatorShouldNotContainEntityHeader( "Allow", "GET,HEAD"); } @Test - public void cacheGenerated304ForStrongDateValidatorShouldNotContainAllow() throws Exception { + void cacheGenerated304ForStrongDateValidatorShouldNotContainAllow() throws Exception { cacheGenerated304ForStrongDateValidatorShouldNotContainEntityHeader( "Allow", "GET,HEAD"); } @Test - public void cacheGenerated304ForStrongEtagValidatorShouldNotContainContentEncoding() throws Exception { + void cacheGenerated304ForStrongEtagValidatorShouldNotContainContentEncoding() throws Exception { cacheGenerated304ForStrongETagValidatorShouldNotContainEntityHeader( "Content-Encoding", "gzip"); } @Test - public void cacheGenerated304ForStrongDateValidatorShouldNotContainContentEncoding() throws Exception { + void cacheGenerated304ForStrongDateValidatorShouldNotContainContentEncoding() throws Exception { cacheGenerated304ForStrongDateValidatorShouldNotContainEntityHeader( "Content-Encoding", "gzip"); } @Test - public void cacheGenerated304ForStrongEtagValidatorShouldNotContainContentLanguage() throws Exception { + void cacheGenerated304ForStrongEtagValidatorShouldNotContainContentLanguage() throws Exception { cacheGenerated304ForStrongETagValidatorShouldNotContainEntityHeader( "Content-Language", "en"); } @Test - public void cacheGenerated304ForStrongDateValidatorShouldNotContainContentLanguage() throws Exception { + void cacheGenerated304ForStrongDateValidatorShouldNotContainContentLanguage() throws Exception { cacheGenerated304ForStrongDateValidatorShouldNotContainEntityHeader( "Content-Language", "en"); } @Test - public void cacheGenerated304ForStrongValidatorShouldNotContainContentLength() throws Exception { + void cacheGenerated304ForStrongValidatorShouldNotContainContentLength() throws Exception { cacheGenerated304ForStrongETagValidatorShouldNotContainEntityHeader( "Content-Length", "128"); } @Test - public void cacheGenerated304ForStrongDateValidatorShouldNotContainContentLength() throws Exception { + void cacheGenerated304ForStrongDateValidatorShouldNotContainContentLength() throws Exception { cacheGenerated304ForStrongDateValidatorShouldNotContainEntityHeader( "Content-Length", "128"); } @Test - public void cacheGenerated304ForStrongValidatorShouldNotContainContentMD5() throws Exception { + void cacheGenerated304ForStrongValidatorShouldNotContainContentMD5() throws Exception { cacheGenerated304ForStrongETagValidatorShouldNotContainEntityHeader( "Content-MD5", "Q2hlY2sgSW50ZWdyaXR5IQ=="); } @Test - public void cacheGenerated304ForStrongDateValidatorShouldNotContainContentMD5() throws Exception { + void cacheGenerated304ForStrongDateValidatorShouldNotContainContentMD5() throws Exception { cacheGenerated304ForStrongDateValidatorShouldNotContainEntityHeader( "Content-MD5", "Q2hlY2sgSW50ZWdyaXR5IQ=="); } @Test - public void cacheGenerated304ForStrongEtagValidatorShouldNotContainContentType() throws Exception { + void cacheGenerated304ForStrongEtagValidatorShouldNotContainContentType() throws Exception { cacheGenerated304ForStrongETagValidatorShouldNotContainEntityHeader( "Content-Type", "text/html"); } @Test - public void cacheGenerated304ForStrongDateValidatorShouldNotContainContentType() throws Exception { + void cacheGenerated304ForStrongDateValidatorShouldNotContainContentType() throws Exception { cacheGenerated304ForStrongDateValidatorShouldNotContainEntityHeader( "Content-Type", "text/html"); } @Test - public void cacheGenerated304ForStrongEtagValidatorShouldNotContainLastModified() throws Exception { + void cacheGenerated304ForStrongEtagValidatorShouldNotContainLastModified() throws Exception { cacheGenerated304ForStrongETagValidatorShouldNotContainEntityHeader( "Last-Modified", DateUtils.formatStandardDate(tenSecondsAgo)); } @Test - public void cacheGenerated304ForStrongDateValidatorShouldNotContainLastModified() throws Exception { + void cacheGenerated304ForStrongDateValidatorShouldNotContainLastModified() throws Exception { cacheGenerated304ForStrongDateValidatorShouldNotContainEntityHeader( "Last-Modified", DateUtils.formatStandardDate(twoMinutesAgo)); } @@ -277,21 +277,21 @@ private void testDoesNotReturnStaleResponseOnError(final ClassicHttpRequest req2 } @Test - public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFirstHandOneWithCacheControl() throws Exception { + void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFirstHandOneWithCacheControl() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("GET", "/"); req.setHeader("Cache-Control","no-cache"); testDoesNotReturnStaleResponseOnError(req); } @Test - public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMaxAge() throws Exception { + void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMaxAge() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("GET", "/"); req.setHeader("Cache-Control","max-age=0"); testDoesNotReturnStaleResponseOnError(req); } @Test - public void testDoesNotReturnStaleResponseIfClientExplicitlySpecifiesLargerMaxAge() throws Exception { + void testDoesNotReturnStaleResponseIfClientExplicitlySpecifiesLargerMaxAge() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("GET", "/"); req.setHeader("Cache-Control","max-age=20"); testDoesNotReturnStaleResponseOnError(req); @@ -299,7 +299,7 @@ public void testDoesNotReturnStaleResponseIfClientExplicitlySpecifiesLargerMaxAg @Test - public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMinFresh() throws Exception { + void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMinFresh() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("GET", "/"); req.setHeader("Cache-Control","min-fresh=2"); @@ -307,7 +307,7 @@ public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMin } @Test - public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMaxStale() throws Exception { + void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMaxStale() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("GET", "/"); req.setHeader("Cache-Control","max-stale=2"); @@ -315,7 +315,7 @@ public void testDoesNotReturnStaleResponseIfClientExplicitlyRequestsFreshWithMax } @Test - public void testMayReturnStaleResponseIfClientExplicitlySpecifiesAcceptableMaxStale() throws Exception { + void testMayReturnStaleResponseIfClientExplicitlySpecifiesAcceptableMaxStale() throws Exception { final ClassicHttpRequest req1 = requestToPopulateStaleCacheEntry(); final ClassicHttpRequest req2 = new BasicClassicHttpRequest("GET", "/"); req2.setHeader("Cache-Control","max-stale=20"); @@ -352,20 +352,20 @@ private void testDoesNotModifyHeaderOnRequests(final String headerName) throws E } @Test - public void testDoesNotModifyAcceptRangesOnResponses() throws Exception { + void testDoesNotModifyAcceptRangesOnResponses() throws Exception { final String headerName = "Accept-Ranges"; originResponse.setHeader(headerName,"bytes"); testDoesNotModifyHeaderOnResponses(headerName); } @Test - public void testDoesNotModifyAuthorizationOnRequests() throws Exception { + void testDoesNotModifyAuthorizationOnRequests() throws Exception { request.setHeader("Authorization", StandardAuthScheme.BASIC + " dXNlcjpwYXNzd2Q="); testDoesNotModifyHeaderOnRequests("Authorization"); } @Test - public void testDoesNotModifyContentLengthOnRequests() throws Exception { + void testDoesNotModifyContentLengthOnRequests() throws Exception { final ClassicHttpRequest post = new BasicClassicHttpRequest("POST", "/"); post.setEntity(HttpTestUtils.makeBody(128)); post.setHeader("Content-Length","128"); @@ -374,14 +374,14 @@ public void testDoesNotModifyContentLengthOnRequests() throws Exception { } @Test - public void testDoesNotModifyContentLengthOnResponses() throws Exception { + void testDoesNotModifyContentLengthOnResponses() throws Exception { originResponse.setEntity(HttpTestUtils.makeBody(128)); originResponse.setHeader("Content-Length","128"); testDoesNotModifyHeaderOnResponses("Content-Length"); } @Test - public void testDoesNotModifyContentMD5OnRequests() throws Exception { + void testDoesNotModifyContentMD5OnRequests() throws Exception { final ClassicHttpRequest post = new BasicClassicHttpRequest("POST", "/"); post.setEntity(HttpTestUtils.makeBody(128)); post.setHeader("Content-Length","128"); @@ -391,14 +391,14 @@ public void testDoesNotModifyContentMD5OnRequests() throws Exception { } @Test - public void testDoesNotModifyContentMD5OnResponses() throws Exception { + void testDoesNotModifyContentMD5OnResponses() throws Exception { originResponse.setEntity(HttpTestUtils.makeBody(128)); originResponse.setHeader("Content-MD5","Q2hlY2sgSW50ZWdyaXR5IQ=="); testDoesNotModifyHeaderOnResponses("Content-MD5"); } @Test - public void testDoesNotModifyContentRangeOnRequests() throws Exception { + void testDoesNotModifyContentRangeOnRequests() throws Exception { final ClassicHttpRequest put = new BasicClassicHttpRequest("PUT", "/"); put.setEntity(HttpTestUtils.makeBody(128)); put.setHeader("Content-Length","128"); @@ -408,7 +408,7 @@ public void testDoesNotModifyContentRangeOnRequests() throws Exception { } @Test - public void testDoesNotModifyContentRangeOnResponses() throws Exception { + void testDoesNotModifyContentRangeOnResponses() throws Exception { request.setHeader("Range","bytes=0-128"); originResponse.setCode(HttpStatus.SC_PARTIAL_CONTENT); originResponse.setReasonPhrase("Partial Content"); @@ -418,7 +418,7 @@ public void testDoesNotModifyContentRangeOnResponses() throws Exception { } @Test - public void testDoesNotModifyContentTypeOnRequests() throws Exception { + void testDoesNotModifyContentTypeOnRequests() throws Exception { final ClassicHttpRequest post = new BasicClassicHttpRequest("POST", "/"); post.setEntity(HttpTestUtils.makeBody(128)); post.setHeader("Content-Length","128"); @@ -428,82 +428,82 @@ public void testDoesNotModifyContentTypeOnRequests() throws Exception { } @Test - public void testDoesNotModifyContentTypeOnResponses() throws Exception { + void testDoesNotModifyContentTypeOnResponses() throws Exception { originResponse.setHeader("Content-Type","application/octet-stream"); testDoesNotModifyHeaderOnResponses("Content-Type"); } @Test - public void testDoesNotModifyDateOnRequests() throws Exception { + void testDoesNotModifyDateOnRequests() throws Exception { request.setHeader("Date", DateUtils.formatStandardDate(Instant.now())); testDoesNotModifyHeaderOnRequests("Date"); } @Test - public void testDoesNotModifyDateOnResponses() throws Exception { + void testDoesNotModifyDateOnResponses() throws Exception { originResponse.setHeader("Date", DateUtils.formatStandardDate(Instant.now())); testDoesNotModifyHeaderOnResponses("Date"); } @Test - public void testDoesNotModifyETagOnResponses() throws Exception { + void testDoesNotModifyETagOnResponses() throws Exception { originResponse.setHeader("ETag", "\"random-etag\""); testDoesNotModifyHeaderOnResponses("ETag"); } @Test - public void testDoesNotModifyExpiresOnResponses() throws Exception { + void testDoesNotModifyExpiresOnResponses() throws Exception { originResponse.setHeader("Expires", DateUtils.formatStandardDate(Instant.now())); testDoesNotModifyHeaderOnResponses("Expires"); } @Test - public void testDoesNotModifyFromOnRequests() throws Exception { + void testDoesNotModifyFromOnRequests() throws Exception { request.setHeader("From", "foo@example.com"); testDoesNotModifyHeaderOnRequests("From"); } @Test - public void testDoesNotModifyIfMatchOnRequests() throws Exception { + void testDoesNotModifyIfMatchOnRequests() throws Exception { request = new BasicClassicHttpRequest("DELETE", "/"); request.setHeader("If-Match", "\"etag\""); testDoesNotModifyHeaderOnRequests("If-Match"); } @Test - public void testDoesNotModifyIfModifiedSinceOnRequests() throws Exception { + void testDoesNotModifyIfModifiedSinceOnRequests() throws Exception { request.setHeader("If-Modified-Since", DateUtils.formatStandardDate(Instant.now())); testDoesNotModifyHeaderOnRequests("If-Modified-Since"); } @Test - public void testDoesNotModifyIfNoneMatchOnRequests() throws Exception { + void testDoesNotModifyIfNoneMatchOnRequests() throws Exception { request.setHeader("If-None-Match", "\"etag\""); testDoesNotModifyHeaderOnRequests("If-None-Match"); } @Test - public void testDoesNotModifyIfRangeOnRequests() throws Exception { + void testDoesNotModifyIfRangeOnRequests() throws Exception { request.setHeader("Range","bytes=0-128"); request.setHeader("If-Range", "\"etag\""); testDoesNotModifyHeaderOnRequests("If-Range"); } @Test - public void testDoesNotModifyIfUnmodifiedSinceOnRequests() throws Exception { + void testDoesNotModifyIfUnmodifiedSinceOnRequests() throws Exception { request = new BasicClassicHttpRequest("DELETE", "/"); request.setHeader("If-Unmodified-Since", DateUtils.formatStandardDate(Instant.now())); testDoesNotModifyHeaderOnRequests("If-Unmodified-Since"); } @Test - public void testDoesNotModifyLastModifiedOnResponses() throws Exception { + void testDoesNotModifyLastModifiedOnResponses() throws Exception { originResponse.setHeader("Last-Modified", DateUtils.formatStandardDate(Instant.now())); testDoesNotModifyHeaderOnResponses("Last-Modified"); } @Test - public void testDoesNotModifyLocationOnResponses() throws Exception { + void testDoesNotModifyLocationOnResponses() throws Exception { originResponse.setCode(HttpStatus.SC_TEMPORARY_REDIRECT); originResponse.setReasonPhrase("Temporary Redirect"); originResponse.setHeader("Location", "http://foo.example.com/bar"); @@ -511,19 +511,19 @@ public void testDoesNotModifyLocationOnResponses() throws Exception { } @Test - public void testDoesNotModifyRangeOnRequests() throws Exception { + void testDoesNotModifyRangeOnRequests() throws Exception { request.setHeader("Range", "bytes=0-128"); testDoesNotModifyHeaderOnRequests("Range"); } @Test - public void testDoesNotModifyRefererOnRequests() throws Exception { + void testDoesNotModifyRefererOnRequests() throws Exception { request.setHeader("Referer", "http://foo.example.com/bar"); testDoesNotModifyHeaderOnRequests("Referer"); } @Test - public void testDoesNotModifyRetryAfterOnResponses() throws Exception { + void testDoesNotModifyRetryAfterOnResponses() throws Exception { originResponse.setCode(HttpStatus.SC_SERVICE_UNAVAILABLE); originResponse.setReasonPhrase("Service Unavailable"); originResponse.setHeader("Retry-After", "120"); @@ -531,38 +531,38 @@ public void testDoesNotModifyRetryAfterOnResponses() throws Exception { } @Test - public void testDoesNotModifyServerOnResponses() throws Exception { + void testDoesNotModifyServerOnResponses() throws Exception { originResponse.setHeader("Server", "SomeServer/1.0"); testDoesNotModifyHeaderOnResponses("Server"); } @Test - public void testDoesNotModifyUserAgentOnRequests() throws Exception { + void testDoesNotModifyUserAgentOnRequests() throws Exception { request.setHeader("User-Agent", "MyClient/1.0"); testDoesNotModifyHeaderOnRequests("User-Agent"); } @Test - public void testDoesNotModifyVaryOnResponses() throws Exception { + void testDoesNotModifyVaryOnResponses() throws Exception { request.setHeader("Accept-Encoding","identity"); originResponse.setHeader("Vary", "Accept-Encoding"); testDoesNotModifyHeaderOnResponses("Vary"); } @Test - public void testDoesNotModifyExtensionHeaderOnRequests() throws Exception { + void testDoesNotModifyExtensionHeaderOnRequests() throws Exception { request.setHeader("X-Extension","x-value"); testDoesNotModifyHeaderOnRequests("X-Extension"); } @Test - public void testDoesNotModifyExtensionHeaderOnResponses() throws Exception { + void testDoesNotModifyExtensionHeaderOnResponses() throws Exception { originResponse.setHeader("X-Extension", "x-value"); testDoesNotModifyHeaderOnResponses("X-Extension"); } @Test - public void testUsesLastModifiedDateForCacheConditionalRequests() throws Exception { + void testUsesLastModifiedDateForCacheConditionalRequests() throws Exception { final Instant twentySecondsAgo = now.plusSeconds(20); final String lmDate = DateUtils.formatStandardDate(twentySecondsAgo); @@ -592,7 +592,7 @@ public void testUsesLastModifiedDateForCacheConditionalRequests() throws Excepti } @Test - public void testUsesBothLastModifiedAndETagForConditionalRequestsIfAvailable() throws Exception { + void testUsesBothLastModifiedAndETagForConditionalRequestsIfAvailable() throws Exception { final Instant twentySecondsAgo = now.plusSeconds(20); final String lmDate = DateUtils.formatStandardDate(twentySecondsAgo); final String etag = "\"etag\""; @@ -625,7 +625,7 @@ public void testUsesBothLastModifiedAndETagForConditionalRequestsIfAvailable() t } @Test - public void testRevalidatesCachedResponseWithExpirationInThePast() throws Exception { + void testRevalidatesCachedResponseWithExpirationInThePast() throws Exception { final Instant oneSecondAgo = now.minusSeconds(1); final Instant oneSecondFromNow = now.plusSeconds(1); final Instant twoSecondsFromNow = now.plusSeconds(2); @@ -656,7 +656,7 @@ public void testRevalidatesCachedResponseWithExpirationInThePast() throws Except } @Test - public void testRetriesValidationThatResultsInAnOlderDated304Response() throws Exception { + void testRetriesValidationThatResultsInAnOlderDated304Response() throws Exception { final Instant elevenSecondsAgo = now.minusSeconds(11); final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -708,7 +708,7 @@ public void testRetriesValidationThatResultsInAnOlderDated304Response() throws E } @Test - public void testSendsAllVariantEtagsInConditionalRequest() throws Exception { + void testSendsAllVariantEtagsInConditionalRequest() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET","/"); req1.setHeader("User-Agent","agent1"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -759,7 +759,7 @@ public void testSendsAllVariantEtagsInConditionalRequest() throws Exception { } @Test - public void testResponseToExistingVariantsUpdatesEntry() throws Exception { + void testResponseToExistingVariantsUpdatesEntry() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); req1.setHeader("User-Agent", "agent1"); @@ -807,7 +807,7 @@ public void testResponseToExistingVariantsUpdatesEntry() throws Exception { } @Test - public void testResponseToExistingVariantsIsCachedForFutureResponses() throws Exception { + void testResponseToExistingVariantsIsCachedForFutureResponses() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); req1.setHeader("User-Agent", "agent1"); @@ -842,7 +842,7 @@ public void testResponseToExistingVariantsIsCachedForFutureResponses() throws Ex } @Test - public void shouldInvalidateNonvariantCacheEntryForUnknownMethod() throws Exception { + void shouldInvalidateNonvariantCacheEntryForUnknownMethod() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Cache-Control","max-age=3600"); @@ -870,7 +870,7 @@ public void shouldInvalidateNonvariantCacheEntryForUnknownMethod() throws Except } @Test - public void shouldInvalidateAllVariantsForUnknownMethod() throws Exception { + void shouldInvalidateAllVariantsForUnknownMethod() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); req1.setHeader("User-Agent", "agent1"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -923,7 +923,7 @@ public void shouldInvalidateAllVariantsForUnknownMethod() throws Exception { } @Test - public void cacheShouldUpdateWithNewCacheableResponse() throws Exception { + void cacheShouldUpdateWithNewCacheableResponse() throws Exception { final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo)); @@ -952,7 +952,7 @@ public void cacheShouldUpdateWithNewCacheableResponse() throws Exception { } @Test - public void expiresEqualToDateWithNoCacheControlIsNotCacheable() throws Exception { + void expiresEqualToDateWithNoCacheControlIsNotCacheable() throws Exception { final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -976,7 +976,7 @@ public void expiresEqualToDateWithNoCacheControlIsNotCacheable() throws Exceptio } @Test - public void expiresPriorToDateWithNoCacheControlIsNotCacheable() throws Exception { + void expiresPriorToDateWithNoCacheControlIsNotCacheable() throws Exception { final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -1000,7 +1000,7 @@ public void expiresPriorToDateWithNoCacheControlIsNotCacheable() throws Exceptio } @Test - public void cacheMissResultsIn504WithOnlyIfCached() throws Exception { + void cacheMissResultsIn504WithOnlyIfCached() throws Exception { final ClassicHttpRequest req = HttpTestUtils.makeDefaultRequest(); req.setHeader("Cache-Control", "only-if-cached"); @@ -1010,7 +1010,7 @@ public void cacheMissResultsIn504WithOnlyIfCached() throws Exception { } @Test - public void cacheHitOkWithOnlyIfCached() throws Exception { + void cacheHitOkWithOnlyIfCached() throws Exception { final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Cache-Control","max-age=3600"); @@ -1027,7 +1027,7 @@ public void cacheHitOkWithOnlyIfCached() throws Exception { } @Test - public void returns504ForStaleEntryWithOnlyIfCached() throws Exception { + void returns504ForStaleEntryWithOnlyIfCached() throws Exception { final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo)); @@ -1045,7 +1045,7 @@ public void returns504ForStaleEntryWithOnlyIfCached() throws Exception { } @Test - public void returnsStaleCacheEntryWithOnlyIfCachedAndMaxStale() throws Exception { + void returnsStaleCacheEntryWithOnlyIfCachedAndMaxStale() throws Exception { final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -1064,7 +1064,7 @@ public void returnsStaleCacheEntryWithOnlyIfCachedAndMaxStale() throws Exception } @Test - public void issues304EvenWithWeakETag() throws Exception { + void issues304EvenWithWeakETag() throws Exception { final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo)); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java index e813b5ea6..02d22a80c 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java @@ -72,7 +72,7 @@ * This test class captures functionality required to achieve conditional * compliance with the HTTP/1.1 caching protocol (MUST and MUST NOT behaviors). */ -public class TestProtocolRequirements { +class TestProtocolRequirements { static final int MAX_BYTES = 1024; static final int MAX_ENTRIES = 100; @@ -95,7 +95,7 @@ public class TestProtocolRequirements { HttpCache cache; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { MockitoAnnotations.openMocks(this); host = new HttpHost("foo.example.com", 80); @@ -128,7 +128,7 @@ public ClassicHttpResponse execute(final ClassicHttpRequest request) throws IOEx } @Test - public void testCacheMissOnGETUsesOriginResponse() throws Exception { + void testCacheMissOnGETUsesOriginResponse() throws Exception { Mockito.when(mockExecChain.proceed(RequestEquivalent.eq(request), Mockito.any())).thenReturn(originResponse); @@ -149,7 +149,7 @@ private void testOrderOfMultipleHeadersIsPreservedOnResponses(final String h) th } @Test - public void testOrderOfMultipleAllowHeadersIsPreservedOnResponses() throws Exception { + void testOrderOfMultipleAllowHeadersIsPreservedOnResponses() throws Exception { originResponse = new BasicClassicHttpResponse(405, "Method Not Allowed"); originResponse.addHeader("Allow", "HEAD"); originResponse.addHeader("Allow", "DELETE"); @@ -157,35 +157,35 @@ public void testOrderOfMultipleAllowHeadersIsPreservedOnResponses() throws Excep } @Test - public void testOrderOfMultipleCacheControlHeadersIsPreservedOnResponses() throws Exception { + void testOrderOfMultipleCacheControlHeadersIsPreservedOnResponses() throws Exception { originResponse.addHeader("Cache-Control", "max-age=0"); originResponse.addHeader("Cache-Control", "no-store, must-revalidate"); testOrderOfMultipleHeadersIsPreservedOnResponses("Cache-Control"); } @Test - public void testOrderOfMultipleContentEncodingHeadersIsPreservedOnResponses() throws Exception { + void testOrderOfMultipleContentEncodingHeadersIsPreservedOnResponses() throws Exception { originResponse.addHeader("Content-Encoding", "gzip"); originResponse.addHeader("Content-Encoding", "compress"); testOrderOfMultipleHeadersIsPreservedOnResponses("Content-Encoding"); } @Test - public void testOrderOfMultipleContentLanguageHeadersIsPreservedOnResponses() throws Exception { + void testOrderOfMultipleContentLanguageHeadersIsPreservedOnResponses() throws Exception { originResponse.addHeader("Content-Language", "mi"); originResponse.addHeader("Content-Language", "en"); testOrderOfMultipleHeadersIsPreservedOnResponses("Content-Language"); } @Test - public void testOrderOfMultipleViaHeadersIsPreservedOnResponses() throws Exception { + void testOrderOfMultipleViaHeadersIsPreservedOnResponses() throws Exception { originResponse.addHeader(HttpHeaders.VIA, "1.0 fred, 1.1 nowhere.com (Apache/1.1)"); originResponse.addHeader(HttpHeaders.VIA, "1.0 ricky, 1.1 mertz, 1.0 lucy"); testOrderOfMultipleHeadersIsPreservedOnResponses(HttpHeaders.VIA); } @Test - public void testOrderOfMultipleWWWAuthenticateHeadersIsPreservedOnResponses() throws Exception { + void testOrderOfMultipleWWWAuthenticateHeadersIsPreservedOnResponses() throws Exception { originResponse.addHeader("WWW-Authenticate", "x-challenge-1"); originResponse.addHeader("WWW-Authenticate", "x-challenge-2"); testOrderOfMultipleHeadersIsPreservedOnResponses("WWW-Authenticate"); @@ -208,7 +208,7 @@ private void testUnknownResponseStatusCodeIsNotCached(final int code) throws Exc } @Test - public void testUnknownResponseStatusCodesAreNotCached() throws Exception { + void testUnknownResponseStatusCodesAreNotCached() throws Exception { for (int i = 100; i <= 199; i++) { testUnknownResponseStatusCodeIsNotCached(i); } @@ -227,7 +227,7 @@ public void testUnknownResponseStatusCodesAreNotCached() throws Exception { } @Test - public void testUnknownHeadersOnRequestsAreForwarded() throws Exception { + void testUnknownHeadersOnRequestsAreForwarded() throws Exception { request.addHeader("X-Unknown-Header", "blahblah"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -240,7 +240,7 @@ public void testUnknownHeadersOnRequestsAreForwarded() throws Exception { } @Test - public void testUnknownHeadersOnResponsesAreForwarded() throws Exception { + void testUnknownHeadersOnResponsesAreForwarded() throws Exception { originResponse.addHeader("X-Unknown-Header", "blahblah"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -249,7 +249,7 @@ public void testUnknownHeadersOnResponsesAreForwarded() throws Exception { } @Test - public void testResponsesToOPTIONSAreNotCacheable() throws Exception { + void testResponsesToOPTIONSAreNotCacheable() throws Exception { request = new BasicClassicHttpRequest("OPTIONS", "/"); originResponse.addHeader("Cache-Control", "max-age=3600"); @@ -261,7 +261,7 @@ public void testResponsesToOPTIONSAreNotCacheable() throws Exception { } @Test - public void testResponsesToPOSTWithoutCacheControlOrExpiresAreNotCached() throws Exception { + void testResponsesToPOSTWithoutCacheControlOrExpiresAreNotCached() throws Exception { final BasicClassicHttpRequest post = new BasicClassicHttpRequest("POST", "/"); post.setHeader("Content-Length", "128"); @@ -278,7 +278,7 @@ public void testResponsesToPOSTWithoutCacheControlOrExpiresAreNotCached() throws } @Test - public void testResponsesToPUTsAreNotCached() throws Exception { + void testResponsesToPUTsAreNotCached() throws Exception { final BasicClassicHttpRequest put = new BasicClassicHttpRequest("PUT", "/"); put.setEntity(HttpTestUtils.makeBody(128)); @@ -294,7 +294,7 @@ public void testResponsesToPUTsAreNotCached() throws Exception { } @Test - public void testResponsesToDELETEsAreNotCached() throws Exception { + void testResponsesToDELETEsAreNotCached() throws Exception { request = new BasicClassicHttpRequest("DELETE", "/"); originResponse.setHeader("Cache-Control", "max-age=3600"); @@ -307,7 +307,7 @@ public void testResponsesToDELETEsAreNotCached() throws Exception { } @Test - public void testResponsesToTRACEsAreNotCached() throws Exception { + void testResponsesToTRACEsAreNotCached() throws Exception { request = new BasicClassicHttpRequest("TRACE", "/"); originResponse.setHeader("Cache-Control", "max-age=3600"); @@ -320,7 +320,7 @@ public void testResponsesToTRACEsAreNotCached() throws Exception { } @Test - public void test304ResponseGeneratedFromCacheIncludesDateHeader() throws Exception { + void test304ResponseGeneratedFromCacheIncludesDateHeader() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); originResponse.setHeader("Cache-Control", "max-age=3600"); @@ -340,7 +340,7 @@ public void test304ResponseGeneratedFromCacheIncludesDateHeader() throws Excepti } @Test - public void test304ResponseGeneratedFromCacheIncludesEtagIfOriginResponseDid() throws Exception { + void test304ResponseGeneratedFromCacheIncludesEtagIfOriginResponseDid() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); originResponse.setHeader("Cache-Control", "max-age=3600"); originResponse.setHeader("ETag", "\"etag\""); @@ -359,7 +359,7 @@ public void test304ResponseGeneratedFromCacheIncludesEtagIfOriginResponseDid() t } @Test - public void test304ResponseGeneratedFromCacheIncludesContentLocationIfOriginResponseDid() throws Exception { + void test304ResponseGeneratedFromCacheIncludesContentLocationIfOriginResponseDid() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); originResponse.setHeader("Cache-Control", "max-age=3600"); originResponse.setHeader("Content-Location", "http://foo.example.com/other"); @@ -379,7 +379,7 @@ public void test304ResponseGeneratedFromCacheIncludesContentLocationIfOriginResp } @Test - public void test304ResponseGeneratedFromCacheIncludesExpiresCacheControlAndOrVaryIfResponseMightDiffer() throws Exception { + void test304ResponseGeneratedFromCacheIncludesExpiresCacheControlAndOrVaryIfResponseMightDiffer() throws Exception { final Instant now = Instant.now(); final Instant inTwoHours = now.plus(2, ChronoUnit.HOURS); @@ -426,7 +426,7 @@ public void test304ResponseGeneratedFromCacheIncludesExpiresCacheControlAndOrVar } @Test - public void test304GeneratedFromCacheOnWeakValidatorDoesNotIncludeOtherEntityHeaders() throws Exception { + void test304GeneratedFromCacheOnWeakValidatorDoesNotIncludeOtherEntityHeaders() throws Exception { final Instant now = Instant.now(); final Instant oneHourAgo = now.minus(1, ChronoUnit.HOURS); @@ -463,7 +463,7 @@ public void test304GeneratedFromCacheOnWeakValidatorDoesNotIncludeOtherEntityHea } @Test - public void testNotModifiedOfNonCachedEntityShouldRevalidateWithUnconditionalGET() throws Exception { + void testNotModifiedOfNonCachedEntityShouldRevalidateWithUnconditionalGET() throws Exception { final Instant now = Instant.now(); @@ -497,7 +497,7 @@ public void testNotModifiedOfNonCachedEntityShouldRevalidateWithUnconditionalGET } @Test - public void testCacheEntryIsUpdatedWithNewFieldValuesIn304Response() throws Exception { + void testCacheEntryIsUpdatedWithNewFieldValuesIn304Response() throws Exception { final Instant now = Instant.now(); final Instant inFiveSeconds = now.plusSeconds(5); @@ -539,7 +539,7 @@ public void testCacheEntryIsUpdatedWithNewFieldValuesIn304Response() throws Exce } @Test - public void testMustReturnACacheEntryIfItCanRevalidateIt() throws Exception { + void testMustReturnACacheEntryIfItCanRevalidateIt() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -594,7 +594,7 @@ public void testMustReturnACacheEntryIfItCanRevalidateIt() throws Exception { } @Test - public void testMustReturnAFreshEnoughCacheEntryIfItHasIt() throws Exception { + void testMustReturnAFreshEnoughCacheEntryIfItHasIt() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -624,7 +624,7 @@ public void testMustReturnAFreshEnoughCacheEntryIfItHasIt() throws Exception { } @Test - public void testAgeHeaderPopulatedFromCacheEntryCurrentAge() throws Exception { + void testAgeHeaderPopulatedFromCacheEntryCurrentAge() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -661,7 +661,7 @@ public void testAgeHeaderPopulatedFromCacheEntryCurrentAge() throws Exception { } @Test - public void testKeepsMostRecentDateHeaderForFreshResponse() throws Exception { + void testKeepsMostRecentDateHeaderForFreshResponse() throws Exception { final Instant now = Instant.now(); final Instant inFiveSecond = now.plusSeconds(5); @@ -699,7 +699,7 @@ public void testKeepsMostRecentDateHeaderForFreshResponse() throws Exception { } @Test - public void testValidationMustUseETagIfProvidedByOriginServer() throws Exception { + void testValidationMustUseETagIfProvidedByOriginServer() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -744,7 +744,7 @@ public void testValidationMustUseETagIfProvidedByOriginServer() throws Exception } @Test - public void testConditionalRequestWhereNotAllValidatorsMatchCannotBeServedFromCache() throws Exception { + void testConditionalRequestWhereNotAllValidatorsMatchCannotBeServedFromCache() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final Instant twentySecondsAgo = now.plusSeconds(20); @@ -771,7 +771,7 @@ public void testConditionalRequestWhereNotAllValidatorsMatchCannotBeServedFromCa } @Test - public void testConditionalRequestWhereAllValidatorsMatchMayBeServedFromCache() throws Exception { + void testConditionalRequestWhereAllValidatorsMatchMayBeServedFromCache() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -797,7 +797,7 @@ public void testConditionalRequestWhereAllValidatorsMatchMayBeServedFromCache() } @Test - public void testCacheWithoutSupportForRangeAndContentRangeHeadersDoesNotCacheA206Response() throws Exception { + void testCacheWithoutSupportForRangeAndContentRangeHeadersDoesNotCacheA206Response() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("GET", "/"); req.setHeader("Range", "bytes=0-50"); @@ -814,7 +814,7 @@ public void testCacheWithoutSupportForRangeAndContentRangeHeadersDoesNotCacheA20 } @Test - public void test302ResponseWithoutExplicitCacheabilityIsNotReturnedFromCache() throws Exception { + void test302ResponseWithoutExplicitCacheabilityIsNotReturnedFromCache() throws Exception { originResponse = new BasicClassicHttpResponse(302, "Temporary Redirect"); originResponse.setHeader("Location", "http://foo.example.com/other"); originResponse.removeHeaders("Expires"); @@ -840,24 +840,24 @@ private void testDoesNotModifyHeaderFromOrigin(final String header, final String } @Test - public void testDoesNotModifyContentLocationHeaderFromOrigin() throws Exception { + void testDoesNotModifyContentLocationHeaderFromOrigin() throws Exception { final String url = "http://foo.example.com/other"; testDoesNotModifyHeaderFromOrigin("Content-Location", url); } @Test - public void testDoesNotModifyContentMD5HeaderFromOrigin() throws Exception { + void testDoesNotModifyContentMD5HeaderFromOrigin() throws Exception { testDoesNotModifyHeaderFromOrigin("Content-MD5", "Q2hlY2sgSW50ZWdyaXR5IQ=="); } @Test - public void testDoesNotModifyEtagHeaderFromOrigin() throws Exception { + void testDoesNotModifyEtagHeaderFromOrigin() throws Exception { testDoesNotModifyHeaderFromOrigin("Etag", "\"the-etag\""); } @Test - public void testDoesNotModifyLastModifiedHeaderFromOrigin() throws Exception { + void testDoesNotModifyLastModifiedHeaderFromOrigin() throws Exception { final String lm = DateUtils.formatStandardDate(Instant.now()); testDoesNotModifyHeaderFromOrigin("Last-Modified", lm); } @@ -873,22 +873,22 @@ private void testDoesNotAddHeaderToOriginResponse(final String header) throws Ex } @Test - public void testDoesNotAddContentLocationToOriginResponse() throws Exception { + void testDoesNotAddContentLocationToOriginResponse() throws Exception { testDoesNotAddHeaderToOriginResponse("Content-Location"); } @Test - public void testDoesNotAddContentMD5ToOriginResponse() throws Exception { + void testDoesNotAddContentMD5ToOriginResponse() throws Exception { testDoesNotAddHeaderToOriginResponse("Content-MD5"); } @Test - public void testDoesNotAddEtagToOriginResponse() throws Exception { + void testDoesNotAddEtagToOriginResponse() throws Exception { testDoesNotAddHeaderToOriginResponse("ETag"); } @Test - public void testDoesNotAddLastModifiedToOriginResponse() throws Exception { + void testDoesNotAddLastModifiedToOriginResponse() throws Exception { testDoesNotAddHeaderToOriginResponse("Last-Modified"); } @@ -910,23 +910,23 @@ private void testDoesNotModifyHeaderFromOriginOnCacheHit(final String header, fi } @Test - public void testDoesNotModifyContentLocationFromOriginOnCacheHit() throws Exception { + void testDoesNotModifyContentLocationFromOriginOnCacheHit() throws Exception { final String url = "http://foo.example.com/other"; testDoesNotModifyHeaderFromOriginOnCacheHit("Content-Location", url); } @Test - public void testDoesNotModifyContentMD5FromOriginOnCacheHit() throws Exception { + void testDoesNotModifyContentMD5FromOriginOnCacheHit() throws Exception { testDoesNotModifyHeaderFromOriginOnCacheHit("Content-MD5", "Q2hlY2sgSW50ZWdyaXR5IQ=="); } @Test - public void testDoesNotModifyEtagFromOriginOnCacheHit() throws Exception { + void testDoesNotModifyEtagFromOriginOnCacheHit() throws Exception { testDoesNotModifyHeaderFromOriginOnCacheHit("Etag", "\"the-etag\""); } @Test - public void testDoesNotModifyLastModifiedFromOriginOnCacheHit() throws Exception { + void testDoesNotModifyLastModifiedFromOriginOnCacheHit() throws Exception { final Instant tenSecondsAgo = Instant.now().minusSeconds(10); testDoesNotModifyHeaderFromOriginOnCacheHit("Last-Modified", DateUtils.formatStandardDate(tenSecondsAgo)); } @@ -948,22 +948,22 @@ private void testDoesNotAddHeaderOnCacheHit(final String header) throws Exceptio } @Test - public void testDoesNotAddContentLocationHeaderOnCacheHit() throws Exception { + void testDoesNotAddContentLocationHeaderOnCacheHit() throws Exception { testDoesNotAddHeaderOnCacheHit("Content-Location"); } @Test - public void testDoesNotAddContentMD5HeaderOnCacheHit() throws Exception { + void testDoesNotAddContentMD5HeaderOnCacheHit() throws Exception { testDoesNotAddHeaderOnCacheHit("Content-MD5"); } @Test - public void testDoesNotAddETagHeaderOnCacheHit() throws Exception { + void testDoesNotAddETagHeaderOnCacheHit() throws Exception { testDoesNotAddHeaderOnCacheHit("ETag"); } @Test - public void testDoesNotAddLastModifiedHeaderOnCacheHit() throws Exception { + void testDoesNotAddLastModifiedHeaderOnCacheHit() throws Exception { testDoesNotAddHeaderOnCacheHit("Last-Modified"); } @@ -983,23 +983,23 @@ private void testDoesNotModifyHeaderOnRequest(final String header, final String } @Test - public void testDoesNotModifyContentLocationHeaderOnRequest() throws Exception { + void testDoesNotModifyContentLocationHeaderOnRequest() throws Exception { final String url = "http://foo.example.com/other"; testDoesNotModifyHeaderOnRequest("Content-Location",url); } @Test - public void testDoesNotModifyContentMD5HeaderOnRequest() throws Exception { + void testDoesNotModifyContentMD5HeaderOnRequest() throws Exception { testDoesNotModifyHeaderOnRequest("Content-MD5", "Q2hlY2sgSW50ZWdyaXR5IQ=="); } @Test - public void testDoesNotModifyETagHeaderOnRequest() throws Exception { + void testDoesNotModifyETagHeaderOnRequest() throws Exception { testDoesNotModifyHeaderOnRequest("ETag","\"etag\""); } @Test - public void testDoesNotModifyLastModifiedHeaderOnRequest() throws Exception { + void testDoesNotModifyLastModifiedHeaderOnRequest() throws Exception { final Instant tenSecondsAgo = Instant.now().minusSeconds(10); testDoesNotModifyHeaderOnRequest("Last-Modified", DateUtils.formatStandardDate(tenSecondsAgo)); } @@ -1022,39 +1022,39 @@ private void testDoesNotAddHeaderToRequestIfNotPresent(final String header) thro } @Test - public void testDoesNotAddContentLocationToRequestIfNotPresent() throws Exception { + void testDoesNotAddContentLocationToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("Content-Location"); } @Test - public void testDoesNotAddContentMD5ToRequestIfNotPresent() throws Exception { + void testDoesNotAddContentMD5ToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("Content-MD5"); } @Test - public void testDoesNotAddETagToRequestIfNotPresent() throws Exception { + void testDoesNotAddETagToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("ETag"); } @Test - public void testDoesNotAddLastModifiedToRequestIfNotPresent() throws Exception { + void testDoesNotAddLastModifiedToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("Last-Modified"); } @Test - public void testDoesNotModifyExpiresHeaderFromOrigin() throws Exception { + void testDoesNotModifyExpiresHeaderFromOrigin() throws Exception { final Instant tenSecondsAgo = Instant.now().minusSeconds(10); testDoesNotModifyHeaderFromOrigin("Expires", DateUtils.formatStandardDate(tenSecondsAgo)); } @Test - public void testDoesNotModifyExpiresHeaderFromOriginOnCacheHit() throws Exception { + void testDoesNotModifyExpiresHeaderFromOriginOnCacheHit() throws Exception { final Instant inTenSeconds = Instant.now().plusSeconds(10); testDoesNotModifyHeaderFromOriginOnCacheHit("Expires", DateUtils.formatStandardDate(inTenSeconds)); } @Test - public void testExpiresHeaderMatchesDateIfAddedToOriginResponse() throws Exception { + void testExpiresHeaderMatchesDateIfAddedToOriginResponse() throws Exception { originResponse.removeHeaders("Expires"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -1080,12 +1080,12 @@ private void testDoesNotModifyHeaderFromOriginResponseWithNoTransform(final Stri } @Test - public void testDoesNotModifyContentEncodingHeaderFromOriginResponseWithNoTransform() throws Exception { + void testDoesNotModifyContentEncodingHeaderFromOriginResponseWithNoTransform() throws Exception { testDoesNotModifyHeaderFromOriginResponseWithNoTransform("Content-Encoding","gzip"); } @Test - public void testDoesNotModifyContentRangeHeaderFromOriginResponseWithNoTransform() throws Exception { + void testDoesNotModifyContentRangeHeaderFromOriginResponseWithNoTransform() throws Exception { request.setHeader("If-Range","\"etag\""); request.setHeader("Range","bytes=0-49"); @@ -1095,7 +1095,7 @@ public void testDoesNotModifyContentRangeHeaderFromOriginResponseWithNoTransform } @Test - public void testDoesNotModifyContentTypeHeaderFromOriginResponseWithNoTransform() throws Exception { + void testDoesNotModifyContentTypeHeaderFromOriginResponseWithNoTransform() throws Exception { testDoesNotModifyHeaderFromOriginResponseWithNoTransform("Content-Type","text/html;charset=utf-8"); } @@ -1115,85 +1115,85 @@ private void testDoesNotModifyHeaderOnCachedResponseWithNoTransform(final String } @Test - public void testDoesNotModifyContentEncodingHeaderOnCachedResponseWithNoTransform() throws Exception { + void testDoesNotModifyContentEncodingHeaderOnCachedResponseWithNoTransform() throws Exception { testDoesNotModifyHeaderOnCachedResponseWithNoTransform("Content-Encoding","gzip"); } @Test - public void testDoesNotModifyContentTypeHeaderOnCachedResponseWithNoTransform() throws Exception { + void testDoesNotModifyContentTypeHeaderOnCachedResponseWithNoTransform() throws Exception { testDoesNotModifyHeaderOnCachedResponseWithNoTransform("Content-Type","text/html;charset=utf-8"); } @Test - public void testDoesNotAddContentEncodingHeaderToOriginResponseWithNoTransformIfNotPresent() throws Exception { + void testDoesNotAddContentEncodingHeaderToOriginResponseWithNoTransformIfNotPresent() throws Exception { originResponse.addHeader("Cache-Control","no-transform"); testDoesNotAddHeaderToOriginResponse("Content-Encoding"); } @Test - public void testDoesNotAddContentRangeHeaderToOriginResponseWithNoTransformIfNotPresent() throws Exception { + void testDoesNotAddContentRangeHeaderToOriginResponseWithNoTransformIfNotPresent() throws Exception { originResponse.addHeader("Cache-Control","no-transform"); testDoesNotAddHeaderToOriginResponse("Content-Range"); } @Test - public void testDoesNotAddContentTypeHeaderToOriginResponseWithNoTransformIfNotPresent() throws Exception { + void testDoesNotAddContentTypeHeaderToOriginResponseWithNoTransformIfNotPresent() throws Exception { originResponse.addHeader("Cache-Control","no-transform"); testDoesNotAddHeaderToOriginResponse("Content-Type"); } /* no add on cache hit with no-transform */ @Test - public void testDoesNotAddContentEncodingHeaderToCachedResponseWithNoTransformIfNotPresent() throws Exception { + void testDoesNotAddContentEncodingHeaderToCachedResponseWithNoTransformIfNotPresent() throws Exception { originResponse.addHeader("Cache-Control","no-transform"); testDoesNotAddHeaderOnCacheHit("Content-Encoding"); } @Test - public void testDoesNotAddContentRangeHeaderToCachedResponseWithNoTransformIfNotPresent() throws Exception { + void testDoesNotAddContentRangeHeaderToCachedResponseWithNoTransformIfNotPresent() throws Exception { originResponse.addHeader("Cache-Control","no-transform"); testDoesNotAddHeaderOnCacheHit("Content-Range"); } @Test - public void testDoesNotAddContentTypeHeaderToCachedResponseWithNoTransformIfNotPresent() throws Exception { + void testDoesNotAddContentTypeHeaderToCachedResponseWithNoTransformIfNotPresent() throws Exception { originResponse.addHeader("Cache-Control","no-transform"); testDoesNotAddHeaderOnCacheHit("Content-Type"); } /* no modify on request */ @Test - public void testDoesNotAddContentEncodingToRequestIfNotPresent() throws Exception { + void testDoesNotAddContentEncodingToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("Content-Encoding"); } @Test - public void testDoesNotAddContentRangeToRequestIfNotPresent() throws Exception { + void testDoesNotAddContentRangeToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("Content-Range"); } @Test - public void testDoesNotAddContentTypeToRequestIfNotPresent() throws Exception { + void testDoesNotAddContentTypeToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("Content-Type"); } @Test - public void testDoesNotAddContentEncodingHeaderToRequestIfNotPresent() throws Exception { + void testDoesNotAddContentEncodingHeaderToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("Content-Encoding"); } @Test - public void testDoesNotAddContentRangeHeaderToRequestIfNotPresent() throws Exception { + void testDoesNotAddContentRangeHeaderToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("Content-Range"); } @Test - public void testDoesNotAddContentTypeHeaderToRequestIfNotPresent() throws Exception { + void testDoesNotAddContentTypeHeaderToRequestIfNotPresent() throws Exception { testDoesNotAddHeaderToRequestIfNotPresent("Content-Type"); } @Test - public void testCachedEntityBodyIsUsedForResponseAfter304Validation() throws Exception { + void testCachedEntityBodyIsUsedForResponseAfter304Validation() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Cache-Control","max-age=3600"); @@ -1238,7 +1238,7 @@ private void decorateWithEndToEndHeaders(final ClassicHttpResponse r) { } @Test - public void testResponseIncludesCacheEntryEndToEndHeadersForResponseAfter304Validation() throws Exception { + void testResponseIncludesCacheEntryEndToEndHeadersForResponseAfter304Validation() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Cache-Control","max-age=3600"); @@ -1271,7 +1271,7 @@ public void testResponseIncludesCacheEntryEndToEndHeadersForResponseAfter304Vali } @Test - public void testUpdatedEndToEndHeadersFrom304ArePassedOnResponseAndUpdatedInCacheEntry() throws Exception { + void testUpdatedEndToEndHeadersFrom304ArePassedOnResponseAndUpdatedInCacheEntry() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -1317,7 +1317,7 @@ public void testUpdatedEndToEndHeadersFrom304ArePassedOnResponseAndUpdatedInCach } @Test - public void testMultiHeadersAreSuccessfullyReplacedOn304Validation() throws Exception { + void testMultiHeadersAreSuccessfullyReplacedOn304Validation() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.addHeader("Cache-Control","max-age=3600"); @@ -1348,7 +1348,7 @@ public void testMultiHeadersAreSuccessfullyReplacedOn304Validation() throws Exce } @Test - public void testCannotUseVariantCacheEntryIfNotAllSelectingRequestHeadersMatch() throws Exception { + void testCannotUseVariantCacheEntryIfNotAllSelectingRequestHeadersMatch() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); req1.setHeader("Accept-Encoding","gzip"); @@ -1378,7 +1378,7 @@ public void testCannotUseVariantCacheEntryIfNotAllSelectingRequestHeadersMatch() } @Test - public void testCannotServeFromCacheForVaryStar() throws Exception { + void testCannotServeFromCacheForVaryStar() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -1405,7 +1405,7 @@ public void testCannotServeFromCacheForVaryStar() throws Exception { } @Test - public void testNonMatchingVariantCannotBeServedFromCacheUnlessConditionallyValidated() throws Exception { + void testNonMatchingVariantCannotBeServedFromCacheUnlessConditionallyValidated() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); req1.setHeader("User-Agent","MyBrowser/1.0"); @@ -1473,19 +1473,19 @@ protected ClassicHttpRequest makeRequestWithBody(final String method, final Stri } @Test - public void testPutToUriInvalidatesCacheForThatUri() throws Exception { + void testPutToUriInvalidatesCacheForThatUri() throws Exception { final ClassicHttpRequest req = makeRequestWithBody("PUT","/"); testUnsafeOperationInvalidatesCacheForThatUri(req); } @Test - public void testDeleteToUriInvalidatesCacheForThatUri() throws Exception { + void testDeleteToUriInvalidatesCacheForThatUri() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("DELETE","/"); testUnsafeOperationInvalidatesCacheForThatUri(req); } @Test - public void testPostToUriInvalidatesCacheForThatUri() throws Exception { + void testPostToUriInvalidatesCacheForThatUri() throws Exception { final ClassicHttpRequest req = makeRequestWithBody("POST","/"); testUnsafeOperationInvalidatesCacheForThatUri(req); } @@ -1535,55 +1535,55 @@ protected void testUnsafeMethodInvalidatesCacheForUriInLocationHeader( } @Test - public void testPutInvalidatesCacheForThatUriInContentLocationHeader() throws Exception { + void testPutInvalidatesCacheForThatUriInContentLocationHeader() throws Exception { final ClassicHttpRequest req2 = makeRequestWithBody("PUT","/"); testUnsafeMethodInvalidatesCacheForUriInContentLocationHeader(req2); } @Test - public void testPutInvalidatesCacheForThatUriInLocationHeader() throws Exception { + void testPutInvalidatesCacheForThatUriInLocationHeader() throws Exception { final ClassicHttpRequest req = makeRequestWithBody("PUT","/"); testUnsafeMethodInvalidatesCacheForUriInLocationHeader(req); } @Test - public void testPutInvalidatesCacheForThatUriInRelativeContentLocationHeader() throws Exception { + void testPutInvalidatesCacheForThatUriInRelativeContentLocationHeader() throws Exception { final ClassicHttpRequest req = makeRequestWithBody("PUT","/"); testUnsafeMethodInvalidatesCacheForRelativeUriInContentLocationHeader(req); } @Test - public void testDeleteInvalidatesCacheForThatUriInContentLocationHeader() throws Exception { + void testDeleteInvalidatesCacheForThatUriInContentLocationHeader() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("DELETE", "/"); testUnsafeMethodInvalidatesCacheForUriInContentLocationHeader(req); } @Test - public void testDeleteInvalidatesCacheForThatUriInRelativeContentLocationHeader() throws Exception { + void testDeleteInvalidatesCacheForThatUriInRelativeContentLocationHeader() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("DELETE", "/"); testUnsafeMethodInvalidatesCacheForRelativeUriInContentLocationHeader(req); } @Test - public void testDeleteInvalidatesCacheForThatUriInLocationHeader() throws Exception { + void testDeleteInvalidatesCacheForThatUriInLocationHeader() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("DELETE", "/"); testUnsafeMethodInvalidatesCacheForUriInLocationHeader(req); } @Test - public void testPostInvalidatesCacheForThatUriInContentLocationHeader() throws Exception { + void testPostInvalidatesCacheForThatUriInContentLocationHeader() throws Exception { final ClassicHttpRequest req = makeRequestWithBody("POST","/"); testUnsafeMethodInvalidatesCacheForUriInContentLocationHeader(req); } @Test - public void testPostInvalidatesCacheForThatUriInLocationHeader() throws Exception { + void testPostInvalidatesCacheForThatUriInLocationHeader() throws Exception { final ClassicHttpRequest req = makeRequestWithBody("POST","/"); testUnsafeMethodInvalidatesCacheForUriInLocationHeader(req); } @Test - public void testPostInvalidatesCacheForRelativeUriInContentLocationHeader() throws Exception { + void testPostInvalidatesCacheForRelativeUriInContentLocationHeader() throws Exception { final ClassicHttpRequest req = makeRequestWithBody("POST","/"); testUnsafeMethodInvalidatesCacheForRelativeUriInContentLocationHeader(req); } @@ -1597,13 +1597,13 @@ private void testRequestIsWrittenThroughToOrigin(final ClassicHttpRequest req) t } @Test - public void testOPTIONSRequestsAreWrittenThroughToOrigin() throws Exception { + void testOPTIONSRequestsAreWrittenThroughToOrigin() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("OPTIONS","*"); testRequestIsWrittenThroughToOrigin(req); } @Test - public void testPOSTRequestsAreWrittenThroughToOrigin() throws Exception { + void testPOSTRequestsAreWrittenThroughToOrigin() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("POST","/"); req.setEntity(HttpTestUtils.makeBody(128)); req.setHeader("Content-Length","128"); @@ -1611,7 +1611,7 @@ public void testPOSTRequestsAreWrittenThroughToOrigin() throws Exception { } @Test - public void testPUTRequestsAreWrittenThroughToOrigin() throws Exception { + void testPUTRequestsAreWrittenThroughToOrigin() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("PUT","/"); req.setEntity(HttpTestUtils.makeBody(128)); req.setHeader("Content-Length","128"); @@ -1619,31 +1619,31 @@ public void testPUTRequestsAreWrittenThroughToOrigin() throws Exception { } @Test - public void testDELETERequestsAreWrittenThroughToOrigin() throws Exception { + void testDELETERequestsAreWrittenThroughToOrigin() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("DELETE", "/"); testRequestIsWrittenThroughToOrigin(req); } @Test - public void testTRACERequestsAreWrittenThroughToOrigin() throws Exception { + void testTRACERequestsAreWrittenThroughToOrigin() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("TRACE","/"); testRequestIsWrittenThroughToOrigin(req); } @Test - public void testCONNECTRequestsAreWrittenThroughToOrigin() throws Exception { + void testCONNECTRequestsAreWrittenThroughToOrigin() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("CONNECT","/"); testRequestIsWrittenThroughToOrigin(req); } @Test - public void testUnknownMethodRequestsAreWrittenThroughToOrigin() throws Exception { + void testUnknownMethodRequestsAreWrittenThroughToOrigin() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("UNKNOWN","/"); testRequestIsWrittenThroughToOrigin(req); } @Test - public void testTransmitsAgeHeaderIfIncomingAgeHeaderTooBig() throws Exception { + void testTransmitsAgeHeaderIfIncomingAgeHeaderTooBig() throws Exception { final String reallyOldAge = "1" + Long.MAX_VALUE; originResponse.setHeader("Age",reallyOldAge); @@ -1656,7 +1656,7 @@ public void testTransmitsAgeHeaderIfIncomingAgeHeaderTooBig() throws Exception { } @Test - public void testDoesNotModifyAllowHeaderWithUnknownMethods() throws Exception { + void testDoesNotModifyAllowHeaderWithUnknownMethods() throws Exception { final String allowHeaderValue = "GET, HEAD, FOOBAR"; originResponse.setHeader("Allow",allowHeaderValue); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -1690,7 +1690,7 @@ protected void testSharedCacheRevalidatesAuthorizedResponse( } @Test - public void testSharedCacheMustNotNormallyCacheAuthorizedResponses() throws Exception { + void testSharedCacheMustNotNormallyCacheAuthorizedResponses() throws Exception { final ClassicHttpResponse resp = HttpTestUtils.make200Response(); resp.setHeader("Cache-Control","max-age=3600"); resp.setHeader("ETag","\"etag\""); @@ -1698,7 +1698,7 @@ public void testSharedCacheMustNotNormallyCacheAuthorizedResponses() throws Exce } @Test - public void testSharedCacheMayCacheAuthorizedResponsesWithSMaxAgeHeader() throws Exception { + void testSharedCacheMayCacheAuthorizedResponsesWithSMaxAgeHeader() throws Exception { final ClassicHttpResponse resp = HttpTestUtils.make200Response(); resp.setHeader("Cache-Control","s-maxage=3600"); resp.setHeader("ETag","\"etag\""); @@ -1706,7 +1706,7 @@ public void testSharedCacheMayCacheAuthorizedResponsesWithSMaxAgeHeader() throws } @Test - public void testSharedCacheMustRevalidateAuthorizedResponsesWhenSMaxAgeIsZero() throws Exception { + void testSharedCacheMustRevalidateAuthorizedResponsesWhenSMaxAgeIsZero() throws Exception { final ClassicHttpResponse resp = HttpTestUtils.make200Response(); resp.setHeader("Cache-Control","s-maxage=0"); resp.setHeader("ETag","\"etag\""); @@ -1714,7 +1714,7 @@ public void testSharedCacheMustRevalidateAuthorizedResponsesWhenSMaxAgeIsZero() } @Test - public void testSharedCacheMayCacheAuthorizedResponsesWithMustRevalidate() throws Exception { + void testSharedCacheMayCacheAuthorizedResponsesWithMustRevalidate() throws Exception { final ClassicHttpResponse resp = HttpTestUtils.make200Response(); resp.setHeader("Cache-Control","must-revalidate"); resp.setHeader("ETag","\"etag\""); @@ -1722,7 +1722,7 @@ public void testSharedCacheMayCacheAuthorizedResponsesWithMustRevalidate() throw } @Test - public void testSharedCacheMayCacheAuthorizedResponsesWithCacheControlPublic() throws Exception { + void testSharedCacheMayCacheAuthorizedResponsesWithCacheControlPublic() throws Exception { final ClassicHttpResponse resp = HttpTestUtils.make200Response(); resp.setHeader("Cache-Control","public"); testSharedCacheRevalidatesAuthorizedResponse(resp, 0, 1); @@ -1763,7 +1763,7 @@ protected void testSharedCacheMustUseNewRequestHeadersWhenRevalidatingAuthorized } @Test - public void testSharedCacheMustUseNewRequestHeadersWhenRevalidatingAuthorizedResponsesWithSMaxAge() throws Exception { + void testSharedCacheMustUseNewRequestHeadersWhenRevalidatingAuthorizedResponsesWithSMaxAge() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -1775,7 +1775,7 @@ public void testSharedCacheMustUseNewRequestHeadersWhenRevalidatingAuthorizedRes } @Test - public void testSharedCacheMustUseNewRequestHeadersWhenRevalidatingAuthorizedResponsesWithMustRevalidate() throws Exception { + void testSharedCacheMustUseNewRequestHeadersWhenRevalidatingAuthorizedResponsesWithMustRevalidate() throws Exception { final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -1814,7 +1814,7 @@ protected void testCacheIsNotUsedWhenRespondingToRequest(final ClassicHttpReques } @Test - public void testCacheIsNotUsedWhenRespondingToRequestWithCacheControlNoCache() throws Exception { + void testCacheIsNotUsedWhenRespondingToRequestWithCacheControlNoCache() throws Exception { final ClassicHttpRequest req = new BasicClassicHttpRequest("GET", "/"); req.setHeader("Cache-Control","no-cache"); testCacheIsNotUsedWhenRespondingToRequest(req); @@ -1856,7 +1856,7 @@ protected void testStaleCacheResponseMustBeRevalidatedWithOrigin( } @Test - public void testStaleEntryWithMustRevalidateIsNotUsedWithoutRevalidatingWithOrigin() throws Exception { + void testStaleEntryWithMustRevalidateIsNotUsedWithoutRevalidatingWithOrigin() throws Exception { final ClassicHttpResponse response = HttpTestUtils.make200Response(); final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -1886,7 +1886,7 @@ protected void testGenerates504IfCannotRevalidateStaleResponse( } @Test - public void testGenerates504IfCannotRevalidateAMustRevalidateEntry() throws Exception { + void testGenerates504IfCannotRevalidateAMustRevalidateEntry() throws Exception { final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -1898,7 +1898,7 @@ public void testGenerates504IfCannotRevalidateAMustRevalidateEntry() throws Exce } @Test - public void testStaleEntryWithProxyRevalidateOnSharedCacheIsNotUsedWithoutRevalidatingWithOrigin() throws Exception { + void testStaleEntryWithProxyRevalidateOnSharedCacheIsNotUsedWithoutRevalidatingWithOrigin() throws Exception { if (config.isSharedCache()) { final ClassicHttpResponse response = HttpTestUtils.make200Response(); final Instant now = Instant.now(); @@ -1912,7 +1912,7 @@ public void testStaleEntryWithProxyRevalidateOnSharedCacheIsNotUsedWithoutRevali } @Test - public void testGenerates504IfSharedCacheCannotRevalidateAProxyRevalidateEntry() throws Exception { + void testGenerates504IfSharedCacheCannotRevalidateAProxyRevalidateEntry() throws Exception { if (config.isSharedCache()) { final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); final Instant now = Instant.now(); @@ -1926,7 +1926,7 @@ public void testGenerates504IfSharedCacheCannotRevalidateAProxyRevalidateEntry() } @Test - public void testCacheControlPrivateIsNotCacheableBySharedCache() throws Exception { + void testCacheControlPrivateIsNotCacheableBySharedCache() throws Exception { if (config.isSharedCache()) { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -1945,7 +1945,7 @@ public void testCacheControlPrivateIsNotCacheableBySharedCache() throws Exceptio } @Test - public void testCacheControlPrivateOnFieldIsNotReturnedBySharedCache() throws Exception { + void testCacheControlPrivateOnFieldIsNotReturnedBySharedCache() throws Exception { if (config.isSharedCache()) { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); @@ -1970,7 +1970,7 @@ public void testCacheControlPrivateOnFieldIsNotReturnedBySharedCache() throws Ex } @Test - public void testNoCacheCannotSatisfyASubsequentRequestWithoutRevalidation() throws Exception { + void testNoCacheCannotSatisfyASubsequentRequestWithoutRevalidation() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("ETag","\"etag\""); @@ -1992,7 +1992,7 @@ public void testNoCacheCannotSatisfyASubsequentRequestWithoutRevalidation() thro } @Test - public void testNoCacheCannotSatisfyASubsequentRequestWithoutRevalidationEvenWithContraryIndications() throws Exception { + void testNoCacheCannotSatisfyASubsequentRequestWithoutRevalidationEvenWithContraryIndications() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("ETag","\"etag\""); @@ -2013,7 +2013,7 @@ public void testNoCacheCannotSatisfyASubsequentRequestWithoutRevalidationEvenWit } @Test - public void testNoCacheOnFieldIsNotReturnedWithoutRevalidation() throws Exception { + void testNoCacheOnFieldIsNotReturnedWithoutRevalidation() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("ETag","\"etag\""); @@ -2044,7 +2044,7 @@ public void testNoCacheOnFieldIsNotReturnedWithoutRevalidation() throws Exceptio } @Test - public void testNoStoreOnRequestIsNotStoredInCache() throws Exception { + void testNoStoreOnRequestIsNotStoredInCache() throws Exception { request.setHeader("Cache-Control","no-store"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -2054,7 +2054,7 @@ public void testNoStoreOnRequestIsNotStoredInCache() throws Exception { } @Test - public void testNoStoreOnRequestIsNotStoredInCacheEvenIfResponseMarkedCacheable() throws Exception { + void testNoStoreOnRequestIsNotStoredInCacheEvenIfResponseMarkedCacheable() throws Exception { request.setHeader("Cache-Control","no-store"); originResponse.setHeader("Cache-Control","max-age=3600"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -2065,7 +2065,7 @@ public void testNoStoreOnRequestIsNotStoredInCacheEvenIfResponseMarkedCacheable( } @Test - public void testNoStoreOnResponseIsNotStoredInCache() throws Exception { + void testNoStoreOnResponseIsNotStoredInCache() throws Exception { originResponse.setHeader("Cache-Control","no-store"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -2075,7 +2075,7 @@ public void testNoStoreOnResponseIsNotStoredInCache() throws Exception { } @Test - public void testNoStoreOnResponseIsNotStoredInCacheEvenWithContraryIndicators() throws Exception { + void testNoStoreOnResponseIsNotStoredInCacheEvenWithContraryIndicators() throws Exception { originResponse.setHeader("Cache-Control","no-store,max-age=3600"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -2085,7 +2085,7 @@ public void testNoStoreOnResponseIsNotStoredInCacheEvenWithContraryIndicators() } @Test - public void testOrderOfMultipleContentEncodingHeaderValuesIsPreserved() throws Exception { + void testOrderOfMultipleContentEncodingHeaderValuesIsPreserved() throws Exception { originResponse.addHeader("Content-Encoding","gzip"); originResponse.addHeader("Content-Encoding","deflate"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -2111,7 +2111,7 @@ public void testOrderOfMultipleContentEncodingHeaderValuesIsPreserved() throws E } @Test - public void testOrderOfMultipleParametersInContentEncodingHeaderIsPreserved() throws Exception { + void testOrderOfMultipleParametersInContentEncodingHeaderIsPreserved() throws Exception { originResponse.addHeader("Content-Encoding","gzip,deflate"); Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(originResponse); @@ -2136,7 +2136,7 @@ public void testOrderOfMultipleParametersInContentEncodingHeaderIsPreserved() th } @Test - public void testCacheDoesNotAssumeContentLocationHeaderIndicatesAnotherCacheableResource() throws Exception { + void testCacheDoesNotAssumeContentLocationHeaderIndicatesAnotherCacheableResource() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/foo"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Cache-Control","public,max-age=3600"); @@ -2157,7 +2157,7 @@ public void testCacheDoesNotAssumeContentLocationHeaderIndicatesAnotherCacheable } @Test - public void testCachedResponsesWithMissingDateHeadersShouldBeAssignedOne() throws Exception { + void testCachedResponsesWithMissingDateHeadersShouldBeAssignedOne() throws Exception { originResponse.removeHeaders("Date"); originResponse.setHeader("Cache-Control","public"); originResponse.setHeader("ETag","\"etag\""); @@ -2189,17 +2189,17 @@ private void testInvalidExpiresHeaderIsTreatedAsStale( } @Test - public void testMalformedExpiresHeaderIsTreatedAsStale() throws Exception { + void testMalformedExpiresHeaderIsTreatedAsStale() throws Exception { testInvalidExpiresHeaderIsTreatedAsStale("garbage"); } @Test - public void testExpiresZeroHeaderIsTreatedAsStale() throws Exception { + void testExpiresZeroHeaderIsTreatedAsStale() throws Exception { testInvalidExpiresHeaderIsTreatedAsStale("0"); } @Test - public void testExpiresHeaderEqualToDateHeaderIsTreatedAsStale() throws Exception { + void testExpiresHeaderEqualToDateHeaderIsTreatedAsStale() throws Exception { final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); resp1.setHeader("Cache-Control","public"); @@ -2219,7 +2219,7 @@ public void testExpiresHeaderEqualToDateHeaderIsTreatedAsStale() throws Exceptio } @Test - public void testDoesNotModifyServerResponseHeader() throws Exception { + void testDoesNotModifyServerResponseHeader() throws Exception { final String server = "MockServer/1.0"; originResponse.setHeader("Server", server); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java index 6d7114d16..1d43834ca 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java @@ -61,7 +61,7 @@ * describes the stale-if-error and stale-while-revalidate * Cache-Control extensions. */ -public class TestRFC5861Compliance { +class TestRFC5861Compliance { static final int MAX_BYTES = 1024; static final int MAX_ENTRIES = 100; @@ -83,7 +83,7 @@ public class TestRFC5861Compliance { ScheduledExecutorService executorService; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { MockitoAnnotations.openMocks(this); host = new HttpHost("foo.example.com", 80); @@ -113,7 +113,7 @@ public void setUp() throws Exception { } @AfterEach - public void cleanup() { + void cleanup() { executorService.shutdownNow(); } @@ -125,7 +125,7 @@ public ClassicHttpResponse execute(final ClassicHttpRequest request) throws IOEx } @Test - public void testConsumesErrorResponseWhenServingStale() + void testConsumesErrorResponseWhenServingStale() throws Exception{ final Instant tenSecondsAgo = Instant.now().minusSeconds(10); final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); @@ -152,7 +152,7 @@ public void testConsumesErrorResponseWhenServingStale() } @Test - public void testStaleIfErrorInResponseYieldsToMustRevalidate() + void testStaleIfErrorInResponseYieldsToMustRevalidate() throws Exception{ final Instant tenSecondsAgo = Instant.now().minusSeconds(10); final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); @@ -174,7 +174,7 @@ public void testStaleIfErrorInResponseYieldsToMustRevalidate() } @Test - public void testStaleIfErrorInResponseYieldsToProxyRevalidateForSharedCache() + void testStaleIfErrorInResponseYieldsToProxyRevalidateForSharedCache() throws Exception{ assertTrue(config.isSharedCache()); final Instant tenSecondsAgo = Instant.now().minusSeconds(10); @@ -197,7 +197,7 @@ public void testStaleIfErrorInResponseYieldsToProxyRevalidateForSharedCache() } @Test - public void testStaleIfErrorInResponseYieldsToExplicitFreshnessRequest() + void testStaleIfErrorInResponseYieldsToExplicitFreshnessRequest() throws Exception{ final Instant tenSecondsAgo = Instant.now().minusSeconds(10); final ClassicHttpRequest req1 = HttpTestUtils.makeDefaultRequest(); @@ -220,7 +220,7 @@ public void testStaleIfErrorInResponseYieldsToExplicitFreshnessRequest() } @Test - public void testStaleIfErrorInResponseIsFalseReturnsError() + void testStaleIfErrorInResponseIsFalseReturnsError() throws Exception{ final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); @@ -244,7 +244,7 @@ public void testStaleIfErrorInResponseIsFalseReturnsError() } @Test - public void testStaleIfErrorInRequestIsFalseReturnsError() + void testStaleIfErrorInRequestIsFalseReturnsError() throws Exception{ final Instant now = Instant.now(); final Instant tenSecondsAgo = now.minusSeconds(10); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCacheConformance.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCacheConformance.java index c35247898..df347b7b8 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCacheConformance.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCacheConformance.java @@ -37,12 +37,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestResponseCacheConformance { +class TestResponseCacheConformance { private ResponseCacheConformance impl; @BeforeEach - public void setUp() { + void setUp() { impl = ResponseCacheConformance.INSTANCE; } @@ -58,31 +58,31 @@ private void shouldStripEntityHeaderFromOrigin304ResponseToStrongValidation( } @Test - public void shouldStripContentEncodingFromOrigin304ResponseToStrongValidation() throws Exception { + void shouldStripContentEncodingFromOrigin304ResponseToStrongValidation() throws Exception { shouldStripEntityHeaderFromOrigin304ResponseToStrongValidation( "Content-Encoding", "gzip"); } @Test - public void shouldStripContentLanguageFromOrigin304ResponseToStrongValidation() throws Exception { + void shouldStripContentLanguageFromOrigin304ResponseToStrongValidation() throws Exception { shouldStripEntityHeaderFromOrigin304ResponseToStrongValidation( "Content-Language", "en"); } @Test - public void shouldStripContentLengthFromOrigin304ResponseToStrongValidation() throws Exception { + void shouldStripContentLengthFromOrigin304ResponseToStrongValidation() throws Exception { shouldStripEntityHeaderFromOrigin304ResponseToStrongValidation( "Content-Length", "128"); } @Test - public void shouldStripContentMD5FromOrigin304ResponseToStrongValidation() throws Exception { + void shouldStripContentMD5FromOrigin304ResponseToStrongValidation() throws Exception { shouldStripEntityHeaderFromOrigin304ResponseToStrongValidation( "Content-MD5", "Q2hlY2sgSW50ZWdyaXR5IQ=="); } @Test - public void shouldStripContentTypeFromOrigin304ResponseToStrongValidation() throws Exception { + void shouldStripContentTypeFromOrigin304ResponseToStrongValidation() throws Exception { shouldStripEntityHeaderFromOrigin304ResponseToStrongValidation( "Content-Type", "text/html;charset=utf-8"); } diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java index c2c5cb53d..d87debe50 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestResponseCachingPolicy.java @@ -50,7 +50,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestResponseCachingPolicy { +class TestResponseCachingPolicy { private ResponseCachingPolicy policy; private HttpResponse response; @@ -64,7 +64,7 @@ public class TestResponseCachingPolicy { private ResponseCacheControl responseCacheControl; @BeforeEach - public void setUp() throws Exception { + void setUp() { now = Instant.now(); sixSecondsAgo = now.minusSeconds(6); tenSecondsFromNow = now.plusSeconds(10); @@ -78,21 +78,21 @@ public void setUp() throws Exception { } @Test - public void testGetCacheable() { + void testGetCacheable() { policy = new ResponseCachingPolicy(true, false, false); request = new BasicHttpRequest(Method.GET, "/"); Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testHeadCacheable() { + void testHeadCacheable() { policy = new ResponseCachingPolicy(true, false, false); request = new BasicHttpRequest(Method.HEAD, "/"); Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testArbitraryMethodNotCacheable() { + void testArbitraryMethodNotCacheable() { request = new BasicHttpRequest("PUT", "/"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); @@ -101,14 +101,14 @@ public void testArbitraryMethodNotCacheable() { } @Test - public void testResponsesToRequestsWithAuthorizationHeadersAreNotCacheableBySharedCache() { + void testResponsesToRequestsWithAuthorizationHeadersAreNotCacheableBySharedCache() { request = new BasicHttpRequest("GET","/"); request.setHeader("Authorization", StandardAuthScheme.BASIC + " dXNlcjpwYXNzd2Q="); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesToRequestsWithAuthorizationHeadersAreCacheableByNonSharedCache() { + void testResponsesToRequestsWithAuthorizationHeadersAreCacheableByNonSharedCache() { policy = new ResponseCachingPolicy(false, false, false); request = new BasicHttpRequest("GET","/"); request.setHeader("Authorization", StandardAuthScheme.BASIC + " dXNlcjpwYXNzd2Q="); @@ -116,7 +116,7 @@ public void testResponsesToRequestsWithAuthorizationHeadersAreCacheableByNonShar } @Test - public void testAuthorizedResponsesWithSMaxAgeAreCacheable() { + void testAuthorizedResponsesWithSMaxAgeAreCacheable() { request = new BasicHttpRequest("GET","/"); request.setHeader("Authorization", StandardAuthScheme.BASIC + " dXNlcjpwYXNzd2Q="); responseCacheControl = ResponseCacheControl.builder() @@ -127,7 +127,7 @@ public void testAuthorizedResponsesWithSMaxAgeAreCacheable() { } @Test - public void testAuthorizedResponsesWithCacheControlPublicAreCacheable() { + void testAuthorizedResponsesWithCacheControlPublicAreCacheable() { request = new BasicHttpRequest("GET","/"); request.setHeader("Authorization", StandardAuthScheme.BASIC + " dXNlcjpwYXNzd2Q="); responseCacheControl = ResponseCacheControl.builder() @@ -137,7 +137,7 @@ public void testAuthorizedResponsesWithCacheControlPublicAreCacheable() { } @Test - public void testAuthorizedResponsesWithCacheControlMaxAgeAreNotCacheable() { + void testAuthorizedResponsesWithCacheControlMaxAgeAreNotCacheable() { request = new BasicHttpRequest("GET","/"); request.setHeader("Authorization", StandardAuthScheme.BASIC + " dXNlcjpwYXNzd2Q="); responseCacheControl = ResponseCacheControl.builder() @@ -147,51 +147,51 @@ public void testAuthorizedResponsesWithCacheControlMaxAgeAreNotCacheable() { } @Test - public void test203ResponseCodeIsCacheable() { + void test203ResponseCodeIsCacheable() { response.setCode(HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION); Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void test206ResponseCodeIsNotCacheable() { + void test206ResponseCodeIsNotCacheable() { response.setCode(HttpStatus.SC_PARTIAL_CONTENT); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void test300ResponseCodeIsCacheable() { + void test300ResponseCodeIsCacheable() { response.setCode(HttpStatus.SC_MULTIPLE_CHOICES); Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void test301ResponseCodeIsCacheable() { + void test301ResponseCodeIsCacheable() { response.setCode(HttpStatus.SC_MOVED_PERMANENTLY); Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void test410ResponseCodeIsCacheable() { + void test410ResponseCodeIsCacheable() { response.setCode(HttpStatus.SC_GONE); Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testPlain302ResponseCodeIsNotCacheable() { + void testPlain302ResponseCodeIsNotCacheable() { response.setCode(HttpStatus.SC_MOVED_TEMPORARILY); response.removeHeaders("Expires"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testPlain303ResponseCodeIsNotCacheableUnderDefaultBehavior() { + void testPlain303ResponseCodeIsNotCacheableUnderDefaultBehavior() { response.setCode(HttpStatus.SC_SEE_OTHER); response.removeHeaders("Expires"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testPlain303ResponseCodeIsNotCacheableEvenIf303CachingEnabled() { + void testPlain303ResponseCodeIsNotCacheableEvenIf303CachingEnabled() { policy = new ResponseCachingPolicy(true, false, true); response.setCode(HttpStatus.SC_SEE_OTHER); response.removeHeaders("Expires"); @@ -200,14 +200,14 @@ public void testPlain303ResponseCodeIsNotCacheableEvenIf303CachingEnabled() { @Test - public void testPlain307ResponseCodeIsNotCacheable() { + void testPlain307ResponseCodeIsNotCacheable() { response.setCode(HttpStatus.SC_TEMPORARY_REDIRECT); response.removeHeaders("Expires"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testNon206WithExplicitExpiresIsCacheable() { + void testNon206WithExplicitExpiresIsCacheable() { final int status = getRandomStatus(); response.setCode(status); response.setHeader("Expires", DateUtils.formatStandardDate(Instant.now().plus(1, ChronoUnit.HOURS))); @@ -215,7 +215,7 @@ public void testNon206WithExplicitExpiresIsCacheable() { } @Test - public void testNon206WithMaxAgeIsCacheable() { + void testNon206WithMaxAgeIsCacheable() { final int status = getRandomStatus(); response.setCode(status); responseCacheControl = ResponseCacheControl.builder() @@ -225,7 +225,7 @@ public void testNon206WithMaxAgeIsCacheable() { } @Test - public void testMissingCacheControlHeader() { + void testMissingCacheControlHeader() { final int status = getRandomStatus(); response.setCode(status); response.removeHeaders(HttpHeaders.CACHE_CONTROL); @@ -233,7 +233,7 @@ public void testMissingCacheControlHeader() { } @Test - public void testNon206WithSMaxAgeIsCacheable() { + void testNon206WithSMaxAgeIsCacheable() { final int status = getRandomStatus(); response.setCode(status); responseCacheControl = ResponseCacheControl.builder() @@ -243,7 +243,7 @@ public void testNon206WithSMaxAgeIsCacheable() { } @Test - public void testNon206WithMustRevalidateIsCacheable() { + void testNon206WithMustRevalidateIsCacheable() { final int status = getRandomStatus(); response.setCode(status); responseCacheControl = ResponseCacheControl.builder() @@ -253,7 +253,7 @@ public void testNon206WithMustRevalidateIsCacheable() { } @Test - public void testNon206WithProxyRevalidateIsCacheable() { + void testNon206WithProxyRevalidateIsCacheable() { final int status = getRandomStatus(); response.setCode(status); responseCacheControl = ResponseCacheControl.builder() @@ -263,7 +263,7 @@ public void testNon206WithProxyRevalidateIsCacheable() { } @Test - public void testNon206WithPublicCacheControlIsCacheable() { + void testNon206WithPublicCacheControlIsCacheable() { final int status = getRandomStatus(); response.setCode(status); responseCacheControl = ResponseCacheControl.builder() @@ -273,7 +273,7 @@ public void testNon206WithPublicCacheControlIsCacheable() { } @Test - public void testNon206WithPrivateCacheControlIsNotCacheableBySharedCache() { + void testNon206WithPrivateCacheControlIsNotCacheableBySharedCache() { final int status = getRandomStatus(); response.setCode(status); responseCacheControl = ResponseCacheControl.builder() @@ -283,7 +283,7 @@ public void testNon206WithPrivateCacheControlIsNotCacheableBySharedCache() { } @Test - public void test200ResponseWithPrivateCacheControlIsCacheableByNonSharedCache() { + void test200ResponseWithPrivateCacheControlIsCacheableByNonSharedCache() { policy = new ResponseCachingPolicy(false, false, false); response.setCode(HttpStatus.SC_OK); responseCacheControl = ResponseCacheControl.builder() @@ -293,7 +293,7 @@ public void test200ResponseWithPrivateCacheControlIsCacheableByNonSharedCache() } @Test - public void testControlNoCacheCacheable() { + void testControlNoCacheCacheable() { responseCacheControl = ResponseCacheControl.builder() .setNoCache(true) .build(); @@ -302,7 +302,7 @@ public void testControlNoCacheCacheable() { } @Test - public void testControlNoStoreNotCacheable() { + void testControlNoStoreNotCacheable() { responseCacheControl = ResponseCacheControl.builder() .setNoStore(true) .build(); @@ -311,7 +311,7 @@ public void testControlNoStoreNotCacheable() { } @Test - public void testControlNoStoreEmbeddedInListCacheable() { + void testControlNoStoreEmbeddedInListCacheable() { responseCacheControl = ResponseCacheControl.builder() .setCachePublic(true) .setNoStore(true) @@ -321,7 +321,7 @@ public void testControlNoStoreEmbeddedInListCacheable() { } @Test - public void testControlNoCacheEmbeddedInListCacheable() { + void testControlNoCacheEmbeddedInListCacheable() { responseCacheControl = ResponseCacheControl.builder() .setCachePublic(true) .setNoCache(true) @@ -331,7 +331,7 @@ public void testControlNoCacheEmbeddedInListCacheable() { } @Test - public void testControlNoCacheEmbeddedInListAfterFirstHeaderCacheable() { + void testControlNoCacheEmbeddedInListAfterFirstHeaderCacheable() { responseCacheControl = ResponseCacheControl.builder() .setMaxAge(20) .setCachePublic(true) @@ -342,7 +342,7 @@ public void testControlNoCacheEmbeddedInListAfterFirstHeaderCacheable() { } @Test - public void testControlNoStoreEmbeddedInListAfterFirstHeaderCacheable() { + void testControlNoStoreEmbeddedInListAfterFirstHeaderCacheable() { responseCacheControl = ResponseCacheControl.builder() .setMaxAge(20) .setCachePublic(true) @@ -353,7 +353,7 @@ public void testControlNoStoreEmbeddedInListAfterFirstHeaderCacheable() { } @Test - public void testControlAnyCacheControlCacheable() { + void testControlAnyCacheControlCacheable() { responseCacheControl = ResponseCacheControl.builder() .setMaxAge(10) .build(); @@ -370,7 +370,7 @@ public void testControlAnyCacheControlCacheable() { } @Test - public void testControlWithout200Cacheable() { + void testControlWithout200Cacheable() { HttpResponse response404 = new BasicHttpResponse(HttpStatus.SC_NOT_FOUND, ""); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response404)); @@ -381,13 +381,13 @@ public void testControlWithout200Cacheable() { } @Test - public void testVaryStarIsNotCacheable() { + void testVaryStarIsNotCacheable() { response.setHeader("Vary", "*"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testVaryStarIsNotCacheableUsingSharedPublicCache() { + void testVaryStarIsNotCacheableUsingSharedPublicCache() { policy = new ResponseCachingPolicy(true, false, false); request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ=="); @@ -399,13 +399,13 @@ public void testVaryStarIsNotCacheableUsingSharedPublicCache() { } @Test - public void testRequestWithVaryHeaderCacheable() { + void testRequestWithVaryHeaderCacheable() { response.addHeader("Vary", "Accept-Encoding"); Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testIsArbitraryMethodCacheableUsingSharedPublicCache() { + void testIsArbitraryMethodCacheableUsingSharedPublicCache() { policy = new ResponseCachingPolicy(true, false, false); request = new HttpOptions("http://foo.example.com/"); @@ -419,14 +419,14 @@ public void testIsArbitraryMethodCacheableUsingSharedPublicCache() { } @Test - public void testResponsesWithMultipleAgeHeadersAreCacheable() { + void testResponsesWithMultipleAgeHeadersAreCacheable() { response.addHeader("Age", "3"); response.addHeader("Age", "5"); Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesWithMultipleAgeHeadersAreNotCacheableUsingSharedPublicCache() { + void testResponsesWithMultipleAgeHeadersAreNotCacheableUsingSharedPublicCache() { policy = new ResponseCachingPolicy(true, false, false); request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ=="); @@ -439,14 +439,14 @@ public void testResponsesWithMultipleAgeHeadersAreNotCacheableUsingSharedPublicC } @Test - public void testResponsesWithMultipleDateHeadersAreNotCacheable() { + void testResponsesWithMultipleDateHeadersAreNotCacheable() { response.addHeader("Date", DateUtils.formatStandardDate(now)); response.addHeader("Date", DateUtils.formatStandardDate(sixSecondsAgo)); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesWithMultipleDateHeadersAreNotCacheableUsingSharedPublicCache() { + void testResponsesWithMultipleDateHeadersAreNotCacheableUsingSharedPublicCache() { policy = new ResponseCachingPolicy(true, false, false); request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ=="); @@ -459,13 +459,13 @@ public void testResponsesWithMultipleDateHeadersAreNotCacheableUsingSharedPublic } @Test - public void testResponsesWithMalformedDateHeadersAreNotCacheable() { + void testResponsesWithMalformedDateHeadersAreNotCacheable() { response.addHeader("Date", "garbage"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesWithMalformedDateHeadersAreNotCacheableUsingSharedPublicCache() { + void testResponsesWithMalformedDateHeadersAreNotCacheableUsingSharedPublicCache() { policy = new ResponseCachingPolicy(true, false, false); request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ=="); @@ -477,14 +477,14 @@ public void testResponsesWithMalformedDateHeadersAreNotCacheableUsingSharedPubli } @Test - public void testResponsesWithMultipleExpiresHeadersAreNotCacheable() { + void testResponsesWithMultipleExpiresHeadersAreNotCacheable() { response.addHeader("Expires", DateUtils.formatStandardDate(now)); response.addHeader("Expires", DateUtils.formatStandardDate(sixSecondsAgo)); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesWithMultipleExpiresHeadersAreNotCacheableUsingSharedPublicCache() { + void testResponsesWithMultipleExpiresHeadersAreNotCacheableUsingSharedPublicCache() { policy = new ResponseCachingPolicy(true, false, false); request.setHeader("Authorization", StandardAuthScheme.BASIC + " QWxhZGRpbjpvcGVuIHNlc2FtZQ=="); @@ -497,39 +497,39 @@ public void testResponsesWithMultipleExpiresHeadersAreNotCacheableUsingSharedPub } @Test - public void testResponsesThatAreSmallEnoughAreCacheable() { + void testResponsesThatAreSmallEnoughAreCacheable() { response.setHeader("Content-Length", "0"); Assertions.assertTrue(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesToGETWithQueryParamsButNoExplicitCachingAreNotCacheable() { + void testResponsesToGETWithQueryParamsButNoExplicitCachingAreNotCacheable() { request = new BasicHttpRequest("GET", "/foo?s=bar"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesToHEADWithQueryParamsButNoExplicitCachingAreNotCacheable() { + void testResponsesToHEADWithQueryParamsButNoExplicitCachingAreNotCacheable() { request = new BasicHttpRequest("HEAD", "/foo?s=bar"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesToGETWithQueryParamsButNoExplicitCachingAreNotCacheableEvenWhen1_0QueryCachingDisabled() { + void testResponsesToGETWithQueryParamsButNoExplicitCachingAreNotCacheableEvenWhen1_0QueryCachingDisabled() { policy = new ResponseCachingPolicy(true, true, false); request = new BasicHttpRequest("GET", "/foo?s=bar"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesToHEADWithQueryParamsButNoExplicitCachingAreNotCacheableEvenWhen1_0QueryCachingDisabled() { + void testResponsesToHEADWithQueryParamsButNoExplicitCachingAreNotCacheableEvenWhen1_0QueryCachingDisabled() { policy = new ResponseCachingPolicy(true, true, false); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void testResponsesToGETWithQueryParamsAndExplicitCachingAreCacheable() { + void testResponsesToGETWithQueryParamsAndExplicitCachingAreCacheable() { request = new BasicHttpRequest("GET", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow)); @@ -537,7 +537,7 @@ public void testResponsesToGETWithQueryParamsAndExplicitCachingAreCacheable() { } @Test - public void testResponsesToHEADWithQueryParamsAndExplicitCachingAreCacheable() { + void testResponsesToHEADWithQueryParamsAndExplicitCachingAreCacheable() { policy = new ResponseCachingPolicy(true, false, false); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -546,7 +546,7 @@ public void testResponsesToHEADWithQueryParamsAndExplicitCachingAreCacheable() { } @Test - public void testResponsesToGETWithQueryParamsAndExplicitCachingAreCacheableEvenWhen1_0QueryCachingDisabled() { + void testResponsesToGETWithQueryParamsAndExplicitCachingAreCacheableEvenWhen1_0QueryCachingDisabled() { policy = new ResponseCachingPolicy(true, true, false); request = new BasicHttpRequest("GET", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -555,7 +555,7 @@ public void testResponsesToGETWithQueryParamsAndExplicitCachingAreCacheableEvenW } @Test - public void testResponsesToHEADWithQueryParamsAndExplicitCachingAreCacheableEvenWhen1_0QueryCachingDisabled() { + void testResponsesToHEADWithQueryParamsAndExplicitCachingAreCacheableEvenWhen1_0QueryCachingDisabled() { policy = new ResponseCachingPolicy(true, true, false); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -564,7 +564,7 @@ public void testResponsesToHEADWithQueryParamsAndExplicitCachingAreCacheableEven } @Test - public void getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheable() { + void getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheable() { request = new BasicHttpRequest("GET", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); response.setVersion(HttpVersion.HTTP_1_0); @@ -572,7 +572,7 @@ public void getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheable() { } @Test - public void headsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheable() { + void headsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheable() { request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); response.setVersion(HttpVersion.HTTP_1_0); @@ -580,7 +580,7 @@ public void headsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheable() { } @Test - public void getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting() { + void getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting() { policy = new ResponseCachingPolicy(true, true, false); request = new BasicHttpRequest("GET", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); @@ -589,7 +589,7 @@ public void getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWith } @Test - public void headsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting() { + void headsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting() { policy = new ResponseCachingPolicy(true, true, false); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); @@ -598,7 +598,7 @@ public void headsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWit } @Test - public void getsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires() { + void getsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires() { request = new BasicHttpRequest("GET", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); response.setVersion(HttpVersion.HTTP_1_0); @@ -608,7 +608,7 @@ public void getsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires } @Test - public void headsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires() { + void headsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires() { policy = new ResponseCachingPolicy(true, false, false); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); @@ -619,7 +619,7 @@ public void headsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpire } @Test - public void getsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires() { + void getsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires() { policy = new ResponseCachingPolicy(true, true, false); request = new BasicHttpRequest("GET", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); @@ -630,7 +630,7 @@ public void getsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWi } @Test - public void headsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires() { + void headsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires() { policy = new ResponseCachingPolicy(true, true, false); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); @@ -641,21 +641,21 @@ public void headsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenW } @Test - public void getsWithQueryParametersFrom1_0OriginsViaProxiesAreNotCacheable() { + void getsWithQueryParametersFrom1_0OriginsViaProxiesAreNotCacheable() { request = new BasicHttpRequest("GET", "/foo?s=bar"); response.setHeader(HttpHeaders.VIA, "1.0 someproxy"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void headsWithQueryParametersFrom1_0OriginsViaProxiesAreNotCacheable() { + void headsWithQueryParametersFrom1_0OriginsViaProxiesAreNotCacheable() { request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response.setHeader(HttpHeaders.VIA, "1.0 someproxy"); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void getsWithQueryParametersFrom1_0OriginsViaProxiesAreCacheableWithExpires() { + void getsWithQueryParametersFrom1_0OriginsViaProxiesAreCacheableWithExpires() { request = new BasicHttpRequest("GET", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow)); @@ -664,7 +664,7 @@ public void getsWithQueryParametersFrom1_0OriginsViaProxiesAreCacheableWithExpir } @Test - public void headsWithQueryParametersFrom1_0OriginsViaProxiesAreCacheableWithExpires() { + void headsWithQueryParametersFrom1_0OriginsViaProxiesAreCacheableWithExpires() { policy = new ResponseCachingPolicy(true, false, false); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -674,7 +674,7 @@ public void headsWithQueryParametersFrom1_0OriginsViaProxiesAreCacheableWithExpi } @Test - public void getsWithQueryParametersFrom1_0OriginsViaProxiesCanNotBeCacheableEvenWithExpires() { + void getsWithQueryParametersFrom1_0OriginsViaProxiesCanNotBeCacheableEvenWithExpires() { policy = new ResponseCachingPolicy(true, true, true); request = new BasicHttpRequest("GET", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -684,7 +684,7 @@ public void getsWithQueryParametersFrom1_0OriginsViaProxiesCanNotBeCacheableEven } @Test - public void headsWithQueryParametersFrom1_0OriginsViaProxiesCanNotBeCacheableEvenWithExpires() { + void headsWithQueryParametersFrom1_0OriginsViaProxiesCanNotBeCacheableEvenWithExpires() { policy = new ResponseCachingPolicy(true, true, true); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -694,7 +694,7 @@ public void headsWithQueryParametersFrom1_0OriginsViaProxiesCanNotBeCacheableEve } @Test - public void getsWithQueryParametersFrom1_0OriginsViaExplicitProxiesAreCacheableWithExpires() { + void getsWithQueryParametersFrom1_0OriginsViaExplicitProxiesAreCacheableWithExpires() { request = new BasicHttpRequest("GET", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); response.setHeader("Expires", DateUtils.formatStandardDate(tenSecondsFromNow)); @@ -703,7 +703,7 @@ public void getsWithQueryParametersFrom1_0OriginsViaExplicitProxiesAreCacheableW } @Test - public void headsWithQueryParametersFrom1_0OriginsViaExplicitProxiesAreCacheableWithExpires() { + void headsWithQueryParametersFrom1_0OriginsViaExplicitProxiesAreCacheableWithExpires() { policy = new ResponseCachingPolicy(true, false, false); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -713,7 +713,7 @@ public void headsWithQueryParametersFrom1_0OriginsViaExplicitProxiesAreCacheable } @Test - public void getsWithQueryParametersFrom1_0OriginsViaExplicitProxiesCanNotBeCacheableEvenWithExpires() { + void getsWithQueryParametersFrom1_0OriginsViaExplicitProxiesCanNotBeCacheableEvenWithExpires() { policy = new ResponseCachingPolicy(true, true, true); request = new BasicHttpRequest("GET", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -723,7 +723,7 @@ public void getsWithQueryParametersFrom1_0OriginsViaExplicitProxiesCanNotBeCache } @Test - public void headsWithQueryParametersFrom1_0OriginsViaExplicitProxiesCanNotBeCacheableEvenWithExpires() { + void headsWithQueryParametersFrom1_0OriginsViaExplicitProxiesCanNotBeCacheableEvenWithExpires() { policy = new ResponseCachingPolicy(true, true, true); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response.setHeader("Date", DateUtils.formatStandardDate(now)); @@ -733,7 +733,7 @@ public void headsWithQueryParametersFrom1_0OriginsViaExplicitProxiesCanNotBeCach } @Test - public void getsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires() { + void getsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires() { request = new BasicHttpRequest("GET", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); response.setVersion(HttpVersion.HTTP_1_0); @@ -744,7 +744,7 @@ public void getsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithEx } @Test - public void headsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires() { + void headsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires() { policy = new ResponseCachingPolicy(true, false, false); request = new BasicHttpRequest("HEAD", "/foo?s=bar"); response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); @@ -757,21 +757,21 @@ public void headsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithE } @Test - public void notCacheableIfExpiresEqualsDateAndNoCacheControl() { + void notCacheableIfExpiresEqualsDateAndNoCacheControl() { response.setHeader("Date", DateUtils.formatStandardDate(now)); response.setHeader("Expires", DateUtils.formatStandardDate(now)); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void notCacheableIfExpiresPrecedesDateAndNoCacheControl() { + void notCacheableIfExpiresPrecedesDateAndNoCacheControl() { response.setHeader("Date", DateUtils.formatStandardDate(now)); response.setHeader("Expires", DateUtils.formatStandardDate(sixSecondsAgo)); Assertions.assertFalse(policy.isResponseCacheable(responseCacheControl, request, response)); } @Test - public void test302WithExplicitCachingHeaders() { + void test302WithExplicitCachingHeaders() { response.setCode(HttpStatus.SC_MOVED_TEMPORARILY); response.setHeader("Date", DateUtils.formatStandardDate(now)); responseCacheControl = ResponseCacheControl.builder() @@ -781,7 +781,7 @@ public void test302WithExplicitCachingHeaders() { } @Test - public void test303WithExplicitCachingHeadersWhenPermittedByConfig() { + void test303WithExplicitCachingHeadersWhenPermittedByConfig() { // HTTPbis working group says ok if explicitly indicated by // response headers policy = new ResponseCachingPolicy(true, false, true); @@ -794,7 +794,7 @@ public void test303WithExplicitCachingHeadersWhenPermittedByConfig() { } @Test - public void test307WithExplicitCachingHeaders() { + void test307WithExplicitCachingHeaders() { response.setCode(HttpStatus.SC_TEMPORARY_REDIRECT); response.setHeader("Date", DateUtils.formatStandardDate(now)); responseCacheControl = ResponseCacheControl.builder() @@ -804,7 +804,7 @@ public void test307WithExplicitCachingHeaders() { } @Test - public void otherStatusCodesAreCacheableWithExplicitCachingHeaders() { + void otherStatusCodesAreCacheableWithExplicitCachingHeaders() { response.setCode(HttpStatus.SC_NOT_FOUND); response.setHeader("Date", DateUtils.formatStandardDate(now)); responseCacheControl = ResponseCacheControl.builder() @@ -895,7 +895,7 @@ private int getRandomStatus() { } @Test - public void testIsResponseCacheable() { + void testIsResponseCacheable() { request = new BasicHttpRequest("GET","/foo?s=bar"); // HTTPbis working group says ok if explicitly indicated by // response headers @@ -936,7 +936,7 @@ void testIsResponseCacheableNoStore() { } @Test - public void testImmutableAndFreshResponseIsCacheable() { + void testImmutableAndFreshResponseIsCacheable() { responseCacheControl = ResponseCacheControl.builder() .setImmutable(true) .setMaxAge(3600) // set this to a value that ensures the response is still fresh diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestViaCacheGenerator.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestViaCacheGenerator.java index 83fff1a65..ffc62841b 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestViaCacheGenerator.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestViaCacheGenerator.java @@ -34,17 +34,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestViaCacheGenerator { +class TestViaCacheGenerator { private ViaCacheGenerator impl; @BeforeEach - public void setUp() { + void setUp() { impl = new ViaCacheGenerator(); } @Test - public void testViaValueGeneration() { + void testViaValueGeneration() { Assertions.assertEquals("1.1 localhost (Apache-HttpClient/UNAVAILABLE (cache))", impl.generateViaHeader(null, HttpVersion.DEFAULT)); Assertions.assertEquals("2.0 localhost (Apache-HttpClient/UNAVAILABLE (cache))", @@ -52,7 +52,7 @@ public void testViaValueGeneration() { } @Test - public void testViaValueLookup() { + void testViaValueLookup() { MatcherAssert.assertThat(impl.lookup(HttpVersion.DEFAULT), Matchers.startsWith("1.1 localhost (Apache-HttpClient/")); MatcherAssert.assertThat(impl.lookup(HttpVersion.HTTP_1_0), diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/memcached/TestPrefixKeyHashingScheme.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/memcached/TestPrefixKeyHashingScheme.java index aeb0627fa..a15b43872 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/memcached/TestPrefixKeyHashingScheme.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/memcached/TestPrefixKeyHashingScheme.java @@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test; -public class TestPrefixKeyHashingScheme { +class TestPrefixKeyHashingScheme { private static final String KEY = "key"; private static final String PREFIX = "prefix"; @@ -41,7 +41,7 @@ public class TestPrefixKeyHashingScheme { private KeyHashingScheme scheme; @BeforeEach - public void setUp() { + void setUp() { scheme = storageKey -> { assertEquals(KEY, storageKey); return "hash"; @@ -50,7 +50,7 @@ public void setUp() { } @Test - public void addsPrefixToBackingScheme() { + void addsPrefixToBackingScheme() { assertEquals("prefixhash", impl.hash(KEY)); } } diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/memcached/TestSHA256HashingScheme.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/memcached/TestSHA256HashingScheme.java index 3d5a47bdd..6f6334b24 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/memcached/TestSHA256HashingScheme.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/memcached/TestSHA256HashingScheme.java @@ -32,10 +32,10 @@ import org.junit.jupiter.api.Test; -public class TestSHA256HashingScheme { +class TestSHA256HashingScheme { @Test - public void canHash() { + void canHash() { final SHA256KeyHashingScheme impl = new SHA256KeyHashingScheme(); final String result = impl.hash("hello, hashing world"); assertTrue(result != null && !result.isEmpty()); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/schedule/TestExponentialBackingOffSchedulingStrategy.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/schedule/TestExponentialBackingOffSchedulingStrategy.java index 4b9ffe973..1b8375339 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/schedule/TestExponentialBackingOffSchedulingStrategy.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/schedule/TestExponentialBackingOffSchedulingStrategy.java @@ -31,12 +31,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestExponentialBackingOffSchedulingStrategy { +class TestExponentialBackingOffSchedulingStrategy { private ExponentialBackOffSchedulingStrategy impl; @BeforeEach - public void setUp() { + void setUp() { impl = new ExponentialBackOffSchedulingStrategy( ExponentialBackOffSchedulingStrategy.DEFAULT_BACK_OFF_RATE, ExponentialBackOffSchedulingStrategy.DEFAULT_INITIAL_EXPIRY, @@ -45,7 +45,7 @@ public void setUp() { } @Test - public void testSchedule() { + void testSchedule() { Assertions.assertEquals(TimeValue.ofMilliseconds(0), impl.schedule(0)); Assertions.assertEquals(TimeValue.ofMilliseconds(6000), impl.schedule(1)); Assertions.assertEquals(TimeValue.ofMilliseconds(60000), impl.schedule(2)); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/schedule/TestImmediateSchedulingStrategy.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/schedule/TestImmediateSchedulingStrategy.java index 9bbb6e1aa..2afac1230 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/schedule/TestImmediateSchedulingStrategy.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/schedule/TestImmediateSchedulingStrategy.java @@ -32,17 +32,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestImmediateSchedulingStrategy { +class TestImmediateSchedulingStrategy { private SchedulingStrategy impl; @BeforeEach - public void setUp() { + void setUp() { impl = new ImmediateSchedulingStrategy(); } @Test - public void testSchedule() { + void testSchedule() { Assertions.assertEquals(TimeValue.ZERO_MILLISECONDS, impl.schedule(0)); Assertions.assertEquals(TimeValue.ZERO_MILLISECONDS, impl.schedule(1)); Assertions.assertEquals(TimeValue.ZERO_MILLISECONDS, impl.schedule(Integer.MAX_VALUE)); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/schedule/TestConcurrentCountMap.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/schedule/TestConcurrentCountMap.java index 9d65423e8..175867d1a 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/schedule/TestConcurrentCountMap.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/schedule/TestConcurrentCountMap.java @@ -31,7 +31,7 @@ import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; -public class TestConcurrentCountMap +class TestConcurrentCountMap { private static final String IDENTIFIER = "some-identifier"; @@ -39,7 +39,7 @@ public class TestConcurrentCountMap private final ConcurrentCountMap map = new ConcurrentCountMap<>(); @Test - public void testBasics() { + void testBasics() { map.increaseCount(IDENTIFIER); map.increaseCount(IDENTIFIER); assertThat(map.getCount(IDENTIFIER), CoreMatchers.equalTo(2)); diff --git a/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/fluent/TestRequest.java b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/fluent/TestRequest.java index 6e030ca03..96693e664 100644 --- a/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/fluent/TestRequest.java +++ b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/fluent/TestRequest.java @@ -37,12 +37,12 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -public class TestRequest { +class TestRequest { private static final String URI_STRING_FIXTURE = "http://localhost"; private static final URI URI_FIXTURE = URI.create(URI_STRING_FIXTURE); - public static Stream data() { + static Stream data() { return Stream.of( Arguments.of("delete", "DELETE"), Arguments.of("get", "GET"), @@ -57,7 +57,7 @@ public static Stream data() { @ParameterizedTest(name = "{index}: {0} => {1}") @MethodSource("data") - public void testCreateFromString(final String methodName, final String expectedMethod) throws Exception { + void testCreateFromString(final String methodName, final String expectedMethod) throws Exception { final Method method = Request.class.getMethod(methodName, String.class); final Request request = (Request) method.invoke(null, URI_STRING_FIXTURE); final ClassicHttpRequest classicHttpRequest = request.getRequest(); @@ -66,7 +66,7 @@ public void testCreateFromString(final String methodName, final String expectedM @ParameterizedTest(name = "{index}: {0} => {1}") @MethodSource("data") - public void testCreateFromURI(final String methodName, final String expectedMethod) throws Exception { + void testCreateFromURI(final String methodName, final String expectedMethod) throws Exception { final Method method = Request.class.getMethod(methodName, URI.class); final Request request = (Request) method.invoke(null, URI_FIXTURE); final ClassicHttpRequest classicHttpRequest = request.getRequest(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthenticationTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthenticationTest.java index db433d369..543ef5a1f 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthenticationTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncClientAuthenticationTest.java @@ -76,14 +76,14 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public abstract class AbstractHttpAsyncClientAuthenticationTest extends AbstractIntegrationTestBase { +abstract class AbstractHttpAsyncClientAuthenticationTest extends AbstractIntegrationTestBase { public AbstractHttpAsyncClientAuthenticationTest(final URIScheme scheme, final ClientProtocolLevel clientProtocolLevel, final ServerProtocolLevel serverProtocolLevel) { super(scheme, clientProtocolLevel, serverProtocolLevel); } @Test - public void testBasicAuthenticationNoCreds() throws Exception { + void testBasicAuthenticationNoCreds() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); @@ -106,7 +106,7 @@ public void testBasicAuthenticationNoCreds() throws Exception { } @Test - public void testBasicAuthenticationFailure() throws Exception { + void testBasicAuthenticationFailure() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); @@ -131,7 +131,7 @@ public void testBasicAuthenticationFailure() throws Exception { } @Test - public void testBasicAuthenticationSuccess() throws Exception { + void testBasicAuthenticationSuccess() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); @@ -157,7 +157,7 @@ public void testBasicAuthenticationSuccess() throws Exception { } @Test - public void testBasicAuthenticationWithEntitySuccess() throws Exception { + void testBasicAuthenticationWithEntitySuccess() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); @@ -183,7 +183,7 @@ public void testBasicAuthenticationWithEntitySuccess() throws Exception { } @Test - public void testBasicAuthenticationExpectationFailure() throws Exception { + void testBasicAuthenticationExpectationFailure() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); @@ -208,7 +208,7 @@ public void testBasicAuthenticationExpectationFailure() throws Exception { } @Test - public void testBasicAuthenticationExpectationSuccess() throws Exception { + void testBasicAuthenticationExpectationSuccess() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); @@ -235,7 +235,7 @@ public void testBasicAuthenticationExpectationSuccess() throws Exception { } @Test - public void testBasicAuthenticationCredentialsCaching() throws Exception { + void testBasicAuthenticationCredentialsCaching() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); @@ -262,7 +262,7 @@ public void testBasicAuthenticationCredentialsCaching() throws Exception { } @Test - public void testBasicAuthenticationCredentialsCachingByPathPrefix() throws Exception { + void testBasicAuthenticationCredentialsCachingByPathPrefix() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); @@ -327,7 +327,7 @@ public void testBasicAuthenticationCredentialsCachingByPathPrefix() throws Excep } @Test - public void testAuthenticationUserinfoInRequestFailure() throws Exception { + void testAuthenticationUserinfoInRequestFailure() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap.register("*", AsyncEchoHandler::new)); @@ -344,7 +344,7 @@ public void testAuthenticationUserinfoInRequestFailure() throws Exception { } @Test - public void testReauthentication() throws Exception { + void testReauthentication() throws Exception { final Authenticator authenticator = new BasicTestAuthenticator("test:test", "test realm") { private final AtomicLong count = new AtomicLong(0); @@ -413,7 +413,7 @@ public String getName() { } @Test - public void testAuthenticationFallback() throws Exception { + void testAuthenticationFallback() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap .register("*", AsyncEchoHandler::new) @@ -448,7 +448,7 @@ protected void customizeUnauthorizedResponse(final HttpResponse unauthorized) { private final static String CHARS = "0123456789abcdef"; @Test - public void testBearerTokenAuthentication() throws Exception { + void testBearerTokenAuthentication() throws Exception { final SecureRandom secureRandom = SecureRandom.getInstanceStrong(); secureRandom.setSeed(System.currentTimeMillis()); final StringBuilder buf = new StringBuilder(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java index f8488b24f..1f38c166c 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncFundamentalsTest.java @@ -58,14 +58,14 @@ import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; -public abstract class AbstractHttpAsyncFundamentalsTest extends AbstractIntegrationTestBase { +abstract class AbstractHttpAsyncFundamentalsTest extends AbstractIntegrationTestBase { protected AbstractHttpAsyncFundamentalsTest(final URIScheme scheme, final ClientProtocolLevel clientProtocolLevel, final ServerProtocolLevel serverProtocolLevel) { super(scheme, clientProtocolLevel, serverProtocolLevel); } @Test - public void testSequentialGetRequests() throws Exception { + void testSequentialGetRequests() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", AsyncRandomHandler::new)); final HttpHost target = startServer(); @@ -87,7 +87,7 @@ public void testSequentialGetRequests() throws Exception { } @Test - public void testSequentialHeadRequests() throws Exception { + void testSequentialHeadRequests() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", AsyncRandomHandler::new)); final HttpHost target = startServer(); final TestAsyncClient client = startClient(); @@ -106,7 +106,7 @@ public void testSequentialHeadRequests() throws Exception { } @Test - public void testSequentialPostRequests() throws Exception { + void testSequentialPostRequests() throws Exception { configureServer(bootstrap -> bootstrap.register("/echo/*", AsyncEchoHandler::new)); final HttpHost target = startServer(); final TestAsyncClient client = startClient(); @@ -128,7 +128,7 @@ public void testSequentialPostRequests() throws Exception { } @Test - public void testConcurrentPostRequests() throws Exception { + void testConcurrentPostRequests() throws Exception { configureServer(bootstrap -> bootstrap.register("/echo/*", AsyncEchoHandler::new)); final HttpHost target = startServer(); final TestAsyncClient client = startClient(); @@ -159,7 +159,7 @@ public void testConcurrentPostRequests() throws Exception { } @Test - public void testRequestExecutionFromCallback() throws Exception { + void testRequestExecutionFromCallback() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", AsyncRandomHandler::new)); final HttpHost target = startServer(); final TestAsyncClient client = startClient(); @@ -226,7 +226,7 @@ public void cancelled() { } @Test - public void testBadRequest() throws Exception { + void testBadRequest() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", AsyncRandomHandler::new)); final HttpHost target = startServer(); final TestAsyncClient client = startClient(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java index 5cb0a4699..77e42504a 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpAsyncRedirectsTest.java @@ -66,14 +66,14 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public abstract class AbstractHttpAsyncRedirectsTest extends AbstractIntegrationTestBase { +abstract class AbstractHttpAsyncRedirectsTest extends AbstractIntegrationTestBase { public AbstractHttpAsyncRedirectsTest(final URIScheme scheme, final ClientProtocolLevel clientProtocolLevel, final ServerProtocolLevel serverProtocolLevel) { super(scheme, clientProtocolLevel, serverProtocolLevel); } @Test - public void testBasicRedirect300() throws Exception { + void testBasicRedirect300() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -99,7 +99,7 @@ public void testBasicRedirect300() throws Exception { } @Test - public void testBasicRedirect301() throws Exception { + void testBasicRedirect301() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -126,7 +126,7 @@ public void testBasicRedirect301() throws Exception { } @Test - public void testBasicRedirect302() throws Exception { + void testBasicRedirect302() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -153,7 +153,7 @@ public void testBasicRedirect302() throws Exception { } @Test - public void testBasicRedirect302NoLocation() throws Exception { + void testBasicRedirect302NoLocation() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -185,7 +185,7 @@ public void testBasicRedirect302NoLocation() throws Exception { } @Test - public void testBasicRedirect303() throws Exception { + void testBasicRedirect303() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -213,14 +213,14 @@ public void testBasicRedirect303() throws Exception { } @Test - public void testBasicRedirect304() throws Exception { + void testBasicRedirect304() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .register("/oldlocation/*", () -> new AbstractSimpleServerExchangeHandler() { @Override protected SimpleHttpResponse handle(final SimpleHttpRequest request, - final HttpCoreContext context) throws HttpException { + final HttpCoreContext context) { return SimpleHttpResponse.create(HttpStatus.SC_NOT_MODIFIED, (String) null); } })); @@ -244,14 +244,14 @@ protected SimpleHttpResponse handle(final SimpleHttpRequest request, } @Test - public void testBasicRedirect305() throws Exception { + void testBasicRedirect305() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .register("/oldlocation/*", () -> new AbstractSimpleServerExchangeHandler() { @Override protected SimpleHttpResponse handle(final SimpleHttpRequest request, - final HttpCoreContext context) throws HttpException { + final HttpCoreContext context) { return SimpleHttpResponse.create(HttpStatus.SC_USE_PROXY, (String) null); } })); @@ -275,7 +275,7 @@ protected SimpleHttpResponse handle(final SimpleHttpRequest request, } @Test - public void testBasicRedirect307() throws Exception { + void testBasicRedirect307() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -302,7 +302,7 @@ public void testBasicRedirect307() throws Exception { } @Test - public void testMaxRedirectCheck() throws Exception { + void testMaxRedirectCheck() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -328,7 +328,7 @@ public void testMaxRedirectCheck() throws Exception { } @Test - public void testCircularRedirect() throws Exception { + void testCircularRedirect() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -355,7 +355,7 @@ public void testCircularRedirect() throws Exception { } @Test - public void testPostRedirect() throws Exception { + void testPostRedirect() throws Exception { configureServer(bootstrap -> bootstrap .register("/echo/*", AsyncEchoHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -383,7 +383,7 @@ public void testPostRedirect() throws Exception { } @Test - public void testPostRedirectSeeOther() throws Exception { + void testPostRedirectSeeOther() throws Exception { configureServer(bootstrap -> bootstrap .register("/echo/*", AsyncEchoHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -411,7 +411,7 @@ public void testPostRedirectSeeOther() throws Exception { } @Test - public void testRelativeRedirect() throws Exception { + void testRelativeRedirect() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -446,7 +446,7 @@ public void testRelativeRedirect() throws Exception { } @Test - public void testRelativeRedirect2() throws Exception { + void testRelativeRedirect2() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -481,7 +481,7 @@ public void testRelativeRedirect2() throws Exception { } @Test - public void testRejectBogusRedirectLocation() throws Exception { + void testRejectBogusRedirectLocation() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -510,7 +510,7 @@ public void testRejectBogusRedirectLocation() throws Exception { } @Test - public void testRejectInvalidRedirectLocation() throws Exception { + void testRejectInvalidRedirectLocation() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -538,7 +538,7 @@ public void testRejectInvalidRedirectLocation() throws Exception { } @Test - public void testRedirectWithCookie() throws Exception { + void testRedirectWithCookie() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -576,7 +576,7 @@ public void testRedirectWithCookie() throws Exception { } @Test - public void testCrossSiteRedirect() throws Exception { + void testCrossSiteRedirect() throws Exception { final URIScheme scheme = scheme(); final TestAsyncServer secondServer = new TestAsyncServerBootstrap(scheme(), getServerProtocolLevel()) .register("/random/*", AsyncRandomHandler::new) diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpReactiveFundamentalsTest.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpReactiveFundamentalsTest.java index 58fd9e0eb..1ff6f97cc 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpReactiveFundamentalsTest.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractHttpReactiveFundamentalsTest.java @@ -77,7 +77,7 @@ import org.junit.jupiter.api.Timeout; import org.reactivestreams.Publisher; -public abstract class AbstractHttpReactiveFundamentalsTest extends AbstractIntegrationTestBase { +abstract class AbstractHttpReactiveFundamentalsTest extends AbstractIntegrationTestBase { public AbstractHttpReactiveFundamentalsTest(final URIScheme scheme, final ClientProtocolLevel clientProtocolLevel, final ServerProtocolLevel serverProtocolLevel) { super(scheme, clientProtocolLevel, serverProtocolLevel); @@ -271,7 +271,7 @@ public void cancelled() { } @Test - public void testBadRequest() throws Exception { + void testBadRequest() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", () -> new ReactiveServerExchangeHandler(new ReactiveRandomProcessor()))); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java index 0dc5ca4cc..8df05f111 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/AbstractIntegrationTestBase.java @@ -42,7 +42,7 @@ import org.apache.hc.core5.util.Timeout; import org.junit.jupiter.api.extension.RegisterExtension; -public abstract class AbstractIntegrationTestBase { +abstract class AbstractIntegrationTestBase { public static final Timeout TIMEOUT = Timeout.ofMinutes(1); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/HttpIntegrationTests.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/HttpIntegrationTests.java index df5da9203..d5dfc1324 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/HttpIntegrationTests.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/HttpIntegrationTests.java @@ -31,13 +31,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; -public class HttpIntegrationTests { +class HttpIntegrationTests { @Nested @DisplayName("Fundamentals (HTTP/1.1)") - public class Http1 extends TestHttp1Async { + class Http1 extends TestHttp1Async { - public Http1() throws Exception { + public Http1() { super(URIScheme.HTTP); } @@ -45,9 +45,9 @@ public Http1() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/1.1, TLS)") - public class Http1Tls extends TestHttp1Async { + class Http1Tls extends TestHttp1Async { - public Http1Tls() throws Exception { + public Http1Tls() { super(URIScheme.HTTPS); } @@ -55,9 +55,9 @@ public Http1Tls() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/2)") - public class H2 extends TestH2Async { + class H2 extends TestH2Async { - public H2() throws Exception { + public H2() { super(URIScheme.HTTP); } @@ -65,9 +65,9 @@ public H2() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/2, TLS)") - public class H2Tls extends TestH2Async { + class H2Tls extends TestH2Async { - public H2Tls() throws Exception { + public H2Tls() { super(URIScheme.HTTPS); } @@ -75,9 +75,9 @@ public H2Tls() throws Exception { @Nested @DisplayName("Request re-execution (HTTP/1.1)") - public class Http1RequestReExecution extends TestHttp1RequestReExecution { + class Http1RequestReExecution extends TestHttp1RequestReExecution { - public Http1RequestReExecution() throws Exception { + public Http1RequestReExecution() { super(URIScheme.HTTP); } @@ -85,9 +85,9 @@ public Http1RequestReExecution() throws Exception { @Nested @DisplayName("Request re-execution (HTTP/1.1, TLS)") - public class Http1RequestReExecutionTls extends TestHttp1RequestReExecution { + class Http1RequestReExecutionTls extends TestHttp1RequestReExecution { - public Http1RequestReExecutionTls() throws Exception { + public Http1RequestReExecutionTls() { super(URIScheme.HTTPS); } @@ -95,9 +95,9 @@ public Http1RequestReExecutionTls() throws Exception { @Nested @DisplayName("HTTP protocol policy (HTTP/1.1)") - public class Http1ProtocolPolicy extends TestHttpAsyncProtocolPolicy { + class Http1ProtocolPolicy extends TestHttpAsyncProtocolPolicy { - public Http1ProtocolPolicy() throws Exception { + public Http1ProtocolPolicy() { super(URIScheme.HTTP, HttpVersion.HTTP_1_1); } @@ -105,9 +105,9 @@ public Http1ProtocolPolicy() throws Exception { @Nested @DisplayName("HTTP protocol policy (HTTP/1.1, TLS)") - public class Http1ProtocolPolicyTls extends TestHttpAsyncProtocolPolicy { + class Http1ProtocolPolicyTls extends TestHttpAsyncProtocolPolicy { - public Http1ProtocolPolicyTls() throws Exception { + public Http1ProtocolPolicyTls() { super(URIScheme.HTTPS, HttpVersion.HTTP_1_1); } @@ -115,9 +115,9 @@ public Http1ProtocolPolicyTls() throws Exception { @Nested @DisplayName("HTTP protocol policy (HTTP/2)") - public class H2ProtocolPolicy extends TestHttpAsyncProtocolPolicy { + class H2ProtocolPolicy extends TestHttpAsyncProtocolPolicy { - public H2ProtocolPolicy() throws Exception { + public H2ProtocolPolicy() { super(URIScheme.HTTP, HttpVersion.HTTP_2); } @@ -125,9 +125,9 @@ public H2ProtocolPolicy() throws Exception { @Nested @DisplayName("HTTP protocol policy (HTTP/2, TLS)") - public class H2ProtocolPolicyTls extends TestHttpAsyncProtocolPolicy { + class H2ProtocolPolicyTls extends TestHttpAsyncProtocolPolicy { - public H2ProtocolPolicyTls() throws Exception { + public H2ProtocolPolicyTls() { super(URIScheme.HTTPS, HttpVersion.HTTP_2); } @@ -135,9 +135,9 @@ public H2ProtocolPolicyTls() throws Exception { @Nested @DisplayName("Redirects (HTTP/1.1)") - public class RedirectsHttp1 extends TestHttp1AsyncRedirects { + class RedirectsHttp1 extends TestHttp1AsyncRedirects { - public RedirectsHttp1() throws Exception { + public RedirectsHttp1() { super(URIScheme.HTTP); } @@ -145,9 +145,9 @@ public RedirectsHttp1() throws Exception { @Nested @DisplayName("Redirects (HTTP/1.1, TLS)") - public class RedirectsHttp1Tls extends TestHttp1AsyncRedirects { + class RedirectsHttp1Tls extends TestHttp1AsyncRedirects { - public RedirectsHttp1Tls() throws Exception { + public RedirectsHttp1Tls() { super(URIScheme.HTTPS); } @@ -155,9 +155,9 @@ public RedirectsHttp1Tls() throws Exception { @Nested @DisplayName("Redirects (HTTP/2)") - public class RedirectsH2 extends TestH2AsyncRedirect { + class RedirectsH2 extends TestH2AsyncRedirect { - public RedirectsH2() throws Exception { + public RedirectsH2() { super(URIScheme.HTTP); } @@ -165,9 +165,9 @@ public RedirectsH2() throws Exception { @Nested @DisplayName("Redirects (HTTP/2, TLS)") - public class RedirectsH2Tls extends TestH2AsyncRedirect { + class RedirectsH2Tls extends TestH2AsyncRedirect { - public RedirectsH2Tls() throws Exception { + public RedirectsH2Tls() { super(URIScheme.HTTPS); } @@ -175,7 +175,7 @@ public RedirectsH2Tls() throws Exception { // @Nested // @DisplayName("Client authentication (HTTP/1.1)") -// public class AuthenticationHttp1 extends TestHttp1ClientAuthentication { +// class AuthenticationHttp1 extends TestHttp1ClientAuthentication { // // public AuthenticationHttp1() throws Exception { // super(URIScheme.HTTP); @@ -185,7 +185,7 @@ public RedirectsH2Tls() throws Exception { // // @Nested // @DisplayName("Client authentication (HTTP/1.1, TLS)") -// public class AuthenticationHttp1Tls extends TestHttp1ClientAuthentication { +// class AuthenticationHttp1Tls extends TestHttp1ClientAuthentication { // // public AuthenticationHttp1Tls() throws Exception { // super(URIScheme.HTTPS); @@ -195,7 +195,7 @@ public RedirectsH2Tls() throws Exception { // @Nested // @DisplayName("Client authentication (HTTP/2)") -// public class AuthenticationH2 extends TestH2ClientAuthentication { +// class AuthenticationH2 extends TestH2ClientAuthentication { // // public AuthenticationH2() throws Exception { // super(URIScheme.HTTP); @@ -205,7 +205,7 @@ public RedirectsH2Tls() throws Exception { // // @Nested // @DisplayName("Client authentication (HTTP/2, TLS)") -// public class AuthenticationH2Tls extends TestH2ClientAuthentication { +// class AuthenticationH2Tls extends TestH2ClientAuthentication { // // public AuthenticationH2Tls() throws Exception { // super(URIScheme.HTTPS); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/HttpMinimalIntegrationTests.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/HttpMinimalIntegrationTests.java index fc0169e64..5ba83aa30 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/HttpMinimalIntegrationTests.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/HttpMinimalIntegrationTests.java @@ -30,13 +30,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; -public class HttpMinimalIntegrationTests { +class HttpMinimalIntegrationTests { @Nested @DisplayName("Fundamentals (HTTP/1.1)") - public class Http1 extends TestHttp1AsyncMinimal { + class Http1 extends TestHttp1AsyncMinimal { - public Http1() throws Exception { + public Http1() { super(URIScheme.HTTP); } @@ -44,9 +44,9 @@ public Http1() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/1.1, TLS)") - public class Http1Tls extends TestHttp1AsyncMinimal { + class Http1Tls extends TestHttp1AsyncMinimal { - public Http1Tls() throws Exception { + public Http1Tls() { super(URIScheme.HTTPS); } @@ -54,9 +54,9 @@ public Http1Tls() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/2)") - public class H2 extends TestH2AsyncMinimal { + class H2 extends TestH2AsyncMinimal { - public H2() throws Exception { + public H2() { super(URIScheme.HTTP); } @@ -64,9 +64,9 @@ public H2() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/2, TLS)") - public class H2Tls extends TestH2AsyncMinimal { + class H2Tls extends TestH2AsyncMinimal { - public H2Tls() throws Exception { + public H2Tls() { super(URIScheme.HTTPS); } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/ReactiveIntegrationTests.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/ReactiveIntegrationTests.java index 81e49b544..91795772d 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/ReactiveIntegrationTests.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/ReactiveIntegrationTests.java @@ -30,13 +30,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; -public class ReactiveIntegrationTests { +class ReactiveIntegrationTests { @Nested @DisplayName("Fundamentals (HTTP/1.1)") - public class Http1 extends TestHttp1Reactive { + class Http1 extends TestHttp1Reactive { - public Http1() throws Exception { + public Http1() { super(URIScheme.HTTP); } @@ -44,9 +44,9 @@ public Http1() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/1.1, TLS)") - public class Http1Tls extends TestHttp1Reactive { + class Http1Tls extends TestHttp1Reactive { - public Http1Tls() throws Exception { + public Http1Tls() { super(URIScheme.HTTPS); } @@ -54,9 +54,9 @@ public Http1Tls() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/2)") - public class H2 extends TestH2Reactive { + class H2 extends TestH2Reactive { - public H2() throws Exception { + public H2() { super(URIScheme.HTTP); } @@ -64,9 +64,9 @@ public H2() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/2, TLS)") - public class H2Tls extends TestH2Reactive { + class H2Tls extends TestH2Reactive { - public H2Tls() throws Exception { + public H2Tls() { super(URIScheme.HTTPS); } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/ReactiveMinimalIntegrationTests.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/ReactiveMinimalIntegrationTests.java index 27a7da833..149a81ca9 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/ReactiveMinimalIntegrationTests.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/ReactiveMinimalIntegrationTests.java @@ -30,13 +30,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; -public class ReactiveMinimalIntegrationTests { +class ReactiveMinimalIntegrationTests { @Nested @DisplayName("Fundamentals (HTTP/1.1)") - public class Http1 extends TestHttp1ReactiveMinimal { + class Http1 extends TestHttp1ReactiveMinimal { - public Http1() throws Exception { + public Http1() { super(URIScheme.HTTP); } @@ -44,9 +44,9 @@ public Http1() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/1.1, TLS)") - public class Http1Tls extends TestHttp1ReactiveMinimal { + class Http1Tls extends TestHttp1ReactiveMinimal { - public Http1Tls() throws Exception { + public Http1Tls() { super(URIScheme.HTTPS); } @@ -54,9 +54,9 @@ public Http1Tls() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/2)") - public class H2 extends TestH2ReactiveMinimal { + class H2 extends TestH2ReactiveMinimal { - public H2() throws Exception { + public H2() { super(URIScheme.HTTP); } @@ -64,9 +64,9 @@ public H2() throws Exception { @Nested @DisplayName("Fundamentals (HTTP/2, TLS)") - public class H2Tls extends TestH2ReactiveMinimal { + class H2Tls extends TestH2ReactiveMinimal { - public H2Tls() throws Exception { + public H2Tls() { super(URIScheme.HTTPS); } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Async.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Async.java index 2774b1d08..e661e060c 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Async.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Async.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -public abstract class TestH2Async extends AbstractHttpAsyncFundamentalsTest { +abstract class TestH2Async extends AbstractHttpAsyncFundamentalsTest { public TestH2Async(final URIScheme scheme) { super(scheme, ClientProtocolLevel.H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncMinimal.java index c4045cf18..bb6e204c5 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncMinimal.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncMinimal.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -public abstract class TestH2AsyncMinimal extends AbstractHttpAsyncFundamentalsTest { +abstract class TestH2AsyncMinimal extends AbstractHttpAsyncFundamentalsTest { public TestH2AsyncMinimal(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL_H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncRedirect.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncRedirect.java index b3d93c769..0eede8e15 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncRedirect.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2AsyncRedirect.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -public abstract class TestH2AsyncRedirect extends AbstractHttpAsyncRedirectsTest { +abstract class TestH2AsyncRedirect extends AbstractHttpAsyncRedirectsTest { public TestH2AsyncRedirect(final URIScheme scheme) { super(scheme, ClientProtocolLevel.H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ClientAuthentication.java index 178030bf8..7f929e691 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ClientAuthentication.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ClientAuthentication.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -public abstract class TestH2ClientAuthentication extends AbstractHttpAsyncClientAuthenticationTest { +abstract class TestH2ClientAuthentication extends AbstractHttpAsyncClientAuthenticationTest { public TestH2ClientAuthentication(final URIScheme scheme) { super(scheme, ClientProtocolLevel.H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Reactive.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Reactive.java index 7d4cb7d0d..24152bada 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Reactive.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2Reactive.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -public abstract class TestH2Reactive extends AbstractHttpReactiveFundamentalsTest { +abstract class TestH2Reactive extends AbstractHttpReactiveFundamentalsTest { public TestH2Reactive(final URIScheme scheme) { super(scheme, ClientProtocolLevel.H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ReactiveMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ReactiveMinimal.java index 56da02d9f..310cf4c1f 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ReactiveMinimal.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestH2ReactiveMinimal.java @@ -30,7 +30,7 @@ import org.apache.hc.client5.testing.extension.async.ServerProtocolLevel; import org.apache.hc.core5.http.URIScheme; -public abstract class TestH2ReactiveMinimal extends AbstractHttpReactiveFundamentalsTest { +abstract class TestH2ReactiveMinimal extends AbstractHttpReactiveFundamentalsTest { public TestH2ReactiveMinimal(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL_H2_ONLY, ServerProtocolLevel.H2_ONLY); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Async.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Async.java index 9e4b52566..15f93b597 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Async.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Async.java @@ -52,7 +52,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -public abstract class TestHttp1Async extends AbstractHttpAsyncFundamentalsTest { +abstract class TestHttp1Async extends AbstractHttpAsyncFundamentalsTest { public TestHttp1Async(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); @@ -86,7 +86,7 @@ public void testSequentialGetRequestsCloseConnection(final int concurrentConns) } @Test - public void testSharedPool() throws Exception { + void testSharedPool() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", AsyncRandomHandler::new)); final HttpHost target = startServer(); @@ -138,7 +138,7 @@ public void testSharedPool() throws Exception { } @Test - public void testRequestCancellation() throws Exception { + void testRequestCancellation() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", AsyncRandomHandler::new)); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncMinimal.java index 081f97b3e..e4a08c0cc 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncMinimal.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncMinimal.java @@ -52,14 +52,14 @@ import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; -public abstract class TestHttp1AsyncMinimal extends AbstractHttpAsyncFundamentalsTest { +abstract class TestHttp1AsyncMinimal extends AbstractHttpAsyncFundamentalsTest { public TestHttp1AsyncMinimal(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL, ServerProtocolLevel.STANDARD); } @Test - public void testConcurrentPostRequestsSameEndpoint() throws Exception { + void testConcurrentPostRequestsSameEndpoint() throws Exception { configureServer(bootstrap -> bootstrap.register("/echo/*", AsyncEchoHandler::new)); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java index 597dcacda..9dc9c59a5 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncRedirects.java @@ -52,14 +52,14 @@ /** * Redirection test cases. */ -public abstract class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest { +abstract class TestHttp1AsyncRedirects extends AbstractHttpAsyncRedirectsTest { public TestHttp1AsyncRedirects(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); } @Test - public void testBasicRedirect300NoKeepAlive() throws Exception { + void testBasicRedirect300NoKeepAlive() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -85,7 +85,7 @@ public void testBasicRedirect300NoKeepAlive() throws Exception { } @Test - public void testBasicRedirect301NoKeepAlive() throws Exception { + void testBasicRedirect301NoKeepAlive() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( @@ -112,7 +112,7 @@ public void testBasicRedirect301NoKeepAlive() throws Exception { } @Test - public void testDefaultHeadersRedirect() throws Exception { + void testDefaultHeadersRedirect() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", AsyncRandomHandler::new) .setExchangeHandlerDecorator(exchangeHandler -> new RedirectingAsyncDecorator( diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java index fa3292969..651539ff3 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java @@ -50,20 +50,20 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTestBase { +class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTestBase { public TestHttp1AsyncStatefulConnManagement() { super(URIScheme.HTTP, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); } @Test - public void testStatefulConnections() throws Exception { + void testStatefulConnections() throws Exception { configureServer(bootstrap -> bootstrap.register("*", () -> new AbstractSimpleServerExchangeHandler() { @Override protected SimpleHttpResponse handle( final SimpleHttpRequest request, - final HttpCoreContext context) throws HttpException { + final HttpCoreContext context) { final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK); response.setBody("Whatever", ContentType.TEXT_PLAIN); return response; @@ -173,13 +173,13 @@ public void run() { } @Test - public void testRouteSpecificPoolRecylcing() throws Exception { + void testRouteSpecificPoolRecylcing() throws Exception { configureServer(bootstrap -> bootstrap.register("*", () -> new AbstractSimpleServerExchangeHandler() { @Override protected SimpleHttpResponse handle( final SimpleHttpRequest request, - final HttpCoreContext context) throws HttpException { + final HttpCoreContext context) { final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_OK); response.setBody("Whatever", ContentType.TEXT_PLAIN); return response; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ClientAuthentication.java index 0d5a72fbb..11a4e9fe7 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ClientAuthentication.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ClientAuthentication.java @@ -49,14 +49,14 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public abstract class TestHttp1ClientAuthentication extends AbstractHttpAsyncClientAuthenticationTest { +abstract class TestHttp1ClientAuthentication extends AbstractHttpAsyncClientAuthenticationTest { public TestHttp1ClientAuthentication(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); } @Test - public void testBasicAuthenticationSuccessNonPersistentConnection() throws Exception { + void testBasicAuthenticationSuccessNonPersistentConnection() throws Exception { final HttpHost target = startServer(); configureServer(bootstrap -> bootstrap .register("*", AsyncEchoHandler::new) diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Reactive.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Reactive.java index 460ab77bc..9de0a3456 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Reactive.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1Reactive.java @@ -57,7 +57,7 @@ import org.junit.jupiter.params.provider.ValueSource; import org.reactivestreams.Publisher; -public abstract class TestHttp1Reactive extends AbstractHttpReactiveFundamentalsTest { +abstract class TestHttp1Reactive extends AbstractHttpReactiveFundamentalsTest { public TestHttp1Reactive(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ReactiveMinimal.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ReactiveMinimal.java index 07f490b28..6d0c1cdbf 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ReactiveMinimal.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1ReactiveMinimal.java @@ -54,14 +54,14 @@ import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; -public abstract class TestHttp1ReactiveMinimal extends AbstractHttpReactiveFundamentalsTest { +abstract class TestHttp1ReactiveMinimal extends AbstractHttpReactiveFundamentalsTest { public TestHttp1ReactiveMinimal(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL, ServerProtocolLevel.STANDARD); } @Test - public void testConcurrentPostRequestsSameEndpoint() throws Exception { + void testConcurrentPostRequestsSameEndpoint() throws Exception { configureServer(bootstrap -> bootstrap.register("/echo/*", () -> new ReactiveServerExchangeHandler(new ReactiveEchoProcessor()))); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1RequestReExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1RequestReExecution.java index 8a59b9d99..f743871da 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1RequestReExecution.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1RequestReExecution.java @@ -47,14 +47,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public abstract class TestHttp1RequestReExecution extends AbstractIntegrationTestBase { +abstract class TestHttp1RequestReExecution extends AbstractIntegrationTestBase { public TestHttp1RequestReExecution(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD, ServerProtocolLevel.STANDARD); } @BeforeEach - public void setup() { + void setup() { final Resolver serviceAvailabilityResolver = new Resolver() { private final AtomicInteger count = new AtomicInteger(0); @@ -72,7 +72,7 @@ public TimeValue resolve(final HttpRequest request) { } @Test - public void testGiveUpAfterOneRetry() throws Exception { + void testGiveUpAfterOneRetry() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", AsyncRandomHandler::new)); final HttpHost target = startServer(); @@ -91,7 +91,7 @@ public void testGiveUpAfterOneRetry() throws Exception { } @Test - public void testDoNotGiveUpEasily() throws Exception { + void testDoNotGiveUpEasily() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", AsyncRandomHandler::new)); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimalTlsHandshake.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimalTlsHandshake.java index 91bb36d82..50c7cfb57 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimalTlsHandshake.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncMinimalTlsHandshake.java @@ -44,14 +44,14 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestHttpAsyncMinimalTlsHandshake extends AbstractIntegrationTestBase { +class TestHttpAsyncMinimalTlsHandshake extends AbstractIntegrationTestBase { public TestHttpAsyncMinimalTlsHandshake() { super(URIScheme.HTTPS, ClientProtocolLevel.MINIMAL, ServerProtocolLevel.STANDARD); } @Test - public void testSuccessfulTlsHandshake() throws Exception { + void testSuccessfulTlsHandshake() throws Exception { final HttpHost target = startServer(); final int maxConnNo = 2; @@ -69,7 +69,7 @@ public void testSuccessfulTlsHandshake() throws Exception { } @Test - public void testTlsHandshakeFailure() throws Exception { + void testTlsHandshakeFailure() throws Exception { final HttpHost target = startServer(); configureClient(builder -> diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncProtocolPolicy.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncProtocolPolicy.java index d9f631223..cfefde58e 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncProtocolPolicy.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttpAsyncProtocolPolicy.java @@ -45,7 +45,7 @@ import org.hamcrest.CoreMatchers; import org.junit.jupiter.api.Test; -public abstract class TestHttpAsyncProtocolPolicy extends AbstractIntegrationTestBase { +abstract class TestHttpAsyncProtocolPolicy extends AbstractIntegrationTestBase { private final HttpVersion version; @@ -55,7 +55,7 @@ public TestHttpAsyncProtocolPolicy(final URIScheme scheme, final HttpVersion ver } @Test - public void testRequestContext() throws Exception { + void testRequestContext() throws Exception { configureServer(bootstrap -> bootstrap.register("/random/*", AsyncRandomHandler::new)); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/async/TestAsyncResources.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/async/TestAsyncResources.java index 86ee12467..0c470fbdf 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/async/TestAsyncResources.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/async/TestAsyncResources.java @@ -79,7 +79,7 @@ public TestAsyncResources(final URIScheme scheme, final ClientProtocolLevel clie } @Override - public void afterEach(final ExtensionContext extensionContext) throws Exception { + public void afterEach(final ExtensionContext extensionContext) { LOG.debug("Shutting down test server"); if (client != null) { client.close(CloseMode.GRACEFUL); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientResources.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientResources.java index 2a32ad148..c38c7fba1 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientResources.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientResources.java @@ -70,7 +70,7 @@ public TestClientResources(final URIScheme scheme, final ClientProtocolLevel cli } @Override - public void afterEach(final ExtensionContext extensionContext) throws Exception { + public void afterEach(final ExtensionContext extensionContext) { LOG.debug("Shutting down test server"); if (client != null) { diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/fluent/TestFluent.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/fluent/TestFluent.java index 9eefe100c..047178743 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/fluent/TestFluent.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/fluent/TestFluent.java @@ -51,7 +51,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -public class TestFluent { +class TestFluent { public static final Timeout TIMEOUT = Timeout.ofMinutes(1); @@ -59,7 +59,7 @@ public class TestFluent { private TestClientResources testResources = new TestClientResources(URIScheme.HTTP, ClientProtocolLevel.STANDARD, TIMEOUT); @BeforeEach - public void setUp() throws Exception { + void setUp() { testResources.configureServer(bootstrap -> bootstrap .register("/", (request, response, context) -> response.setEntity(new StringEntity("All is well", ContentType.TEXT_PLAIN))) @@ -99,7 +99,7 @@ public HttpHost startServer() throws Exception { } @Test - public void testGetRequest() throws Exception { + void testGetRequest() throws Exception { final HttpHost target = startServer(); final String baseURL = "http://localhost:" + target.getPort(); final String message = Request.get(baseURL + "/").execute().returnContent().asString(); @@ -107,7 +107,7 @@ public void testGetRequest() throws Exception { } @Test - public void testGetRequestByName() throws Exception { + void testGetRequestByName() throws Exception { final HttpHost target = startServer(); final String baseURL = "http://localhost:" + target.getPort(); final String message = Request.create("GET", baseURL + "/").execute().returnContent().asString(); @@ -115,7 +115,7 @@ public void testGetRequestByName() throws Exception { } @Test - public void testGetRequestByNameWithURI() throws Exception { + void testGetRequestByNameWithURI() throws Exception { final HttpHost target = startServer(); final String baseURL = "http://localhost:" + target.getPort(); final String message = Request.create("GET", new URI(baseURL + "/")).execute().returnContent().asString(); @@ -123,7 +123,7 @@ public void testGetRequestByNameWithURI() throws Exception { } @Test - public void testGetRequestFailure() throws Exception { + void testGetRequestFailure() throws Exception { final HttpHost target = startServer(); final String baseURL = "http://localhost:" + target.getPort(); Assertions.assertThrows(ClientProtocolException.class, () -> @@ -131,7 +131,7 @@ public void testGetRequestFailure() throws Exception { } @Test - public void testPostRequest() throws Exception { + void testPostRequest() throws Exception { final HttpHost target = startServer(); final String baseURL = "http://localhost:" + target.getPort(); final String message1 = Request.post(baseURL + "/echo") @@ -145,7 +145,7 @@ public void testPostRequest() throws Exception { } @Test - public void testContentAsStringWithCharset() throws Exception { + void testContentAsStringWithCharset() throws Exception { final HttpHost target = startServer(); final String baseURL = "http://localhost:" + target.getPort(); final Content content = Request.post(baseURL + "/echo").bodyByteArray("Ü".getBytes(StandardCharsets.UTF_8)).execute() @@ -156,7 +156,7 @@ public void testContentAsStringWithCharset() throws Exception { } @Test - public void testConnectionRelease() throws Exception { + void testConnectionRelease() throws Exception { final HttpHost target = startServer(); final String baseURL = "http://localhost:" + target.getPort(); for (int i = 0; i < 20; i++) { @@ -182,7 +182,7 @@ private String generateLargeString(final int size) { } @Test - public void testLargeResponse() throws Exception { + void testLargeResponse() throws Exception { final HttpHost target = startServer(); final String baseURL = "http://localhost:" + target.getPort(); @@ -192,7 +192,7 @@ public void testLargeResponse() throws Exception { } @Test - public void testLargeResponseError() throws Exception { + void testLargeResponseError() throws Exception { final HttpHost target = startServer(); final String baseURL = "http://localhost:" + target.getPort(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/AbstractIntegrationTestBase.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/AbstractIntegrationTestBase.java index 72d21b442..bf31dbf4c 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/AbstractIntegrationTestBase.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/AbstractIntegrationTestBase.java @@ -41,7 +41,7 @@ import org.apache.hc.core5.util.Timeout; import org.junit.jupiter.api.extension.RegisterExtension; -public abstract class AbstractIntegrationTestBase { +abstract class AbstractIntegrationTestBase { public static final Timeout TIMEOUT = Timeout.ofMinutes(1); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpIntegrationTests.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpIntegrationTests.java index 639b0c063..f162795f6 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpIntegrationTests.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpIntegrationTests.java @@ -30,13 +30,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; -public class HttpIntegrationTests { +class HttpIntegrationTests { @Nested @DisplayName("Request execution (HTTP/1.1)") - public class RequestExecution extends TestClientRequestExecution { + class RequestExecution extends TestClientRequestExecution { - public RequestExecution() throws Exception { + public RequestExecution() { super(URIScheme.HTTP); } @@ -44,9 +44,9 @@ public RequestExecution() throws Exception { @Nested @DisplayName("Request execution (HTTP/1.1, TLS)") - public class RequestExecutionTls extends TestClientRequestExecution { + class RequestExecutionTls extends TestClientRequestExecution { - public RequestExecutionTls() throws Exception { + public RequestExecutionTls() { super(URIScheme.HTTPS); } @@ -54,9 +54,9 @@ public RequestExecutionTls() throws Exception { @Nested @DisplayName("Authentication (HTTP/1.1)") - public class Authentication extends TestClientAuthentication { + class Authentication extends TestClientAuthentication { - public Authentication() throws Exception { + public Authentication() { super(URIScheme.HTTP); } @@ -64,9 +64,9 @@ public Authentication() throws Exception { @Nested @DisplayName("Authentication (HTTP/1.1, TLS)") - public class AuthenticationTls extends TestClientAuthentication { + class AuthenticationTls extends TestClientAuthentication { - public AuthenticationTls() throws Exception { + public AuthenticationTls() { super(URIScheme.HTTPS); } @@ -74,9 +74,9 @@ public AuthenticationTls() throws Exception { @Nested @DisplayName("Content coding (HTTP/1.1)") - public class ContentCoding extends TestContentCodings { + class ContentCoding extends TestContentCodings { - public ContentCoding() throws Exception { + public ContentCoding() { super(URIScheme.HTTP); } @@ -84,9 +84,9 @@ public ContentCoding() throws Exception { @Nested @DisplayName("Content coding (HTTP/1.1, TLS)") - public class ContentCodingTls extends TestContentCodings { + class ContentCodingTls extends TestContentCodings { - public ContentCodingTls() throws Exception { + public ContentCodingTls() { super(URIScheme.HTTPS); } @@ -94,9 +94,9 @@ public ContentCodingTls() throws Exception { @Nested @DisplayName("Redirects (HTTP/1.1)") - public class Redirects extends TestRedirects { + class Redirects extends TestRedirects { - public Redirects() throws Exception { + public Redirects() { super(URIScheme.HTTP); } @@ -104,9 +104,9 @@ public Redirects() throws Exception { @Nested @DisplayName("Redirects (HTTP/1.1, TLS)") - public class RedirectsTls extends TestRedirects { + class RedirectsTls extends TestRedirects { - public RedirectsTls() throws Exception { + public RedirectsTls() { super(URIScheme.HTTPS); } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpMinimalIntegrationTests.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpMinimalIntegrationTests.java index 6ba2fdac6..e7a480142 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpMinimalIntegrationTests.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/HttpMinimalIntegrationTests.java @@ -30,13 +30,13 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; -public class HttpMinimalIntegrationTests { +class HttpMinimalIntegrationTests { @Nested @DisplayName("Request execution (HTTP/1.1)") - public class RequestExecution extends TestMinimalClientRequestExecution { + class RequestExecution extends TestMinimalClientRequestExecution { - public RequestExecution() throws Exception { + public RequestExecution() { super(URIScheme.HTTP); } @@ -44,9 +44,9 @@ public RequestExecution() throws Exception { @Nested @DisplayName("Request execution (HTTP/1.1, TLS)") - public class RequestExecutionTls extends TestMinimalClientRequestExecution { + class RequestExecutionTls extends TestMinimalClientRequestExecution { - public RequestExecutionTls() throws Exception { + public RequestExecutionTls() { super(URIScheme.HTTPS); } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestBasicConnectionManager.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestBasicConnectionManager.java index 18c1eeaef..374b86654 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestBasicConnectionManager.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestBasicConnectionManager.java @@ -37,14 +37,14 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestBasicConnectionManager extends AbstractIntegrationTestBase { +class TestBasicConnectionManager extends AbstractIntegrationTestBase { public TestBasicConnectionManager() { super(URIScheme.HTTP, ClientProtocolLevel.STANDARD); } @Test - public void testBasics() throws Exception { + void testBasics() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", new RandomHandler())); final HttpHost target = startServer(); @@ -62,7 +62,7 @@ public void testBasics() throws Exception { } @Test - public void testConnectionStillInUse() throws Exception { + void testConnectionStillInUse() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", new RandomHandler())); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java index e49c25f0f..d54f25223 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java @@ -94,14 +94,14 @@ /** * Unit tests for automatic client authentication. */ -public abstract class TestClientAuthentication extends AbstractIntegrationTestBase { +abstract class TestClientAuthentication extends AbstractIntegrationTestBase { protected TestClientAuthentication(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD); } public void configureServerWithBasicAuth(final Authenticator authenticator, - final Consumer serverCustomizer) throws IOException { + final Consumer serverCustomizer) { configureServer(bootstrap -> { bootstrap.setExchangeHandlerDecorator(requestHandler -> new AuthenticatingDecorator(requestHandler, authenticator)); @@ -109,14 +109,14 @@ public void configureServerWithBasicAuth(final Authenticator authenticator, }); } - public void configureServerWithBasicAuth(final Consumer serverCustomizer) throws IOException { + public void configureServerWithBasicAuth(final Consumer serverCustomizer) { configureServerWithBasicAuth( new BasicTestAuthenticator("test:test", "test realm"), serverCustomizer); } @Test - public void testBasicAuthenticationNoCreds() throws Exception { + void testBasicAuthenticationNoCreds() throws Exception { configureServerWithBasicAuth(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -140,7 +140,7 @@ public void testBasicAuthenticationNoCreds() throws Exception { } @Test - public void testBasicAuthenticationFailure() throws Exception { + void testBasicAuthenticationFailure() throws Exception { configureServerWithBasicAuth(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -166,7 +166,7 @@ public void testBasicAuthenticationFailure() throws Exception { } @Test - public void testBasicAuthenticationSuccess() throws Exception { + void testBasicAuthenticationSuccess() throws Exception { configureServerWithBasicAuth(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -191,7 +191,7 @@ public void testBasicAuthenticationSuccess() throws Exception { } @Test - public void testBasicAuthenticationSuccessOnNonRepeatablePutExpectContinue() throws Exception { + void testBasicAuthenticationSuccessOnNonRepeatablePutExpectContinue() throws Exception { configureServer(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -222,7 +222,7 @@ public void testBasicAuthenticationSuccessOnNonRepeatablePutExpectContinue() thr } @Test - public void testBasicAuthenticationFailureOnNonRepeatablePutDontExpectContinue() throws Exception { + void testBasicAuthenticationFailureOnNonRepeatablePutDontExpectContinue() throws Exception { configureServerWithBasicAuth(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -253,7 +253,7 @@ public void testBasicAuthenticationFailureOnNonRepeatablePutDontExpectContinue() } @Test - public void testBasicAuthenticationSuccessOnRepeatablePost() throws Exception { + void testBasicAuthenticationSuccessOnRepeatablePost() throws Exception { configureServerWithBasicAuth(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -281,7 +281,7 @@ public void testBasicAuthenticationSuccessOnRepeatablePost() throws Exception { } @Test - public void testBasicAuthenticationFailureOnNonRepeatablePost() throws Exception { + void testBasicAuthenticationFailureOnNonRepeatablePost() throws Exception { configureServerWithBasicAuth(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -312,7 +312,7 @@ public void testBasicAuthenticationFailureOnNonRepeatablePost() throws Exception } @Test - public void testBasicAuthenticationCredentialsCaching() throws Exception { + void testBasicAuthenticationCredentialsCaching() throws Exception { configureServerWithBasicAuth(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -350,7 +350,7 @@ public void testBasicAuthenticationCredentialsCaching() throws Exception { } @Test - public void testBasicAuthenticationCredentialsCachingByPathPrefix() throws Exception { + void testBasicAuthenticationCredentialsCachingByPathPrefix() throws Exception { configureServerWithBasicAuth(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -415,7 +415,7 @@ public void testBasicAuthenticationCredentialsCachingByPathPrefix() throws Excep } @Test - public void testAuthenticationCredentialsCachingReAuthenticationOnDifferentRealm() throws Exception { + void testAuthenticationCredentialsCachingReAuthenticationOnDifferentRealm() throws Exception { configureServerWithBasicAuth(new Authenticator() { @Override @@ -492,7 +492,7 @@ public String getRealm(final URIAuthority authority, final String requestUri) { } @Test - public void testAuthenticationUserinfoInRequest() throws Exception { + void testAuthenticationUserinfoInRequest() throws Exception { configureServer(bootstrap -> bootstrap .register("*", new EchoHandler())); final HttpHost target = startServer(); @@ -505,7 +505,7 @@ public void testAuthenticationUserinfoInRequest() throws Exception { } @Test - public void testPreemptiveAuthentication() throws Exception { + void testPreemptiveAuthentication() throws Exception { final Authenticator authenticator = Mockito.spy(new BasicTestAuthenticator("test:test", "test realm")); configureServerWithBasicAuth(authenticator, bootstrap -> bootstrap @@ -534,7 +534,7 @@ public void testPreemptiveAuthentication() throws Exception { } @Test - public void testPreemptiveAuthenticationFailure() throws Exception { + void testPreemptiveAuthenticationFailure() throws Exception { final Authenticator authenticator = Mockito.spy(new BasicTestAuthenticator("test:test", "test realm")); configureServerWithBasicAuth(authenticator, bootstrap -> bootstrap @@ -569,7 +569,7 @@ static class ProxyAuthHandler implements HttpRequestHandler { public void handle( final ClassicHttpRequest request, final ClassicHttpResponse response, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { final String creds = (String) context.getAttribute("creds"); if (creds == null || !creds.equals("test:test")) { response.setCode(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED); @@ -583,7 +583,7 @@ public void handle( } @Test - public void testAuthenticationTargetAsProxy() throws Exception { + void testAuthenticationTargetAsProxy() throws Exception { configureServer(bootstrap -> bootstrap .register("*", new ProxyAuthHandler())); final HttpHost target = startServer(); @@ -604,7 +604,7 @@ public void testAuthenticationTargetAsProxy() throws Exception { } @Test - public void testConnectionCloseAfterAuthenticationSuccess() throws Exception { + void testConnectionCloseAfterAuthenticationSuccess() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new AuthenticatingDecorator(requestHandler, new BasicTestAuthenticator("test:test", "test realm")) { @@ -640,7 +640,7 @@ protected void customizeUnauthorizedResponse(final ClassicHttpResponse unauthori } @Test - public void testReauthentication() throws Exception { + void testReauthentication() throws Exception { final BasicSchemeFactory myBasicAuthSchemeFactory = new BasicSchemeFactory() { @Override @@ -720,7 +720,7 @@ protected void customizeUnauthorizedResponse(final ClassicHttpResponse unauthori } @Test - public void testAuthenticationFallback() throws Exception { + void testAuthenticationFallback() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new AuthenticatingDecorator(requestHandler, new BasicTestAuthenticator("test:test", "test realm")) { @@ -759,7 +759,7 @@ protected void customizeUnauthorizedResponse(final ClassicHttpResponse unauthori private final static String CHARS = "0123456789abcdef"; @Test - public void testBearerTokenAuthentication() throws Exception { + void testBearerTokenAuthentication() throws Exception { final SecureRandom secureRandom = SecureRandom.getInstanceStrong(); secureRandom.setSeed(System.currentTimeMillis()); final StringBuilder buf = new StringBuilder(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java index a797d9114..fc850e92e 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientRequestExecution.java @@ -71,7 +71,7 @@ /** * Client protocol handling tests. */ -public abstract class TestClientRequestExecution extends AbstractIntegrationTestBase { +abstract class TestClientRequestExecution extends AbstractIntegrationTestBase { public TestClientRequestExecution(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD); @@ -87,7 +87,7 @@ public SimpleService() { public void handle( final ClassicHttpRequest request, final ClassicHttpResponse response, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { response.setCode(HttpStatus.SC_OK); final StringEntity entity = new StringEntity("Whatever"); response.setEntity(entity); @@ -131,7 +131,7 @@ public ClassicHttpResponse execute( } @Test - public void testAutoGeneratedHeaders() throws Exception { + void testAutoGeneratedHeaders() throws Exception { configureServer(bootstrap -> bootstrap.register("*", new SimpleService())); final HttpHost target = startServer(); @@ -191,7 +191,7 @@ public TimeValue getRetryInterval( } @Test - public void testNonRepeatableEntity() throws Exception { + void testNonRepeatableEntity() throws Exception { configureServer(bootstrap -> bootstrap.register("*", new SimpleService())); final HttpHost target = startServer(); @@ -242,7 +242,7 @@ public TimeValue getRetryInterval( } @Test - public void testNonCompliantURI() throws Exception { + void testNonCompliantURI() throws Exception { configureServer(bootstrap -> bootstrap.register("*", new SimpleService())); final HttpHost target = startServer(); @@ -262,7 +262,7 @@ public void testNonCompliantURI() throws Exception { } @Test - public void testRelativeRequestURIWithFragment() throws Exception { + void testRelativeRequestURIWithFragment() throws Exception { configureServer(bootstrap -> bootstrap.register("*", new SimpleService())); final HttpHost target = startServer(); @@ -282,7 +282,7 @@ public void testRelativeRequestURIWithFragment() throws Exception { } @Test - public void testAbsoluteRequestURIWithFragment() throws Exception { + void testAbsoluteRequestURIWithFragment() throws Exception { configureServer(bootstrap -> bootstrap.register("*", new SimpleService())); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java index 028d8e473..8c215b2a8 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionManagement.java @@ -67,7 +67,7 @@ * Tests for {@code PoolingHttpClientConnectionManager} that do require a server * to communicate with. */ -public class TestConnectionManagement extends AbstractIntegrationTestBase { +class TestConnectionManagement extends AbstractIntegrationTestBase { public TestConnectionManagement() { super(URIScheme.HTTP, ClientProtocolLevel.STANDARD); @@ -76,7 +76,7 @@ public TestConnectionManagement() { ConnectionEndpoint.RequestExecutor exec; @BeforeEach - public void setup() { + void setup() { exec = new ConnectionEndpoint.RequestExecutor() { final HttpRequestExecutor requestExecutor = new HttpRequestExecutor(); @@ -99,7 +99,7 @@ public ClassicHttpResponse execute(final ClassicHttpRequest request, * Tests releasing and re-using a connection after a response is read. */ @Test - public void testReleaseConnection() throws Exception { + void testReleaseConnection() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", new RandomHandler())); final HttpHost target = startServer(); @@ -162,7 +162,7 @@ public void testReleaseConnection() throws Exception { * Tests releasing with time limits. */ @Test - public void testReleaseConnectionWithTimeLimits() throws Exception { + void testReleaseConnectionWithTimeLimits() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", new RandomHandler())); final HttpHost target = startServer(); @@ -233,7 +233,7 @@ public void testReleaseConnectionWithTimeLimits() throws Exception { } @Test - public void testCloseExpiredIdleConnections() throws Exception { + void testCloseExpiredIdleConnections() throws Exception { final HttpHost target = startServer(); final TestClient client = client(); final PoolingHttpClientConnectionManager connManager = client.getConnectionManager(); @@ -273,7 +273,7 @@ public void testCloseExpiredIdleConnections() throws Exception { } @Test - public void testCloseExpiredTTLConnections() throws Exception { + void testCloseExpiredTTLConnections() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", new RandomHandler())); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java index d056e10a9..3b11dd0d3 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java @@ -59,14 +59,14 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestConnectionReuse extends AbstractIntegrationTestBase { +class TestConnectionReuse extends AbstractIntegrationTestBase { public TestConnectionReuse() { super(URIScheme.HTTP, ClientProtocolLevel.STANDARD); } @Test - public void testReuseOfPersistentConnections() throws Exception { + void testReuseOfPersistentConnections() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", new RandomHandler())); final HttpHost target = startServer(); @@ -103,7 +103,7 @@ public void testReuseOfPersistentConnections() throws Exception { } @Test - public void testReuseOfPersistentConnectionsWithStreamedRequestAndResponse() throws Exception { + void testReuseOfPersistentConnectionsWithStreamedRequestAndResponse() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", new RandomHandler())); final HttpHost target = startServer(); @@ -150,14 +150,14 @@ private static class AlwaysCloseConn implements HttpResponseInterceptor { public void process( final HttpResponse response, final EntityDetails entityDetails, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { response.setHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE); } } @Test - public void testReuseOfClosedConnections() throws Exception { + void testReuseOfClosedConnections() throws Exception { configureServer(bootstrap -> bootstrap .setHttpProcessor(HttpProcessors.customServer(null) .add(new AlwaysCloseConn()) @@ -196,7 +196,7 @@ public void testReuseOfClosedConnections() throws Exception { } @Test - public void testReuseOfAbortedConnections() throws Exception { + void testReuseOfAbortedConnections() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", new RandomHandler())); final HttpHost target = startServer(); @@ -233,7 +233,7 @@ public void testReuseOfAbortedConnections() throws Exception { } @Test - public void testKeepAliveHeaderRespected() throws Exception { + void testKeepAliveHeaderRespected() throws Exception { configureServer(bootstrap -> bootstrap .setHttpProcessor(HttpProcessors.customServer(null) .add(new ResponseKeepAlive()) @@ -350,7 +350,7 @@ private static class ResponseKeepAlive implements HttpResponseInterceptor { public void process( final HttpResponse response, final EntityDetails entityDetails, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { final Header connection = response.getFirstHeader(HttpHeaders.CONNECTION); if(connection != null) { if(!connection.getValue().equalsIgnoreCase("Close")) { diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java index 2e179ca9c..8a5e4c1c1 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java @@ -68,7 +68,7 @@ * require no intervention from the user of HttpClient, but we still want to let clients do their * own thing if they so wish. */ -public abstract class TestContentCodings extends AbstractIntegrationTestBase { +abstract class TestContentCodings extends AbstractIntegrationTestBase { protected TestContentCodings(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD); @@ -82,7 +82,7 @@ protected TestContentCodings(final URIScheme scheme) { * if there was a problem */ @Test - public void testResponseWithNoContent() throws Exception { + void testResponseWithNoContent() throws Exception { configureServer(bootstrap -> bootstrap .register("*", new HttpRequestHandler() { @@ -93,7 +93,7 @@ public void testResponseWithNoContent() throws Exception { public void handle( final ClassicHttpRequest request, final ClassicHttpResponse response, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { response.setCode(HttpStatus.SC_NO_CONTENT); } })); @@ -117,7 +117,7 @@ public void handle( * @throws Exception */ @Test - public void testDeflateSupportForServerReturningRfc1950Stream() throws Exception { + void testDeflateSupportForServerReturningRfc1950Stream() throws Exception { final String entityText = "Hello, this is some plain text coming back."; configureServer(bootstrap -> bootstrap @@ -142,7 +142,7 @@ public void testDeflateSupportForServerReturningRfc1950Stream() throws Exception * @throws Exception */ @Test - public void testDeflateSupportForServerReturningRfc1951Stream() throws Exception { + void testDeflateSupportForServerReturningRfc1951Stream() throws Exception { final String entityText = "Hello, this is some plain text coming back."; configureServer(bootstrap -> bootstrap @@ -166,7 +166,7 @@ public void testDeflateSupportForServerReturningRfc1951Stream() throws Exception * @throws Exception */ @Test - public void testGzipSupport() throws Exception { + void testGzipSupport() throws Exception { final String entityText = "Hello, this is some plain text coming back."; configureServer(bootstrap -> bootstrap @@ -191,7 +191,7 @@ public void testGzipSupport() throws Exception { * if there was a problem */ @Test - public void testThreadSafetyOfContentCodings() throws Exception { + void testThreadSafetyOfContentCodings() throws Exception { final String entityText = "Hello, this is some plain text coming back."; configureServer(bootstrap -> bootstrap @@ -241,7 +241,7 @@ public void testThreadSafetyOfContentCodings() throws Exception { } @Test - public void testHttpEntityWriteToForGzip() throws Exception { + void testHttpEntityWriteToForGzip() throws Exception { final String entityText = "Hello, this is some plain text coming back."; configureServer(bootstrap -> bootstrap @@ -262,7 +262,7 @@ public void testHttpEntityWriteToForGzip() throws Exception { } @Test - public void testHttpEntityWriteToForDeflate() throws Exception { + void testHttpEntityWriteToForDeflate() throws Exception { final String entityText = "Hello, this is some plain text coming back."; configureServer(bootstrap -> bootstrap @@ -282,7 +282,7 @@ public void testHttpEntityWriteToForDeflate() throws Exception { } @Test - public void gzipResponsesWorkWithBasicResponseHandler() throws Exception { + void gzipResponsesWorkWithBasicResponseHandler() throws Exception { final String entityText = "Hello, this is some plain text coming back."; configureServer(bootstrap -> bootstrap @@ -298,7 +298,7 @@ public void gzipResponsesWorkWithBasicResponseHandler() throws Exception { } @Test - public void deflateResponsesWorkWithBasicResponseHandler() throws Exception { + void deflateResponsesWorkWithBasicResponseHandler() throws Exception { final String entityText = "Hello, this is some plain text coming back."; configureServer(bootstrap -> bootstrap @@ -336,7 +336,7 @@ private HttpRequestHandler createDeflateEncodingRequestHandler( public void handle( final ClassicHttpRequest request, final ClassicHttpResponse response, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { response.setEntity(new StringEntity(entityText)); response.addHeader("Content-Type", "text/plain"); final Iterator it = MessageSupport.iterate(request, "Accept-Encoding"); @@ -384,7 +384,7 @@ private HttpRequestHandler createGzipEncodingRequestHandler(final String entityT public void handle( final ClassicHttpRequest request, final ClassicHttpResponse response, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) throws IOException { response.setEntity(new StringEntity(entityText)); response.addHeader("Content-Type", "text/plain"); response.addHeader("Content-Type", "text/plain"); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestCookieVirtualHost.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestCookieVirtualHost.java index 6eea853d3..8e5eced0a 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestCookieVirtualHost.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestCookieVirtualHost.java @@ -50,19 +50,19 @@ /** * This class tests cookie matching when using Virtual Host. */ -public class TestCookieVirtualHost { +class TestCookieVirtualHost { private HttpServer server; @AfterEach - public void shutDown() throws Exception { + void shutDown() { if (this.server != null) { this.server.close(CloseMode.GRACEFUL); } } @Test - public void testCookieMatchingWithVirtualHosts() throws Exception { + void testCookieMatchingWithVirtualHosts() throws Exception { server = ServerBootstrap.bootstrap() .register("app.mydomain.fr", "*", (request, response, context) -> { diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestDefaultClientTlsStrategy.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestDefaultClientTlsStrategy.java index 0242a9cc3..736e21f6d 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestDefaultClientTlsStrategy.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestDefaultClientTlsStrategy.java @@ -68,12 +68,12 @@ /** * Unit tests for {@link DefaultClientTlsStrategy}. */ -public class TestDefaultClientTlsStrategy { +class TestDefaultClientTlsStrategy { private HttpServer server; @AfterEach - public void shutDown() throws Exception { + void shutDown() { if (this.server != null) { this.server.close(CloseMode.GRACEFUL); } @@ -96,7 +96,7 @@ public boolean isFired() { } @Test - public void testBasicSSL() throws Exception { + void testBasicSSL() throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) @@ -126,7 +126,7 @@ public void testBasicSSL() throws Exception { } @Test - public void testBasicDefaultHostnameVerifier() throws Exception { + void testBasicDefaultHostnameVerifier() throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) @@ -153,7 +153,7 @@ public void testBasicDefaultHostnameVerifier() throws Exception { } @Test - public void testClientAuthSSL() throws Exception { + void testClientAuthSSL() throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) @@ -183,7 +183,7 @@ public void testClientAuthSSL() throws Exception { } @Test - public void testClientAuthSSLFailure() throws Exception { + void testClientAuthSSLFailure() throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) @@ -217,7 +217,7 @@ public void testClientAuthSSLFailure() throws Exception { } @Test - public void testSSLTrustVerification() throws Exception { + void testSSLTrustVerification() throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) @@ -245,13 +245,13 @@ public void testSSLTrustVerification() throws Exception { } @Test - public void testSSLTrustVerificationOverrideWithCustom() throws Exception { + void testSSLTrustVerificationOverrideWithCustom() throws Exception { final TrustStrategy trustStrategy = (chain, authType) -> chain.length == 1; testSSLTrustVerificationOverride(trustStrategy); } private void testSSLTrustVerificationOverride(final TrustStrategy trustStrategy) - throws Exception, IOException, NoSuchAlgorithmException, KeyManagementException, KeyStoreException { + throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) @@ -284,7 +284,7 @@ private void testSSLTrustVerificationOverride(final TrustStrategy trustStrategy) } @Test - public void testSSLDisabledByDefault() throws Exception { + void testSSLDisabledByDefault() throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) @@ -310,7 +310,7 @@ public void testSSLDisabledByDefault() throws Exception { } @Test - public void testWeakCiphersDisabledByDefault() { + void testWeakCiphersDisabledByDefault() { final String[] weakCiphersSuites = { "SSL_RSA_WITH_RC4_128_SHA", "SSL_RSA_WITH_3DES_EDE_CBC_SHA", @@ -362,7 +362,7 @@ private void testWeakCipherDisabledByDefault(final String cipherSuite) throws Ex } @Test - public void testHostnameVerificationClient() throws Exception { + void testHostnameVerificationClient() throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) @@ -424,7 +424,7 @@ public void testHostnameVerificationClient() throws Exception { } @Test - public void testHostnameVerificationBuiltIn() throws Exception { + void testHostnameVerificationBuiltIn() throws Exception { // @formatter:off this.server = ServerBootstrap.bootstrap() .setSslContext(SSLTestContexts.createServerSSLContext()) diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java index b4008b20b..3a366ca12 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java @@ -61,7 +61,7 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("boxing") // test code -public class TestFutureRequestExecutionService { +class TestFutureRequestExecutionService { private HttpServer localServer; private String uri; @@ -70,7 +70,7 @@ public class TestFutureRequestExecutionService { private final AtomicBoolean blocked = new AtomicBoolean(false); @BeforeEach - public void before() throws Exception { + void before() throws Exception { this.localServer = ServerBootstrap.bootstrap() .setCanonicalHostName("localhost") .register("/wait", (request, response, context) -> { @@ -97,21 +97,21 @@ public void before() throws Exception { } @AfterEach - public void after() throws Exception { + void after() throws Exception { blocked.set(false); // any remaining requests should unblock this.localServer.stop(); httpAsyncClientWithFuture.close(); } @Test - public void shouldExecuteSingleCall() throws InterruptedException, ExecutionException { + void shouldExecuteSingleCall() throws InterruptedException, ExecutionException { final FutureTask task = httpAsyncClientWithFuture.execute( new HttpGet(uri), HttpClientContext.create(), new OkidokiHandler()); Assertions.assertTrue(task.get(), "request should have returned OK"); } @Test - public void shouldCancel() throws InterruptedException, ExecutionException { + void shouldCancel() { final FutureTask task = httpAsyncClientWithFuture.execute( new HttpGet(uri), HttpClientContext.create(), new OkidokiHandler()); task.cancel(true); @@ -122,7 +122,7 @@ public void shouldCancel() throws InterruptedException, ExecutionException { } @Test - public void shouldTimeout() throws InterruptedException, ExecutionException, TimeoutException { + void shouldTimeout() { blocked.set(true); final FutureTask task = httpAsyncClientWithFuture.execute( new HttpGet(uri), HttpClientContext.create(), new OkidokiHandler()); @@ -131,7 +131,7 @@ public void shouldTimeout() throws InterruptedException, ExecutionException, Tim } @Test - public void shouldExecuteMultipleCalls() throws Exception { + void shouldExecuteMultipleCalls() throws Exception { final int reqNo = 100; final Queue> tasks = new LinkedList<>(); for(int i = 0; i < reqNo; i++) { @@ -147,7 +147,7 @@ public void shouldExecuteMultipleCalls() throws Exception { } @Test - public void shouldExecuteMultipleCallsAndCallback() throws Exception { + void shouldExecuteMultipleCallsAndCallback() throws Exception { final int reqNo = 100; final Queue> tasks = new LinkedList<>(); final CountDownLatch latch = new CountDownLatch(reqNo); @@ -194,7 +194,7 @@ public void cancelled() { private final class OkidokiHandler implements HttpClientResponseHandler { @Override public Boolean handleResponse( - final ClassicHttpResponse response) throws IOException { + final ClassicHttpResponse response) { return response.getCode() == 200; } } diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestHttpClientBuilderInterceptors.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestHttpClientBuilderInterceptors.java index 160616e2d..621a45f38 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestHttpClientBuilderInterceptors.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestHttpClientBuilderInterceptors.java @@ -40,14 +40,14 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("boxing") // test code -public class TestHttpClientBuilderInterceptors extends AbstractIntegrationTestBase { +class TestHttpClientBuilderInterceptors extends AbstractIntegrationTestBase { public TestHttpClientBuilderInterceptors() { super(URIScheme.HTTP, ClientProtocolLevel.STANDARD); } @BeforeEach - public void before() throws Exception { + void before() { configureServer(bootstrap -> bootstrap .register("/test", (request, response, context) -> { final Header testInterceptorHeader = request.getHeader("X-Test-Interceptor"); @@ -64,7 +64,7 @@ public void before() throws Exception { } @Test - public void testAddExecInterceptorLastShouldBeExecuted() throws Exception { + void testAddExecInterceptorLastShouldBeExecuted() throws Exception { final HttpHost httpHost = startServer(); final TestClient client = client(); final ClassicHttpRequest request = new HttpPost("/test"); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestIdleConnectionEviction.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestIdleConnectionEviction.java index 0bf8777f3..24fe2bf76 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestIdleConnectionEviction.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestIdleConnectionEviction.java @@ -43,14 +43,14 @@ import org.apache.hc.core5.util.TimeValue; import org.junit.jupiter.api.Test; -public class TestIdleConnectionEviction extends AbstractIntegrationTestBase { +class TestIdleConnectionEviction extends AbstractIntegrationTestBase { public TestIdleConnectionEviction() { super(URIScheme.HTTP, ClientProtocolLevel.STANDARD); } @Test - public void testIdleConnectionEviction() throws Exception { + void testIdleConnectionEviction() throws Exception { configureServer(bootstrap -> bootstrap .register("/random/*", new RandomHandler())); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMalformedServerResponse.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMalformedServerResponse.java index d3e118e67..21b034bde 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMalformedServerResponse.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMalformedServerResponse.java @@ -48,12 +48,12 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestMalformedServerResponse { +class TestMalformedServerResponse { private HttpServer server; @AfterEach - public void shutDown() throws Exception { + void shutDown() { if (this.server != null) { this.server.close(CloseMode.GRACEFUL); } @@ -95,7 +95,7 @@ public DefaultBHttpServerConnection createConnection(final Socket socket) throws } @Test - public void testNoContentResponseWithGarbage() throws Exception { + void testNoContentResponseWithGarbage() throws Exception { server = ServerBootstrap.bootstrap() .setCanonicalHostName("localhost") .setConnectionFactory(new BrokenServerConnectionFactory()) diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java index 0ab13d15f..ad213718e 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java @@ -53,7 +53,7 @@ /** * Client protocol handling tests. */ -public abstract class TestMinimalClientRequestExecution extends AbstractIntegrationTestBase { +abstract class TestMinimalClientRequestExecution extends AbstractIntegrationTestBase { protected TestMinimalClientRequestExecution(final URIScheme scheme) { super(scheme, ClientProtocolLevel.MINIMAL); @@ -69,7 +69,7 @@ public SimpleService() { public void handle( final ClassicHttpRequest request, final ClassicHttpResponse response, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { response.setCode(HttpStatus.SC_OK); final StringEntity entity = new StringEntity("Whatever"); response.setEntity(entity); @@ -77,7 +77,7 @@ public void handle( } @Test - public void testNonCompliantURIWithContext() throws Exception { + void testNonCompliantURIWithContext() throws Exception { configureServer(bootstrap -> bootstrap.register("*", new SimpleService())); final HttpHost target = startServer(); @@ -108,7 +108,7 @@ public void testNonCompliantURIWithContext() throws Exception { } @Test - public void testNonCompliantURIWithoutContext() throws Exception { + void testNonCompliantURIWithoutContext() throws Exception { configureServer(bootstrap -> bootstrap.register("*", new SimpleService())); final HttpHost target = startServer(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java index 9545835ff..3f1b30a76 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestRedirects.java @@ -75,14 +75,14 @@ /** * Redirection test cases. */ -public abstract class TestRedirects extends AbstractIntegrationTestBase { +abstract class TestRedirects extends AbstractIntegrationTestBase { protected TestRedirects(final URIScheme scheme) { super(scheme, ClientProtocolLevel.STANDARD); } @Test - public void testBasicRedirect300() throws Exception { + void testBasicRedirect300() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -110,7 +110,7 @@ public void testBasicRedirect300() throws Exception { } @Test - public void testBasicRedirect300NoKeepAlive() throws Exception { + void testBasicRedirect300NoKeepAlive() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -140,7 +140,7 @@ public void testBasicRedirect300NoKeepAlive() throws Exception { } @Test - public void testBasicRedirect301() throws Exception { + void testBasicRedirect301() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -172,7 +172,7 @@ public void testBasicRedirect301() throws Exception { } @Test - public void testBasicRedirect302() throws Exception { + void testBasicRedirect302() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -198,7 +198,7 @@ public void testBasicRedirect302() throws Exception { } @Test - public void testBasicRedirect302NoLocation() throws Exception { + void testBasicRedirect302NoLocation() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -229,7 +229,7 @@ public void testBasicRedirect302NoLocation() throws Exception { } @Test - public void testBasicRedirect303() throws Exception { + void testBasicRedirect303() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -254,7 +254,7 @@ public void testBasicRedirect303() throws Exception { } @Test - public void testBasicRedirect304() throws Exception { + void testBasicRedirect304() throws Exception { configureServer(bootstrap -> bootstrap .register("/oldlocation/*", (request, response, context) -> { response.setCode(HttpStatus.SC_NOT_MODIFIED); @@ -284,7 +284,7 @@ public void testBasicRedirect304() throws Exception { } @Test - public void testBasicRedirect305() throws Exception { + void testBasicRedirect305() throws Exception { configureServer(bootstrap -> bootstrap .register("/oldlocation/*", (request, response, context) -> { response.setCode(HttpStatus.SC_USE_PROXY); @@ -314,7 +314,7 @@ public void testBasicRedirect305() throws Exception { } @Test - public void testBasicRedirect307() throws Exception { + void testBasicRedirect307() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -339,7 +339,7 @@ public void testBasicRedirect307() throws Exception { } @Test - public void testMaxRedirectCheck() throws Exception { + void testMaxRedirectCheck() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -362,7 +362,7 @@ public void testMaxRedirectCheck() throws Exception { } @Test - public void testCircularRedirect() throws Exception { + void testCircularRedirect() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -385,7 +385,7 @@ public void testCircularRedirect() throws Exception { } @Test - public void testPostRedirectSeeOther() throws Exception { + void testPostRedirectSeeOther() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -412,7 +412,7 @@ public void testPostRedirectSeeOther() throws Exception { } @Test - public void testRelativeRedirect() throws Exception { + void testRelativeRedirect() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -444,7 +444,7 @@ public void testRelativeRedirect() throws Exception { } @Test - public void testRelativeRedirect2() throws Exception { + void testRelativeRedirect2() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -476,7 +476,7 @@ public void testRelativeRedirect2() throws Exception { } @Test - public void testRejectBogusRedirectLocation() throws Exception { + void testRejectBogusRedirectLocation() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -500,7 +500,7 @@ public void testRejectBogusRedirectLocation() throws Exception { } @Test - public void testRejectInvalidRedirectLocation() throws Exception { + void testRejectInvalidRedirectLocation() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -524,7 +524,7 @@ public void testRejectInvalidRedirectLocation() throws Exception { } @Test - public void testRedirectWithCookie() throws Exception { + void testRedirectWithCookie() throws Exception { configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(requestHandler -> new RedirectingDecorator( requestHandler, @@ -561,7 +561,7 @@ public void testRedirectWithCookie() throws Exception { } @Test - public void testDefaultHeadersRedirect() throws Exception { + void testDefaultHeadersRedirect() throws Exception { configureClient(builder -> builder .setDefaultHeaders(Collections.singletonList(new BasicHeader(HttpHeaders.USER_AGENT, "my-test-client"))) ); @@ -593,7 +593,7 @@ public void testDefaultHeadersRedirect() throws Exception { } @Test - public void testCompressionHeaderRedirect() throws Exception { + void testCompressionHeaderRedirect() throws Exception { final Queue values = new ConcurrentLinkedQueue<>(); configureServer(bootstrap -> bootstrap .setExchangeHandlerDecorator(new Decorator() { diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java index cc8efd213..b0d631f77 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java @@ -53,7 +53,7 @@ /** * Test cases for state-ful connections. */ -public class TestStatefulConnManagement extends AbstractIntegrationTestBase { +class TestStatefulConnManagement extends AbstractIntegrationTestBase { public static final Timeout LONG_TIMEOUT = Timeout.ofMinutes(3); @@ -71,7 +71,7 @@ public SimpleService() { public void handle( final ClassicHttpRequest request, final ClassicHttpResponse response, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { response.setCode(HttpStatus.SC_OK); final StringEntity entity = new StringEntity("Whatever"); response.setEntity(entity); @@ -79,7 +79,7 @@ public void handle( } @Test - public void testStatefulConnections() throws Exception { + void testStatefulConnections() throws Exception { configureServer(bootstrap -> bootstrap .register("*", new SimpleService())); final HttpHost target = startServer(); @@ -193,7 +193,7 @@ public void run() { } @Test - public void testRouteSpecificPoolRecylcing() throws Exception { + void testRouteSpecificPoolRecylcing() throws Exception { configureServer(bootstrap -> bootstrap.register("*", new SimpleService())); final HttpHost target = startServer(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/ConnectExceptionSupportTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/ConnectExceptionSupportTest.java index 0a2020ec2..0f1904511 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/ConnectExceptionSupportTest.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/ConnectExceptionSupportTest.java @@ -38,23 +38,23 @@ * Unit tests for exceptions. * Trivial, but it looks better in the Clover reports. */ -public class ConnectExceptionSupportTest { +class ConnectExceptionSupportTest { @Test - public void testConnectTimeoutExceptionFromNullMessageAndHost() { + void testConnectTimeoutExceptionFromNullMessageAndHost() { final ConnectTimeoutException ctx = ConnectExceptionSupport.createConnectTimeoutException(null, null); Assertions.assertEquals("Connect to remote endpoint timed out", ctx.getMessage()); } @Test - public void testConnectTimeoutExceptionFromCause() { + void testConnectTimeoutExceptionFromCause() { final IOException cause = new IOException("something awful"); final ConnectTimeoutException ctx = ConnectExceptionSupport.createConnectTimeoutException(cause, null); Assertions.assertEquals("Connect to remote endpoint failed: something awful", ctx.getMessage()); } @Test - public void testConnectTimeoutExceptionFromCauseAndHost() { + void testConnectTimeoutExceptionFromCauseAndHost() { final HttpHost target = new HttpHost("localhost"); final IOException cause = new IOException(); final ConnectTimeoutException ctx = ConnectExceptionSupport.createConnectTimeoutException(cause, target); @@ -62,7 +62,7 @@ public void testConnectTimeoutExceptionFromCauseAndHost() { } @Test - public void testConnectTimeoutExceptionFromCauseHostAndRemoteAddress() throws Exception { + void testConnectTimeoutExceptionFromCauseHostAndRemoteAddress() throws Exception { final HttpHost target = new HttpHost("localhost"); final InetAddress remoteAddress = InetAddress.getByAddress(new byte[] {1,2,3,4}); final IOException cause = new IOException(); @@ -71,21 +71,21 @@ public void testConnectTimeoutExceptionFromCauseHostAndRemoteAddress() throws Ex } @Test - public void testHttpHostConnectExceptionFromNullCause() { + void testHttpHostConnectExceptionFromNullCause() { final HttpHostConnectException ctx = ConnectExceptionSupport.createHttpHostConnectException(null, null, (InetAddress [])null); Assertions.assertEquals("Connect to remote endpoint refused", ctx.getMessage()); } @Test - public void testHttpHostConnectExceptionFromCause() { + void testHttpHostConnectExceptionFromCause() { final IOException cause = new IOException("something awful"); final HttpHostConnectException ctx = ConnectExceptionSupport.createHttpHostConnectException(cause, null); Assertions.assertEquals("Connect to remote endpoint failed: something awful", ctx.getMessage()); } @Test - public void testHttpHostConnectExceptionFromCauseAndHost() { + void testHttpHostConnectExceptionFromCauseAndHost() { final HttpHost target = new HttpHost("localhost"); final IOException cause = new IOException(); final HttpHostConnectException ctx = ConnectExceptionSupport.createHttpHostConnectException(cause, target); @@ -93,7 +93,7 @@ public void testHttpHostConnectExceptionFromCauseAndHost() { } @Test - public void testHttpHostConnectExceptionFromCauseHostAndRemoteAddress() throws Exception { + void testHttpHostConnectExceptionFromCauseHostAndRemoteAddress() throws Exception { final HttpHost target = new HttpHost("localhost"); final InetAddress remoteAddress1 = InetAddress.getByAddress(new byte[] {1,2,3,4}); final InetAddress remoteAddress2 = InetAddress.getByAddress(new byte[] {5,6,7,8}); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/SystemDefaultDnsResolverTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/SystemDefaultDnsResolverTest.java index 58304dca8..d99817e05 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/SystemDefaultDnsResolverTest.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/SystemDefaultDnsResolverTest.java @@ -34,7 +34,7 @@ import org.junit.jupiter.api.Test; -public class SystemDefaultDnsResolverTest { +class SystemDefaultDnsResolverTest { @Test void resolve() throws UnknownHostException { diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java b/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java index 87f06f24d..c1ba0b5eb 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java @@ -41,7 +41,7 @@ /** * Tests for {@link HttpRoute}. */ -public class TestHttpRoute { +class TestHttpRoute { // a selection of constants for generating routes public final static @@ -83,7 +83,7 @@ public class TestHttpRoute { } @Test - public void testCstrFullRoute() { + void testCstrFullRoute() { // create a route with all arguments and check the details final HttpHost[] chain3 = { PROXY1, PROXY2, PROXY3 }; @@ -110,7 +110,7 @@ public void testCstrFullRoute() { } @Test - public void testCstrFullFlags() { + void testCstrFullFlags() { // tests the flag parameters in the full-blown constructor final HttpHost[] chain3 = { PROXY1, PROXY2, PROXY3 }; @@ -174,7 +174,7 @@ public void testCstrFullFlags() { } @Test - public void testInvalidArguments() { + void testInvalidArguments() { final HttpHost[] chain1 = { PROXY1 }; // for reference: this one should succeed @@ -189,7 +189,7 @@ public void testInvalidArguments() { } @Test - public void testNullEnums() { + void testNullEnums() { // tests the default values for the enum parameters // also covers the accessors for the enum attributes @@ -205,7 +205,7 @@ public void testNullEnums() { } @Test - public void testEqualsHashcodeClone() throws CloneNotSupportedException { + void testEqualsHashcodeClone() throws CloneNotSupportedException { final HttpHost[] chain0 = { }; final HttpHost[] chain1 = { PROXY1 }; final HttpHost[] chain3 = { PROXY1, PROXY2, PROXY3 }; @@ -337,7 +337,7 @@ public void testEqualsHashcodeClone() throws CloneNotSupportedException { } @Test - public void testHopping() { + void testHopping() { // test getHopCount() and getHopTarget() with different proxy chains final HttpHost[] proxies = null; final HttpRoute route = new HttpRoute(TARGET1, null, proxies, true, @@ -369,7 +369,7 @@ public void testHopping() { } @Test - public void testCstr1() { + void testCstr1() { final HttpRoute route = new HttpRoute(TARGET2); final HttpRoute should = new HttpRoute (TARGET2, null, (HttpHost[]) null, false, @@ -378,7 +378,7 @@ public void testCstr1() { } @Test - public void testCstr3() { + void testCstr3() { // test convenience constructor with 3 arguments HttpRoute route = new HttpRoute(TARGET2, LOCAL61, false); HttpRoute should = new HttpRoute @@ -394,7 +394,7 @@ public void testCstr3() { @SuppressWarnings("unused") @Test - public void testCstr4() { + void testCstr4() { // test convenience constructor with 4 arguments HttpRoute route = new HttpRoute(TARGET2, null, PROXY2, false); HttpRoute should = new HttpRoute @@ -414,7 +414,7 @@ public void testCstr4() { } @Test - public void testCstr6() { + void testCstr6() { // test convenience constructor with 6 arguments HttpRoute route = new HttpRoute (TARGET2, null, PROXY2, true, @@ -436,7 +436,7 @@ public void testCstr6() { } @Test - public void testImmutable() throws CloneNotSupportedException { + void testImmutable() throws CloneNotSupportedException { final HttpHost[] proxies = new HttpHost[]{ PROXY1, PROXY2, PROXY3 }; final HttpRoute route1 = new HttpRoute(TARGET1, null, proxies, false, diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/async/methods/TestSimpleMessageBuilders.java b/httpclient5/src/test/java/org/apache/hc/client5/http/async/methods/TestSimpleMessageBuilders.java index 786d7dfd4..56dbb5c8c 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/async/methods/TestSimpleMessageBuilders.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/async/methods/TestSimpleMessageBuilders.java @@ -50,10 +50,10 @@ /** * Simple tests for {@link SimpleResponseBuilder} and {@link SimpleRequestBuilder}. */ -public class TestSimpleMessageBuilders { +class TestSimpleMessageBuilders { @Test - public void testResponseBasics() throws Exception { + void testResponseBasics() { final SimpleResponseBuilder builder = SimpleResponseBuilder.create(200); Assertions.assertEquals(200, builder.getStatus()); Assertions.assertNull(builder.getHeaders()); @@ -111,7 +111,7 @@ public void testResponseBasics() throws Exception { } @Test - public void testRequestBasics() throws Exception { + void testRequestBasics() throws Exception { final SimpleRequestBuilder builder = SimpleRequestBuilder.get(); Assertions.assertEquals(URI.create("/"), builder.getUri()); Assertions.assertEquals("GET", builder.getMethod()); @@ -205,7 +205,7 @@ public void testRequestBasics() throws Exception { } @Test - public void testResponseCopy() throws Exception { + void testResponseCopy() { final SimpleHttpResponse response = SimpleHttpResponse.create(400); response.addHeader("h1", "v1"); response.addHeader("h1", "v2"); @@ -220,7 +220,7 @@ public void testResponseCopy() throws Exception { } @Test - public void testRequestCopy() throws Exception { + void testRequestCopy() { final SimpleHttpRequest request = SimpleHttpRequest.create(Method.GET, URI.create("https://host:3456/stuff?blah")) ; request.addHeader("h1", "v1"); request.addHeader("h1", "v2"); @@ -238,7 +238,7 @@ public void testRequestCopy() throws Exception { } @Test - public void testGetParameters() throws Exception { + void testGetParameters() { final SimpleRequestBuilder builder = SimpleRequestBuilder.get(URI.create("https://host:3456/stuff?p0=p0")); builder.addParameter("p1", "v1"); builder.addParameters(new BasicNameValuePair("p2", "v2"), new BasicNameValuePair("p3", "v3")); @@ -256,7 +256,7 @@ public void testGetParameters() throws Exception { } @Test - public void testPostParameters() throws Exception { + void testPostParameters() { final SimpleRequestBuilder builder = SimpleRequestBuilder.post(URI.create("https://host:3456/stuff?p0=p0")); builder.addParameter("p1", "v1"); builder.addParameters(new BasicNameValuePair("p2", "v2"), new BasicNameValuePair("p3", "v3")); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthChallenge.java b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthChallenge.java index e987792a9..b7bb0ea77 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthChallenge.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthChallenge.java @@ -33,10 +33,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestAuthChallenge { +class TestAuthChallenge { @Test - public void testAuthChallengeWithValue() { + void testAuthChallengeWithValue() { final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.TARGET, StandardAuthScheme.BASIC, "blah", null); Assertions.assertEquals(StandardAuthScheme.BASIC, authChallenge.getSchemeName()); Assertions.assertEquals("blah", authChallenge.getValue()); @@ -45,7 +45,7 @@ public void testAuthChallengeWithValue() { } @Test - public void testAuthChallengeWithParams() { + void testAuthChallengeWithParams() { final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.TARGET, StandardAuthScheme.BASIC, null, Arrays.asList(new BasicNameValuePair("blah", "this"), new BasicNameValuePair("blah", "that"))); Assertions.assertEquals(StandardAuthScheme.BASIC, authChallenge.getSchemeName()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthScope.java b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthScope.java index b7b72b7b4..531d0119b 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthScope.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestAuthScope.java @@ -33,10 +33,10 @@ /** * Tests for {@link org.apache.hc.client5.http.auth.AuthScope}. */ -public class TestAuthScope { +class TestAuthScope { @Test - public void testBasics() { + void testBasics() { final AuthScope authscope = new AuthScope("http", "somehost", 80, "somerealm", "SomeScheme"); Assertions.assertEquals("SOMESCHEME", authscope.getSchemeName()); Assertions.assertEquals("http", authscope.getProtocol()); @@ -47,7 +47,7 @@ public void testBasics() { } @Test - public void testByOrigin() { + void testByOrigin() { final HttpHost host = new HttpHost("http", "somehost", 8080); final AuthScope authscope = new AuthScope(host); Assertions.assertNull(authscope.getSchemeName()); @@ -59,7 +59,7 @@ public void testByOrigin() { } @Test - public void testMixedCaseHostname() { + void testMixedCaseHostname() { final AuthScope authscope = new AuthScope("SomeHost", 80); Assertions.assertNull(authscope.getSchemeName()); Assertions.assertEquals("somehost", authscope.getHost()); @@ -69,14 +69,14 @@ public void testMixedCaseHostname() { } @Test - public void testByOriginMixedCaseHostname() throws Exception { + void testByOriginMixedCaseHostname() { final HttpHost host = new HttpHost("http", "SomeHost", 8080); final AuthScope authscope = new AuthScope(host); Assertions.assertEquals("somehost", authscope.getHost()); } @Test - public void testBasicsAllOptional() { + void testBasicsAllOptional() { final AuthScope authscope = new AuthScope(null, null, -1, null, null); Assertions.assertNull(authscope.getSchemeName()); Assertions.assertNull(authscope.getHost()); @@ -86,7 +86,7 @@ public void testBasicsAllOptional() { } @Test - public void testScopeMatching() { + void testScopeMatching() { final AuthScope authscope1 = new AuthScope("http", "somehost", 80, "somerealm", "somescheme"); final AuthScope authscope2 = new AuthScope("http", "someotherhost", 80, "somerealm", "somescheme"); Assertions.assertTrue(authscope1.match(authscope2) < 0); @@ -117,7 +117,7 @@ public void testScopeMatching() { } @Test - public void testEquals() { + void testEquals() { final AuthScope authscope1 = new AuthScope("http", "somehost", 80, "somerealm", "somescheme"); final AuthScope authscope2 = new AuthScope("http", "someotherhost", 80, "somerealm", "somescheme"); final AuthScope authscope3 = new AuthScope("http", "somehost", 80, "somerealm", "somescheme"); @@ -137,7 +137,7 @@ public void testEquals() { } @Test - public void testHash() { + void testHash() { final AuthScope authscope1 = new AuthScope("http", "somehost", 80, "somerealm", "somescheme"); final AuthScope authscope2 = new AuthScope("http", "someotherhost", 80, "somerealm", "somescheme"); final AuthScope authscope3 = new AuthScope("http", "somehost", 80, "somerealm", "somescheme"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java index ee7df8940..51896c097 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/auth/TestCredentials.java @@ -36,10 +36,10 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("deprecation") -public class TestCredentials { +class TestCredentials { @Test - public void testUsernamePasswordCredentialsBasics() { + void testUsernamePasswordCredentialsBasics() { final UsernamePasswordCredentials creds1 = new UsernamePasswordCredentials( "name","pwd".toCharArray()); Assertions.assertEquals("name", creds1.getUserName()); @@ -57,7 +57,7 @@ public void testUsernamePasswordCredentialsBasics() { } @Test - public void testNTCredentialsBasics() { + void testNTCredentialsBasics() { final NTCredentials creds1 = new NTCredentials( "name","pwd".toCharArray(), "localhost", "domain"); Assertions.assertEquals("name", creds1.getUserName()); @@ -77,7 +77,7 @@ public void testNTCredentialsBasics() { } @Test - public void testUsernamePasswordCredentialsHashCode() { + void testUsernamePasswordCredentialsHashCode() { final UsernamePasswordCredentials creds1 = new UsernamePasswordCredentials( "name","pwd".toCharArray()); final UsernamePasswordCredentials creds2 = new UsernamePasswordCredentials( @@ -91,7 +91,7 @@ public void testUsernamePasswordCredentialsHashCode() { } @Test - public void testUsernamePasswordCredentialsEquals() { + void testUsernamePasswordCredentialsEquals() { final UsernamePasswordCredentials creds1 = new UsernamePasswordCredentials( "name","pwd".toCharArray()); final UsernamePasswordCredentials creds2 = new UsernamePasswordCredentials( @@ -105,13 +105,13 @@ public void testUsernamePasswordCredentialsEquals() { } @Test - public void tesBearerTokenBasics() { + void tesBearerTokenBasics() { final BearerToken creds1 = new BearerToken("token of some sort"); Assertions.assertEquals("token of some sort", creds1.getToken()); } @Test - public void testBearerTokenHashCode() { + void testBearerTokenHashCode() { final BearerToken creds1 = new BearerToken("token of some sort"); final BearerToken creds2 = new BearerToken("another token of some sort"); final BearerToken creds3 = new BearerToken("token of some sort"); @@ -122,7 +122,7 @@ public void testBearerTokenHashCode() { } @Test - public void testBearerTokenEquals() { + void testBearerTokenEquals() { final BearerToken creds1 = new BearerToken("token of some sort"); final BearerToken creds2 = new BearerToken("another token of some sort"); final BearerToken creds3 = new BearerToken("token of some sort"); @@ -133,7 +133,7 @@ public void testBearerTokenEquals() { } @Test - public void testNTCredentialsHashCode() { + void testNTCredentialsHashCode() { final NTCredentials creds1 = new NTCredentials( "name","pwd".toCharArray(), "somehost", "domain"); final NTCredentials creds2 = new NTCredentials( @@ -165,7 +165,7 @@ public void testNTCredentialsHashCode() { } @Test - public void testNTCredentialsEquals() { + void testNTCredentialsEquals() { final NTCredentials creds1 = new NTCredentials( "name","pwd".toCharArray(), "somehost", "domain"); final NTCredentials creds2 = new NTCredentials( @@ -198,7 +198,7 @@ public void testNTCredentialsEquals() { } @Test - public void testUsernamePasswordCredentialsSerialization() throws Exception { + void testUsernamePasswordCredentialsSerialization() throws Exception { final UsernamePasswordCredentials orig = new UsernamePasswordCredentials("name","pwd".toCharArray()); final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream(); final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer); @@ -212,7 +212,7 @@ public void testUsernamePasswordCredentialsSerialization() throws Exception { } @Test - public void testNTCredentialsSerialization() throws Exception { + void testNTCredentialsSerialization() throws Exception { final NTCredentials orig = new NTCredentials("name","pwd".toCharArray(), "somehost", "domain"); final ByteArrayOutputStream outbuffer = new ByteArrayOutputStream(); final ObjectOutputStream outStream = new ObjectOutputStream(outbuffer); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpOptions.java b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpOptions.java index c660ddfc9..210852570 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpOptions.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpOptions.java @@ -33,10 +33,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestHttpOptions { +class TestHttpOptions { @Test - public void testMultipleAllows() { + void testMultipleAllows() { final BasicHttpResponse resp = new BasicHttpResponse(200, "test reason"); resp.addHeader("Allow", "POST"); resp.addHeader("Allow", "GET"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java index d6ba7b8cf..7103294ae 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java @@ -47,54 +47,54 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestHttpRequestBase { +class TestHttpRequestBase { private static final String HOT_URL = "http://host/path"; @Test - public void testBasicGetMethodProperties() throws Exception { + void testBasicGetMethodProperties() throws Exception { final HttpGet httpget = new HttpGet(HOT_URL); Assertions.assertEquals("GET", httpget.getMethod()); Assertions.assertEquals(new URI(HOT_URL), httpget.getUri()); } @Test - public void testBasicHttpPostMethodProperties() throws Exception { + void testBasicHttpPostMethodProperties() throws Exception { final HttpPost HttpPost = new HttpPost(HOT_URL); Assertions.assertEquals("POST", HttpPost.getMethod()); Assertions.assertEquals(new URI(HOT_URL), HttpPost.getUri()); } @Test - public void testBasicHttpHeadMethodProperties() throws Exception { + void testBasicHttpHeadMethodProperties() throws Exception { final HttpHead httpHead = new HttpHead(HOT_URL); Assertions.assertEquals("HEAD", httpHead.getMethod()); Assertions.assertEquals(new URI(HOT_URL), httpHead.getUri()); } @Test - public void testBasicHttpOptionMethodProperties() throws Exception { + void testBasicHttpOptionMethodProperties() throws Exception { final HttpOptions httpOption = new HttpOptions(HOT_URL); Assertions.assertEquals("OPTIONS", httpOption.getMethod()); Assertions.assertEquals(new URI(HOT_URL), httpOption.getUri()); } @Test - public void testBasicHttpPatchMethodProperties() throws Exception { + void testBasicHttpPatchMethodProperties() throws Exception { final HttpPatch httpPatch = new HttpPatch(HOT_URL); Assertions.assertEquals("PATCH", httpPatch.getMethod()); Assertions.assertEquals(new URI(HOT_URL), httpPatch.getUri()); } @Test - public void testBasicHttpPutMethodProperties() throws Exception { + void testBasicHttpPutMethodProperties() throws Exception { final HttpPut httpPut = new HttpPut(HOT_URL); Assertions.assertEquals("PUT", httpPut.getMethod()); Assertions.assertEquals(new URI(HOT_URL), httpPut.getUri()); } @Test - public void testBasicHttpTraceMethodProperties() throws Exception { + void testBasicHttpTraceMethodProperties() throws Exception { final HttpTrace httpTrace = new HttpTrace(HOT_URL); Assertions.assertEquals("TRACE", httpTrace.getMethod()); Assertions.assertEquals(new URI(HOT_URL), httpTrace.getUri()); @@ -102,7 +102,7 @@ public void testBasicHttpTraceMethodProperties() throws Exception { @Test - public void testBasicHttpDeleteMethodProperties() throws Exception { + void testBasicHttpDeleteMethodProperties() throws Exception { final HttpDelete httpDelete = new HttpDelete(HOT_URL); Assertions.assertEquals("DELETE", httpDelete.getMethod()); Assertions.assertEquals(new URI(HOT_URL), httpDelete.getUri()); @@ -110,64 +110,64 @@ public void testBasicHttpDeleteMethodProperties() throws Exception { @Test - public void testGetMethodEmptyURI() throws Exception { + void testGetMethodEmptyURI() throws Exception { final HttpGet httpget = new HttpGet(""); Assertions.assertEquals(new URI("/"), httpget.getUri()); } @Test - public void testPostMethodEmptyURI() throws Exception { + void testPostMethodEmptyURI() throws Exception { final HttpPost HttpPost = new HttpPost(""); Assertions.assertEquals(new URI("/"), HttpPost.getUri()); } @Test - public void testHeadMethodEmptyURI() throws Exception { + void testHeadMethodEmptyURI() throws Exception { final HttpHead httpHead = new HttpHead(""); Assertions.assertEquals(new URI("/"), httpHead.getUri()); } @Test - public void testOptionMethodEmptyURI() throws Exception { + void testOptionMethodEmptyURI() throws Exception { final HttpOptions httpOption = new HttpOptions(""); Assertions.assertEquals(new URI("/"), httpOption.getUri()); } @Test - public void testPatchMethodEmptyURI() throws Exception { + void testPatchMethodEmptyURI() throws Exception { final HttpPatch httpPatch = new HttpPatch(""); Assertions.assertEquals(new URI("/"), httpPatch.getUri()); } @Test - public void testPutMethodEmptyURI() throws Exception { + void testPutMethodEmptyURI() throws Exception { final HttpPut httpPut = new HttpPut(""); Assertions.assertEquals(new URI("/"), httpPut.getUri()); } @Test - public void testTraceMethodEmptyURI() throws Exception { + void testTraceMethodEmptyURI() throws Exception { final HttpTrace httpTrace = new HttpTrace(""); Assertions.assertEquals(new URI("/"), httpTrace.getUri()); } @Test - public void testDeleteMethodEmptyURI() throws Exception { + void testDeleteMethodEmptyURI() throws Exception { final HttpDelete httpDelete = new HttpDelete(""); Assertions.assertEquals(new URI("/"), httpDelete.getUri()); } @Test - public void testTraceMethodSetEntity() { + void testTraceMethodSetEntity() { final HttpTrace httpTrace = new HttpTrace(HOT_URL); final HttpEntity entity = EntityBuilder.create().setText("stuff").build(); assertThrows(IllegalStateException.class, () -> httpTrace.setEntity(entity)); } @Test - public void testOptionMethodGetAllowedMethods() { + void testOptionMethodGetAllowedMethods() { final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); response.addHeader("Allow", "GET, HEAD"); response.addHeader("Allow", "DELETE"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpTrace.java b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpTrace.java index 2c0a92bc0..ccd5342a7 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpTrace.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpTrace.java @@ -30,10 +30,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestHttpTrace { +class TestHttpTrace { @Test - public void testHttpTraceSetEntity() { + void testHttpTraceSetEntity() { final HttpTrace httpTrace = new HttpTrace("/path"); Assertions.assertThrows(IllegalStateException.class, () -> httpTrace.setEntity(null)); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java b/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java index 8eeea8c31..ac48c99d4 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/config/TestRequestConfig.java @@ -37,16 +37,16 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestRequestConfig { +class TestRequestConfig { @Test - public void testBasics() { + void testBasics() { final RequestConfig config = RequestConfig.custom().build(); config.toString(); } @Test - public void testDefaults() { + void testDefaults() { final RequestConfig config = RequestConfig.DEFAULT; Assertions.assertEquals(Timeout.ofMinutes(3), config.getConnectionRequestTimeout()); Assertions.assertFalse(config.isExpectContinueEnabled()); @@ -61,7 +61,7 @@ public void testDefaults() { } @Test - public void testBuildAndCopy() throws Exception { + void testBuildAndCopy() { final RequestConfig config0 = RequestConfig.custom() .setConnectionRequestTimeout(44, TimeUnit.MILLISECONDS) .setExpectContinueEnabled(true) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookieOrigin.java b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookieOrigin.java index a94dc951d..542aec858 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookieOrigin.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookieOrigin.java @@ -33,10 +33,10 @@ /** * Test cases for {@link CookieOrigin}. */ -public class TestCookieOrigin { +class TestCookieOrigin { @Test - public void testConstructor() { + void testConstructor() { final CookieOrigin origin = new CookieOrigin("www.apache.org", 80, "/", false); Assertions.assertEquals("www.apache.org", origin.getHost()); Assertions.assertEquals(80, origin.getPort()); @@ -45,31 +45,31 @@ public void testConstructor() { } @Test - public void testNullHost() { + void testNullHost() { Assertions.assertThrows(NullPointerException.class, () -> new CookieOrigin(null, 80, "/", false)); } @Test - public void testEmptyHost() { + void testEmptyHost() { Assertions.assertThrows(IllegalArgumentException.class, () -> new CookieOrigin(" ", 80, "/", false)); } @Test - public void testNegativePort() { + void testNegativePort() { Assertions.assertThrows(IllegalArgumentException.class, () -> new CookieOrigin("www.apache.org", -80, "/", false)); } @Test - public void testNullPath() { + void testNullPath() { Assertions.assertThrows(NullPointerException.class, () -> new CookieOrigin("www.apache.org", 80, null, false)); } @Test - public void testEmptyPath() { + void testEmptyPath() { final CookieOrigin origin = new CookieOrigin("www.apache.org", 80, "", false); Assertions.assertEquals("www.apache.org", origin.getHost()); Assertions.assertEquals(80, origin.getPort()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePathComparator.java b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePathComparator.java index adcfa22d0..48499d0b4 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePathComparator.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePathComparator.java @@ -36,10 +36,10 @@ /** * Test cases for {@link CookiePathComparator}. */ -public class TestCookiePathComparator { +class TestCookiePathComparator { @Test - public void testUnequality1() { + void testUnequality1() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/a/b/"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -50,7 +50,7 @@ public void testUnequality1() { } @Test - public void testUnequality2() { + void testUnequality2() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/a/b"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -61,7 +61,7 @@ public void testUnequality2() { } @Test - public void testEquality1() { + void testEquality1() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/a"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -72,7 +72,7 @@ public void testEquality1() { } @Test - public void testEquality2() { + void testEquality2() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/a/"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -83,7 +83,7 @@ public void testEquality2() { } @Test - public void testEquality3() { + void testEquality3() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath(null); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -94,7 +94,7 @@ public void testEquality3() { } @Test - public void testEquality4() { + void testEquality4() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/this"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePriorityComparator.java b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePriorityComparator.java index f980f0443..086eb9c82 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePriorityComparator.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/cookie/TestCookiePriorityComparator.java @@ -38,17 +38,17 @@ /** * Test cases for {@link org.apache.hc.client5.http.cookie.CookiePriorityComparator}. */ -public class TestCookiePriorityComparator { +class TestCookiePriorityComparator { private Comparator comparator; @BeforeEach - public void setup() { + void setup() { comparator = CookiePriorityComparator.INSTANCE; } @Test - public void testUnequality() { + void testUnequality() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/a/b/"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -58,7 +58,7 @@ public void testUnequality() { } @Test - public void testEquality() { + void testEquality() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/a"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -68,7 +68,7 @@ public void testEquality() { } @Test - public void testUnequalityTrailingSlash() { + void testUnequalityTrailingSlash() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/a/"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -78,7 +78,7 @@ public void testUnequalityTrailingSlash() { } @Test - public void testEqualityNullPath() { + void testEqualityNullPath() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath(null); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -88,7 +88,7 @@ public void testEqualityNullPath() { } @Test - public void testEqualitySameLength() { + void testEqualitySameLength() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/this"); final BasicClientCookie cookie2 = new BasicClientCookie("name1", "value"); @@ -98,7 +98,7 @@ public void testEqualitySameLength() { } @Test - public void testUnequalityCreationDate() { + void testUnequalityCreationDate() { final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value"); cookie1.setPath("/blah"); cookie1.setCreationDate(Instant.now().minusMillis(200000)); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestBrotli.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestBrotli.java index 5b48150fa..735a62399 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestBrotli.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestBrotli.java @@ -33,7 +33,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestBrotli { +class TestBrotli { /** * Brotli decompression test implemented by request with specified response encoding br @@ -41,7 +41,7 @@ public class TestBrotli { * @throws Exception */ @Test - public void testDecompressionWithBrotli() throws Exception { + void testDecompressionWithBrotli() throws Exception { final byte[] bytes = new byte[] {33, 44, 0, 4, 116, 101, 115, 116, 32, 98, 114, 111, 116, 108, 105, 10, 3}; diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDecompressingEntity.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDecompressingEntity.java index cc439405e..ecbb27cc2 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDecompressingEntity.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDecompressingEntity.java @@ -43,10 +43,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestDecompressingEntity { +class TestDecompressingEntity { @Test - public void testNonStreaming() throws Exception { + void testNonStreaming() throws Exception { final CRC32 crc32 = new CRC32(); final StringEntity wrapped = new StringEntity("1234567890", StandardCharsets.US_ASCII); final ChecksumEntity entity = new ChecksumEntity(wrapped, crc32); @@ -60,7 +60,7 @@ public void testNonStreaming() throws Exception { } @Test - public void testStreaming() throws Exception { + void testStreaming() throws Exception { final CRC32 crc32 = new CRC32(); final ByteArrayInputStream in = new ByteArrayInputStream("1234567890".getBytes(StandardCharsets.US_ASCII)); final InputStreamEntity wrapped = new InputStreamEntity(in, -1, ContentType.DEFAULT_TEXT); @@ -77,7 +77,7 @@ public void testStreaming() throws Exception { } @Test - public void testWriteToStream() throws Exception { + void testWriteToStream() throws Exception { final CRC32 crc32 = new CRC32(); final StringEntity wrapped = new StringEntity("1234567890", StandardCharsets.US_ASCII); try (final ChecksumEntity entity = new ChecksumEntity(wrapped, crc32)) { diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDeflate.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDeflate.java index b0ab922a1..0859a8bd1 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDeflate.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestDeflate.java @@ -37,10 +37,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestDeflate { +class TestDeflate { @Test - public void testCompressDecompress() throws Exception { + void testCompressDecompress() throws Exception { final String s = "some kind of text"; final byte[] input = s.getBytes(StandardCharsets.US_ASCII); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestEntityBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestEntityBuilder.java index 4f975dbaa..fec3a0aef 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestEntityBuilder.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestEntityBuilder.java @@ -37,16 +37,16 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public class TestEntityBuilder { +class TestEntityBuilder { @Test - public void testBuildEmptyEntity() throws Exception { + void testBuildEmptyEntity() { Assertions.assertThrows(IllegalStateException.class, () -> EntityBuilder.create().build()); } @Test - public void testBuildTextEntity() throws Exception { + void testBuildTextEntity() throws Exception { final HttpEntity entity = EntityBuilder.create().setText("stuff").build(); Assertions.assertNotNull(entity); Assertions.assertNotNull(entity.getContent()); @@ -55,7 +55,7 @@ public void testBuildTextEntity() throws Exception { } @Test - public void testBuildBinaryEntity() throws Exception { + void testBuildBinaryEntity() throws Exception { final HttpEntity entity = EntityBuilder.create().setBinary(new byte[] {0, 1, 2}).build(); Assertions.assertNotNull(entity); Assertions.assertNotNull(entity.getContent()); @@ -64,7 +64,7 @@ public void testBuildBinaryEntity() throws Exception { } @Test - public void testBuildStreamEntity() throws Exception { + void testBuildStreamEntity() throws Exception { final InputStream in = Mockito.mock(InputStream.class); final HttpEntity entity = EntityBuilder.create().setStream(in).build(); Assertions.assertNotNull(entity); @@ -75,7 +75,7 @@ public void testBuildStreamEntity() throws Exception { } @Test - public void testBuildSerializableEntity() throws Exception { + void testBuildSerializableEntity() throws Exception { final HttpEntity entity = EntityBuilder.create().setSerializable(Boolean.TRUE).build(); Assertions.assertNotNull(entity); Assertions.assertNotNull(entity.getContent()); @@ -84,7 +84,7 @@ public void testBuildSerializableEntity() throws Exception { } @Test - public void testBuildFileEntity() throws Exception { + void testBuildFileEntity() { final File file = new File("stuff"); final HttpEntity entity = EntityBuilder.create().setFile(file).build(); Assertions.assertNotNull(entity); @@ -93,7 +93,7 @@ public void testBuildFileEntity() throws Exception { } @Test - public void testExplicitContentProperties() throws Exception { + void testExplicitContentProperties() throws Exception { final HttpEntity entity = EntityBuilder.create() .setContentType(ContentType.APPLICATION_JSON) .setContentEncoding("identity") @@ -108,14 +108,14 @@ public void testExplicitContentProperties() throws Exception { } @Test - public void testBuildChunked() throws Exception { + void testBuildChunked() { final HttpEntity entity = EntityBuilder.create().setText("stuff").chunked().build(); Assertions.assertNotNull(entity); Assertions.assertTrue(entity.isChunked()); } @Test - public void testBuildGZipped() throws Exception { + void testBuildGZipped() { final HttpEntity entity = EntityBuilder.create().setText("stuff").gzipCompressed().build(); Assertions.assertNotNull(entity); Assertions.assertNotNull(entity.getContentType()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java index 786c8a0e0..7ca13caf4 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java @@ -44,10 +44,10 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -public class TestGZip { +class TestGZip { @Test - public void testBasic() throws Exception { + void testBasic() throws Exception { final String s = "some kind of text"; final StringEntity e = new StringEntity(s, ContentType.TEXT_PLAIN, false); try (final GzipCompressingEntity gzipe = new GzipCompressingEntity(e)) { @@ -59,7 +59,7 @@ public void testBasic() throws Exception { } @Test - public void testCompressionDecompression() throws Exception { + void testCompressionDecompression() throws Exception { final StringEntity in = new StringEntity("some kind of text", ContentType.TEXT_PLAIN); try (final GzipCompressingEntity gzipe = new GzipCompressingEntity(in)) { final ByteArrayOutputStream buf = new ByteArrayOutputStream(); @@ -71,7 +71,7 @@ public void testCompressionDecompression() throws Exception { } @Test - public void testCompressionIOExceptionLeavesOutputStreamOpen() throws Exception { + void testCompressionIOExceptionLeavesOutputStreamOpen() throws Exception { final HttpEntity in = Mockito.mock(HttpEntity.class); Mockito.doThrow(new IOException("Ooopsie")).when(in).writeTo(ArgumentMatchers.any()); try (final GzipCompressingEntity gzipe = new GzipCompressingEntity(in)) { @@ -85,7 +85,7 @@ public void testCompressionIOExceptionLeavesOutputStreamOpen() throws Exception } @Test - public void testDecompressionWithMultipleGZipStream() throws Exception { + void testDecompressionWithMultipleGZipStream() throws Exception { final int[] data = new int[] { 0x1f, 0x8b, 0x08, 0x08, 0x03, 0xf1, 0x55, 0x5a, 0x00, 0x03, 0x74, 0x65, 0x73, 0x74, 0x31, 0x00, 0x2b, 0x2e, 0x29, 0x4a, 0x4d, 0xcc, 0xd5, 0x35, 0xe4, 0x02, 0x00, 0x03, 0x61, 0xf0, 0x5f, 0x09, diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/FormBodyPartTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/FormBodyPartTest.java index 989bfd8a9..109d529dc 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/FormBodyPartTest.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/FormBodyPartTest.java @@ -33,10 +33,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class FormBodyPartTest { +class FormBodyPartTest { @Test - public void testConstructorCompat() throws Exception { + void testConstructorCompat() throws Exception { final File tmp= File.createTempFile("test", "test"); tmp.deleteOnExit(); final FileBody obj = new FileBody(tmp, ContentType.APPLICATION_OCTET_STREAM); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/HttpRFC7578MultipartTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/HttpRFC7578MultipartTest.java index b3a553839..91d71d299 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/HttpRFC7578MultipartTest.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/HttpRFC7578MultipartTest.java @@ -32,10 +32,10 @@ import org.apache.hc.core5.net.PercentCodec; import org.junit.jupiter.api.Test; -public class HttpRFC7578MultipartTest { +class HttpRFC7578MultipartTest { @Test - public void testPercentDecodingWithValidMessages() throws Exception { + void testPercentDecodingWithValidMessages() { final String[][] tests = new String[][] { {"test", "test"}, {"%20", " "}, diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestFormBodyPartBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestFormBodyPartBuilder.java index 5d5898fef..a4692ede8 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestFormBodyPartBuilder.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestFormBodyPartBuilder.java @@ -35,10 +35,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestFormBodyPartBuilder { +class TestFormBodyPartBuilder { @Test - public void testBuildBodyPartBasics() throws Exception { + void testBuildBodyPartBasics() { final StringBody stringBody = new StringBody("stuff", ContentType.TEXT_PLAIN); final FormBodyPart bodyPart = FormBodyPartBuilder.create() .setName("blah") @@ -56,7 +56,7 @@ public void testBuildBodyPartBasics() throws Exception { } @Test - public void testBuildBodyPartMultipleBuilds() throws Exception { + void testBuildBodyPartMultipleBuilds() { final StringBody stringBody = new StringBody("stuff", ContentType.TEXT_PLAIN); final FormBodyPartBuilder builder = FormBodyPartBuilder.create(); final FormBodyPart bodyPart1 = builder @@ -90,7 +90,7 @@ public void testBuildBodyPartMultipleBuilds() throws Exception { } @Test - public void testBuildBodyPartCustomHeaders() throws Exception { + void testBuildBodyPartCustomHeaders() { final StringBody stringBody = new StringBody("stuff", ContentType.TEXT_PLAIN); final FormBodyPartBuilder builder = FormBodyPartBuilder.create("blah", stringBody); final FormBodyPart bodyPart1 = builder diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMimeField.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMimeField.java index 2aa1e24b0..34cbc657e 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMimeField.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMimeField.java @@ -34,10 +34,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestMimeField { +class TestMimeField { @Test - public void testBasics() { + void testBasics() { final MimeField f1 = new MimeField("some-field", "some-value", Arrays.asList( new BasicNameValuePair("p1", "this"), diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartContentBody.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartContentBody.java index 5c07ae776..d413e901d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartContentBody.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartContentBody.java @@ -34,10 +34,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestMultipartContentBody { +class TestMultipartContentBody { @Test - public void testStringBody() throws Exception { + void testStringBody() { final StringBody b1 = new StringBody("text", ContentType.DEFAULT_TEXT); Assertions.assertEquals(4, b1.getContentLength()); @@ -60,7 +60,7 @@ public void testStringBody() throws Exception { } @Test - public void testInputStreamBody() throws Exception { + void testInputStreamBody() { final byte[] stuff = "Stuff".getBytes(StandardCharsets.US_ASCII); final InputStreamBody b1 = new InputStreamBody(new ByteArrayInputStream(stuff), "stuff"); Assertions.assertEquals(-1, b1.getContentLength()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java index b2a42e24c..bdba6c093 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartEntityBuilder.java @@ -40,10 +40,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestMultipartEntityBuilder { +class TestMultipartEntityBuilder { @Test - public void testBasics() throws Exception { + void testBasics() { final MultipartFormEntity entity = MultipartEntityBuilder.create().buildEntity(); Assertions.assertNotNull(entity); Assertions.assertTrue(entity.getMultipart() instanceof HttpStrictMultipart); @@ -51,7 +51,7 @@ public void testBasics() throws Exception { } @Test - public void testMultipartOptions() throws Exception { + void testMultipartOptions() { final MultipartFormEntity entity = MultipartEntityBuilder.create() .setBoundary("blah-blah") .setCharset(StandardCharsets.UTF_8) @@ -64,7 +64,7 @@ public void testMultipartOptions() throws Exception { } @Test - public void testAddBodyParts() throws Exception { + void testAddBodyParts() { final MultipartFormEntity entity = MultipartEntityBuilder.create() .addTextBody("p1", "stuff") .addBinaryBody("p2", new File("stuff")) @@ -80,7 +80,7 @@ public void testAddBodyParts() throws Exception { @Test - public void testMultipartCustomContentType() throws Exception { + void testMultipartCustomContentType() { final MultipartFormEntity entity = MultipartEntityBuilder.create() .setContentType(ContentType.APPLICATION_XML) .setBoundary("blah-blah") @@ -92,7 +92,7 @@ public void testMultipartCustomContentType() throws Exception { } @Test - public void testMultipartContentTypeParameter() throws Exception { + void testMultipartContentTypeParameter() { final MultipartFormEntity entity = MultipartEntityBuilder.create() .setContentType(ContentType.MULTIPART_FORM_DATA.withParameters( new BasicNameValuePair("boundary", "yada-yada"), @@ -105,7 +105,7 @@ public void testMultipartContentTypeParameter() throws Exception { } @Test - public void testMultipartDefaultContentTypeOmitsCharset() throws Exception { + void testMultipartDefaultContentTypeOmitsCharset() { final MultipartFormEntity entity = MultipartEntityBuilder.create() .setCharset(StandardCharsets.UTF_8) .setBoundary("yada-yada") @@ -116,7 +116,7 @@ public void testMultipartDefaultContentTypeOmitsCharset() throws Exception { } @Test - public void testMultipartFormDataContentTypeOmitsCharset() throws Exception { + void testMultipartFormDataContentTypeOmitsCharset() { // Note: org.apache.hc.core5.http.ContentType.MULTIPART_FORM_DATA uses StandardCharsets.ISO_8859_1, // so we create a custom ContentType here final MultipartFormEntity entity = MultipartEntityBuilder.create() @@ -130,7 +130,7 @@ public void testMultipartFormDataContentTypeOmitsCharset() throws Exception { } @Test - public void testMultipartCustomContentTypeParameterOverrides() throws Exception { + void testMultipartCustomContentTypeParameterOverrides() { final MultipartFormEntity entity = MultipartEntityBuilder.create() .setContentType(ContentType.MULTIPART_FORM_DATA.withParameters( new BasicNameValuePair("boundary", "yada-yada"), @@ -146,7 +146,7 @@ public void testMultipartCustomContentTypeParameterOverrides() throws Exception } @Test - public void testMultipartCustomContentTypeUsingAddParameter() { + void testMultipartCustomContentTypeUsingAddParameter() { final MultipartEntityBuilder eb = MultipartEntityBuilder.create(); eb.setMimeSubtype("related"); eb.addParameter(new BasicNameValuePair("boundary", "yada-yada")); @@ -160,7 +160,7 @@ public void testMultipartCustomContentTypeUsingAddParameter() { } @Test - public void testMultipartWriteTo() throws Exception { + void testMultipartWriteTo() throws Exception { final String helloWorld = "hello world"; final List parameters = new ArrayList<>(); parameters.add(new BasicNameValuePair(MimeConsts.FIELD_PARAM_NAME, "test")); @@ -188,7 +188,7 @@ public void testMultipartWriteTo() throws Exception { } @Test - public void testMultipartWriteToRFC7578Mode() throws Exception { + void testMultipartWriteToRFC7578Mode() throws Exception { final String helloWorld = "hello \u03BA\u03CC\u03C3\u03BC\u03B5!%"; final List parameters = new ArrayList<>(); parameters.add(new BasicNameValuePair(MimeConsts.FIELD_PARAM_NAME, "test")); @@ -216,7 +216,7 @@ public void testMultipartWriteToRFC7578Mode() throws Exception { } @Test - public void testMultipartWriteToRFC6532Mode() throws Exception { + void testMultipartWriteToRFC6532Mode() throws Exception { final String helloWorld = "hello \u03BA\u03CC\u03C3\u03BC\u03B5!%"; final List parameters = new ArrayList<>(); parameters.add(new BasicNameValuePair(MimeConsts.FIELD_PARAM_NAME, "test")); @@ -246,7 +246,7 @@ public void testMultipartWriteToRFC6532Mode() throws Exception { } @Test - public void testMultipartWriteToWithPreambleAndEpilogue() throws Exception { + void testMultipartWriteToWithPreambleAndEpilogue() throws Exception { final String helloWorld = "hello \u03BA\u03CC\u03C3\u03BC\u03B5!%"; final List parameters = new ArrayList<>(); parameters.add(new BasicNameValuePair(MimeConsts.FIELD_PARAM_NAME, "test")); @@ -280,7 +280,7 @@ public void testMultipartWriteToWithPreambleAndEpilogue() throws Exception { } @Test - public void testMultipartWriteToRFC7578ModeWithFilenameStar() throws Exception { + void testMultipartWriteToRFC7578ModeWithFilenameStar() throws Exception { final String helloWorld = "hello \u03BA\u03CC\u03C3\u03BC\u03B5!%"; final List parameters = new ArrayList<>(); parameters.add(new BasicNameValuePair(MimeConsts.FIELD_PARAM_NAME, "test")); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartForm.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartForm.java index 9df80b1c9..054b3ade5 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartForm.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartForm.java @@ -41,19 +41,19 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestMultipartForm { +class TestMultipartForm { private File tmpfile; @AfterEach - public void cleanup() { + void cleanup() { if (tmpfile != null) { tmpfile.delete(); } } @Test - public void testMultipartFormStringParts() throws Exception { + void testMultipartFormStringParts() throws Exception { final FormBodyPart p1 = FormBodyPartBuilder.create( "field1", new StringBody("this stuff", ContentType.DEFAULT_TEXT)).build(); @@ -94,7 +94,7 @@ public void testMultipartFormStringParts() throws Exception { } @Test - public void testMultipartFormCustomContentType() throws Exception { + void testMultipartFormCustomContentType() throws Exception { final FormBodyPart p1 = FormBodyPartBuilder.create( "field1", new StringBody("this stuff", ContentType.DEFAULT_TEXT)).build(); @@ -126,7 +126,7 @@ public void testMultipartFormCustomContentType() throws Exception { } @Test - public void testMultipartFormBinaryParts() throws Exception { + void testMultipartFormBinaryParts() throws Exception { tmpfile = File.createTempFile("tmp", ".bin"); try (Writer writer = new FileWriter(tmpfile)) { writer.append("some random whatever"); @@ -166,7 +166,7 @@ public void testMultipartFormBinaryParts() throws Exception { } @Test - public void testMultipartFormStrict() throws Exception { + void testMultipartFormStrict() throws Exception { tmpfile = File.createTempFile("tmp", ".bin"); try (Writer writer = new FileWriter(tmpfile)) { writer.append("some random whatever"); @@ -215,7 +215,7 @@ public void testMultipartFormStrict() throws Exception { } @Test - public void testMultipartFormRFC6532() throws Exception { + void testMultipartFormRFC6532() throws Exception { tmpfile = File.createTempFile("tmp", ".bin"); try (Writer writer = new FileWriter(tmpfile)) { writer.append("some random whatever"); @@ -283,7 +283,7 @@ private static String constructString(final int [] unicodeChars) { } @Test - public void testMultipartFormBrowserCompatibleNonASCIIHeaders() throws Exception { + void testMultipartFormBrowserCompatibleNonASCIIHeaders() throws Exception { final String s1 = constructString(SWISS_GERMAN_HELLO); final String s2 = constructString(RUSSIAN_HELLO); @@ -328,7 +328,7 @@ public void testMultipartFormBrowserCompatibleNonASCIIHeaders() throws Exception } @Test - public void testMultipartFormStringPartsMultiCharsets() throws Exception { + void testMultipartFormStringPartsMultiCharsets() throws Exception { final String s1 = constructString(SWISS_GERMAN_HELLO); final String s2 = constructString(RUSSIAN_HELLO); @@ -374,7 +374,7 @@ public void testMultipartFormStringPartsMultiCharsets() throws Exception { } @Test - public void testMultipartFormBinaryPartsPreamblEpilogue() throws Exception { + void testMultipartFormBinaryPartsPreamblEpilogue() throws Exception { tmpfile = File.createTempFile("tmp", ".bin"); try (Writer writer = new FileWriter(tmpfile)) { writer.append("some random whatever"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormHttpEntity.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormHttpEntity.java index 3ff515ada..47170e128 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormHttpEntity.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormHttpEntity.java @@ -40,10 +40,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestMultipartFormHttpEntity { +class TestMultipartFormHttpEntity { @Test - public void testExplictContractorParams() throws Exception { + void testExplicitContractorParams() { final HttpEntity entity = MultipartEntityBuilder.create() .setLaxMode() .setBoundary("whatever") @@ -65,7 +65,7 @@ public void testExplictContractorParams() throws Exception { } @Test - public void testImplictContractorParams() throws Exception { + void testImplicitContractorParams() { final HttpEntity entity = MultipartEntityBuilder.create().build(); Assertions.assertNull(entity.getContentEncoding()); final String contentType = entity.getContentType(); @@ -86,7 +86,7 @@ public void testImplictContractorParams() throws Exception { } @Test - public void testRepeatable() throws Exception { + void testRepeatable() throws Exception { final HttpEntity entity = MultipartEntityBuilder.create() .addTextBody("p1", "blah blah", ContentType.DEFAULT_TEXT) .addTextBody("p2", "yada yada", ContentType.DEFAULT_TEXT) @@ -118,7 +118,7 @@ public void testRepeatable() throws Exception { } @Test - public void testNonRepeatable() throws Exception { + void testNonRepeatable() { final HttpEntity entity = MultipartEntityBuilder.create() .addPart("p1", new InputStreamBody( new ByteArrayInputStream("blah blah".getBytes()), ContentType.DEFAULT_BINARY)) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormat.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormat.java index eee183c12..cd337419f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormat.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartFormat.java @@ -30,10 +30,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestMultipartFormat { +class TestMultipartFormat { @Test - public void testLineBreak() { + void testLineBreak() { Assertions.assertTrue(AbstractMultipartFormat.isLineBreak('\r')); Assertions.assertTrue(AbstractMultipartFormat.isLineBreak('\n')); Assertions.assertTrue(AbstractMultipartFormat.isLineBreak('\f')); @@ -43,7 +43,7 @@ public void testLineBreak() { } @Test - public void testLineBreakRewrite() { + void testLineBreakRewrite() { final String s = "blah blah blah"; Assertions.assertSame(s, AbstractMultipartFormat.stripLineBreaks(s)); Assertions.assertEquals("blah blah blah ", AbstractMultipartFormat.stripLineBreaks("blah\rblah\nblah\f")); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartMixed.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartMixed.java index 65faea0b5..6a45103ca 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartMixed.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartMixed.java @@ -41,19 +41,19 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestMultipartMixed { +class TestMultipartMixed { private File tmpfile; @AfterEach - public void cleanup() { + void cleanup() { if (tmpfile != null) { tmpfile.delete(); } } @Test - public void testMultipartPartStringParts() throws Exception { + void testMultipartPartStringParts() throws Exception { final MultipartPart p1 = MultipartPartBuilder.create( new StringBody("this stuff", ContentType.DEFAULT_TEXT)).build(); final MultipartPart p2 = MultipartPartBuilder.create( @@ -88,7 +88,7 @@ public void testMultipartPartStringParts() throws Exception { } @Test - public void testMultipartPartCustomContentType() throws Exception { + void testMultipartPartCustomContentType() throws Exception { final MultipartPart p1 = MultipartPartBuilder.create( new StringBody("this stuff", ContentType.DEFAULT_TEXT)).build(); final MultipartPart p2 = MultipartPartBuilder.create( @@ -116,7 +116,7 @@ public void testMultipartPartCustomContentType() throws Exception { } @Test - public void testMultipartPartBinaryParts() throws Exception { + void testMultipartPartBinaryParts() throws Exception { tmpfile = File.createTempFile("tmp", ".bin"); try (Writer writer = new FileWriter(tmpfile)) { writer.append("some random whatever"); @@ -150,7 +150,7 @@ public void testMultipartPartBinaryParts() throws Exception { } @Test - public void testMultipartPartStrict() throws Exception { + void testMultipartPartStrict() throws Exception { tmpfile = File.createTempFile("tmp", ".bin"); try (Writer writer = new FileWriter(tmpfile)) { writer.append("some random whatever"); @@ -190,7 +190,7 @@ public void testMultipartPartStrict() throws Exception { } @Test - public void testMultipartPartRFC6532() throws Exception { + void testMultipartPartRFC6532() throws Exception { tmpfile = File.createTempFile("tmp", ".bin"); try (Writer writer = new FileWriter(tmpfile)) { writer.append("some random whatever"); @@ -249,7 +249,7 @@ private static String constructString(final int [] unicodeChars) { } @Test - public void testMultipartPartBrowserCompatibleNonASCIIHeaders() throws Exception { + void testMultipartPartBrowserCompatibleNonASCIIHeaders() throws Exception { final String s1 = constructString(SWISS_GERMAN_HELLO); final String s2 = constructString(RUSSIAN_HELLO); @@ -288,7 +288,7 @@ public void testMultipartPartBrowserCompatibleNonASCIIHeaders() throws Exception } @Test - public void testMultipartPartStringPartsMultiCharsets() throws Exception { + void testMultipartPartStringPartsMultiCharsets() throws Exception { final String s1 = constructString(SWISS_GERMAN_HELLO); final String s2 = constructString(RUSSIAN_HELLO); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartPartBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartPartBuilder.java index 0c1f01117..a6bb5288a 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartPartBuilder.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/entity/mime/TestMultipartPartBuilder.java @@ -36,10 +36,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestMultipartPartBuilder { +class TestMultipartPartBuilder { @Test - public void testBuildBodyPartBasics() throws Exception { + void testBuildBodyPartBasics() { final StringBody stringBody = new StringBody("stuff", ContentType.TEXT_PLAIN); final MultipartPart part = MultipartPartBuilder.create() .setBody(stringBody) @@ -54,7 +54,7 @@ public void testBuildBodyPartBasics() throws Exception { } @Test - public void testBuildBodyPartMultipleBuilds() throws Exception { + void testBuildBodyPartMultipleBuilds() { final StringBody stringBody = new StringBody("stuff", ContentType.TEXT_PLAIN); final MultipartPartBuilder builder = MultipartPartBuilder.create(); final MultipartPart part1 = builder @@ -82,7 +82,7 @@ public void testBuildBodyPartMultipleBuilds() throws Exception { } @Test - public void testBuildBodyPartCustomHeaders() throws Exception { + void testBuildBodyPartCustomHeaders() { final StringBody stringBody = new StringBody("stuff", ContentType.TEXT_PLAIN); final MultipartPartBuilder builder = MultipartPartBuilder.create(stringBody); final MultipartPart part1 = builder diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java index a30661cd6..0d48e12bc 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java @@ -115,7 +115,7 @@ public void produce(final DataStreamChannel channel) throws IOException { @Override public void consumeInformation( final HttpResponse response, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { System.out.println(request + "->" + new StatusLine(response)); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2FullDuplexExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2FullDuplexExchange.java index b221c7ff5..b6309de7b 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2FullDuplexExchange.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2FullDuplexExchange.java @@ -123,7 +123,7 @@ public void produce(final DataStreamChannel channel) throws IOException { @Override public void consumeInformation( final HttpResponse response, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { System.out.println(request + "->" + new StatusLine(response)); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java index e965ac303..49c752a1f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java @@ -82,7 +82,7 @@ public static void main(final String[] args) throws Exception { protected void start( final HttpRequest promise, final HttpResponse response, - final ContentType contentType) throws HttpException, IOException { + final ContentType contentType) { System.out.println(promise.getPath() + " (push)->" + new StatusLine(response)); } @@ -92,7 +92,7 @@ protected int capacityIncrement() { } @Override - protected void data(final ByteBuffer data, final boolean endOfStream) throws IOException { + protected void data(final ByteBuffer data, final boolean endOfStream) { } @Override @@ -121,7 +121,7 @@ public void releaseResources() { @Override protected void start( final HttpResponse response, - final ContentType contentType) throws HttpException, IOException { + final ContentType contentType) { System.out.println(request + "->" + new StatusLine(response)); } @@ -131,11 +131,11 @@ protected int capacityIncrement() { } @Override - protected void data(final CharBuffer data, final boolean endOfStream) throws IOException { + protected void data(final CharBuffer data, final boolean endOfStream) { } @Override - protected Void buildResult() throws IOException { + protected Void buildResult() { return null; } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java index 28aaa8fd7..79e5acd1f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java @@ -80,7 +80,7 @@ public static void main(final String[] args) throws Exception { @Override protected void start( final HttpResponse response, - final ContentType contentType) throws HttpException, IOException { + final ContentType contentType) { System.out.println(request + "->" + new StatusLine(response)); } @@ -90,7 +90,7 @@ protected int capacityIncrement() { } @Override - protected void data(final CharBuffer data, final boolean endOfStream) throws IOException { + protected void data(final CharBuffer data, final boolean endOfStream) { while (data.hasRemaining()) { System.out.print(data.get()); } @@ -100,7 +100,7 @@ protected void data(final CharBuffer data, final boolean endOfStream) throws IOE } @Override - protected Void buildResult() throws IOException { + protected Void buildResult() { return null; } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java index 1834794ef..3b1dd4c0a 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java @@ -82,7 +82,7 @@ public static void main(final String[] args) throws Exception { public void process( final HttpRequest request, final EntityDetails entity, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { request.setHeader("request-id", Long.toString(count.incrementAndGet())); } }) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java index 3a5c2e6eb..625624056 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java @@ -67,7 +67,7 @@ public static void main(final String[] args) throws Exception { public void process( final HttpRequest request, final EntityDetails entity, - final HttpContext context) throws HttpException, IOException { + final HttpContext context) { request.setHeader("request-id", Long.toString(count.incrementAndGet())); } }) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/ExecSupportTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/ExecSupportTest.java index 8ab023fdd..88c577353 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/ExecSupportTest.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/ExecSupportTest.java @@ -29,10 +29,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class ExecSupportTest { +class ExecSupportTest { @Test - public void testGetNextExchangeId() { + void testGetNextExchangeId() { final long base = ExecSupport.getNextExecNumber(); for (int i = 1; i <= 1_000_000; i++) { Assertions.assertEquals( diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/InMemoryDnsResolverTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/InMemoryDnsResolverTest.java index 7edf39bf6..694f18e21 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/InMemoryDnsResolverTest.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/InMemoryDnsResolverTest.java @@ -38,7 +38,7 @@ /** * Tests {@link InMemoryDnsResolver}. */ -public class InMemoryDnsResolverTest { +class InMemoryDnsResolverTest { @Test void resolve() throws UnknownHostException { diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/PrefixedIncrementingIdTest.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/PrefixedIncrementingIdTest.java index 1a669636e..1bc00d602 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/PrefixedIncrementingIdTest.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/PrefixedIncrementingIdTest.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class PrefixedIncrementingIdTest { +class PrefixedIncrementingIdTest { @Test void testGetNextId() { @@ -39,7 +39,7 @@ void testGetNextId() { } @Test - public void testCreateId() { + void testCreateId() { final PrefixedIncrementingId exchangeId = new PrefixedIncrementingId("ex-"); Assertions.assertEquals(String.format("ex-%010d", 0), exchangeId.createId(0)); for (long i = 1; i <= 100_000_000L; i *= 10) { diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAuthenticationStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAuthenticationStrategy.java index d990ea1a9..3b0bd9a9d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAuthenticationStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestAuthenticationStrategy.java @@ -55,10 +55,10 @@ * Simple tests for {@link DefaultAuthenticationStrategy}. */ @SuppressWarnings("boxing") // test code -public class TestAuthenticationStrategy { +class TestAuthenticationStrategy { @Test - public void testSelectInvalidInput() throws Exception { + void testSelectInvalidInput() { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); final HttpClientContext context = HttpClientContext.create(); Assertions.assertThrows(NullPointerException.class, () -> @@ -70,7 +70,7 @@ public void testSelectInvalidInput() throws Exception { } @Test - public void testSelectNoSchemeRegistry() throws Exception { + void testSelectNoSchemeRegistry() { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); final HttpClientContext context = HttpClientContext.create(); @@ -86,7 +86,7 @@ public void testSelectNoSchemeRegistry() throws Exception { } @Test - public void testUnsupportedScheme() throws Exception { + void testUnsupportedScheme() { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); final HttpClientContext context = HttpClientContext.create(); @@ -116,7 +116,7 @@ public void testUnsupportedScheme() throws Exception { } @Test - public void testCustomAuthPreference() throws Exception { + void testCustomAuthPreference() { final DefaultAuthenticationStrategy authStrategy = new DefaultAuthenticationStrategy(); final RequestConfig config = RequestConfig.custom() .setTargetPreferredAuthSchemes(Collections.singletonList(StandardAuthScheme.BASIC)) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultConnKeepAliveStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultConnKeepAliveStrategy.java index 4bc92aa2d..3354df112 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultConnKeepAliveStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultConnKeepAliveStrategy.java @@ -39,10 +39,10 @@ /** * Simple tests for {@link DefaultConnectionKeepAliveStrategy}. */ -public class TestDefaultConnKeepAliveStrategy { +class TestDefaultConnKeepAliveStrategy { @Test - public void testIllegalResponseArg() throws Exception { + void testIllegalResponseArg() { final HttpClientContext context = HttpClientContext.create(); final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy(); Assertions.assertThrows(NullPointerException.class, () -> @@ -50,7 +50,7 @@ public void testIllegalResponseArg() throws Exception { } @Test - public void testNoKeepAliveHeader() throws Exception { + void testNoKeepAliveHeader() { final HttpClientContext context = HttpClientContext.create(); context.setRequestConfig( RequestConfig.custom() .setConnectionKeepAlive(TimeValue.NEG_ONE_MILLISECOND) @@ -62,7 +62,7 @@ public void testNoKeepAliveHeader() throws Exception { } @Test - public void testEmptyKeepAliveHeader() throws Exception { + void testEmptyKeepAliveHeader() { final HttpClientContext context = HttpClientContext.create(); context.setRequestConfig( RequestConfig.custom() .setConnectionKeepAlive(TimeValue.NEG_ONE_MILLISECOND) @@ -75,7 +75,7 @@ public void testEmptyKeepAliveHeader() throws Exception { } @Test - public void testInvalidKeepAliveHeader() throws Exception { + void testInvalidKeepAliveHeader() { final HttpClientContext context = HttpClientContext.create(); context.setRequestConfig( RequestConfig.custom() .setConnectionKeepAlive(TimeValue.NEG_ONE_MILLISECOND) @@ -88,7 +88,7 @@ public void testInvalidKeepAliveHeader() throws Exception { } @Test - public void testKeepAliveHeader() throws Exception { + void testKeepAliveHeader() { final HttpClientContext context = HttpClientContext.create(); context.setRequestConfig( RequestConfig.custom() .setConnectionKeepAlive(TimeValue.NEG_ONE_MILLISECOND) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultHttpRequestRetryStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultHttpRequestRetryStrategy.java index 3a7b74cfd..2440f5c98 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultHttpRequestRetryStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultHttpRequestRetryStrategy.java @@ -47,17 +47,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestDefaultHttpRequestRetryStrategy { +class TestDefaultHttpRequestRetryStrategy { private DefaultHttpRequestRetryStrategy retryStrategy; @BeforeEach - public void setup() { + void setup() { this.retryStrategy = new DefaultHttpRequestRetryStrategy(3, TimeValue.ofMilliseconds(1234L)); } @Test - public void testBasics() throws Exception { + void testBasics() { final HttpResponse response1 = new BasicHttpResponse(503, "Oopsie"); Assertions.assertTrue(this.retryStrategy.retryRequest(response1, 1, null)); Assertions.assertTrue(this.retryStrategy.retryRequest(response1, 2, null)); @@ -75,7 +75,7 @@ public void testBasics() throws Exception { } @Test - public void testRetryAfterHeaderAsLong() throws Exception { + void testRetryAfterHeaderAsLong() { final HttpResponse response = new BasicHttpResponse(503, "Oopsie"); response.setHeader(HttpHeaders.RETRY_AFTER, "321"); @@ -83,7 +83,7 @@ public void testRetryAfterHeaderAsLong() throws Exception { } @Test - public void testRetryAfterHeaderAsDate() throws Exception { + void testRetryAfterHeaderAsDate() { this.retryStrategy = new DefaultHttpRequestRetryStrategy(3, TimeValue.ZERO_MILLISECONDS); final HttpResponse response = new BasicHttpResponse(503, "Oopsie"); response.setHeader(HttpHeaders.RETRY_AFTER, DateUtils.formatStandardDate(Instant.now().plus(100, ChronoUnit.SECONDS))); @@ -92,7 +92,7 @@ public void testRetryAfterHeaderAsDate() throws Exception { } @Test - public void testRetryAfterHeaderAsPastDate() throws Exception { + void testRetryAfterHeaderAsPastDate() { final HttpResponse response = new BasicHttpResponse(503, "Oopsie"); response.setHeader(HttpHeaders.RETRY_AFTER, DateUtils.formatStandardDate(Instant.now().minus(100, ChronoUnit.SECONDS))); @@ -100,7 +100,7 @@ public void testRetryAfterHeaderAsPastDate() throws Exception { } @Test - public void testInvalidRetryAfterHeader() throws Exception { + void testInvalidRetryAfterHeader() { final HttpResponse response = new BasicHttpResponse(503, "Oopsie"); response.setHeader(HttpHeaders.RETRY_AFTER, "Stuff"); @@ -108,49 +108,49 @@ public void testInvalidRetryAfterHeader() throws Exception { } @Test - public void noRetryOnConnectTimeout() throws Exception { + void noRetryOnConnectTimeout() { final HttpGet request = new HttpGet("/"); Assertions.assertFalse(retryStrategy.retryRequest(request, new SocketTimeoutException(), 1, null)); } @Test - public void noRetryOnConnect() throws Exception { + void noRetryOnConnect() { final HttpGet request = new HttpGet("/"); Assertions.assertFalse(retryStrategy.retryRequest(request, new ConnectException(), 1, null)); } @Test - public void noRetryOnConnectionClosed() throws Exception { + void noRetryOnConnectionClosed() { final HttpGet request = new HttpGet("/"); Assertions.assertFalse(retryStrategy.retryRequest(request, new ConnectionClosedException(), 1, null)); } @Test - public void noRetryForNoRouteToHostException() { + void noRetryForNoRouteToHostException() { final HttpGet request = new HttpGet("/"); Assertions.assertFalse(retryStrategy.retryRequest(request, new NoRouteToHostException(), 1, null)); } @Test - public void noRetryOnSSLFailure() throws Exception { + void noRetryOnSSLFailure() { final HttpGet request = new HttpGet("/"); Assertions.assertFalse(retryStrategy.retryRequest(request, new SSLException("encryption failed"), 1, null)); } @Test - public void noRetryOnUnknownHost() throws Exception { + void noRetryOnUnknownHost() { final HttpGet request = new HttpGet("/"); Assertions.assertFalse(retryStrategy.retryRequest(request, new UnknownHostException(), 1, null)); } @Test - public void noRetryOnAbortedRequests() throws Exception { + void noRetryOnAbortedRequests() { final HttpGet request = new HttpGet("/"); request.cancel(); @@ -158,7 +158,7 @@ public void noRetryOnAbortedRequests() throws Exception { } @Test - public void retryOnNonAbortedRequests() throws Exception { + void retryOnNonAbortedRequests() { final HttpGet request = new HttpGet("/"); Assertions.assertTrue(retryStrategy.retryRequest(request, new IOException(), 1, null)); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultRedirectStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultRedirectStrategy.java index c50063a4c..79f27f527 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultRedirectStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestDefaultRedirectStrategy.java @@ -40,10 +40,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestDefaultRedirectStrategy { +class TestDefaultRedirectStrategy { @Test - public void testIsRedirectedMovedTemporary() throws Exception { + void testIsRedirectedMovedTemporary() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -54,7 +54,7 @@ public void testIsRedirectedMovedTemporary() throws Exception { } @Test - public void testIsRedirectedMovedTemporaryNoLocation() throws Exception { + void testIsRedirectedMovedTemporaryNoLocation() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -63,7 +63,7 @@ public void testIsRedirectedMovedTemporaryNoLocation() throws Exception { } @Test - public void testIsRedirectedMovedPermanently() throws Exception { + void testIsRedirectedMovedPermanently() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -74,7 +74,7 @@ public void testIsRedirectedMovedPermanently() throws Exception { } @Test - public void testIsRedirectedTemporaryRedirect() throws Exception { + void testIsRedirectedTemporaryRedirect() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -85,7 +85,7 @@ public void testIsRedirectedTemporaryRedirect() throws Exception { } @Test - public void testIsRedirectedSeeOther() throws Exception { + void testIsRedirectedSeeOther() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -96,7 +96,7 @@ public void testIsRedirectedSeeOther() throws Exception { } @Test - public void testIsRedirectedUnknownStatus() throws Exception { + void testIsRedirectedUnknownStatus() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -107,7 +107,7 @@ public void testIsRedirectedUnknownStatus() throws Exception { } @Test - public void testIsRedirectedInvalidInput() throws Exception { + void testIsRedirectedInvalidInput() { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -119,7 +119,7 @@ public void testIsRedirectedInvalidInput() throws Exception { } @Test - public void testGetLocationUri() throws Exception { + void testGetLocationUri() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -130,7 +130,7 @@ public void testGetLocationUri() throws Exception { } @Test - public void testGetLocationUriMissingHeader() throws Exception { + void testGetLocationUriMissingHeader() { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -140,7 +140,7 @@ public void testGetLocationUriMissingHeader() throws Exception { } @Test - public void testGetLocationUriInvalidLocation() throws Exception { + void testGetLocationUriInvalidLocation() { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -151,7 +151,7 @@ public void testGetLocationUriInvalidLocation() throws Exception { } @Test - public void testGetLocationUriRelative() throws Exception { + void testGetLocationUriRelative() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -162,7 +162,7 @@ public void testGetLocationUriRelative() throws Exception { } @Test - public void testGetLocationUriRelativeWithFragment() throws Exception { + void testGetLocationUriRelativeWithFragment() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -173,7 +173,7 @@ public void testGetLocationUriRelativeWithFragment() throws Exception { } @Test - public void testGetLocationUriAbsoluteWithFragment() throws Exception { + void testGetLocationUriAbsoluteWithFragment() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -184,7 +184,7 @@ public void testGetLocationUriAbsoluteWithFragment() throws Exception { } @Test - public void testGetLocationUriNormalized() throws Exception { + void testGetLocationUriNormalized() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -195,7 +195,7 @@ public void testGetLocationUriNormalized() throws Exception { } @Test - public void testGetLocationUriInvalidInput() throws Exception { + void testGetLocationUriInvalidInput() { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet httpget = new HttpGet("http://localhost/"); @@ -210,21 +210,21 @@ public void testGetLocationUriInvalidInput() throws Exception { } @Test - public void testCreateLocationURI() throws Exception { + void testCreateLocationURI() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); Assertions.assertEquals("http://blahblah/", redirectStrategy.createLocationURI("http://BlahBlah").toASCIIString()); } @Test - public void testCreateLocationURIInvalid() throws Exception { + void testCreateLocationURIInvalid() { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); Assertions.assertThrows(ProtocolException.class, () -> redirectStrategy.createLocationURI(":::::::")); } @Test - public void testResolveRelativeLocation() throws Exception { + void testResolveRelativeLocation() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet request = new HttpGet("http://localhost/"); @@ -237,7 +237,7 @@ public void testResolveRelativeLocation() throws Exception { } @Test - public void testUseAbsoluteLocation() throws Exception { + void testUseAbsoluteLocation() throws Exception { final DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy(); final HttpClientContext context = HttpClientContext.create(); final HttpGet request = new HttpGet("http://localhost/"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java index 0f88dfc05..95665e0b9 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestIdleConnectionEvictor.java @@ -38,10 +38,10 @@ /** * Unit tests for {@link IdleConnectionEvictor}. */ -public class TestIdleConnectionEvictor { +class TestIdleConnectionEvictor { @Test - public void testEvictExpiredAndIdle() throws Exception { + void testEvictExpiredAndIdle() throws Exception { final ConnPoolControl cm = Mockito.mock(ConnPoolControl.class); final IdleConnectionEvictor connectionEvictor = new IdleConnectionEvictor(cm, TimeValue.ofMilliseconds(500), TimeValue.ofSeconds(3)); @@ -60,7 +60,7 @@ public void testEvictExpiredAndIdle() throws Exception { } @Test - public void testEvictExpiredOnly() throws Exception { + void testEvictExpiredOnly() throws Exception { final ConnPoolControl cm = Mockito.mock(ConnPoolControl.class); final IdleConnectionEvictor connectionEvictor = new IdleConnectionEvictor(cm, TimeValue.ofMilliseconds(500), null); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestProtocolSwitchStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestProtocolSwitchStrategy.java index 1775bf49c..9c8593a44 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestProtocolSwitchStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestProtocolSwitchStrategy.java @@ -39,7 +39,7 @@ /** * Simple tests for {@link DefaultAuthenticationStrategy}. */ -public class TestProtocolSwitchStrategy { +class TestProtocolSwitchStrategy { ProtocolSwitchStrategy switchStrategy; @@ -49,7 +49,7 @@ void setUp() { } @Test - public void testSwitchToTLS() throws Exception { + void testSwitchToTLS() throws Exception { final HttpResponse response1 = new BasicHttpResponse(HttpStatus.SC_SWITCHING_PROTOCOLS); response1.addHeader(HttpHeaders.UPGRADE, "TLS"); Assertions.assertEquals(TLS.V_1_2.getVersion(), switchStrategy.switchProtocol(response1)); @@ -60,7 +60,7 @@ public void testSwitchToTLS() throws Exception { } @Test - public void testSwitchToHTTP11AndTLS() throws Exception { + void testSwitchToHTTP11AndTLS() throws Exception { final HttpResponse response1 = new BasicHttpResponse(HttpStatus.SC_SWITCHING_PROTOCOLS); response1.addHeader(HttpHeaders.UPGRADE, "TLS, HTTP/1.1"); Assertions.assertEquals(TLS.V_1_2.getVersion(), switchStrategy.switchProtocol(response1)); @@ -81,7 +81,7 @@ public void testSwitchToHTTP11AndTLS() throws Exception { } @Test - public void testSwitchInvalid() throws Exception { + void testSwitchInvalid() { final HttpResponse response1 = new BasicHttpResponse(HttpStatus.SC_SWITCHING_PROTOCOLS); response1.addHeader(HttpHeaders.UPGRADE, "Crap"); Assertions.assertThrows(ProtocolException.class, () -> switchStrategy.switchProtocol(response1)); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestRequestSupport.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestRequestSupport.java index ac993bf90..d403b3c04 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestRequestSupport.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/TestRequestSupport.java @@ -33,10 +33,10 @@ /** * Simple tests for {@link RequestSupport}. */ -public class TestRequestSupport { +class TestRequestSupport { @Test - public void testPathPrefixExtraction() { + void testPathPrefixExtraction() { Assertions.assertEquals("/aaaa/", RequestSupport.extractPathPrefix(new BasicHttpRequest("GET", "/aaaa/bbbb"))); Assertions.assertEquals("/aaaa/", RequestSupport.extractPathPrefix(new BasicHttpRequest("GET", "/aaaa/"))); Assertions.assertEquals("/aaaa/", RequestSupport.extractPathPrefix(new BasicHttpRequest("GET", "/aaaa/../aaaa/"))); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestAuthChallengeParser.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestAuthChallengeParser.java index cda0d57dd..cc525c77f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestAuthChallengeParser.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestAuthChallengeParser.java @@ -43,17 +43,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestAuthChallengeParser { +class TestAuthChallengeParser { private AuthChallengeParser parser; @BeforeEach - public void setUp() throws Exception { + void setUp() { this.parser = new AuthChallengeParser(); } @Test - public void testParseTokenTerminatedByBlank() throws Exception { + void testParseTokenTerminatedByBlank() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("aaabbbbccc "); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -61,7 +61,7 @@ public void testParseTokenTerminatedByBlank() throws Exception { } @Test - public void testParseTokenTerminatedByComma() throws Exception { + void testParseTokenTerminatedByComma() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("aaabbbbccc, "); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -69,7 +69,7 @@ public void testParseTokenTerminatedByComma() throws Exception { } @Test - public void testParseTokenTerminatedByEndOfStream() throws Exception { + void testParseTokenTerminatedByEndOfStream() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("aaabbbbccc"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -77,7 +77,7 @@ public void testParseTokenTerminatedByEndOfStream() throws Exception { } @Test - public void testParsePaddedToken68() throws Exception { + void testParsePaddedToken68() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("aaabbbbccc==== "); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -87,7 +87,7 @@ public void testParsePaddedToken68() throws Exception { } @Test - public void testParsePaddedToken68SingleEqual() throws Exception { + void testParsePaddedToken68SingleEqual() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("aaabbbbccc="); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -96,7 +96,7 @@ public void testParsePaddedToken68SingleEqual() throws Exception { } @Test - public void testParsePaddedToken68MultipleEquals() throws Exception { + void testParsePaddedToken68MultipleEquals() { final CharArrayBuffer buffer = new CharArrayBuffer(16); buffer.append("aaabbbbccc======"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -105,7 +105,7 @@ public void testParsePaddedToken68MultipleEquals() throws Exception { } @Test - public void testParsePaddedToken68TerminatedByComma() throws Exception { + void testParsePaddedToken68TerminatedByComma() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("aaabbbbccc====,"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -115,7 +115,7 @@ public void testParsePaddedToken68TerminatedByComma() throws Exception { } @Test - public void testParseTokenTerminatedByParameter() throws Exception { + void testParseTokenTerminatedByParameter() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("aaabbbbccc=blah"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -125,7 +125,7 @@ public void testParseTokenTerminatedByParameter() throws Exception { } @Test - public void testParseBasicAuthChallenge() throws Exception { + void testParseBasicAuthChallenge() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append(StandardAuthScheme.BASIC + " realm=blah"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -142,7 +142,7 @@ public void testParseBasicAuthChallenge() throws Exception { } @Test - public void testParseAuthChallengeWithBlanks() throws Exception { + void testParseAuthChallengeWithBlanks() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append(" " + StandardAuthScheme.BASIC + " realm = blah "); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -159,7 +159,7 @@ public void testParseAuthChallengeWithBlanks() throws Exception { } @Test - public void testParseMultipleAuthChallenge() throws Exception { + void testParseMultipleAuthChallenge() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("This xxxxxxxxxxxxxxxxxxxxxx, " + "That yyyyyyyyyyyyyyyyyyyyyy "); @@ -180,7 +180,7 @@ public void testParseMultipleAuthChallenge() throws Exception { } @Test - public void testParseMultipleAuthChallengeWithParams() throws Exception { + void testParseMultipleAuthChallengeWithParams() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append(StandardAuthScheme.BASIC + " realm=blah, param1 = this, param2=that, " + StandardAuthScheme.BASIC + " realm=\"\\\"yada\\\"\", this, that=,this-and-that "); @@ -212,7 +212,7 @@ public void testParseMultipleAuthChallengeWithParams() throws Exception { } @Test - public void testParseMultipleAuthChallengeWithParamsContainingComma() throws Exception { + void testParseMultipleAuthChallengeWithParamsContainingComma() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append(StandardAuthScheme.BASIC + " realm=blah, param1 = \"this, param2=that\", " + StandardAuthScheme.BASIC + " realm=\"\\\"yada,,,,\\\"\""); @@ -240,7 +240,7 @@ public void testParseMultipleAuthChallengeWithParamsContainingComma() throws Exc } @Test - public void testParseEmptyAuthChallenge1() throws Exception { + void testParseEmptyAuthChallenge1() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("This"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -255,7 +255,7 @@ public void testParseEmptyAuthChallenge1() throws Exception { } @Test - public void testParseMalformedAuthChallenge1() throws Exception { + void testParseMalformedAuthChallenge1() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("This , "); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -264,7 +264,7 @@ public void testParseMalformedAuthChallenge1() throws Exception { } @Test - public void testParseMalformedAuthChallenge2() throws Exception { + void testParseMalformedAuthChallenge2() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("This = that"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -273,7 +273,7 @@ public void testParseMalformedAuthChallenge2() throws Exception { } @Test - public void testParseMalformedAuthChallenge3() throws Exception { + void testParseMalformedAuthChallenge3() { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("blah blah blah"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -282,7 +282,7 @@ public void testParseMalformedAuthChallenge3() throws Exception { } @Test - public void testParseValidAuthChallenge1() throws Exception { + void testParseValidAuthChallenge1() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("blah blah"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -297,7 +297,7 @@ public void testParseValidAuthChallenge1() throws Exception { } @Test - public void testParseValidAuthChallenge2() throws Exception { + void testParseValidAuthChallenge2() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("blah blah, blah"); final ParserCursor cursor = new ParserCursor(0, buffer.length()); @@ -316,7 +316,7 @@ public void testParseValidAuthChallenge2() throws Exception { } @Test - public void testParseParameterAndToken68AuthChallengeMix() throws Exception { + void testParseParameterAndToken68AuthChallengeMix() throws Exception { final CharArrayBuffer buffer = new CharArrayBuffer(64); buffer.append("scheme1 aaaa , scheme2 aaaa==, scheme3 aaaa=aaaa, scheme4 aaaa="); final ParserCursor cursor = new ParserCursor(0, buffer.length()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicAuthCache.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicAuthCache.java index f529be590..da635ad08 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicAuthCache.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicAuthCache.java @@ -36,10 +36,10 @@ * Unit tests for {@link BasicAuthCache}. */ @SuppressWarnings("boxing") // test code -public class TestBasicAuthCache { +class TestBasicAuthCache { @Test - public void testBasicStoreRestore() throws Exception { + void testBasicStoreRestore() { final BasicAuthCache cache = new BasicAuthCache(); final AuthScheme authScheme = new BasicScheme(); cache.put(new HttpHost("localhost", 80), authScheme); @@ -52,7 +52,7 @@ public void testBasicStoreRestore() throws Exception { } @Test - public void testNullKey() throws Exception { + void testNullKey() { final BasicAuthCache cache = new BasicAuthCache(); final AuthScheme authScheme = new BasicScheme(); Assertions.assertThrows(NullPointerException.class, () -> @@ -60,7 +60,7 @@ public void testNullKey() throws Exception { } @Test - public void testNullAuthScheme() throws Exception { + void testNullAuthScheme() { final BasicAuthCache cache = new BasicAuthCache(); cache.put(new HttpHost("localhost", 80), null); Assertions.assertNull(cache.get(new HttpHost("localhost", 80))); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicScheme.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicScheme.java index c75ca8f2b..57674be66 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicScheme.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBasicScheme.java @@ -50,7 +50,7 @@ /** * Basic authentication test cases. */ -public class TestBasicScheme { +class TestBasicScheme { private static final Base64.Encoder BASE64_ENC = Base64.getEncoder(); private static AuthChallenge parse(final String s) throws ParseException { @@ -63,7 +63,7 @@ private static AuthChallenge parse(final String s) throws ParseException { } @Test - public void testBasicAuthenticationEmptyChallenge() throws Exception { + void testBasicAuthenticationEmptyChallenge() throws Exception { final String challenge = StandardAuthScheme.BASIC; final AuthChallenge authChallenge = parse(challenge); final AuthScheme authscheme = new BasicScheme(); @@ -72,7 +72,7 @@ public void testBasicAuthenticationEmptyChallenge() throws Exception { } @Test - public void testBasicAuthentication() throws Exception { + void testBasicAuthentication() throws Exception { final AuthChallenge authChallenge = parse("Basic realm=\"test\""); final BasicScheme authscheme = new BasicScheme(); @@ -100,7 +100,7 @@ public void testBasicAuthentication() throws Exception { static final String TEST_UTF8_PASSWORD = "123\u00A3"; @Test - public void testBasicAuthenticationDefaultCharset() throws Exception { + void testBasicAuthenticationDefaultCharset() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final UsernamePasswordCredentials creds = new UsernamePasswordCredentials("test", TEST_UTF8_PASSWORD.toCharArray()); final BasicScheme authscheme = new BasicScheme(); @@ -111,7 +111,7 @@ public void testBasicAuthenticationDefaultCharset() throws Exception { } @Test - public void testBasicAuthenticationDefaultCharsetUTF8() throws Exception { + void testBasicAuthenticationDefaultCharsetUTF8() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final UsernamePasswordCredentials creds = new UsernamePasswordCredentials("test", TEST_UTF8_PASSWORD.toCharArray()); final BasicScheme authscheme = new BasicScheme(); @@ -122,7 +122,7 @@ public void testBasicAuthenticationDefaultCharsetUTF8() throws Exception { } @Test - public void testBasicAuthenticationWithCharset() throws Exception { + void testBasicAuthenticationWithCharset() throws Exception { final AuthChallenge authChallenge = parse("Basic realm=\"test\", charset=\"utf-8\""); final BasicScheme authscheme = new BasicScheme(); @@ -143,7 +143,7 @@ public void testBasicAuthenticationWithCharset() throws Exception { } @Test - public void testSerialization() throws Exception { + void testSerialization() throws Exception { final AuthChallenge authChallenge = parse("Basic realm=\"test\""); final BasicScheme basicScheme = new BasicScheme(); @@ -159,7 +159,7 @@ public void testSerialization() throws Exception { } @Test - public void testBasicAuthenticationUserCredentialsMissing() throws Exception { + void testBasicAuthenticationUserCredentialsMissing() { final BasicScheme authscheme = new BasicScheme(); final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); @@ -167,7 +167,7 @@ public void testBasicAuthenticationUserCredentialsMissing() throws Exception { } @Test - public void testBasicAuthenticationUsernameWithBlank() throws Exception { + void testBasicAuthenticationUsernameWithBlank() throws Exception { final BasicScheme authscheme = new BasicScheme(); final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); @@ -176,7 +176,7 @@ public void testBasicAuthenticationUsernameWithBlank() throws Exception { } @Test - public void testBasicAuthenticationUsernameWithTab() throws Exception { + void testBasicAuthenticationUsernameWithTab() { final BasicScheme authscheme = new BasicScheme(); final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); @@ -185,7 +185,7 @@ public void testBasicAuthenticationUsernameWithTab() throws Exception { } @Test - public void testBasicAuthenticationUsernameWithColon() throws Exception { + void testBasicAuthenticationUsernameWithColon() { final BasicScheme authscheme = new BasicScheme(); final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); @@ -194,7 +194,7 @@ public void testBasicAuthenticationUsernameWithColon() throws Exception { } @Test - public void testBasicAuthenticationPasswordWithControlCharacters() throws Exception { + void testBasicAuthenticationPasswordWithControlCharacters() { final BasicScheme authscheme = new BasicScheme(); final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBearerScheme.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBearerScheme.java index 109cd6b1d..175a357e8 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBearerScheme.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestBearerScheme.java @@ -42,10 +42,10 @@ /** * Bearer authentication test cases. */ -public class TestBearerScheme { +class TestBearerScheme { @Test - public void testBearerAuthenticationEmptyChallenge() throws Exception { + void testBearerAuthenticationEmptyChallenge() throws Exception { final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.TARGET, "BEARER"); final AuthScheme authscheme = new BearerScheme(); authscheme.processChallenge(authChallenge, null); @@ -53,7 +53,7 @@ public void testBearerAuthenticationEmptyChallenge() throws Exception { } @Test - public void testBearerAuthentication() throws Exception { + void testBearerAuthentication() throws Exception { final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.TARGET, "Bearer", new BasicNameValuePair("realm", "test")); @@ -75,7 +75,7 @@ public void testBearerAuthentication() throws Exception { } @Test - public void testStateStorage() throws Exception { + void testStateStorage() throws Exception { final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.TARGET, "Bearer", new BasicNameValuePair("realm", "test"), new BasicNameValuePair("code", "read")); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestCredentialsProviders.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestCredentialsProviders.java index e0cc9b0d3..d6505fa47 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestCredentialsProviders.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestCredentialsProviders.java @@ -38,7 +38,7 @@ /** * Tests for {@link org.apache.hc.client5.http.auth.CredentialsProvider} implementations. */ -public class TestCredentialsProviders { +class TestCredentialsProviders { public final static Credentials CREDS1 = new UsernamePasswordCredentials("user1", "pass1".toCharArray()); @@ -51,7 +51,7 @@ public class TestCredentialsProviders { public final static AuthScope DEFSCOPE = new AuthScope(null, "host", -1, "realm", null); @Test - public void testBasicCredentialsProviderCredentials() { + void testBasicCredentialsProviderCredentials() { final BasicCredentialsProvider state = new BasicCredentialsProvider(); state.setCredentials(SCOPE1, CREDS1); state.setCredentials(SCOPE2, CREDS2); @@ -60,13 +60,13 @@ public void testBasicCredentialsProviderCredentials() { } @Test - public void testBasicCredentialsProviderNoCredentials() { + void testBasicCredentialsProviderNoCredentials() { final BasicCredentialsProvider state = new BasicCredentialsProvider(); Assertions.assertNull(state.getCredentials(BOGUS, null)); } @Test - public void testBasicCredentialsProviderDefaultCredentials() { + void testBasicCredentialsProviderDefaultCredentials() { final BasicCredentialsProvider state = new BasicCredentialsProvider(); state.setCredentials(new AuthScope(null, null, -1, null ,null), CREDS1); state.setCredentials(SCOPE2, CREDS2); @@ -74,7 +74,7 @@ public void testBasicCredentialsProviderDefaultCredentials() { } @Test - public void testDefaultCredentials() throws Exception { + void testDefaultCredentials() { final BasicCredentialsProvider state = new BasicCredentialsProvider(); final Credentials expected = new UsernamePasswordCredentials("name", "pass".toCharArray()); state.setCredentials(new AuthScope(null, null, -1, null ,null), expected); @@ -83,7 +83,7 @@ public void testDefaultCredentials() throws Exception { } @Test - public void testRealmCredentials() throws Exception { + void testRealmCredentials() { final BasicCredentialsProvider state = new BasicCredentialsProvider(); final Credentials expected = new UsernamePasswordCredentials("name", "pass".toCharArray()); state.setCredentials(DEFSCOPE, expected); @@ -92,7 +92,7 @@ public void testRealmCredentials() throws Exception { } @Test - public void testHostCredentials() throws Exception { + void testHostCredentials() { final BasicCredentialsProvider state = new BasicCredentialsProvider(); final Credentials expected = new UsernamePasswordCredentials("name", "pass".toCharArray()); state.setCredentials(new AuthScope(null, "host", -1, null, null), expected); @@ -101,7 +101,7 @@ public void testHostCredentials() throws Exception { } @Test - public void testWrongHostCredentials() throws Exception { + void testWrongHostCredentials() { final BasicCredentialsProvider state = new BasicCredentialsProvider(); final Credentials expected = new UsernamePasswordCredentials("name", "pass".toCharArray()); state.setCredentials(new AuthScope(null, "host1", -1, "realm", null), expected); @@ -110,7 +110,7 @@ public void testWrongHostCredentials() throws Exception { } @Test - public void testWrongRealmCredentials() throws Exception { + void testWrongRealmCredentials() { final BasicCredentialsProvider state = new BasicCredentialsProvider(); final Credentials cred = new UsernamePasswordCredentials("name", "pass".toCharArray()); state.setCredentials(new AuthScope(null, "host", -1, "realm1", null), cred); @@ -119,7 +119,7 @@ public void testWrongRealmCredentials() throws Exception { } @Test - public void testMixedCaseHostname() throws Exception { + void testMixedCaseHostname() { final HttpHost httpHost = new HttpHost("hOsT", 80); final BasicCredentialsProvider state = new BasicCredentialsProvider(); final Credentials expected = new UsernamePasswordCredentials("name", "pass".toCharArray()); @@ -129,7 +129,7 @@ public void testMixedCaseHostname() throws Exception { } @Test - public void testCredentialsMatching() { + void testCredentialsMatching() { final Credentials creds1 = new UsernamePasswordCredentials("name1", "pass1".toCharArray()); final Credentials creds2 = new UsernamePasswordCredentials("name2", "pass2".toCharArray()); final Credentials creds3 = new UsernamePasswordCredentials("name3", "pass3".toCharArray()); @@ -157,7 +157,7 @@ public void testCredentialsMatching() { } @Test - public void testSingleCredentialsProvider() { + void testSingleCredentialsProvider() { final Credentials creds1 = new UsernamePasswordCredentials("name1", "pass1".toCharArray()); final CredentialsProvider credentialsProvider1 = new SingleCredentialsProvider(new AuthScope(null, null, -1, null, null), creds1); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java index 6dfbbe86e..98b9747ea 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestDigestScheme.java @@ -64,7 +64,7 @@ /** * Test Methods for DigestScheme Authentication. */ -public class TestDigestScheme { +class TestDigestScheme { private static AuthChallenge parse(final String s) throws ParseException { final CharArrayBuffer buffer = new CharArrayBuffer(s.length()); @@ -76,7 +76,7 @@ private static AuthChallenge parse(final String s) throws ParseException { } @Test - public void testDigestAuthenticationEmptyChallenge1() throws Exception { + void testDigestAuthenticationEmptyChallenge1() throws Exception { final AuthChallenge authChallenge = parse(StandardAuthScheme.DIGEST); final AuthScheme authscheme = new DigestScheme(); Assertions.assertThrows(MalformedChallengeException.class, () -> @@ -84,7 +84,7 @@ public void testDigestAuthenticationEmptyChallenge1() throws Exception { } @Test - public void testDigestAuthenticationEmptyChallenge2() throws Exception { + void testDigestAuthenticationEmptyChallenge2() throws Exception { final AuthChallenge authChallenge = parse(StandardAuthScheme.DIGEST + " "); final AuthScheme authscheme = new DigestScheme(); Assertions.assertThrows(MalformedChallengeException.class, () -> @@ -92,7 +92,7 @@ public void testDigestAuthenticationEmptyChallenge2() throws Exception { } @Test - public void testDigestAuthenticationWithDefaultCreds() throws Exception { + void testDigestAuthenticationWithDefaultCreds() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -118,7 +118,7 @@ public void testDigestAuthenticationWithDefaultCreds() throws Exception { } @Test - public void testDigestAuthentication() throws Exception { + void testDigestAuthentication() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -142,7 +142,7 @@ public void testDigestAuthentication() throws Exception { } @Test - public void testDigestAuthenticationInvalidInput() throws Exception { + void testDigestAuthenticationInvalidInput() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() .add(new AuthScope(host, "realm1", null), "username", "password".toCharArray()) @@ -162,7 +162,7 @@ public void testDigestAuthenticationInvalidInput() throws Exception { } @Test - public void testDigestAuthenticationWithSHA() throws Exception { + void testDigestAuthenticationWithSHA() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -188,7 +188,7 @@ public void testDigestAuthenticationWithSHA() throws Exception { } @Test - public void testDigestAuthenticationWithQueryStringInDigestURI() throws Exception { + void testDigestAuthenticationWithQueryStringInDigestURI() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/?param=value"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -212,7 +212,7 @@ public void testDigestAuthenticationWithQueryStringInDigestURI() throws Exceptio } @Test - public void testDigestAuthenticationNoRealm() throws Exception { + void testDigestAuthenticationNoRealm() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -230,7 +230,7 @@ public void testDigestAuthenticationNoRealm() throws Exception { } @Test - public void testDigestAuthenticationNoNonce() throws Exception { + void testDigestAuthenticationNoNonce() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -248,7 +248,7 @@ public void testDigestAuthenticationNoNonce() throws Exception { } @Test - public void testDigestAuthenticationNoAlgorithm() throws Exception { + void testDigestAuthenticationNoAlgorithm() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -268,7 +268,7 @@ public void testDigestAuthenticationNoAlgorithm() throws Exception { } @Test - public void testDigestAuthenticationMD5Algorithm() throws Exception { + void testDigestAuthenticationMD5Algorithm() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -293,7 +293,7 @@ public void testDigestAuthenticationMD5Algorithm() throws Exception { * Test digest authentication using the MD5-sess algorithm. */ @Test - public void testDigestAuthenticationMD5Sess() throws Exception { + void testDigestAuthenticationMD5Sess() throws Exception { // Example using Digest auth with MD5-sess final String realm="realm"; @@ -343,7 +343,7 @@ public void testDigestAuthenticationMD5Sess() throws Exception { * Test digest authentication using the MD5-sess algorithm. */ @Test - public void testDigestAuthenticationMD5SessNoQop() throws Exception { + void testDigestAuthenticationMD5SessNoQop() throws Exception { // Example using Digest auth with MD5-sess final String realm="realm"; @@ -387,7 +387,7 @@ public void testDigestAuthenticationMD5SessNoQop() throws Exception { * Test digest authentication with unknown qop value */ @Test - public void testDigestAuthenticationMD5SessUnknownQop() throws Exception { + void testDigestAuthenticationMD5SessUnknownQop() throws Exception { // Example using Digest auth with MD5-sess final String realm="realm"; @@ -422,7 +422,7 @@ public void testDigestAuthenticationMD5SessUnknownQop() throws Exception { * Test digest authentication with unknown qop value */ @Test - public void testDigestAuthenticationUnknownAlgo() throws Exception { + void testDigestAuthenticationUnknownAlgo() throws Exception { // Example using Digest auth with MD5-sess final String realm="realm"; @@ -454,7 +454,7 @@ public void testDigestAuthenticationUnknownAlgo() throws Exception { } @Test - public void testDigestAuthenticationWithStaleNonce() throws Exception { + void testDigestAuthenticationWithStaleNonce() throws Exception { final String challenge = StandardAuthScheme.DIGEST + " realm=\"realm1\", " + "nonce=\"f2a3f18799759d4f1a1c068b92b573cb\", stale=\"true\""; final AuthChallenge authChallenge = parse(challenge); @@ -479,7 +479,7 @@ private static Map parseAuthResponse(final String authResponse) } @Test - public void testDigestNouceCount() throws Exception { + void testDigestNouceCount() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -523,7 +523,7 @@ public void testDigestNouceCount() throws Exception { } @Test - public void testDigestMD5SessA1AndCnonceConsistency() throws Exception { + void testDigestMD5SessA1AndCnonceConsistency() throws Exception { final HttpHost host = new HttpHost("somehost", 80); final HttpRequest request = new BasicHttpRequest("GET", "/"); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -585,7 +585,7 @@ public void testDigestMD5SessA1AndCnonceConsistency() throws Exception { } @Test - public void testHttpEntityDigest() throws Exception { + void testHttpEntityDigest() throws Exception { final HttpEntityDigester digester = new HttpEntityDigester(MessageDigest.getInstance("MD5")); Assertions.assertNull(digester.getDigest()); digester.write('a'); @@ -603,7 +603,7 @@ public void testHttpEntityDigest() throws Exception { } @Test - public void testDigestAuthenticationQopAuthInt() throws Exception { + void testDigestAuthenticationQopAuthInt() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("Post", "/"); request.setEntity(new StringEntity("abc\u00e4\u00f6\u00fcabc", StandardCharsets.ISO_8859_1)); final HttpHost host = new HttpHost("somehost", 80); @@ -630,7 +630,7 @@ public void testDigestAuthenticationQopAuthInt() throws Exception { } @Test - public void testDigestAuthenticationQopAuthIntNullEntity() throws Exception { + void testDigestAuthenticationQopAuthIntNullEntity() throws Exception { final HttpRequest request = new BasicHttpRequest("Post", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -656,7 +656,7 @@ public void testDigestAuthenticationQopAuthIntNullEntity() throws Exception { } @Test - public void testDigestAuthenticationQopAuthOrAuthIntNonRepeatableEntity() throws Exception { + void testDigestAuthenticationQopAuthOrAuthIntNonRepeatableEntity() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("Post", "/"); request.setEntity(new InputStreamEntity(new ByteArrayInputStream(new byte[] {'a'}), -1, ContentType.DEFAULT_TEXT)); final HttpHost host = new HttpHost("somehost", 80); @@ -683,7 +683,7 @@ public void testDigestAuthenticationQopAuthOrAuthIntNonRepeatableEntity() throws } @Test - public void testParameterCaseSensitivity() throws Exception { + void testParameterCaseSensitivity() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -703,7 +703,7 @@ public void testParameterCaseSensitivity() throws Exception { } @Test - public void testDigestAuthenticationQopIntOnlyNonRepeatableEntity() throws Exception { + void testDigestAuthenticationQopIntOnlyNonRepeatableEntity() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("Post", "/"); request.setEntity(new InputStreamEntity(new ByteArrayInputStream(new byte[] {'a'}), -1, ContentType.DEFAULT_TEXT)); final HttpHost host = new HttpHost("somehost", 80); @@ -723,7 +723,7 @@ public void testDigestAuthenticationQopIntOnlyNonRepeatableEntity() throws Excep } @Test - public void testSerialization() throws Exception { + void testSerialization() throws Exception { final String challenge = StandardAuthScheme.DIGEST + " realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\", " + "qop=\"auth,auth-int\""; final AuthChallenge authChallenge = parse(challenge); @@ -748,7 +748,7 @@ public void testSerialization() throws Exception { @Test - public void testDigestAuthenticationWithUserHash() throws Exception { + void testDigestAuthenticationWithUserHash() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -791,7 +791,7 @@ private static String bytesToHex(final byte[] bytes) { } @Test - public void testDigestAuthenticationWithQuotedStringsAndWhitespace() throws Exception { + void testDigestAuthenticationWithQuotedStringsAndWhitespace() throws Exception { final HttpRequest request = new BasicHttpRequest("Simple", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -820,7 +820,7 @@ public void testDigestAuthenticationWithQuotedStringsAndWhitespace() throws Exce Assertions.assertNotNull(response); } @Test - public void testDigestAuthenticationWithInvalidUsernameAndValidUsernameStar() throws Exception { + void testDigestAuthenticationWithInvalidUsernameAndValidUsernameStar() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/"); final HttpHost host = new HttpHost("somehost", 80); final CredentialsProvider credentialsProvider = CredentialsProviderBuilder.create() @@ -841,7 +841,7 @@ public void testDigestAuthenticationWithInvalidUsernameAndValidUsernameStar() th } @Test - public void testDigestAuthenticationWithHighAsciiCharInUsername() throws Exception { + void testDigestAuthenticationWithHighAsciiCharInUsername() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/"); final HttpHost host = new HttpHost("somehost", 80); // Using a username with a high ASCII character @@ -863,7 +863,7 @@ public void testDigestAuthenticationWithHighAsciiCharInUsername() throws Excepti @Test - public void testDigestAuthenticationWithExtendedAsciiCharInUsername() throws Exception { + void testDigestAuthenticationWithExtendedAsciiCharInUsername() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/"); final HttpHost host = new HttpHost("somehost", 80); // Using an extended ASCII character (e.g., 0x80) in the username @@ -885,7 +885,7 @@ public void testDigestAuthenticationWithExtendedAsciiCharInUsername() throws Exc @Test - public void testDigestAuthenticationWithNonAsciiUsername() throws Exception { + void testDigestAuthenticationWithNonAsciiUsername() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/"); final HttpHost host = new HttpHost("somehost", 80); // Using a username with non-ASCII characters diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestHttpAuthenticator.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestHttpAuthenticator.java index fcf9e0249..9107e8801 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestHttpAuthenticator.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestHttpAuthenticator.java @@ -60,7 +60,7 @@ import org.mockito.Mockito; @SuppressWarnings({"boxing","static-access"}) -public class TestHttpAuthenticator { +class TestHttpAuthenticator { @AuthStateCacheable abstract class CacheableAuthState implements AuthScheme { @@ -81,7 +81,7 @@ public String getName() { private HttpAuthenticator httpAuthenticator; @BeforeEach - public void setUp() throws Exception { + void setUp() { this.authExchange = new AuthExchange(); this.authScheme = Mockito.mock(CacheableAuthState.class, Mockito.withSettings() .defaultAnswer(Answers.CALLS_REAL_METHODS)); @@ -99,7 +99,7 @@ public void setUp() throws Exception { } @Test - public void testUpdateAuthExchange() throws Exception { + void testUpdateAuthExchange() { final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.setHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.BASIC + " realm=test"); Assertions.assertTrue(this.httpAuthenticator.isChallenged( @@ -107,7 +107,7 @@ public void testUpdateAuthExchange() throws Exception { } @Test - public void testAuthenticationRequestedAfterSuccess() throws Exception { + void testAuthenticationRequestedAfterSuccess() { final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.setHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.BASIC + " realm=test"); @@ -119,7 +119,7 @@ public void testAuthenticationRequestedAfterSuccess() throws Exception { } @Test - public void testAuthenticationNotRequestedUnchallenged() throws Exception { + void testAuthenticationNotRequestedUnchallenged() { final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); Assertions.assertFalse(this.httpAuthenticator.isChallenged( @@ -128,7 +128,7 @@ public void testAuthenticationNotRequestedUnchallenged() throws Exception { } @Test - public void testAuthenticationNotRequestedSuccess1() throws Exception { + void testAuthenticationNotRequestedSuccess1() { final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); this.authExchange.select(this.authScheme); this.authExchange.setState(AuthExchange.State.CHALLENGED); @@ -139,7 +139,7 @@ public void testAuthenticationNotRequestedSuccess1() throws Exception { } @Test - public void testAuthenticationNotRequestedSuccess2() throws Exception { + void testAuthenticationNotRequestedSuccess2() { final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK, "OK"); this.authExchange.select(this.authScheme); this.authExchange.setState(AuthExchange.State.HANDSHAKE); @@ -150,7 +150,7 @@ public void testAuthenticationNotRequestedSuccess2() throws Exception { } @Test - public void testAuthentication() throws Exception { + void testAuthentication() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.BASIC + " realm=\"test\"")); @@ -179,7 +179,7 @@ public void testAuthentication() throws Exception { } @Test - public void testAuthenticationCredentialsForBasic() throws Exception { + void testAuthenticationCredentialsForBasic() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); @@ -205,7 +205,7 @@ public void testAuthenticationCredentialsForBasic() throws Exception { } @Test - public void testAuthenticationNoChallenges() throws Exception { + void testAuthenticationNoChallenges() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); @@ -216,7 +216,7 @@ public void testAuthenticationNoChallenges() throws Exception { } @Test - public void testAuthenticationNoSupportedChallenges() throws Exception { + void testAuthenticationNoSupportedChallenges() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "This realm=\"test\"")); @@ -229,7 +229,7 @@ public void testAuthenticationNoSupportedChallenges() throws Exception { } @Test - public void testAuthenticationNoCredentials() throws Exception { + void testAuthenticationNoCredentials() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.BASIC + " realm=\"test\"")); @@ -242,7 +242,7 @@ public void testAuthenticationNoCredentials() throws Exception { } @Test - public void testAuthenticationFailed() throws Exception { + void testAuthenticationFailed() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.BASIC + " realm=\"test\"")); @@ -260,7 +260,7 @@ public void testAuthenticationFailed() throws Exception { } @Test - public void testAuthenticationFailedPreviously() throws Exception { + void testAuthenticationFailedPreviously() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.BASIC + " realm=\"test\"")); @@ -277,7 +277,7 @@ public void testAuthenticationFailedPreviously() throws Exception { } @Test - public void testAuthenticationFailure() throws Exception { + void testAuthenticationFailure() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.BASIC + " realm=\"test\"")); @@ -295,7 +295,7 @@ public void testAuthenticationFailure() throws Exception { } @Test - public void testAuthenticationHandshaking() throws Exception { + void testAuthenticationHandshaking() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.BASIC + " realm=\"test\"")); @@ -314,7 +314,7 @@ public void testAuthenticationHandshaking() throws Exception { } @Test - public void testAuthenticationNoMatchingChallenge() throws Exception { + void testAuthenticationNoMatchingChallenge() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, StandardAuthScheme.DIGEST + " realm=\"realm1\", nonce=\"1234\"")); @@ -342,7 +342,7 @@ public void testAuthenticationNoMatchingChallenge() throws Exception { } @Test - public void testAuthenticationException() throws Exception { + void testAuthenticationException() { final HttpHost host = new HttpHost("somehost", 80); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED"); response.addHeader(new BasicHeader(HttpHeaders.WWW_AUTHENTICATE, "blah blah blah")); @@ -359,7 +359,7 @@ public void testAuthenticationException() throws Exception { } @Test - public void testAuthFailureState() throws Exception { + void testAuthFailureState() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); this.authExchange.setState(AuthExchange.State.FAILURE); this.authExchange.select(this.authScheme); @@ -375,7 +375,7 @@ public void testAuthFailureState() throws Exception { } @Test - public void testAuthChallengeStateNoOption() throws Exception { + void testAuthChallengeStateNoOption() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); this.authExchange.setState(AuthExchange.State.CHALLENGED); this.authExchange.select(this.authScheme); @@ -391,7 +391,7 @@ public void testAuthChallengeStateNoOption() throws Exception { } @Test - public void testAuthChallengeStateOneOptions() throws Exception { + void testAuthChallengeStateOneOptions() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); this.authExchange.setState(AuthExchange.State.CHALLENGED); final LinkedList authOptions = new LinkedList<>(); @@ -412,7 +412,7 @@ public void testAuthChallengeStateOneOptions() throws Exception { } @Test - public void testAuthChallengeStateMultipleOption() throws Exception { + void testAuthChallengeStateMultipleOption() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); this.authExchange.setState(AuthExchange.State.CHALLENGED); @@ -440,7 +440,7 @@ public void testAuthChallengeStateMultipleOption() throws Exception { } @Test - public void testAuthSuccess() throws Exception { + void testAuthSuccess() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); this.authExchange.setState(AuthExchange.State.SUCCESS); this.authExchange.select(this.authScheme); @@ -460,7 +460,7 @@ public void testAuthSuccess() throws Exception { } @Test - public void testAuthSuccessConnectionBased() throws Exception { + void testAuthSuccessConnectionBased() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); this.authExchange.setState(AuthExchange.State.SUCCESS); this.authExchange.select(this.authScheme); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMEngineImpl.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMEngineImpl.java index 76dea6396..f5773f96f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMEngineImpl.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMEngineImpl.java @@ -36,10 +36,10 @@ import org.junit.jupiter.api.Test; @SuppressWarnings("deprecation") -public class TestNTLMEngineImpl { +class TestNTLMEngineImpl { @Test - public void testMD4() throws Exception { + void testMD4() throws Exception { checkMD4("", "31d6cfe0d16ae931b73c59d7e0c089c0"); checkMD4("a", "bde52cb31de33e46245e05fbdbd6fb24"); checkMD4("abc", "a448017aaf21d8525fc10ae87aa6729d"); @@ -96,7 +96,7 @@ static void checkMD4(final String input, final String hexOutput) throws Exceptio } @Test - public void testLMResponse() throws Exception { + void testLMResponse() throws Exception { final NTLMEngineImpl.CipherGen gen = new NTLMEngineImpl.CipherGen( new Random(1234), 1234L, @@ -116,7 +116,7 @@ public void testLMResponse() throws Exception { } @Test - public void testNTLMResponse() throws Exception { + void testNTLMResponse() throws Exception { final NTLMEngineImpl.CipherGen gen = new NTLMEngineImpl.CipherGen( new Random(1234), 1234L, @@ -136,7 +136,7 @@ public void testNTLMResponse() throws Exception { } @Test - public void testLMv2Response() throws Exception { + void testLMv2Response() throws Exception { final NTLMEngineImpl.CipherGen gen = new NTLMEngineImpl.CipherGen( new Random(1234), 1234L, @@ -156,7 +156,7 @@ public void testLMv2Response() throws Exception { } @Test - public void testNTLMv2Response() throws Exception { + void testNTLMv2Response() throws Exception { final NTLMEngineImpl.CipherGen gen = new NTLMEngineImpl.CipherGen( new Random(1234), 1234L, @@ -178,7 +178,7 @@ public void testNTLMv2Response() throws Exception { } @Test - public void testLM2SessionResponse() throws Exception { + void testLM2SessionResponse() { final NTLMEngineImpl.CipherGen gen = new NTLMEngineImpl.CipherGen( new Random(1234), 1234L, @@ -198,7 +198,7 @@ public void testLM2SessionResponse() throws Exception { } @Test - public void testNTLM2SessionResponse() throws Exception { + void testNTLM2SessionResponse() throws Exception { final NTLMEngineImpl.CipherGen gen = new NTLMEngineImpl.CipherGen( new Random(1234), 1234L, @@ -218,7 +218,7 @@ public void testNTLM2SessionResponse() throws Exception { } @Test - public void testNTLMUserSessionKey() throws Exception { + void testNTLMUserSessionKey() throws Exception { final NTLMEngineImpl.CipherGen gen = new NTLMEngineImpl.CipherGen( new Random(1234), 1234L, @@ -238,14 +238,14 @@ public void testNTLMUserSessionKey() throws Exception { } @Test - public void testType1Message() throws Exception { + void testType1Message() { final byte[] bytes = new NTLMEngineImpl.Type1Message("myhost", "mydomain").getBytes(); final byte[] bytes2 = toBytes("4E544C4D5353500001000000018208A20C000C003800000010001000280000000501280A0000000F6D00790064006F006D00610069006E004D00590048004F0053005400"); checkArraysMatch(bytes2, bytes); } @Test - public void testType3Message() throws Exception { + void testType3Message() throws Exception { final byte[] bytes = new NTLMEngineImpl.Type3Message( new Random(1234), 1234L, @@ -286,7 +286,7 @@ public void testType3Message() throws Exception { "-----END CERTIFICATE-----"; @Test - public void testType3MessageWithCert() throws Exception { + void testType3MessageWithCert() throws Exception { final ByteArrayInputStream fis = new ByteArrayInputStream(cannedCert.getBytes(StandardCharsets.US_ASCII)); final CertificateFactory cf = CertificateFactory.getInstance("X.509"); @@ -310,15 +310,14 @@ public void testType3MessageWithCert() throws Exception { } @Test - public void testRC4() throws Exception { + void testRC4() throws Exception { checkArraysMatch(toBytes("e37f97f2544f4d7e"), NTLMEngineImpl.RC4(toBytes("0a003602317a759a"), toBytes("2785f595293f3e2813439d73a223810d"))); } /* Byte array check helper */ - static void checkArraysMatch(final byte[] a1, final byte[] a2) - throws Exception { + static void checkArraysMatch(final byte[] a1, final byte[] a2) { Assertions.assertEquals(a1.length,a2.length); for (int i = 0; i < a1.length; i++) { Assertions.assertEquals(a1[i],a2[i]); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMScheme.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMScheme.java index 6c545a4eb..2e2191864 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMScheme.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestNTLMScheme.java @@ -38,10 +38,10 @@ * Unit tests for {@link NTLMScheme}. */ @SuppressWarnings("deprecation") -public class TestNTLMScheme { +class TestNTLMScheme { @Test - public void testNTLMAuthenticationEmptyProxyChallenge() throws Exception { + void testNTLMAuthenticationEmptyProxyChallenge() throws Exception { final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.PROXY, StandardAuthScheme.NTLM); final AuthScheme authScheme = new NTLMScheme(); authScheme.processChallenge(authChallenge, null); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestSystemDefaultCredentialsProvider.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestSystemDefaultCredentialsProvider.java index c2cbc4286..2aec4041d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestSystemDefaultCredentialsProvider.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/auth/TestSystemDefaultCredentialsProvider.java @@ -46,7 +46,7 @@ /** * Simple tests for {@link SystemDefaultCredentialsProvider}. */ -public class TestSystemDefaultCredentialsProvider { +class TestSystemDefaultCredentialsProvider { private final static String PROXY_PROTOCOL1 = "http"; private final static String PROXY_HOST1 = "proxyhost1"; @@ -88,7 +88,7 @@ PasswordAuthentication getPasswordAuthentication( } @Test - public void testSystemCredentialsProviderCredentials() throws Exception { + void testSystemCredentialsProviderCredentials() throws Exception { final AuthenticatorDelegate authenticatorDelegate = installAuthenticator(AUTH1); @@ -110,7 +110,7 @@ public void testSystemCredentialsProviderCredentials() throws Exception { } @Test - public void testSystemCredentialsProviderNoContext() throws Exception { + void testSystemCredentialsProviderNoContext() { final AuthenticatorDelegate authenticatorDelegate = installAuthenticator(AUTH1); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestAIMDBackoffManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestAIMDBackoffManager.java index 00be6e221..2c740850b 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestAIMDBackoffManager.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestAIMDBackoffManager.java @@ -44,7 +44,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestAIMDBackoffManager { +class TestAIMDBackoffManager { private AIMDBackoffManager impl; private MockConnPoolControl connPerRoute; @@ -53,7 +53,7 @@ public class TestAIMDBackoffManager { @BeforeEach - public void setUp() { + void setUp() { connPerRoute = new MockConnPoolControl(); route = new HttpRoute(new HttpHost("localhost", 80)); impl = new AIMDBackoffManager(connPerRoute); @@ -63,33 +63,33 @@ public void setUp() { } @Test - public void isABackoffManager() { + void isABackoffManager() { assertTrue(impl instanceof BackoffManager); } @Test - public void halvesConnectionsOnBackoff() { + void halvesConnectionsOnBackoff() { connPerRoute.setMaxPerRoute(route, 4); impl.backOff(route); assertEquals(2, connPerRoute.getMaxPerRoute(route)); } @Test - public void doesNotBackoffBelowOneConnection() { + void doesNotBackoffBelowOneConnection() { connPerRoute.setMaxPerRoute(route, 1); impl.backOff(route); assertEquals(1, connPerRoute.getMaxPerRoute(route)); } @Test - public void increasesByOneOnProbe() { + void increasesByOneOnProbe() { connPerRoute.setMaxPerRoute(route, 2); impl.probe(route); assertEquals(3, connPerRoute.getMaxPerRoute(route)); } @Test - public void doesNotIncreaseBeyondPerHostMaxOnProbe() { + void doesNotIncreaseBeyondPerHostMaxOnProbe() { connPerRoute.setDefaultMaxPerRoute(5); connPerRoute.setMaxPerRoute(route, 5); impl.setPerHostConnectionCap(5); @@ -98,7 +98,7 @@ public void doesNotIncreaseBeyondPerHostMaxOnProbe() { } @Test - public void backoffDoesNotAdjustDuringCoolDownPeriod() { + void backoffDoesNotAdjustDuringCoolDownPeriod() { // Arrange connPerRoute.setMaxPerRoute(route, 4); @@ -120,7 +120,7 @@ public void backoffDoesNotAdjustDuringCoolDownPeriod() { @Test - public void backoffStillAdjustsAfterCoolDownPeriod() { + void backoffStillAdjustsAfterCoolDownPeriod() { // Arrange: Initialize the maximum number of connections for a route to 8 connPerRoute.setMaxPerRoute(route, 8); @@ -146,7 +146,7 @@ public void backoffStillAdjustsAfterCoolDownPeriod() { @Test - public void probeDoesNotAdjustDuringCooldownPeriod() { + void probeDoesNotAdjustDuringCooldownPeriod() { // Arrange connPerRoute.setMaxPerRoute(route, 4); @@ -168,7 +168,7 @@ public void probeDoesNotAdjustDuringCooldownPeriod() { @Test - public void probeStillAdjustsAfterCoolDownPeriod() { + void probeStillAdjustsAfterCoolDownPeriod() { connPerRoute.setMaxPerRoute(route, 8); // First probe @@ -188,7 +188,7 @@ public void probeStillAdjustsAfterCoolDownPeriod() { @Test - public void willBackoffImmediatelyEvenAfterAProbe() { + void willBackoffImmediatelyEvenAfterAProbe() { connPerRoute.setMaxPerRoute(route, 8); impl.probe(route); final long max = connPerRoute.getMaxPerRoute(route); @@ -197,7 +197,7 @@ public void willBackoffImmediatelyEvenAfterAProbe() { } @Test - public void backOffFactorIsConfigurable() { + void backOffFactorIsConfigurable() { connPerRoute.setMaxPerRoute(route, 10); impl.setBackoffFactor(0.9); impl.backOff(route); @@ -205,7 +205,7 @@ public void backOffFactorIsConfigurable() { } @Test - public void coolDownPeriodIsConfigurable() { + void coolDownPeriodIsConfigurable() { final long cd = new Random().nextInt(500) + 500; // Random cooldown period between 500 and 1000 milliseconds impl.setCoolDown(TimeValue.ofMilliseconds(cd)); @@ -230,7 +230,7 @@ public void coolDownPeriodIsConfigurable() { } @Test - public void testConcurrency() throws InterruptedException { + void testConcurrency() throws InterruptedException { final int initialMaxPerRoute = 10; final int numberOfThreads = 20; final int numberOfOperationsPerThread = 100; // reduced operations diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestAbstractHttpClientResponseHandler.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestAbstractHttpClientResponseHandler.java index 4f6fc7760..8351bc7ae 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestAbstractHttpClientResponseHandler.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestAbstractHttpClientResponseHandler.java @@ -42,10 +42,10 @@ /** * Unit tests for {@link BasicHttpClientResponseHandler}. */ -public class TestAbstractHttpClientResponseHandler { +class TestAbstractHttpClientResponseHandler { @Test - public void testSuccessfulResponse() throws Exception { + void testSuccessfulResponse() throws Exception { final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class); final HttpEntity entity = new StringEntity("42"); Mockito.when(response.getCode()).thenReturn(200); @@ -64,7 +64,7 @@ public Integer handleEntity(final HttpEntity entity) throws IOException { @SuppressWarnings("boxing") @Test - public void testUnsuccessfulResponse() throws Exception { + void testUnsuccessfulResponse() throws Exception { final InputStream inStream = Mockito.mock(InputStream.class); final HttpEntity entity = Mockito.mock(HttpEntity.class); Mockito.when(entity.isStreaming()).thenReturn(true); @@ -86,7 +86,7 @@ public void testUnsuccessfulResponse() throws Exception { @SuppressWarnings("boxing") @Test - public void testUnsuccessfulResponseEmptyReason() throws Exception { + void testUnsuccessfulResponseEmptyReason() throws Exception { final InputStream inStream = Mockito.mock(InputStream.class); final HttpEntity entity = Mockito.mock(HttpEntity.class); Mockito.when(entity.isStreaming()).thenReturn(true); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestBasicResponseHandler.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestBasicResponseHandler.java index b49a9f555..e995b8655 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestBasicResponseHandler.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestBasicResponseHandler.java @@ -41,10 +41,10 @@ * Unit tests for {@link BasicHttpClientResponseHandler}. */ @SuppressWarnings("boxing") // test code -public class TestBasicResponseHandler { +class TestBasicResponseHandler { @Test - public void testSuccessfulResponse() throws Exception { + void testSuccessfulResponse() throws Exception { final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class); final HttpEntity entity = new StringEntity("stuff"); Mockito.when(response.getCode()).thenReturn(200); @@ -56,7 +56,7 @@ public void testSuccessfulResponse() throws Exception { } @Test - public void testUnsuccessfulResponse() throws Exception { + void testUnsuccessfulResponse() throws Exception { final InputStream inStream = Mockito.mock(InputStream.class); final HttpEntity entity = Mockito.mock(HttpEntity.class); Mockito.when(entity.isStreaming()).thenReturn(true); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCloseableHttpClient.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCloseableHttpClient.java index e446e5cca..c6faca7a2 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCloseableHttpClient.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCloseableHttpClient.java @@ -46,7 +46,7 @@ * Simple tests for {@link CloseableHttpClient}. */ @SuppressWarnings({"boxing","static-access"}) // test code -public class TestCloseableHttpClient { +class TestCloseableHttpClient { static abstract class NoopCloseableHttpClient extends CloseableHttpClient { @@ -54,7 +54,7 @@ static abstract class NoopCloseableHttpClient extends CloseableHttpClient { protected CloseableHttpResponse doExecute( final HttpHost target, final ClassicHttpRequest request, - final HttpContext context) throws IOException { + final HttpContext context) { return null; } @@ -67,7 +67,7 @@ protected CloseableHttpResponse doExecute( private CloseableHttpResponse response; @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { content = Mockito.mock(InputStream.class); entity = Mockito.mock(HttpEntity.class); originResponse = Mockito.mock(ClassicHttpResponse.class); @@ -79,7 +79,7 @@ public void setup() throws Exception { } @Test - public void testExecuteRequestAbsoluteURI() throws Exception { + void testExecuteRequestAbsoluteURI() throws Exception { final HttpGet httpget = new HttpGet("https://somehost:444/stuff"); Mockito.when(client.doExecute( Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(response); @@ -92,7 +92,7 @@ public void testExecuteRequestAbsoluteURI() throws Exception { } @Test - public void testExecuteRequestRelativeURI() throws Exception { + void testExecuteRequestRelativeURI() throws Exception { final HttpGet httpget = new HttpGet("/stuff"); Mockito.when(client.doExecute( Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(response); @@ -105,7 +105,7 @@ public void testExecuteRequestRelativeURI() throws Exception { } @Test - public void testExecuteRequestHandleResponse() throws Exception { + void testExecuteRequestHandleResponse() throws Exception { final HttpGet httpget = new HttpGet("https://somehost:444/stuff"); Mockito.when(client.doExecute( @@ -124,7 +124,7 @@ public void testExecuteRequestHandleResponse() throws Exception { } @Test - public void testExecuteRequestHandleResponseIOException() throws Exception { + void testExecuteRequestHandleResponseIOException() throws Exception { final HttpGet httpget = new HttpGet("https://somehost:444/stuff"); Mockito.when(client.doExecute( @@ -144,7 +144,7 @@ public void testExecuteRequestHandleResponseIOException() throws Exception { } @Test - public void testExecuteRequestHandleResponseHttpException() throws Exception { + void testExecuteRequestHandleResponseHttpException() throws Exception { final HttpGet httpget = new HttpGet("https://somehost:444/stuff"); Mockito.when(client.doExecute( diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java index a1716d4b2..c6e6e912d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestConnectExec.java @@ -65,7 +65,7 @@ import org.mockito.stubbing.Answer; @SuppressWarnings({"boxing","static-access"}) // test code -public class TestConnectExec { +class TestConnectExec { @Mock private ConnectionReuseStrategy reuseStrategy; @@ -83,7 +83,7 @@ public class TestConnectExec { private HttpHost proxy; @BeforeEach - public void setup() throws Exception { + void setup() { MockitoAnnotations.openMocks(this); exec = new ConnectExec(reuseStrategy, proxyHttpProcessor, proxyAuthStrategy, null, true); target = new HttpHost("foo", 80); @@ -91,7 +91,7 @@ public void setup() throws Exception { } @Test - public void testExecAcquireConnection() throws Exception { + void testExecAcquireConnection() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -110,7 +110,7 @@ public void testExecAcquireConnection() throws Exception { } @Test - public void testEstablishDirectRoute() throws Exception { + void testEstablishDirectRoute() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -130,7 +130,7 @@ public void testEstablishDirectRoute() throws Exception { } @Test - public void testEstablishRouteDirectProxy() throws Exception { + void testEstablishRouteDirectProxy() throws Exception { final HttpRoute route = new HttpRoute(target, null, proxy, false); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -150,7 +150,7 @@ public void testEstablishRouteDirectProxy() throws Exception { } @Test - public void testEstablishRouteViaProxyTunnel() throws Exception { + void testEstablishRouteViaProxyTunnel() throws Exception { final HttpRoute route = new HttpRoute(target, null, proxy, true); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -181,7 +181,7 @@ public void testEstablishRouteViaProxyTunnel() throws Exception { } @Test - public void testEstablishRouteViaProxyTunnelUnexpectedResponse() throws Exception { + void testEstablishRouteViaProxyTunnelUnexpectedResponse() throws Exception { final HttpRoute route = new HttpRoute(target, null, proxy, true); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -201,7 +201,7 @@ public void testEstablishRouteViaProxyTunnelUnexpectedResponse() throws Exceptio } @Test - public void testEstablishRouteViaProxyTunnelFailure() throws Exception { + void testEstablishRouteViaProxyTunnelFailure() throws Exception { final HttpRoute route = new HttpRoute(target, null, proxy, true); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -222,7 +222,7 @@ public void testEstablishRouteViaProxyTunnelFailure() throws Exception { } @Test - public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengePersistentConnection() throws Exception { + void testEstablishRouteViaProxyTunnelRetryOnAuthChallengePersistentConnection() throws Exception { final HttpRoute route = new HttpRoute(target, null, proxy, true); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -263,7 +263,7 @@ public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengePersistentConnec } @Test - public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengeNonPersistentConnection() throws Exception { + void testEstablishRouteViaProxyTunnelRetryOnAuthChallengeNonPersistentConnection() throws Exception { final HttpRoute route = new HttpRoute(target, null, proxy, true); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -302,7 +302,7 @@ public void testEstablishRouteViaProxyTunnelRetryOnAuthChallengeNonPersistentCon } @Test - public void testEstablishRouteViaProxyTunnelMultipleHops() throws Exception { + void testEstablishRouteViaProxyTunnelMultipleHops() throws Exception { final HttpHost proxy1 = new HttpHost("this", 8888); final HttpHost proxy2 = new HttpHost("that", 8888); final HttpRoute route = new HttpRoute(target, null, new HttpHost[] {proxy1, proxy2}, diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java index 904bb7efe..60eaa27f6 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestContentCompressionExec.java @@ -50,7 +50,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -public class TestContentCompressionExec { +class TestContentCompressionExec { @Mock private ExecRuntime execRuntime; @@ -65,7 +65,7 @@ public class TestContentCompressionExec { private ContentCompressionExec impl; @BeforeEach - public void setup() { + void setup() { MockitoAnnotations.openMocks(this); host = new HttpHost("somehost", 80); context = HttpClientContext.create(); @@ -75,7 +75,7 @@ public void setup() { @Test - public void testContentEncodingNoEntity() throws Exception { + void testContentEncodingNoEntity() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); @@ -88,7 +88,7 @@ public void testContentEncodingNoEntity() throws Exception { } @Test - public void testNoContentEncoding() throws Exception { + void testNoContentEncoding() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final StringEntity original = new StringEntity("plain stuff"); @@ -104,7 +104,7 @@ public void testNoContentEncoding() throws Exception { } @Test - public void testGzipContentEncoding() throws Exception { + void testGzipContentEncoding() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build(); @@ -120,7 +120,7 @@ public void testGzipContentEncoding() throws Exception { } @Test - public void testGzipContentEncodingZeroLength() throws Exception { + void testGzipContentEncodingZeroLength() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("").setContentEncoding("GZip").build(); @@ -136,7 +136,7 @@ public void testGzipContentEncodingZeroLength() throws Exception { } @Test - public void testXGzipContentEncoding() throws Exception { + void testXGzipContentEncoding() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("x-gzip").build(); @@ -152,7 +152,7 @@ public void testXGzipContentEncoding() throws Exception { } @Test - public void testDeflateContentEncoding() throws Exception { + void testDeflateContentEncoding() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("deFlaTe").build(); @@ -168,7 +168,7 @@ public void testDeflateContentEncoding() throws Exception { } @Test - public void testIdentityContentEncoding() throws Exception { + void testIdentityContentEncoding() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("identity").build(); @@ -184,7 +184,7 @@ public void testIdentityContentEncoding() throws Exception { } @Test - public void testBrotliContentEncoding() throws Exception { + void testBrotliContentEncoding() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("br").build(); @@ -200,7 +200,7 @@ public void testBrotliContentEncoding() throws Exception { } @Test - public void testUnknownContentEncoding() throws Exception { + void testUnknownContentEncoding() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("whatever").build(); @@ -215,7 +215,7 @@ public void testUnknownContentEncoding() throws Exception { } @Test - public void testContentEncodingRequestParameter() throws Exception { + void testContentEncodingRequestParameter() throws Exception { final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCookieIdentityComparator.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCookieIdentityComparator.java index a39960bc2..4bf8ebeab 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCookieIdentityComparator.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestCookieIdentityComparator.java @@ -34,10 +34,10 @@ /** * Simple tests for {@link CookieIdentityComparator}. */ -public class TestCookieIdentityComparator { +class TestCookieIdentityComparator { @Test - public void testCookieIdentityComparasionByName() { + void testCookieIdentityComparasionByName() { final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE; final BasicClientCookie c1 = new BasicClientCookie("name", "value1"); final BasicClientCookie c2 = new BasicClientCookie("name", "value2"); @@ -49,7 +49,7 @@ public void testCookieIdentityComparasionByName() { } @Test - public void testCookieIdentityComparasionByNameAndDomain() { + void testCookieIdentityComparasionByNameAndDomain() { final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE; final BasicClientCookie c1 = new BasicClientCookie("name", "value1"); c1.setDomain("www.domain.com"); @@ -65,7 +65,7 @@ public void testCookieIdentityComparasionByNameAndDomain() { } @Test - public void testCookieIdentityComparasionByNameAndNullDomain() { + void testCookieIdentityComparasionByNameAndNullDomain() { final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE; final BasicClientCookie c1 = new BasicClientCookie("name", "value1"); c1.setDomain(null); @@ -81,7 +81,7 @@ public void testCookieIdentityComparasionByNameAndNullDomain() { } @Test - public void testCookieIdentityComparasionByNameDomainAndPath() { + void testCookieIdentityComparasionByNameDomainAndPath() { final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE; final BasicClientCookie c1 = new BasicClientCookie("name", "value1"); c1.setDomain("www.domain.com"); @@ -101,7 +101,7 @@ public void testCookieIdentityComparasionByNameDomainAndPath() { } @Test - public void testCookieIdentityComparasionByNameDomainAndNullPath() { + void testCookieIdentityComparasionByNameDomainAndNullPath() { final CookieIdentityComparator comparator = CookieIdentityComparator.INSTANCE; final BasicClientCookie c1 = new BasicClientCookie("name", "value1"); c1.setDomain("www.domain.com"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestDefaultBackoffStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestDefaultBackoffStrategy.java index a350988df..d2d6d4be1 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestDefaultBackoffStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestDefaultBackoffStrategy.java @@ -41,44 +41,44 @@ import org.junit.jupiter.api.Test; -public class TestDefaultBackoffStrategy { +class TestDefaultBackoffStrategy { private DefaultBackoffStrategy impl; @BeforeEach - public void setUp() { + void setUp() { impl = new DefaultBackoffStrategy(); } @Test - public void backsOffForSocketTimeouts() { + void backsOffForSocketTimeouts() { assertTrue(impl.shouldBackoff(new SocketTimeoutException())); } @Test - public void backsOffForConnectionTimeouts() { + void backsOffForConnectionTimeouts() { assertTrue(impl.shouldBackoff(new ConnectException())); } @Test - public void doesNotBackOffForConnectionManagerTimeout() { + void doesNotBackOffForConnectionManagerTimeout() { assertFalse(impl.shouldBackoff(new ConnectionRequestTimeoutException())); } @Test - public void backsOffForServiceUnavailable() { + void backsOffForServiceUnavailable() { final HttpResponse resp = new BasicHttpResponse(HttpStatus.SC_SERVICE_UNAVAILABLE, "Service Unavailable"); assertTrue(impl.shouldBackoff(resp)); } @Test - public void backsOffForTooManyRequests() { + void backsOffForTooManyRequests() { final HttpResponse resp = new BasicHttpResponse(HttpStatus.SC_TOO_MANY_REQUESTS, "Too Many Requests"); assertTrue(impl.shouldBackoff(resp)); } @Test - public void doesNotBackOffForNon429And503StatusCodes() { + void doesNotBackOffForNon429And503StatusCodes() { for(int i = 100; i <= 599; i++) { if (i== HttpStatus.SC_TOO_MANY_REQUESTS || i == HttpStatus.SC_SERVICE_UNAVAILABLE) { continue; diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestExponentialBackoffManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestExponentialBackoffManager.java index 7e22a5372..c6ab69c6d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestExponentialBackoffManager.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestExponentialBackoffManager.java @@ -39,7 +39,7 @@ import java.time.Instant; import java.util.Map; -public class TestExponentialBackoffManager { +class TestExponentialBackoffManager { private ExponentialBackoffManager impl; private MockConnPoolControl connPerRoute; @@ -47,7 +47,7 @@ public class TestExponentialBackoffManager { private static final long DEFAULT_COOL_DOWN_MS = 5000; // Adjust this value to match the default cooldown period in ExponentialBackoffManager @BeforeEach - public void setUp() { + void setUp() { connPerRoute = new MockConnPoolControl(); route = new HttpRoute(new HttpHost("localhost", 80)); impl = new ExponentialBackoffManager(connPerRoute); @@ -57,7 +57,7 @@ public void setUp() { } @Test - public void exponentialBackoffApplied() { + void exponentialBackoffApplied() { connPerRoute.setMaxPerRoute(route, 4); impl.setBackoffFactor(2); // Sets the growth rate to 2 for this test impl.backOff(route); @@ -65,7 +65,7 @@ public void exponentialBackoffApplied() { } @Test - public void exponentialGrowthRateIsConfigurable() { + void exponentialGrowthRateIsConfigurable() { final int customCoolDownMs = 500; connPerRoute.setMaxPerRoute(route, 4); impl.setBackoffFactor(0.5); @@ -82,7 +82,7 @@ public void exponentialGrowthRateIsConfigurable() { } @Test - public void doesNotIncreaseBeyondPerHostMaxOnProbe() { + void doesNotIncreaseBeyondPerHostMaxOnProbe() { connPerRoute.setDefaultMaxPerRoute(5); connPerRoute.setMaxPerRoute(route, 5); impl.setPerHostConnectionCap(5); @@ -91,7 +91,7 @@ public void doesNotIncreaseBeyondPerHostMaxOnProbe() { } @Test - public void backoffDoesNotAdjustDuringCoolDownPeriod() { + void backoffDoesNotAdjustDuringCoolDownPeriod() { connPerRoute.setMaxPerRoute(route, 4); impl.backOff(route); final long max = connPerRoute.getMaxPerRoute(route); @@ -106,7 +106,7 @@ public void backoffDoesNotAdjustDuringCoolDownPeriod() { } @Test - public void backoffStillAdjustsAfterCoolDownPeriod() { + void backoffStillAdjustsAfterCoolDownPeriod() { connPerRoute.setMaxPerRoute(route, 8); impl.backOff(route); final long max = connPerRoute.getMaxPerRoute(route); @@ -124,7 +124,7 @@ public void backoffStillAdjustsAfterCoolDownPeriod() { @Test - public void probeDoesNotAdjustDuringCooldownPeriod() { + void probeDoesNotAdjustDuringCooldownPeriod() { connPerRoute.setMaxPerRoute(route, 4); impl.probe(route); final long max = connPerRoute.getMaxPerRoute(route); @@ -138,7 +138,7 @@ public void probeDoesNotAdjustDuringCooldownPeriod() { } @Test - public void probeStillAdjustsAfterCoolDownPeriod() { + void probeStillAdjustsAfterCoolDownPeriod() { connPerRoute.setMaxPerRoute(route, 8); impl.probe(route); final long max = connPerRoute.getMaxPerRoute(route); @@ -152,7 +152,7 @@ public void probeStillAdjustsAfterCoolDownPeriod() { } @Test - public void willBackoffImmediatelyEvenAfterAProbe() { + void willBackoffImmediatelyEvenAfterAProbe() { connPerRoute.setMaxPerRoute(route, 8); impl.probe(route); final long max = connPerRoute.getMaxPerRoute(route); @@ -161,7 +161,7 @@ public void willBackoffImmediatelyEvenAfterAProbe() { } @Test - public void coolDownPeriodIsConfigurable() { + void coolDownPeriodIsConfigurable() { final long cd = 500; // Fixed cooldown period of 500 milliseconds impl.setCoolDown(TimeValue.ofMilliseconds(cd)); connPerRoute.setMaxPerRoute(route, 4); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpAsyncClientBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpAsyncClientBuilder.java index b62b43b29..ac15ce15d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpAsyncClientBuilder.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpAsyncClientBuilder.java @@ -37,10 +37,10 @@ import org.apache.hc.core5.http.nio.AsyncEntityProducer; import org.junit.jupiter.api.Test; -public class TestHttpAsyncClientBuilder { +class TestHttpAsyncClientBuilder { @Test - public void testAddInterceptorFirstDoesNotThrow() throws IOException { + void testAddInterceptorFirstDoesNotThrow() throws IOException { HttpAsyncClients.custom() .addExecInterceptorFirst("first", NopExecChainHandler.INSTANCE) .build() @@ -48,7 +48,7 @@ public void testAddInterceptorFirstDoesNotThrow() throws IOException { } @Test - public void testAddInterceptorLastDoesNotThrow() throws IOException { + void testAddInterceptorLastDoesNotThrow() throws IOException { HttpAsyncClients.custom() .addExecInterceptorLast("last", NopExecChainHandler.INSTANCE) .build() @@ -56,7 +56,7 @@ public void testAddInterceptorLastDoesNotThrow() throws IOException { } @Test - public void testH2AddInterceptorFirstDoesNotThrow() throws IOException { + void testH2AddInterceptorFirstDoesNotThrow() throws IOException { HttpAsyncClients.customHttp2() .addExecInterceptorFirst("first", NopExecChainHandler.INSTANCE) .build() @@ -64,7 +64,7 @@ public void testH2AddInterceptorFirstDoesNotThrow() throws IOException { } @Test - public void testH2AddInterceptorLastDoesNotThrow() throws IOException { + void testH2AddInterceptorLastDoesNotThrow() throws IOException { HttpAsyncClients.customHttp2() .addExecInterceptorLast("last", NopExecChainHandler.INSTANCE) .build() diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpClientBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpClientBuilder.java index 185dde52d..2cec4699e 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpClientBuilder.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpClientBuilder.java @@ -35,10 +35,10 @@ import org.apache.hc.core5.http.HttpException; import org.junit.jupiter.api.Test; -public class TestHttpClientBuilder { +class TestHttpClientBuilder { @Test - public void testAddInterceptorFirstDoesNotThrow() throws IOException { + void testAddInterceptorFirstDoesNotThrow() throws IOException { // HTTPCLIENT-2083 HttpClients.custom() .addExecInterceptorFirst("first", NopExecChainHandler.INSTANCE) @@ -47,7 +47,7 @@ public void testAddInterceptorFirstDoesNotThrow() throws IOException { } @Test - public void testAddInterceptorLastDoesNotThrow() throws IOException { + void testAddInterceptorLastDoesNotThrow() throws IOException { // HTTPCLIENT-2083 HttpClients.custom() .addExecInterceptorLast("last", NopExecChainHandler.INSTANCE) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java index b885ae7ba..1792387d2 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java @@ -54,7 +54,7 @@ import org.mockito.MockitoAnnotations; @SuppressWarnings({"boxing","static-access"}) // test code -public class TestHttpRequestRetryExec { +class TestHttpRequestRetryExec { @Mock private HttpRequestRetryStrategy retryStrategy; @@ -69,7 +69,7 @@ public class TestHttpRequestRetryExec { private HttpHost target; @BeforeEach - public void setup() throws Exception { + void setup() { MockitoAnnotations.openMocks(this); retryExec = new HttpRequestRetryExec(retryStrategy); target = new HttpHost("localhost", 80); @@ -77,7 +77,7 @@ public void setup() throws Exception { @Test - public void testFundamentals1() throws Exception { + void testFundamentals1() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -106,7 +106,7 @@ public void testFundamentals1() throws Exception { } @Test - public void testRetrySleepOnIOException() throws Exception { + void testRetrySleepOnIOException() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -139,7 +139,7 @@ public void testRetrySleepOnIOException() throws Exception { } @Test - public void testRetryIntervalGreaterResponseTimeout() throws Exception { + void testRetryIntervalGreaterResponseTimeout() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -171,7 +171,7 @@ public void testRetryIntervalGreaterResponseTimeout() throws Exception { } @Test - public void testRetryIntervalResponseTimeoutNull() throws Exception { + void testRetryIntervalResponseTimeoutNull() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -203,7 +203,7 @@ public void testRetryIntervalResponseTimeoutNull() throws Exception { } @Test - public void testStrategyRuntimeException() throws Exception { + void testStrategyRuntimeException() throws Exception { final HttpRoute route = new HttpRoute(target); final ClassicHttpRequest request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -223,7 +223,7 @@ public void testStrategyRuntimeException() throws Exception { } @Test - public void testNonRepeatableEntityResponseReturnedImmediately() throws Exception { + void testNonRepeatableEntityResponseReturnedImmediately() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpPost request = new HttpPost("/test"); @@ -245,7 +245,7 @@ public void testNonRepeatableEntityResponseReturnedImmediately() throws Exceptio } @Test - public void testFundamentals2() throws Exception { + void testFundamentals2() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet originalRequest = new HttpGet("/test"); originalRequest.addHeader("header", "this"); @@ -280,7 +280,7 @@ public void testFundamentals2() throws Exception { @Test - public void testAbortedRequest() throws Exception { + void testAbortedRequest() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet originalRequest = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -305,7 +305,7 @@ public void testAbortedRequest() throws Exception { } @Test - public void testNonRepeatableRequest() throws Exception { + void testNonRepeatableRequest() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpPost originalRequest = new HttpPost("/test"); originalRequest.setEntity(EntityBuilder.create() diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalExecRuntime.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalExecRuntime.java index bbc534423..fa2710f67 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalExecRuntime.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalExecRuntime.java @@ -52,7 +52,7 @@ import org.slf4j.Logger; @SuppressWarnings({"static-access"}) // test code -public class TestInternalExecRuntime { +class TestInternalExecRuntime { @Mock private Logger log; @@ -71,14 +71,14 @@ public class TestInternalExecRuntime { private InternalExecRuntime execRuntime; @BeforeEach - public void setup() { + void setup() { MockitoAnnotations.openMocks(this); route = new HttpRoute(new HttpHost("host", 80)); execRuntime = new InternalExecRuntime(log, mgr, requestExecutor, cancellableDependency); } @Test - public void testAcquireEndpoint() throws Exception { + void testAcquireEndpoint() throws Exception { final HttpClientContext context = HttpClientContext.create(); @SuppressWarnings("deprecation") final RequestConfig config = RequestConfig.custom() @@ -106,7 +106,7 @@ public void testAcquireEndpoint() throws Exception { } @Test - public void testAcquireEndpointAlreadyAcquired() throws Exception { + void testAcquireEndpointAlreadyAcquired() throws Exception { final HttpClientContext context = HttpClientContext.create(); Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any())) @@ -123,7 +123,7 @@ public void testAcquireEndpointAlreadyAcquired() throws Exception { } @Test - public void testAcquireEndpointLeaseRequestTimeout() throws Exception { + void testAcquireEndpointLeaseRequestTimeout() throws Exception { final HttpClientContext context = HttpClientContext.create(); Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any())) @@ -135,7 +135,7 @@ public void testAcquireEndpointLeaseRequestTimeout() throws Exception { } @Test - public void testAcquireEndpointLeaseRequestFailure() throws Exception { + void testAcquireEndpointLeaseRequestFailure() throws Exception { final HttpClientContext context = HttpClientContext.create(); Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any())) @@ -147,7 +147,7 @@ public void testAcquireEndpointLeaseRequestFailure() throws Exception { } @Test - public void testAbortEndpoint() throws Exception { + void testAbortEndpoint() throws Exception { final HttpClientContext context = HttpClientContext.create(); Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any())) .thenReturn(leaseRequest); @@ -172,7 +172,7 @@ public void testAbortEndpoint() throws Exception { } @Test - public void testCancell() throws Exception { + void testCancell() throws Exception { final HttpClientContext context = HttpClientContext.create(); Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any())) @@ -199,7 +199,7 @@ public void testCancell() throws Exception { } @Test - public void testReleaseEndpointReusable() throws Exception { + void testReleaseEndpointReusable() throws Exception { final HttpClientContext context = HttpClientContext.create(); Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any())) @@ -227,7 +227,7 @@ public void testReleaseEndpointReusable() throws Exception { } @Test - public void testReleaseEndpointNonReusable() throws Exception { + void testReleaseEndpointNonReusable() throws Exception { final HttpClientContext context = HttpClientContext.create(); Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any())) @@ -256,7 +256,7 @@ public void testReleaseEndpointNonReusable() throws Exception { } @Test - public void testConnectEndpoint() throws Exception { + void testConnectEndpoint() throws Exception { final HttpClientContext context = HttpClientContext.create(); @SuppressWarnings("deprecation") final RequestConfig config = RequestConfig.custom() @@ -281,7 +281,7 @@ public void testConnectEndpoint() throws Exception { } @Test - public void testDisonnectEndpoint() throws Exception { + void testDisonnectEndpoint() throws Exception { final HttpClientContext context = HttpClientContext.create(); Mockito.when(mgr.lease(Mockito.eq("some-id"), Mockito.eq(route), Mockito.any(), Mockito.any())) diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java index 501a89a3b..ad74b7215 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestInternalHttpClient.java @@ -57,7 +57,7 @@ /** * Simple tests for {@link InternalHttpClient}. */ -public class TestInternalHttpClient { +class TestInternalHttpClient { @Mock private HttpClientConnectionManager connManager; @@ -85,7 +85,7 @@ public class TestInternalHttpClient { private InternalHttpClient client; @BeforeEach - public void setup() throws Exception { + void setup() { MockitoAnnotations.openMocks(this); client = new InternalHttpClient(connManager, requestExecutor, new ExecChainElement(execChain, null), routePlanner, cookieSpecRegistry, authSchemeRegistry, cookieStore, credentialsProvider, @@ -94,7 +94,7 @@ public void setup() throws Exception { } @Test - public void testExecute() throws Exception { + void testExecute() throws Exception { final HttpGet httpget = new HttpGet("http://somehost/stuff"); final HttpRoute route = new HttpRoute(new HttpHost("somehost", 80)); @@ -115,7 +115,7 @@ public void testExecute() throws Exception { } @Test - public void testExecuteHttpException() throws Exception { + void testExecuteHttpException() throws Exception { final HttpGet httpget = new HttpGet("http://somehost/stuff"); final HttpRoute route = new HttpRoute(new HttpHost("somehost", 80)); @@ -136,7 +136,7 @@ public void testExecuteHttpException() throws Exception { } @Test - public void testExecuteDefaultContext() throws Exception { + void testExecuteDefaultContext() throws Exception { final HttpGet httpget = new HttpGet("http://somehost/stuff"); final HttpRoute route = new HttpRoute(new HttpHost("somehost", 80)); @@ -159,7 +159,7 @@ public void testExecuteDefaultContext() throws Exception { } @Test - public void testExecuteRequestConfig() throws Exception { + void testExecuteRequestConfig() throws Exception { final HttpGet httpget = new HttpGet("http://somehost/stuff"); final HttpRoute route = new HttpRoute(new HttpHost("somehost", 80)); @@ -180,7 +180,7 @@ public void testExecuteRequestConfig() throws Exception { } @Test - public void testExecuteLocalContext() throws Exception { + void testExecuteLocalContext() throws Exception { final HttpGet httpget = new HttpGet("http://somehost/stuff"); final HttpRoute route = new HttpRoute(new HttpHost("somehost", 80)); @@ -216,7 +216,7 @@ public void testExecuteLocalContext() throws Exception { } @Test - public void testClientClose() throws Exception { + void testClientClose() throws Exception { client.close(); Mockito.verify(closeable1).close(); @@ -224,7 +224,7 @@ public void testClientClose() throws Exception { } @Test - public void testClientCloseIOException() throws Exception { + void testClientCloseIOException() throws Exception { Mockito.doThrow(new IOException()).when(closeable1).close(); client.close(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestLinearBackoffManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestLinearBackoffManager.java index c8e74289b..d3a289ede 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestLinearBackoffManager.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestLinearBackoffManager.java @@ -39,7 +39,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestLinearBackoffManager { +class TestLinearBackoffManager { private LinearBackoffManager impl; private MockConnPoolControl connPerRoute; @@ -47,7 +47,7 @@ public class TestLinearBackoffManager { private static final long DEFAULT_COOL_DOWN_MS = 10; @BeforeEach - public void setUp() { + void setUp() { connPerRoute = new MockConnPoolControl(); route = new HttpRoute(new HttpHost("localhost", 80)); impl = new LinearBackoffManager(connPerRoute); @@ -55,7 +55,7 @@ public void setUp() { } @Test - public void incrementsConnectionsOnBackoff() { + void incrementsConnectionsOnBackoff() { final LinearBackoffManager impl = new LinearBackoffManager(connPerRoute); impl.setCoolDown(TimeValue.ofMilliseconds(DEFAULT_COOL_DOWN_MS)); // Set the cool-down period connPerRoute.setMaxPerRoute(route, 4); @@ -64,14 +64,14 @@ public void incrementsConnectionsOnBackoff() { } @Test - public void decrementsConnectionsOnProbe() { + void decrementsConnectionsOnProbe() { connPerRoute.setMaxPerRoute(route, 4); impl.probe(route); assertEquals(3, connPerRoute.getMaxPerRoute(route)); } @Test - public void backoffDoesNotAdjustDuringCoolDownPeriod() { + void backoffDoesNotAdjustDuringCoolDownPeriod() { // Arrange connPerRoute.setMaxPerRoute(route, 4); impl.backOff(route); @@ -88,7 +88,7 @@ public void backoffDoesNotAdjustDuringCoolDownPeriod() { assertEquals(max, connPerRoute.getMaxPerRoute(route)); } @Test - public void backoffStillAdjustsAfterCoolDownPeriod() { + void backoffStillAdjustsAfterCoolDownPeriod() { // Arrange final LinearBackoffManager impl = new LinearBackoffManager(connPerRoute); impl.setCoolDown(TimeValue.ofMilliseconds(DEFAULT_COOL_DOWN_MS)); // Set the cool-down period @@ -109,7 +109,7 @@ public void backoffStillAdjustsAfterCoolDownPeriod() { } @Test - public void probeDoesNotAdjustDuringCooldownPeriod() { + void probeDoesNotAdjustDuringCooldownPeriod() { // Arrange connPerRoute.setMaxPerRoute(route, 4); impl.probe(route); @@ -127,7 +127,7 @@ public void probeDoesNotAdjustDuringCooldownPeriod() { } @Test - public void probeStillAdjustsAfterCoolDownPeriod() { + void probeStillAdjustsAfterCoolDownPeriod() { // Arrange connPerRoute.setMaxPerRoute(route, 4); impl.probe(route); @@ -146,7 +146,7 @@ public void probeStillAdjustsAfterCoolDownPeriod() { @Test - public void testSetPerHostConnectionCap() { + void testSetPerHostConnectionCap() { connPerRoute.setMaxPerRoute(route, 5); impl.setPerHostConnectionCap(10); // Set the cap to a higher value impl.backOff(route); @@ -185,7 +185,7 @@ public void probeUpdatesRemainingAttemptsIndirectly() { } @Test - public void linearIncrementTest() { + void linearIncrementTest() { final int initialMax = 4; connPerRoute.setMaxPerRoute(route, initialMax); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java index 078b3a4b0..aa40efb93 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java @@ -56,7 +56,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -public class TestMainClientExec { +class TestMainClientExec { @Mock private HttpClientConnectionManager connectionManager; @@ -75,14 +75,14 @@ public class TestMainClientExec { private HttpHost target; @BeforeEach - public void setup() throws Exception { + void setup() { MockitoAnnotations.openMocks(this); mainClientExec = new MainClientExec(connectionManager, httpProcessor, reuseStrategy, keepAliveStrategy, userTokenHandler); target = new HttpHost("foo", 80); } @Test - public void testFundamentals() throws Exception { + void testFundamentals() throws Exception { final HttpRoute route = new HttpRoute(target); final ClassicHttpRequest request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -112,7 +112,7 @@ public void testFundamentals() throws Exception { } @Test - public void testExecRequestNonPersistentConnection() throws Exception { + void testExecRequestNonPersistentConnection() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -143,7 +143,7 @@ public void testExecRequestNonPersistentConnection() throws Exception { } @Test - public void testExecRequestNonPersistentConnectionNoResponseEntity() throws Exception { + void testExecRequestNonPersistentConnectionNoResponseEntity() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -172,7 +172,7 @@ public void testExecRequestNonPersistentConnectionNoResponseEntity() throws Exce } @Test - public void testExecRequestPersistentConnection() throws Exception { + void testExecRequestPersistentConnection() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -208,7 +208,7 @@ public void testExecRequestPersistentConnection() throws Exception { } @Test - public void testExecRequestPersistentConnectionNoResponseEntity() throws Exception { + void testExecRequestPersistentConnectionNoResponseEntity() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -238,7 +238,7 @@ public void testExecRequestPersistentConnectionNoResponseEntity() throws Excepti } @Test - public void testExecRequestConnectionRelease() throws Exception { + void testExecRequestConnectionRelease() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -273,7 +273,7 @@ public void testExecRequestConnectionRelease() throws Exception { } @Test - public void testExecConnectionShutDown() throws Exception { + void testExecConnectionShutDown() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -291,7 +291,7 @@ public void testExecConnectionShutDown() throws Exception { } @Test - public void testExecRuntimeException() throws Exception { + void testExecRuntimeException() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -309,7 +309,7 @@ public void testExecRuntimeException() throws Exception { } @Test - public void testExecHttpException() throws Exception { + void testExecHttpException() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); @@ -327,7 +327,7 @@ public void testExecHttpException() throws Exception { } @Test - public void testExecIOException() throws Exception { + void testExecIOException() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://bar/test"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestNullBackoffStrategy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestNullBackoffStrategy.java index 5c5525ca4..8cc256952 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestNullBackoffStrategy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestNullBackoffStrategy.java @@ -35,22 +35,22 @@ import org.junit.jupiter.api.Test; -public class TestNullBackoffStrategy { +class TestNullBackoffStrategy { private NullBackoffStrategy impl; @BeforeEach - public void setUp() { + void setUp() { impl = new NullBackoffStrategy(); } @Test - public void doesNotBackoffForThrowables() { + void doesNotBackoffForThrowables() { assertFalse(impl.shouldBackoff(new Exception())); } @Test - public void doesNotBackoffForResponses() { + void doesNotBackoffForResponses() { final HttpResponse resp = new BasicHttpResponse(HttpStatus.SC_SERVICE_UNAVAILABLE, "Service Unavailable"); assertFalse(impl.shouldBackoff(resp)); } diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java index 1cc8b8d70..9f92bec24 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestProtocolExec.java @@ -63,7 +63,7 @@ import org.mockito.stubbing.Answer; @SuppressWarnings({"static-access"}) // test code -public class TestProtocolExec { +class TestProtocolExec { @Mock private AuthenticationStrategy targetAuthStrategy; @@ -79,7 +79,7 @@ public class TestProtocolExec { private HttpHost proxy; @BeforeEach - public void setup() throws Exception { + void setup() { MockitoAnnotations.openMocks(this); protocolExec = new ProtocolExec(targetAuthStrategy, proxyAuthStrategy, null, true); target = new HttpHost("foo", 80); @@ -87,7 +87,7 @@ public void setup() throws Exception { } @Test - public void testUserInfoInRequestURI() throws Exception { + void testUserInfoInRequestURI() { final HttpRoute route = new HttpRoute(new HttpHost("somehost", 8080)); final ClassicHttpRequest request = new HttpGet("http://somefella:secret@bar/test"); final HttpClientContext context = HttpClientContext.create(); @@ -97,7 +97,7 @@ public void testUserInfoInRequestURI() throws Exception { } @Test - public void testPostProcessHttpException() throws Exception { + void testPostProcessHttpException() throws Exception { final HttpRoute route = new HttpRoute(target); final ClassicHttpRequest request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -115,7 +115,7 @@ public void testPostProcessHttpException() throws Exception { } @Test - public void testPostProcessIOException() throws Exception { + void testPostProcessIOException() throws Exception { final HttpRoute route = new HttpRoute(target); final ClassicHttpRequest request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -132,7 +132,7 @@ public void testPostProcessIOException() throws Exception { } @Test - public void testPostProcessRuntimeException() throws Exception { + void testPostProcessRuntimeException() throws Exception { final HttpRoute route = new HttpRoute(target); final ClassicHttpRequest request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -149,7 +149,7 @@ public void testPostProcessRuntimeException() throws Exception { } @Test - public void testExecRequestRetryOnAuthChallenge() throws Exception { + void testExecRequestRetryOnAuthChallenge() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new HttpGet("http://foo/test"); @@ -189,7 +189,7 @@ public void testExecRequestRetryOnAuthChallenge() throws Exception { } @Test - public void testExecEntityEnclosingRequestRetryOnAuthChallenge() throws Exception { + void testExecEntityEnclosingRequestRetryOnAuthChallenge() throws Exception { final HttpRoute route = new HttpRoute(target); final ClassicHttpRequest request = new HttpGet("http://foo/test"); final ClassicHttpResponse response1 = new BasicClassicHttpResponse(401, "Huh?"); @@ -243,7 +243,7 @@ public boolean isConnectionBased() { } @Test - public void testExecEntityEnclosingRequest() throws Exception { + void testExecEntityEnclosingRequest() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); final HttpPost request = new HttpPost("http://foo/test"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java index 5095497c3..4a21390a1 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java @@ -69,7 +69,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -public class TestRedirectExec { +class TestRedirectExec { @Mock private HttpRoutePlanner httpRoutePlanner; @@ -83,7 +83,7 @@ public class TestRedirectExec { private HttpHost target; @BeforeEach - public void setup() throws Exception { + void setup() { MockitoAnnotations.openMocks(this); target = new HttpHost("localhost", 80); redirectStrategy = Mockito.spy(new DefaultRedirectStrategy()); @@ -91,7 +91,7 @@ public void setup() throws Exception { } @Test - public void testFundamentals() throws Exception { + void testFundamentals() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -136,7 +136,7 @@ public void testFundamentals() throws Exception { } @Test - public void testMaxRedirect() throws Exception { + void testMaxRedirect() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -158,7 +158,7 @@ public void testMaxRedirect() throws Exception { } @Test - public void testRelativeRedirect() throws Exception { + void testRelativeRedirect() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -176,7 +176,7 @@ public void testRelativeRedirect() throws Exception { } @Test - public void testCrossSiteRedirect() throws Exception { + void testCrossSiteRedirect() throws Exception { final HttpHost proxy = new HttpHost("proxy"); final HttpRoute route = new HttpRoute(target, proxy); @@ -228,7 +228,7 @@ public boolean isConnectionBased() { } @Test - public void testAllowCircularRedirects() throws Exception { + void testAllowCircularRedirects() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); context.setRequestConfig(RequestConfig.custom() @@ -270,7 +270,7 @@ public void testAllowCircularRedirects() throws Exception { } @Test - public void testGetLocationUriDisallowCircularRedirects() throws Exception { + void testGetLocationUriDisallowCircularRedirects() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpClientContext context = HttpClientContext.create(); context.setRequestConfig(RequestConfig.custom() @@ -308,7 +308,7 @@ public void testGetLocationUriDisallowCircularRedirects() throws Exception { } @Test - public void testRedirectRuntimeException() throws Exception { + void testRedirectRuntimeException() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -331,7 +331,7 @@ public void testRedirectRuntimeException() throws Exception { } @Test - public void testRedirectProtocolException() throws Exception { + void testRedirectProtocolException() throws Exception { final HttpRoute route = new HttpRoute(target); final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); @@ -360,7 +360,7 @@ public void testRedirectProtocolException() throws Exception { } @Test - public void testPutSeeOtherRedirect() throws Exception { + void testPutSeeOtherRedirect() throws Exception { final HttpRoute route = new HttpRoute(target); final URI targetUri = new URI("http://localhost:80/stuff"); final ClassicHttpRequest request = ClassicRequestBuilder.put() diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java index 7bd7c4a62..a37cefe4e 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityProxy.java @@ -49,7 +49,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -public class TestResponseEntityProxy { +class TestResponseEntityProxy { @Mock private ClassicHttpResponse response; @@ -59,14 +59,14 @@ public class TestResponseEntityProxy { private HttpEntity entity; @BeforeEach - public void setUp() { + void setUp() { MockitoAnnotations.openMocks(this); Mockito.when(entity.isStreaming()).thenReturn(Boolean.TRUE); Mockito.when(response.getEntity()).thenReturn(entity); } @Test - public void testGetTrailersWithNoChunkedInputStream() throws Exception { + void testGetTrailersWithNoChunkedInputStream() throws Exception { final ByteArrayInputStream inputStream = new ByteArrayInputStream("Test payload".getBytes()); Mockito.when(entity.getContent()).thenReturn(inputStream); final ArgumentCaptor httpEntityArgumentCaptor = ArgumentCaptor.forClass(HttpEntity.class); @@ -84,7 +84,7 @@ public void testGetTrailersWithNoChunkedInputStream() throws Exception { } @Test - public void testGetTrailersWithChunkedInputStream() throws Exception { + void testGetTrailersWithChunkedInputStream() throws Exception { final SessionInputBuffer sessionInputBuffer = new SessionInputBufferImpl(100); final ByteArrayInputStream inputStream = new ByteArrayInputStream("0\r\nX-Test-Trailer-Header: test\r\n".getBytes()); final ChunkedInputStream chunkedInputStream = new ChunkedInputStream(sessionInputBuffer, inputStream); @@ -109,7 +109,7 @@ public void testGetTrailersWithChunkedInputStream() throws Exception { } @Test - public void testWriteToNullDrainsAndReleasesStream() throws Exception { + void testWriteToNullDrainsAndReleasesStream() throws Exception { final SessionInputBuffer sessionInputBuffer = new SessionInputBufferImpl(100); final ByteArrayInputStream inputStream = new ByteArrayInputStream("0\r\nX-Test-Trailer-Header: test\r\n".getBytes()); final ChunkedInputStream chunkedInputStream = new ChunkedInputStream(sessionInputBuffer, inputStream); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityWrapper.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityWrapper.java index b61c61093..c9412e710 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityWrapper.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestResponseEntityWrapper.java @@ -40,7 +40,7 @@ import org.mockito.Mockito; @SuppressWarnings("boxing") // test code -public class TestResponseEntityWrapper { +class TestResponseEntityWrapper { private InputStream inStream; private HttpEntity entity; @@ -48,7 +48,7 @@ public class TestResponseEntityWrapper { private ResponseEntityProxy wrapper; @BeforeEach - public void setup() throws Exception { + void setup() throws Exception { inStream = Mockito.mock(InputStream.class); entity = Mockito.mock(HttpEntity.class); Mockito.when(entity.getContent()).thenReturn(inStream); @@ -57,7 +57,7 @@ public void setup() throws Exception { } @Test - public void testReusableEntityStreamClosed() throws Exception { + void testReusableEntityStreamClosed() throws Exception { Mockito.when(entity.isStreaming()).thenReturn(true); Mockito.when(execRuntime.isConnectionReusable()).thenReturn(true); EntityUtils.consume(wrapper); @@ -67,7 +67,7 @@ public void testReusableEntityStreamClosed() throws Exception { } @Test - public void testReusableEntityStreamClosedIOError() throws Exception { + void testReusableEntityStreamClosedIOError() throws Exception { Mockito.when(entity.isStreaming()).thenReturn(true); Mockito.when(execRuntime.isConnectionReusable()).thenReturn(true); Mockito.doThrow(new IOException()).when(inStream).close(); @@ -76,7 +76,7 @@ public void testReusableEntityStreamClosedIOError() throws Exception { } @Test - public void testEntityStreamClosedIOErrorAlreadyReleased() throws Exception { + void testEntityStreamClosedIOErrorAlreadyReleased() throws Exception { Mockito.when(entity.isStreaming()).thenReturn(true); Mockito.when(execRuntime.isConnectionReusable()).thenReturn(true); Mockito.when(execRuntime.isEndpointAcquired()).thenReturn(false); @@ -86,7 +86,7 @@ public void testEntityStreamClosedIOErrorAlreadyReleased() throws Exception { } @Test - public void testReusableEntityWriteTo() throws Exception { + void testReusableEntityWriteTo() throws Exception { final OutputStream outStream = Mockito.mock(OutputStream.class); Mockito.when(entity.isStreaming()).thenReturn(true); Mockito.when(execRuntime.isConnectionReusable()).thenReturn(true); @@ -95,7 +95,7 @@ public void testReusableEntityWriteTo() throws Exception { } @Test - public void testReusableEntityWriteToIOError() throws Exception { + void testReusableEntityWriteToIOError() throws Exception { final OutputStream outStream = Mockito.mock(OutputStream.class); Mockito.when(entity.isStreaming()).thenReturn(true); Mockito.when(execRuntime.isConnectionReusable()).thenReturn(true); @@ -106,7 +106,7 @@ public void testReusableEntityWriteToIOError() throws Exception { } @Test - public void testReusableEntityEndOfStream() throws Exception { + void testReusableEntityEndOfStream() throws Exception { Mockito.when(inStream.read()).thenReturn(-1); Mockito.when(entity.isStreaming()).thenReturn(true); Mockito.when(execRuntime.isConnectionReusable()).thenReturn(true); @@ -117,7 +117,7 @@ public void testReusableEntityEndOfStream() throws Exception { } @Test - public void testReusableEntityEndOfStreamIOError() throws Exception { + void testReusableEntityEndOfStreamIOError() throws Exception { Mockito.when(inStream.read()).thenReturn(-1); Mockito.when(entity.isStreaming()).thenReturn(true); Mockito.when(execRuntime.isConnectionReusable()).thenReturn(true); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicClientCookie.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicClientCookie.java index 0eb22cae7..7f435c189 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicClientCookie.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicClientCookie.java @@ -38,11 +38,11 @@ /** * Unit tests for {@link BasicClientCookie}. */ -public class TestBasicClientCookie { +class TestBasicClientCookie { @SuppressWarnings("unused") @Test - public void testConstructor() { + void testConstructor() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); Assertions.assertEquals("name", cookie.getName()); Assertions.assertEquals("value", cookie.getValue()); @@ -50,7 +50,7 @@ public void testConstructor() { } @Test - public void testCloning() throws Exception { + void testCloning() throws Exception { final BasicClientCookie orig = new BasicClientCookie("name", "value"); orig.setDomain("domain"); orig.setPath("/"); @@ -64,7 +64,7 @@ public void testCloning() throws Exception { } @Test - public void testSerialization() throws Exception { + void testSerialization() throws Exception { final BasicClientCookie orig = new BasicClientCookie("name", "value"); orig.setDomain("domain"); orig.setPath("/"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieAttribHandlers.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieAttribHandlers.java index 4b8b63993..d44a0cd65 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieAttribHandlers.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieAttribHandlers.java @@ -40,10 +40,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestBasicCookieAttribHandlers { +class TestBasicCookieAttribHandlers { @Test - public void testBasicDomainParse() throws Exception { + void testBasicDomainParse() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; h.parse(cookie, "www.somedomain.com"); @@ -51,7 +51,7 @@ public void testBasicDomainParse() throws Exception { } @Test - public void testBasicDomainParseInvalid1() throws Exception { + void testBasicDomainParseInvalid1() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -59,7 +59,7 @@ public void testBasicDomainParseInvalid1() throws Exception { } @Test - public void testBasicDomainParseInvalid2() throws Exception { + void testBasicDomainParseInvalid2() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -67,7 +67,7 @@ public void testBasicDomainParseInvalid2() throws Exception { } @Test - public void testBasicDomainValidate1() throws Exception { + void testBasicDomainValidate1() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; @@ -82,7 +82,7 @@ public void testBasicDomainValidate1() throws Exception { } @Test - public void testBasicDomainValidate2() throws Exception { + void testBasicDomainValidate2() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somehost", 80, "/", false); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; @@ -95,7 +95,7 @@ public void testBasicDomainValidate2() throws Exception { } @Test - public void testBasicDomainValidate3() throws Exception { + void testBasicDomainValidate3() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; @@ -105,7 +105,7 @@ public void testBasicDomainValidate3() throws Exception { } @Test - public void testBasicDomainValidate4() throws Exception { + void testBasicDomainValidate4() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; @@ -115,7 +115,7 @@ public void testBasicDomainValidate4() throws Exception { } @Test - public void testBasicDomainMatch1() throws Exception { + void testBasicDomainMatch1() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somedomain.com", 80, "/", false); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; @@ -129,7 +129,7 @@ public void testBasicDomainMatch1() throws Exception { } @Test - public void testBasicDomainMatch2() throws Exception { + void testBasicDomainMatch2() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("www.somedomain.com", 80, "/", false); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; @@ -146,7 +146,7 @@ public void testBasicDomainMatch2() throws Exception { } @Test - public void testBasicDomainMatchOneLetterPrefix() throws Exception { + void testBasicDomainMatchOneLetterPrefix() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("a.somedomain.com", 80, "/", false); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; @@ -157,7 +157,7 @@ public void testBasicDomainMatchOneLetterPrefix() throws Exception { } @Test - public void testBasicDomainMatchMixedCase() throws Exception { + void testBasicDomainMatchMixedCase() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("a.SomeDomain.com", 80, "/", false); final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; @@ -168,7 +168,7 @@ public void testBasicDomainMatchMixedCase() throws Exception { } @Test - public void testBasicDomainInvalidInput() throws Exception { + void testBasicDomainInvalidInput() { final CookieAttributeHandler h = BasicDomainHandler.INSTANCE; Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, null)); Assertions.assertThrows(NullPointerException.class, () -> h.validate(null, null)); @@ -180,7 +180,7 @@ public void testBasicDomainInvalidInput() throws Exception { } @Test - public void testBasicPathParse() throws Exception { + void testBasicPathParse() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = BasicPathHandler.INSTANCE; h.parse(cookie, "stuff"); @@ -192,7 +192,7 @@ public void testBasicPathParse() throws Exception { } @Test - public void testBasicPathMatch1() throws Exception { + void testBasicPathMatch1() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false); final CookieAttributeHandler h = BasicPathHandler.INSTANCE; @@ -201,7 +201,7 @@ public void testBasicPathMatch1() throws Exception { } @Test - public void testBasicPathMatch2() throws Exception { + void testBasicPathMatch2() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/", false); final CookieAttributeHandler h = BasicPathHandler.INSTANCE; @@ -210,7 +210,7 @@ public void testBasicPathMatch2() throws Exception { } @Test - public void testBasicPathMatch3() throws Exception { + void testBasicPathMatch3() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff/more-stuff", false); final CookieAttributeHandler h = BasicPathHandler.INSTANCE; @@ -219,7 +219,7 @@ public void testBasicPathMatch3() throws Exception { } @Test - public void testBasicPathMatch4() throws Exception { + void testBasicPathMatch4() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuffed", false); final CookieAttributeHandler h = BasicPathHandler.INSTANCE; @@ -228,7 +228,7 @@ public void testBasicPathMatch4() throws Exception { } @Test - public void testBasicPathMatch5() throws Exception { + void testBasicPathMatch5() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somehost", 80, "/otherstuff", false); final CookieAttributeHandler h = BasicPathHandler.INSTANCE; @@ -237,7 +237,7 @@ public void testBasicPathMatch5() throws Exception { } @Test - public void testBasicPathMatch6() throws Exception { + void testBasicPathMatch6() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false); final CookieAttributeHandler h = BasicPathHandler.INSTANCE; @@ -246,7 +246,7 @@ public void testBasicPathMatch6() throws Exception { } @Test - public void testBasicPathMatch7() throws Exception { + void testBasicPathMatch7() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieOrigin origin = new CookieOrigin("somehost", 80, "/stuff", false); final CookieAttributeHandler h = BasicPathHandler.INSTANCE; @@ -254,7 +254,7 @@ public void testBasicPathMatch7() throws Exception { } @Test - public void testBasicPathInvalidInput() throws Exception { + void testBasicPathInvalidInput() { final CookieAttributeHandler h = BasicPathHandler.INSTANCE; Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, null)); Assertions.assertThrows(NullPointerException.class, () -> h.match(null, null)); @@ -263,7 +263,7 @@ public void testBasicPathInvalidInput() throws Exception { } @Test - public void testBasicMaxAgeParse() throws Exception { + void testBasicMaxAgeParse() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = BasicMaxAgeHandler.INSTANCE; h.parse(cookie, "2000"); @@ -271,7 +271,7 @@ public void testBasicMaxAgeParse() throws Exception { } @Test - public void testBasicMaxAgeParseInvalid() throws Exception { + void testBasicMaxAgeParseInvalid() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = BasicMaxAgeHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> h.parse(cookie, "garbage")); @@ -279,13 +279,13 @@ public void testBasicMaxAgeParseInvalid() throws Exception { } @Test - public void testBasicMaxAgeInvalidInput() throws Exception { + void testBasicMaxAgeInvalidInput() { final CookieAttributeHandler h = BasicMaxAgeHandler.INSTANCE; Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, null)); } @Test - public void testBasicSecureParse() throws Exception { + void testBasicSecureParse() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = BasicSecureHandler.INSTANCE; h.parse(cookie, "whatever"); @@ -295,7 +295,7 @@ public void testBasicSecureParse() throws Exception { } @Test - public void testBasicSecureMatch() throws Exception { + void testBasicSecureMatch() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = BasicSecureHandler.INSTANCE; @@ -313,7 +313,7 @@ public void testBasicSecureMatch() throws Exception { } @Test - public void testBasicSecureInvalidInput() throws Exception { + void testBasicSecureInvalidInput() { final CookieAttributeHandler h = new BasicSecureHandler(); Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, null)); Assertions.assertThrows(NullPointerException.class, () -> h.match(null, null)); @@ -322,7 +322,7 @@ public void testBasicSecureInvalidInput() throws Exception { } @Test - public void testBasicExpiresParse() throws Exception { + void testBasicExpiresParse() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = new BasicExpiresHandler(DateUtils.FORMATTER_RFC1123); @@ -331,7 +331,7 @@ public void testBasicExpiresParse() throws Exception { } @Test - public void testBasicExpiresParseInvalid() throws Exception { + void testBasicExpiresParseInvalid() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = new BasicExpiresHandler(DateUtils.FORMATTER_RFC1123); Assertions.assertThrows(MalformedCookieException.class, () -> @@ -342,13 +342,13 @@ public void testBasicExpiresParseInvalid() throws Exception { @SuppressWarnings("unused") @Test - public void testBasicExpiresInvalidInput() throws Exception { + void testBasicExpiresInvalidInput() { final CookieAttributeHandler h = new BasicExpiresHandler(DateUtils.FORMATTER_RFC1123); Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, null)); } @Test - public void testPublicSuffixFilter() throws Exception { + void testPublicSuffixFilter() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final PublicSuffixMatcher matcher = new PublicSuffixMatcher(DomainType.ICANN, Arrays.asList("co.uk", "com"), null); @@ -391,7 +391,7 @@ public void testPublicSuffixFilter() throws Exception { Assertions.assertTrue(h.match(cookie, new CookieOrigin("localhost", 80, "/stuff", false))); } @Test - public void testBasicHttpOnlyParse() throws Exception { + void testBasicHttpOnlyParse() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = new BasicHttpOnlyHandler(); h.parse(cookie, "true"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieStore.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieStore.java index 30675c4f1..9544a8ed8 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieStore.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestBasicCookieStore.java @@ -43,10 +43,10 @@ /** * Unit tests for {@link BasicCookieStore}. */ -public class TestBasicCookieStore { +class TestBasicCookieStore { @Test - public void testBasics() throws Exception { + void testBasics() { final BasicCookieStore store = new BasicCookieStore(); store.addCookie(new BasicClientCookie("name1", "value1")); store.addCookies(new BasicClientCookie[] {new BasicClientCookie("name2", "value2")}); @@ -62,7 +62,7 @@ public void testBasics() throws Exception { } @Test - public void testExpiredCookie() throws Exception { + void testExpiredCookie() { final BasicCookieStore store = new BasicCookieStore(); final BasicClientCookie cookie = new BasicClientCookie("name1", "value1"); @@ -75,7 +75,7 @@ public void testExpiredCookie() throws Exception { } @Test - public void testSerialization() throws Exception { + void testSerialization() throws Exception { final BasicCookieStore orig = new BasicCookieStore(); orig.addCookie(new BasicClientCookie("name1", "value1")); orig.addCookie(new BasicClientCookie("name2", "value2")); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java index 47aa9a825..5b1e116ba 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestLaxCookieAttribHandlers.java @@ -36,10 +36,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestLaxCookieAttribHandlers { +class TestLaxCookieAttribHandlers { @Test - public void testParseMaxAge() throws Exception { + void testParseMaxAge() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE; h.parse(cookie, "2000"); @@ -47,7 +47,7 @@ public void testParseMaxAge() throws Exception { } @Test - public void testParseMaxNegative() throws Exception { + void testParseMaxNegative() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE; h.parse(cookie, "-2000"); @@ -55,7 +55,7 @@ public void testParseMaxNegative() throws Exception { } @Test - public void testParseMaxZero() throws Exception { + void testParseMaxZero() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE; h.parse(cookie, "0000"); @@ -63,7 +63,7 @@ public void testParseMaxZero() throws Exception { } @Test - public void testBasicMaxAgeParseEmpty() throws Exception { + void testBasicMaxAgeParseEmpty() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE; h.parse(cookie, " "); @@ -71,7 +71,7 @@ public void testBasicMaxAgeParseEmpty() throws Exception { } @Test - public void testBasicMaxAgeParseInvalid() throws Exception { + void testBasicMaxAgeParseInvalid() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE; h.parse(cookie, "garbage"); @@ -79,13 +79,13 @@ public void testBasicMaxAgeParseInvalid() throws Exception { } @Test - public void testBasicMaxAgeInvalidInput() throws Exception { + void testBasicMaxAgeInvalidInput() { final CookieAttributeHandler h = LaxMaxAgeHandler.INSTANCE; Assertions.assertThrows(NullPointerException.class, () -> h.parse(null, "stuff")); } @Test - public void testExpiryGarbage() throws Exception { + void testExpiryGarbage() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -93,7 +93,7 @@ public void testExpiryGarbage() throws Exception { } @Test - public void testParseExpiry() throws Exception { + void testParseExpiry() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "1:0:12 8-jan-2012"); @@ -111,7 +111,7 @@ public void testParseExpiry() throws Exception { } @Test - public void testParseExpiryInstant() throws Exception { + void testParseExpiryInstant() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "1:0:12 8-jan-2012"); @@ -129,7 +129,7 @@ public void testParseExpiryInstant() throws Exception { } @Test - public void testParseExpiryInvalidTime0() throws Exception { + void testParseExpiryInvalidTime0() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, null); @@ -137,7 +137,7 @@ public void testParseExpiryInvalidTime0() throws Exception { } @Test - public void testParseExpiryInvalidTime1() throws Exception { + void testParseExpiryInvalidTime1() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -145,7 +145,7 @@ public void testParseExpiryInvalidTime1() throws Exception { } @Test - public void testParseExpiryInvalidTime2() throws Exception { + void testParseExpiryInvalidTime2() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -153,7 +153,7 @@ public void testParseExpiryInvalidTime2() throws Exception { } @Test - public void testParseExpiryInvalidTime3() throws Exception { + void testParseExpiryInvalidTime3() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -161,7 +161,7 @@ public void testParseExpiryInvalidTime3() throws Exception { } @Test - public void testParseExpiryInvalidTime4() throws Exception { + void testParseExpiryInvalidTime4() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -169,7 +169,7 @@ public void testParseExpiryInvalidTime4() throws Exception { } @Test - public void testParseExpiryFunnyTime() throws Exception { + void testParseExpiryFunnyTime() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "1:59:00blah; 8-feb-2000"); @@ -187,7 +187,7 @@ public void testParseExpiryFunnyTime() throws Exception { } @Test - public void testParseExpiryFunnyTimeInstant() throws Exception { + void testParseExpiryFunnyTimeInstant() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "1:59:00blah; 8-feb-2000"); @@ -205,7 +205,7 @@ public void testParseExpiryFunnyTimeInstant() throws Exception { } @Test - public void testParseExpiryInvalidDayOfMonth1() throws Exception { + void testParseExpiryInvalidDayOfMonth1() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -213,7 +213,7 @@ public void testParseExpiryInvalidDayOfMonth1() throws Exception { } @Test - public void testParseExpiryInvalidDayOfMonth2() throws Exception { + void testParseExpiryInvalidDayOfMonth2() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -221,7 +221,7 @@ public void testParseExpiryInvalidDayOfMonth2() throws Exception { } @Test - public void testParseExpiryInvalidDayOfMonth3() throws Exception { + void testParseExpiryInvalidDayOfMonth3() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -229,7 +229,7 @@ public void testParseExpiryInvalidDayOfMonth3() throws Exception { } @Test - public void testParseExpiryFunnyDayOfMonth() throws Exception { + void testParseExpiryFunnyDayOfMonth() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "12:00:00 8blah;mar;1880"); @@ -247,7 +247,7 @@ public void testParseExpiryFunnyDayOfMonth() throws Exception { } @Test - public void testParseExpiryFunnyDayOfMonthInstant() throws Exception { + void testParseExpiryFunnyDayOfMonthInstant() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "12:00:00 8blah;mar;1880"); @@ -265,7 +265,7 @@ public void testParseExpiryFunnyDayOfMonthInstant() throws Exception { } @Test - public void testParseExpiryInvalidMonth() throws Exception { + void testParseExpiryInvalidMonth() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -273,7 +273,7 @@ public void testParseExpiryInvalidMonth() throws Exception { } @Test - public void testParseExpiryFunnyMonth() throws Exception { + void testParseExpiryFunnyMonth() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "23:59:59; 1-ApriLLLLL-2008"); @@ -291,7 +291,7 @@ public void testParseExpiryFunnyMonth() throws Exception { } @Test - public void testParseExpiryFunnyMonthInstant() throws Exception { + void testParseExpiryFunnyMonthInstant() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "23:59:59; 1-ApriLLLLL-2008"); @@ -309,7 +309,7 @@ public void testParseExpiryFunnyMonthInstant() throws Exception { } @Test - public void testParseExpiryInvalidYearTooShort() throws Exception { + void testParseExpiryInvalidYearTooShort() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -317,7 +317,7 @@ public void testParseExpiryInvalidYearTooShort() throws Exception { } @Test - public void testParseExpiryInvalidYearTooLong() throws Exception { + void testParseExpiryInvalidYearTooLong() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -325,7 +325,7 @@ public void testParseExpiryInvalidYearTooLong() throws Exception { } @Test - public void testParseExpiryInvalidYearTooLongAgo() throws Exception { + void testParseExpiryInvalidYearTooLongAgo() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; Assertions.assertThrows(MalformedCookieException.class, () -> @@ -333,7 +333,7 @@ public void testParseExpiryInvalidYearTooLongAgo() throws Exception { } @Test - public void testParseExpiryFunnyYear() throws Exception { + void testParseExpiryFunnyYear() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "23:59:59; 1-Apr-2008blah"); @@ -351,7 +351,7 @@ public void testParseExpiryFunnyYear() throws Exception { } @Test - public void testParseExpiryFunnyYearInstant() throws Exception { + void testParseExpiryFunnyYearInstant() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "23:59:59; 1-Apr-2008blah"); @@ -369,7 +369,7 @@ public void testParseExpiryFunnyYearInstant() throws Exception { } @Test - public void testParseExpiryYearTwoDigit1() throws Exception { + void testParseExpiryYearTwoDigit1() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "23:59:59; 1-Apr-70"); @@ -381,7 +381,7 @@ public void testParseExpiryYearTwoDigit1() throws Exception { } @Test - public void testParseExpiryYearTwoDigit2() throws Exception { + void testParseExpiryYearTwoDigit2() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "23:59:59; 1-Apr-99"); @@ -393,7 +393,7 @@ public void testParseExpiryYearTwoDigit2() throws Exception { } @Test - public void testParseExpiryYearTwoDigit3() throws Exception { + void testParseExpiryYearTwoDigit3() throws Exception { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); final CookieAttributeHandler h = LaxExpiresHandler.INSTANCE; h.parse(cookie, "23:59:59; 1-Apr-00"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestPublicSuffixListParser.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestPublicSuffixListParser.java index c8e2f69e4..aeb7a971b 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestPublicSuffixListParser.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestPublicSuffixListParser.java @@ -40,14 +40,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestPublicSuffixListParser { +class TestPublicSuffixListParser { private static final String SOURCE_FILE = "suffixlist.txt"; private PublicSuffixDomainFilter filter; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final InputStream in = classLoader.getResourceAsStream(SOURCE_FILE); Assertions.assertNotNull(in); @@ -63,7 +63,7 @@ public void setUp() throws Exception { } @Test - public void testParse() throws Exception { + void testParse() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); cookie.setAttribute(Cookie.DOMAIN_ATTR, ".jp"); @@ -82,7 +82,7 @@ public void testParse() throws Exception { } @Test - public void testParseLocal() throws Exception { + void testParseLocal() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); cookie.setDomain("localhost"); @@ -115,7 +115,7 @@ public void testParseLocal() throws Exception { } @Test - public void testUnicode() throws Exception { + void testUnicode() { final BasicClientCookie cookie = new BasicClientCookie("name", "value"); cookie.setDomain(".h\u00E5.no"); // \u00E5 is diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java index d66c53f06..945938cf1 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/cookie/TestRFC6265CookieSpec.java @@ -42,10 +42,10 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -public class TestRFC6265CookieSpec { +class TestRFC6265CookieSpec { @Test - public void testParseCookieBasics() throws Exception { + void testParseCookieBasics() throws Exception { final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class); Mockito.when(h1.getAttributeName()).thenReturn("this"); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttributeHandler.class); @@ -71,7 +71,7 @@ public void testParseCookieBasics() throws Exception { } @Test - public void testParseCookieQuotedValue() throws Exception { + void testParseCookieQuotedValue() throws Exception { final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(); final Header header = new BasicHeader("Set-Cookie", "name = \" one, two, three; four \" ; this = stuff;"); @@ -86,7 +86,7 @@ public void testParseCookieQuotedValue() throws Exception { } @Test - public void testParseCookieWrongHeader() throws Exception { + void testParseCookieWrongHeader() { final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(); final Header header = new BasicHeader("Set-Cookie2", "blah"); @@ -96,7 +96,7 @@ public void testParseCookieWrongHeader() throws Exception { } @Test - public void testParseCookieMissingName() throws Exception { + void testParseCookieMissingName() throws Exception { final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(); final Header header = new BasicHeader("Set-Cookie", "=blah ; this = stuff;"); @@ -106,7 +106,7 @@ public void testParseCookieMissingName() throws Exception { } @Test - public void testParseCookieMissingValue1() throws Exception { + void testParseCookieMissingValue1() throws Exception { final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(); final Header header = new BasicHeader("Set-Cookie", "blah"); @@ -116,7 +116,7 @@ public void testParseCookieMissingValue1() throws Exception { } @Test - public void testParseCookieMissingValue2() throws Exception { + void testParseCookieMissingValue2() { final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(); final Header header = new BasicHeader("Set-Cookie", "blah;"); @@ -126,7 +126,7 @@ public void testParseCookieMissingValue2() throws Exception { } @Test - public void testParseCookieEmptyValue() throws Exception { + void testParseCookieEmptyValue() throws Exception { final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(); final Header header = new BasicHeader("Set-Cookie", "blah=;"); @@ -139,7 +139,7 @@ public void testParseCookieEmptyValue() throws Exception { } @Test - public void testParseCookieWithAttributes() throws Exception { + void testParseCookieWithAttributes() throws Exception { final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class); Mockito.when(h1.getAttributeName()).thenReturn("this"); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttributeHandler.class); @@ -163,7 +163,7 @@ public void testParseCookieWithAttributes() throws Exception { } @Test - public void testParseCookieWithAttributes2() throws Exception { + void testParseCookieWithAttributes2() throws Exception { final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class); Mockito.when(h1.getAttributeName()).thenReturn("this"); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttributeHandler.class); @@ -183,7 +183,7 @@ public void testParseCookieWithAttributes2() throws Exception { } @Test - public void testParseCookieWithAttributes3() throws Exception { + void testParseCookieWithAttributes3() throws Exception { final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class); Mockito.when(h1.getAttributeName()).thenReturn("this"); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttributeHandler.class); @@ -203,7 +203,7 @@ public void testParseCookieWithAttributes3() throws Exception { } @Test - public void testValidateCookieBasics() throws Exception { + void testValidateCookieBasics() throws Exception { final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class); Mockito.when(h1.getAttributeName()).thenReturn("this"); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttributeHandler.class); @@ -220,7 +220,7 @@ public void testValidateCookieBasics() throws Exception { } @Test - public void testMatchCookie() throws Exception { + void testMatchCookie() { final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class); Mockito.when(h1.getAttributeName()).thenReturn("this"); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttributeHandler.class); @@ -241,7 +241,7 @@ public void testMatchCookie() throws Exception { } @Test - public void testMatchCookieNoMatch() throws Exception { + void testMatchCookieNoMatch() { final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class); Mockito.when(h1.getAttributeName()).thenReturn("this"); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttributeHandler.class); @@ -262,7 +262,7 @@ public void testMatchCookieNoMatch() throws Exception { } @Test - public void testFormatCookiesBasics() throws Exception { + void testFormatCookiesBasics() { final Cookie cookie1 = new BasicClientCookie("name1", "value"); final RFC6265CookieSpec cookiespec = new RFC6265CookieSpec(); @@ -275,7 +275,7 @@ public void testFormatCookiesBasics() throws Exception { } @Test - public void testFormatCookiesIllegalCharsInValue() throws Exception { + void testFormatCookiesIllegalCharsInValue() { final Cookie cookie1 = new BasicClientCookie("name1", "value"); final Cookie cookie2 = new BasicClientCookie("name2", "some value"); final Cookie cookie3 = new BasicClientCookie("name3", "\"\\\""); @@ -289,7 +289,7 @@ public void testFormatCookiesIllegalCharsInValue() throws Exception { } @Test - public void testParseCookieMultipleAttributes() throws Exception { + void testParseCookieMultipleAttributes() throws Exception { final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class); Mockito.when(h1.getAttributeName()).thenReturn("this"); @@ -304,7 +304,7 @@ public void testParseCookieMultipleAttributes() throws Exception { } @Test - public void testParseCookieMaxAgeOverExpires() throws Exception { + void testParseCookieMaxAgeOverExpires() throws Exception { final CommonCookieAttributeHandler h1 = Mockito.mock(CommonCookieAttributeHandler.class); Mockito.when(h1.getAttributeName()).thenReturn("Expires"); final CommonCookieAttributeHandler h2 = Mockito.mock(CommonCookieAttributeHandler.class); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java index f8ac4dae5..3a712370e 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestBasicHttpClientConnectionManager.java @@ -59,7 +59,7 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -public class TestBasicHttpClientConnectionManager { +class TestBasicHttpClientConnectionManager { @Mock private ManagedHttpClientConnection conn; @@ -83,7 +83,7 @@ public class TestBasicHttpClientConnectionManager { private BasicHttpClientConnectionManager mgr; @BeforeEach - public void setup() throws Exception { + void setup() { MockitoAnnotations.openMocks(this); mgr = new BasicHttpClientConnectionManager(new DefaultHttpClientConnectionOperator( detachedSocketFactory, schemePortResolver, dnsResolver, tlsSocketStrategyLookup), @@ -91,7 +91,7 @@ public void setup() throws Exception { } @Test - public void testLeaseReleaseNonReusable() throws Exception { + void testLeaseReleaseNonReusable() throws Exception { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); @@ -116,7 +116,7 @@ public void testLeaseReleaseNonReusable() throws Exception { } @Test - public void testLeaseReleaseReusable() throws Exception { + void testLeaseReleaseReusable() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); @@ -146,7 +146,7 @@ public void testLeaseReleaseReusable() throws Exception { } @Test - public void testLeaseReleaseReusableWithState() throws Exception { + void testLeaseReleaseReusableWithState() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); @@ -175,7 +175,7 @@ public void testLeaseReleaseReusableWithState() throws Exception { } @Test - public void testLeaseDifferentRoute() throws Exception { + void testLeaseDifferentRoute() throws Exception { final HttpHost target1 = new HttpHost("somehost", 80); final HttpRoute route1 = new HttpRoute(target1); @@ -207,7 +207,7 @@ public void testLeaseDifferentRoute() throws Exception { } @Test - public void testLeaseExpired() throws Exception { + void testLeaseExpired() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); @@ -239,20 +239,20 @@ public void testLeaseExpired() throws Exception { } @Test - public void testReleaseInvalidArg() throws Exception { + void testReleaseInvalidArg() { Assertions.assertThrows(NullPointerException.class, () -> mgr.release(null, null, TimeValue.NEG_ONE_MILLISECOND)); } @Test - public void testReleaseAnotherConnection() throws Exception { + void testReleaseAnotherConnection() { final ConnectionEndpoint wrongCon = Mockito.mock(ConnectionEndpoint.class); Assertions.assertThrows(IllegalStateException.class, () -> mgr.release(wrongCon, null, TimeValue.NEG_ONE_MILLISECOND)); } @Test - public void testShutdown() throws Exception { + void testShutdown() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); @@ -285,7 +285,7 @@ public void testShutdown() throws Exception { } @Test - public void testCloseExpired() throws Exception { + void testCloseExpired() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); @@ -313,7 +313,7 @@ public void testCloseExpired() throws Exception { } @Test - public void testCloseIdle() throws Exception { + void testCloseIdle() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); @@ -341,7 +341,7 @@ public void testCloseIdle() throws Exception { } @Test - public void testAlreadyLeased() throws Exception { + void testAlreadyLeased() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); @@ -358,7 +358,7 @@ public void testAlreadyLeased() throws Exception { } @Test - public void testTargetConnect() throws Exception { + void testTargetConnect() throws Exception { final HttpHost target = new HttpHost("https", "somehost", 443); final InetAddress remote = InetAddress.getByAddress(new byte[] {10, 0, 0, 1}); final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 1}); @@ -414,7 +414,7 @@ public void testTargetConnect() throws Exception { } @Test - public void testProxyConnectAndUpgrade() throws Exception { + void testProxyConnectAndUpgrade() throws Exception { final HttpHost target = new HttpHost("https", "somehost", 443); final HttpHost proxy = new HttpHost("someproxy", 8080); final InetAddress remote = InetAddress.getByAddress(new byte[] {10, 0, 0, 1}); @@ -464,7 +464,7 @@ public void testProxyConnectAndUpgrade() throws Exception { @Test - public void shouldCloseStaleConnectionAndCreateNewOne() throws Exception { + void shouldCloseStaleConnectionAndCreateNewOne() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); @@ -494,7 +494,7 @@ public void shouldCloseStaleConnectionAndCreateNewOne() throws Exception { } @Test - public void shouldCloseGRACEFULStaleConnection() throws Exception { + void shouldCloseGRACEFULStaleConnection() throws Exception { final HttpHost target = new HttpHost("somehost", 80); final HttpRoute route = new HttpRoute(target); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java index e369f495a..0b78a2160 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestHttpClientConnectionOperator.java @@ -57,7 +57,7 @@ import org.junit.jupiter.api.Test; import org.mockito.Mockito; -public class TestHttpClientConnectionOperator { +class TestHttpClientConnectionOperator { private ManagedHttpClientConnection conn; private Socket socket; @@ -69,7 +69,7 @@ public class TestHttpClientConnectionOperator { private DefaultHttpClientConnectionOperator connectionOperator; @BeforeEach - public void setup() throws Exception { + void setup() { conn = Mockito.mock(ManagedHttpClientConnection.class); socket = Mockito.mock(Socket.class); detachedSocketFactory = Mockito.mock(DetachedSocketFactory.class); @@ -82,7 +82,7 @@ public void setup() throws Exception { } @Test - public void testConnect() throws Exception { + void testConnect() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpHost host = new HttpHost("somehost"); final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 0}); @@ -115,7 +115,7 @@ public void testConnect() throws Exception { } @Test - public void testConnectWithTLSUpgrade() throws Exception { + void testConnectWithTLSUpgrade() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpHost host = new HttpHost("https", "somehost"); final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 0}); @@ -151,7 +151,7 @@ public void testConnectWithTLSUpgrade() throws Exception { } @Test - public void testConnectTimeout() throws Exception { + void testConnectTimeout() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpHost host = new HttpHost("somehost"); final InetAddress ip1 = InetAddress.getByAddress(new byte[] {10, 0, 0, 1}); @@ -168,7 +168,7 @@ public void testConnectTimeout() throws Exception { } @Test - public void testConnectFailure() throws Exception { + void testConnectFailure() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpHost host = new HttpHost("somehost"); final InetAddress ip1 = InetAddress.getByAddress(new byte[] {10, 0, 0, 1}); @@ -185,7 +185,7 @@ public void testConnectFailure() throws Exception { } @Test - public void testConnectFailover() throws Exception { + void testConnectFailover() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpHost host = new HttpHost("somehost"); final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 0}); @@ -212,7 +212,7 @@ public void testConnectFailover() throws Exception { } @Test - public void testConnectExplicitAddress() throws Exception { + void testConnectExplicitAddress() throws Exception { final HttpClientContext context = HttpClientContext.create(); final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 0}); final InetAddress ip = InetAddress.getByAddress(new byte[] {127, 0, 0, 23}); @@ -234,7 +234,7 @@ public void testConnectExplicitAddress() throws Exception { } @Test - public void testUpgrade() throws Exception { + void testUpgrade() throws Exception { final HttpClientContext context = HttpClientContext.create(); final HttpHost host = new HttpHost("https", "somehost", -1); @@ -256,7 +256,7 @@ public void testUpgrade() throws Exception { } @Test - public void testUpgradeUpsupportedScheme() throws Exception { + void testUpgradeUpsupportedScheme() { final HttpClientContext context = HttpClientContext.create(); final HttpHost host = new HttpHost("httpsssss", "somehost", -1); @@ -268,7 +268,7 @@ public void testUpgradeUpsupportedScheme() throws Exception { } @Test - public void testUpgradeNonLayeringScheme() throws Exception { + void testUpgradeNonLayeringScheme() { final HttpClientContext context = HttpClientContext.create(); final HttpHost host = new HttpHost("http", "somehost", -1); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java index b70b72213..b87fa54f4 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/io/TestPoolingHttpClientConnectionManager.java @@ -66,7 +66,7 @@ /** * {@link PoolingHttpClientConnectionManager} tests. */ -public class TestPoolingHttpClientConnectionManager { +class TestPoolingHttpClientConnectionManager { @Mock private ManagedHttpClientConnection conn; @@ -92,7 +92,7 @@ public class TestPoolingHttpClientConnectionManager { private PoolingHttpClientConnectionManager mgr; @BeforeEach - public void setup() throws Exception { + void setup() { MockitoAnnotations.openMocks(this); mgr = new PoolingHttpClientConnectionManager(new DefaultHttpClientConnectionOperator( detachedSocketFactory, schemePortResolver, dnsResolver, tlsSocketStrategyLookup), pool, @@ -100,7 +100,7 @@ public void setup() throws Exception { } @Test - public void testLeaseRelease() throws Exception { + void testLeaseRelease() throws Exception { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); @@ -128,7 +128,7 @@ public void testLeaseRelease() throws Exception { } @Test - public void testReleaseRouteIncomplete() throws Exception { + void testReleaseRouteIncomplete() throws Exception { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); @@ -153,7 +153,7 @@ public void testReleaseRouteIncomplete() throws Exception { } @Test - public void testLeaseFutureTimeout() throws Exception { + void testLeaseFutureTimeout() throws Exception { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); @@ -171,7 +171,7 @@ public void testLeaseFutureTimeout() throws Exception { } @Test - public void testReleaseReusable() throws Exception { + void testReleaseReusable() throws Exception { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); @@ -200,7 +200,7 @@ public void testReleaseReusable() throws Exception { } @Test - public void testReleaseNonReusable() throws Exception { + void testReleaseNonReusable() throws Exception { final HttpHost target = new HttpHost("localhost", 80); final HttpRoute route = new HttpRoute(target); @@ -228,7 +228,7 @@ public void testReleaseNonReusable() throws Exception { } @Test - public void testTargetConnect() throws Exception { + void testTargetConnect() throws Exception { final HttpHost target = new HttpHost("https", "somehost", 443); final InetAddress remote = InetAddress.getByAddress(new byte[] {10, 0, 0, 1}); final InetAddress local = InetAddress.getByAddress(new byte[]{127, 0, 0, 1}); @@ -294,7 +294,7 @@ public void testTargetConnect() throws Exception { } @Test - public void testProxyConnectAndUpgrade() throws Exception { + void testProxyConnectAndUpgrade() throws Exception { final HttpHost target = new HttpHost("https", "somehost", 443); final HttpHost proxy = new HttpHost("someproxy", 8080); final InetAddress remote = InetAddress.getByAddress(new byte[] {10, 0, 0, 1}); @@ -354,12 +354,12 @@ public void testProxyConnectAndUpgrade() throws Exception { } @Test - public void testIsShutdownInitially() { + void testIsShutdownInitially() { Assertions.assertFalse(mgr.isClosed(), "Connection manager should not be shutdown initially."); } @Test - public void testShutdownIdempotency() { + void testShutdownIdempotency() { mgr.close(); Assertions.assertTrue(mgr.isClosed(), "Connection manager should remain shutdown after the first call to shutdown."); mgr.close(); // Second call to shutdown @@ -367,7 +367,7 @@ public void testShutdownIdempotency() { } @Test - public void testLeaseAfterShutdown() { + void testLeaseAfterShutdown() { mgr.close(); Assertions.assertThrows(IllegalArgumentException.class, () -> { // Attempt to lease a connection after shutdown @@ -377,7 +377,7 @@ public void testLeaseAfterShutdown() { @Test - public void testIsShutdown() { + void testIsShutdown() { // Setup phase Mockito.when(pool.isShutdown()).thenReturn(false, true); // Simulate changing states @@ -393,7 +393,7 @@ public void testIsShutdown() { @Test - public void testConcurrentShutdown() throws InterruptedException { + void testConcurrentShutdown() throws InterruptedException { final ExecutorService executor = Executors.newFixedThreadPool(2); // Submit two shutdown tasks to be run in parallel, explicitly calling close() with no arguments executor.submit(() -> mgr.close()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultProxyRoutePlanner.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultProxyRoutePlanner.java index 7fd414f20..cf0866731 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultProxyRoutePlanner.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultProxyRoutePlanner.java @@ -41,14 +41,14 @@ /** * Tests for {@link DefaultProxyRoutePlanner}. */ -public class TestDefaultProxyRoutePlanner { +class TestDefaultProxyRoutePlanner { private HttpHost defaultProxy; private SchemePortResolver schemePortResolver; private DefaultProxyRoutePlanner routePlanner; @BeforeEach - public void setup() { + void setup() { defaultProxy = new HttpHost("default.proxy.host", 8888); schemePortResolver = Mockito.mock(SchemePortResolver.class); routePlanner = new DefaultProxyRoutePlanner(defaultProxy, @@ -56,7 +56,7 @@ public void setup() { } @Test - public void testDefaultProxyDirect() throws Exception { + void testDefaultProxyDirect() throws Exception { final HttpHost target = new HttpHost("http", "somehost", 80); final HttpContext context = HttpClientContext.create(); @@ -70,7 +70,7 @@ public void testDefaultProxyDirect() throws Exception { @Test @SuppressWarnings("deprecation") - public void testViaProxy() throws Exception { + void testViaProxy() throws Exception { final HttpHost target = new HttpHost("http", "somehost", 80); final HttpHost proxy = new HttpHost("custom.proxy.host", 8080); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultRoutePlanner.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultRoutePlanner.java index eda0397ac..9672c6152 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultRoutePlanner.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestDefaultRoutePlanner.java @@ -45,19 +45,19 @@ /** * Tests for {@link DefaultRoutePlanner}. */ -public class TestDefaultRoutePlanner { +class TestDefaultRoutePlanner { private SchemePortResolver schemePortResolver; private DefaultRoutePlanner routePlanner; @BeforeEach - public void setup() { + void setup() { schemePortResolver = Mockito.mock(SchemePortResolver.class); routePlanner = new DefaultRoutePlanner(schemePortResolver); } @Test - public void testDirect() throws Exception { + void testDirect() throws Exception { final HttpHost target = new HttpHost("http", "somehost", 80); final HttpContext context = HttpClientContext.create(); @@ -70,7 +70,7 @@ public void testDirect() throws Exception { } @Test - public void testDirectDefaultPort() throws Exception { + void testDirectDefaultPort() throws Exception { final HttpHost target = new HttpHost("https", "somehost", -1); Mockito.when(schemePortResolver.resolve(target)).thenReturn(443); @@ -84,7 +84,7 @@ public void testDirectDefaultPort() throws Exception { @Test @SuppressWarnings("deprecation") - public void testViaProxy() throws Exception { + void testViaProxy() throws Exception { final HttpHost target = new HttpHost("http", "somehost", 80); final HttpHost proxy = new HttpHost("proxy", 8080); @@ -100,14 +100,14 @@ public void testViaProxy() throws Exception { } @Test - public void testNullTarget() throws Exception { + void testNullTarget() { final HttpContext context = HttpClientContext.create(); Assertions.assertThrows(ProtocolException.class, () -> routePlanner.determineRoute(null, context)); } @Test - public void testVirtualSecureHost() throws Exception { + void testVirtualSecureHost() throws Exception { final HttpHost target = new HttpHost("https", "somehost", 443); final URIAuthority virtualHost = new URIAuthority("someotherhost", 443); final HttpRequest request = new BasicHttpRequest("https", "GET", virtualHost, "/"); @@ -123,7 +123,7 @@ public void testVirtualSecureHost() throws Exception { } @Test - public void testVirtualInsecureHost() throws Exception { + void testVirtualInsecureHost() throws Exception { final HttpHost target = new HttpHost("http", "somehost", 80); final URIAuthority virtualHost = new URIAuthority("someotherhost", 80); final HttpRequest request = new BasicHttpRequest("http", "GET", virtualHost, "/"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteDirector.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteDirector.java index 1890d281b..4de226b67 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteDirector.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteDirector.java @@ -40,7 +40,7 @@ /** * Tests for {@link BasicRouteDirector}. */ -public class TestRouteDirector { +class TestRouteDirector { // a selection of constants for generating routes public final static @@ -82,7 +82,7 @@ public class TestRouteDirector { } @Test - public void testIllegal() { + void testIllegal() { final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; final HttpRoute route = new HttpRoute(TARGET1); Assertions.assertThrows(NullPointerException.class, () -> @@ -90,7 +90,7 @@ public void testIllegal() { } @Test - public void testDirect() { + void testDirect() { final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; final HttpRoute route1 = new HttpRoute(TARGET1); @@ -117,7 +117,7 @@ public void testDirect() { } @Test - public void testProxy() { + void testProxy() { final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; final HttpRoute route1p1 = new HttpRoute(TARGET1, null, PROXY1, false); @@ -155,7 +155,7 @@ public void testProxy() { } @Test - public void testProxyChain() { + void testProxyChain() { final HttpHost[] chainA = { PROXY1 }; final HttpHost[] chainB = { PROXY1, PROXY2 }; final HttpHost[] chainC = { PROXY2, PROXY1 }; @@ -201,7 +201,7 @@ public void testProxyChain() { } @Test - public void testLocalDirect() { + void testLocalDirect() { final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; final HttpRoute route1l41 = new HttpRoute(TARGET1, LOCAL41, false); @@ -255,7 +255,7 @@ public void testLocalDirect() { } @Test - public void testDirectSecure() { + void testDirectSecure() { final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; final HttpRoute route1u = new HttpRoute(TARGET1, null, false); @@ -287,7 +287,7 @@ public void testDirectSecure() { } @Test - public void testProxyTLS() { + void testProxyTLS() { final HttpRouteDirector rowdy = BasicRouteDirector.INSTANCE; final HttpRoute route1 = new HttpRoute diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java index ad77953b6..f73812286 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRouteTracker.java @@ -44,7 +44,7 @@ * Tests for {@link RouteTracker}. */ @SuppressWarnings("boxing") // test code -public class TestRouteTracker { +class TestRouteTracker { // a selection of constants for generating routes public final static @@ -87,7 +87,7 @@ public class TestRouteTracker { @SuppressWarnings("unused") @Test - public void testCstrTargetLocal() { + void testCstrTargetLocal() { RouteTracker rt = new RouteTracker(TARGET1, null); Assertions.assertEquals(TARGET1, rt.getTargetHost(), "wrong target (target,null)"); @@ -111,7 +111,7 @@ public void testCstrTargetLocal() { @SuppressWarnings("unused") @Test - public void testCstrRoute() { + void testCstrRoute() { HttpRoute r = new HttpRoute(TARGET1); RouteTracker rt = new RouteTracker(r); @@ -145,7 +145,7 @@ public void testCstrRoute() { } @Test - public void testIllegalArgs() { + void testIllegalArgs() { final RouteTracker rt = new RouteTracker(TARGET2, null); @@ -161,7 +161,7 @@ public void testIllegalArgs() { } @Test - public void testIllegalStates() { + void testIllegalStates() { final RouteTracker rt = new RouteTracker(TARGET1, null); @@ -179,7 +179,7 @@ public void testIllegalStates() { } @Test - public void testDirectRoutes() { + void testDirectRoutes() { final HttpRouteDirector rd = BasicRouteDirector.INSTANCE; HttpRoute r = new HttpRoute(TARGET1, LOCAL41, false); @@ -194,7 +194,7 @@ public void testDirectRoutes() { } @Test - public void testProxyRoutes() { + void testProxyRoutes() { final HttpRouteDirector rd = BasicRouteDirector.INSTANCE; HttpRoute r = new HttpRoute(TARGET2, null, PROXY1, false); @@ -224,7 +224,7 @@ public void testProxyRoutes() { } @Test - public void testProxyChainRoutes() { + void testProxyChainRoutes() { final HttpRouteDirector rd = BasicRouteDirector.INSTANCE; HttpHost[] proxies = { PROXY1, PROXY2 }; @@ -260,7 +260,7 @@ public void testProxyChainRoutes() { } @Test - public void testEqualsHashcodeCloneToString() + void testEqualsHashcodeCloneToString() throws CloneNotSupportedException { final RouteTracker rt0 = new RouteTracker(TARGET1, null); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRoutingSupport.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRoutingSupport.java index 073be3dc5..da81aee84 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRoutingSupport.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestRoutingSupport.java @@ -43,10 +43,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestRoutingSupport { +class TestRoutingSupport { @Test - public void testDetermineHost() throws Exception { + void testDetermineHost() throws Exception { final HttpRequest request1 = new BasicHttpRequest("GET", "/"); final HttpHost host1 = RoutingSupport.determineHost(request1); assertThat(host1, CoreMatchers.nullValue()); @@ -57,7 +57,7 @@ public void testDetermineHost() throws Exception { } @Test - public void testDetermineHostMissingScheme() throws Exception { + void testDetermineHostMissingScheme() { final HttpRequest request1 = new BasicHttpRequest("GET", "/"); request1.setAuthority(new URIAuthority("host")); Assertions.assertThrows(ProtocolException.class, () -> @@ -65,7 +65,7 @@ public void testDetermineHostMissingScheme() throws Exception { } @Test - public void testNormalizeHost() throws Exception { + void testNormalizeHost() throws Exception { Assertions.assertEquals(new HttpHost("http", "somehost", 80), RoutingSupport.normalize( new HttpHost("http", "somehost", -1), diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestSystemDefaultRoutePlanner.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestSystemDefaultRoutePlanner.java index 0d3bd3127..29260551f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestSystemDefaultRoutePlanner.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/routing/TestSystemDefaultRoutePlanner.java @@ -49,21 +49,21 @@ * Tests for {@link SystemDefaultRoutePlanner}. */ @SuppressWarnings("boxing") // test code -public class TestSystemDefaultRoutePlanner { +class TestSystemDefaultRoutePlanner { private SchemePortResolver schemePortResolver; private ProxySelector proxySelector; private SystemDefaultRoutePlanner routePlanner; @BeforeEach - public void setup() { + void setup() { schemePortResolver = Mockito.mock(SchemePortResolver.class); proxySelector = Mockito.mock(ProxySelector.class); routePlanner = new SystemDefaultRoutePlanner(schemePortResolver, proxySelector); } @Test - public void testDirect() throws Exception { + void testDirect() throws Exception { final HttpHost target = new HttpHost("http", "somehost", 80); final HttpClientContext context = HttpClientContext.create(); @@ -76,7 +76,7 @@ public void testDirect() throws Exception { } @Test - public void testDirectDefaultPort() throws Exception { + void testDirectDefaultPort() throws Exception { final HttpHost target = new HttpHost("https", "somehost", -1); Mockito.when(schemePortResolver.resolve(target)).thenReturn(443); @@ -89,7 +89,7 @@ public void testDirectDefaultPort() throws Exception { } @Test - public void testProxy() throws Exception { + void testProxy() throws Exception { final InetAddress ia = InetAddress.getByAddress(new byte[] { (byte)127, (byte)0, (byte)0, (byte)1 diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRedirectLocation.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRedirectLocation.java index 20b4f0d7d..a78fa6a02 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRedirectLocation.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRedirectLocation.java @@ -35,10 +35,10 @@ /** * Simple tests for {@link RedirectLocations}. */ -public class TestRedirectLocation { +class TestRedirectLocation { @Test - public void testBasics() throws Exception { + void testBasics() throws Exception { final RedirectLocations locations = new RedirectLocations(); final URI uri1 = new URI("/this"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java index deb096ae1..6486aef18 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestAddCookies.java @@ -55,14 +55,14 @@ import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -public class TestRequestAddCookies { +class TestRequestAddCookies { private HttpHost target; private CookieStore cookieStore; private Lookup cookieSpecRegistry; @BeforeEach - public void setUp() { + void setUp() { this.target = new HttpHost("localhost.local", 80); this.cookieStore = new BasicCookieStore(); final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value1"); @@ -84,7 +84,7 @@ public void setUp() { } @Test - public void testRequestParameterCheck() throws Exception { + void testRequestParameterCheck() { final HttpClientContext context = HttpClientContext.create(); final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE; Assertions.assertThrows(NullPointerException.class, () -> @@ -92,7 +92,7 @@ public void testRequestParameterCheck() throws Exception { } @Test - public void testContextParameterCheck() throws Exception { + void testContextParameterCheck() { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpRequestInterceptor interceptor = RequestAddCookies.INSTANCE; Assertions.assertThrows(NullPointerException.class, () -> @@ -100,7 +100,7 @@ public void testContextParameterCheck() throws Exception { } @Test - public void testAddCookies() throws Exception { + void testAddCookies() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpRoute route = new HttpRoute(this.target, null, false); @@ -127,7 +127,7 @@ public void testAddCookies() throws Exception { } @Test - public void testCookiesForConnectRequest() throws Exception { + void testCookiesForConnectRequest() throws Exception { final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com"); final HttpRoute route = new HttpRoute(this.target, null, false); @@ -146,7 +146,7 @@ public void testCookiesForConnectRequest() throws Exception { } @Test - public void testNoCookieStore() throws Exception { + void testNoCookieStore() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpRoute route = new HttpRoute(this.target, null, false); @@ -165,7 +165,7 @@ public void testNoCookieStore() throws Exception { } @Test - public void testNoCookieSpecRegistry() throws Exception { + void testNoCookieSpecRegistry() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpRoute route = new HttpRoute(this.target, null, false); @@ -184,7 +184,7 @@ public void testNoCookieSpecRegistry() throws Exception { } @Test - public void testNoHttpConnection() throws Exception { + void testNoHttpConnection() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpClientContext context = HttpClientContext.create(); @@ -201,7 +201,7 @@ public void testNoHttpConnection() throws Exception { } @Test - public void testAddCookiesUsingExplicitCookieSpec() throws Exception { + void testAddCookiesUsingExplicitCookieSpec() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final RequestConfig config = RequestConfig.custom() .setCookieSpec(StandardCookieSpec.STRICT) @@ -227,7 +227,7 @@ public void testAddCookiesUsingExplicitCookieSpec() throws Exception { } @Test - public void testAuthScopeInvalidRequestURI() throws Exception { + void testAuthScopeInvalidRequestURI() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "crap:"); final HttpRoute route = new HttpRoute(this.target, null, false); @@ -242,7 +242,7 @@ public void testAuthScopeInvalidRequestURI() throws Exception { } @Test - public void testAuthScopeRemotePortWhenDirect() throws Exception { + void testAuthScopeRemotePortWhenDirect() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/stuff"); this.target = new HttpHost("localhost.local"); @@ -265,7 +265,7 @@ public void testAuthScopeRemotePortWhenDirect() throws Exception { } @Test - public void testAuthDefaultHttpPortWhenProxy() throws Exception { + void testAuthDefaultHttpPortWhenProxy() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/stuff"); this.target = new HttpHost("localhost.local"); @@ -289,7 +289,7 @@ public void testAuthDefaultHttpPortWhenProxy() throws Exception { } @Test - public void testAuthDefaultHttpsPortWhenProxy() throws Exception { + void testAuthDefaultHttpsPortWhenProxy() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/stuff"); this.target = new HttpHost("https", "localhost", -1); @@ -314,7 +314,7 @@ public void testAuthDefaultHttpsPortWhenProxy() throws Exception { } @Test - public void testExcludeExpiredCookies() throws Exception { + void testExcludeExpiredCookies() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final BasicClientCookie cookie3 = new BasicClientCookie("name3", "value3"); @@ -349,7 +349,7 @@ public void testExcludeExpiredCookies() throws Exception { } @Test - public void testNoMatchingCookies() throws Exception { + void testNoMatchingCookies() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); this.cookieStore.clear(); @@ -383,7 +383,7 @@ private BasicClientCookie makeCookie(final String name, final String value, fina @Test // Test for ordering adapted from test in Commons HC 3.1 - public void testCookieOrder() throws Exception { + void testCookieOrder() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/foobar/yada/yada"); this.cookieStore.clear(); @@ -411,7 +411,7 @@ public void testCookieOrder() throws Exception { } @Test - public void testSkipAddingCookiesWhenCookieHeaderPresent() throws Exception { + void testSkipAddingCookiesWhenCookieHeaderPresent() throws Exception { // Prepare a request with an existing Cookie header final HttpRequest request = new BasicHttpRequest("GET", "/"); request.addHeader("Cookie", "existingCookie=existingValue"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestClientConnControl.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestClientConnControl.java index a44a6760d..8042a8d72 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestClientConnControl.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestClientConnControl.java @@ -39,10 +39,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestRequestClientConnControl { +class TestRequestClientConnControl { @Test - public void testRequestParameterCheck() throws Exception { + void testRequestParameterCheck() { final HttpClientContext context = HttpClientContext.create(); final HttpRequestInterceptor interceptor = new RequestClientConnControl(); Assertions.assertThrows(NullPointerException.class, () -> @@ -50,7 +50,7 @@ public void testRequestParameterCheck() throws Exception { } @Test - public void testConnectionKeepAliveForConnectRequest() throws Exception { + void testConnectionKeepAliveForConnectRequest() throws Exception { final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com"); final HttpClientContext context = HttpClientContext.create(); @@ -61,7 +61,7 @@ public void testConnectionKeepAliveForConnectRequest() throws Exception { } @Test - public void testConnectionKeepAliveForDirectRequests() throws Exception { + void testConnectionKeepAliveForDirectRequests() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpClientContext context = HttpClientContext.create(); @@ -79,7 +79,7 @@ public void testConnectionKeepAliveForDirectRequests() throws Exception { } @Test - public void testConnectionKeepAliveForTunneledRequests() throws Exception { + void testConnectionKeepAliveForTunneledRequests() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpClientContext context = HttpClientContext.create(); @@ -99,7 +99,7 @@ public void testConnectionKeepAliveForTunneledRequests() throws Exception { } @Test - public void testProxyConnectionKeepAliveForRequestsOverProxy() throws Exception { + void testProxyConnectionKeepAliveForRequestsOverProxy() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpClientContext context = HttpClientContext.create(); @@ -118,7 +118,7 @@ public void testProxyConnectionKeepAliveForRequestsOverProxy() throws Exception } @Test - public void testPreserveCustomConnectionHeader() throws Exception { + void testPreserveCustomConnectionHeader() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); request.addHeader(HttpHeaders.CONNECTION, HeaderElements.CLOSE); final HttpClientContext context = HttpClientContext.create(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestDefaultHeaders.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestDefaultHeaders.java index 928603794..3d3040cdc 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestDefaultHeaders.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestDefaultHeaders.java @@ -38,10 +38,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestRequestDefaultHeaders { +class TestRequestDefaultHeaders { @Test - public void testRequestParameterCheck() throws Exception { + void testRequestParameterCheck() { final HttpContext context = HttpClientContext.create(); final HttpRequestInterceptor interceptor = RequestDefaultHeaders.INSTANCE; Assertions.assertThrows(NullPointerException.class, () -> @@ -49,7 +49,7 @@ public void testRequestParameterCheck() throws Exception { } @Test - public void testNoDefaultHeadersForConnectRequest() throws Exception { + void testNoDefaultHeadersForConnectRequest() throws Exception { final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com"); final List
defheaders = new ArrayList<>(); defheaders.add(new BasicHeader("custom", "stuff")); @@ -62,7 +62,7 @@ public void testNoDefaultHeadersForConnectRequest() throws Exception { } @Test - public void testDefaultHeaders() throws Exception { + void testDefaultHeaders() throws Exception { final HttpRequest request = new BasicHttpRequest("GET", "/"); request.addHeader("custom", "stuff"); final List
defheaders = new ArrayList<>(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestExpectContinue.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestExpectContinue.java index 5a0068c7f..9a02f14e6 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestExpectContinue.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestRequestExpectContinue.java @@ -40,10 +40,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestRequestExpectContinue { +class TestRequestExpectContinue { @Test - public void testRequestExpectContinueGenerated() throws Exception { + void testRequestExpectContinueGenerated() throws Exception { final HttpClientContext context = HttpClientContext.create(); final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build(); context.setRequestConfig(config); @@ -59,7 +59,7 @@ public void testRequestExpectContinueGenerated() throws Exception { } @Test - public void testRequestExpectContinueNotGenerated() throws Exception { + void testRequestExpectContinueNotGenerated() throws Exception { final HttpClientContext context = HttpClientContext.create(); final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(false).build(); context.setRequestConfig(config); @@ -74,7 +74,7 @@ public void testRequestExpectContinueNotGenerated() throws Exception { } @Test - public void testRequestExpectContinueHTTP10() throws Exception { + void testRequestExpectContinueHTTP10() throws Exception { final HttpClientContext context = HttpClientContext.create(); final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build(); context.setRequestConfig(config); @@ -90,7 +90,7 @@ public void testRequestExpectContinueHTTP10() throws Exception { } @Test - public void testRequestExpectContinueZeroContent() throws Exception { + void testRequestExpectContinueZeroContent() throws Exception { final HttpClientContext context = HttpClientContext.create(); final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build(); context.setRequestConfig(config); @@ -105,13 +105,13 @@ public void testRequestExpectContinueZeroContent() throws Exception { } @Test - public void testRequestExpectContinueInvalidInput() throws Exception { + void testRequestExpectContinueInvalidInput() { final RequestExpectContinue interceptor = new RequestExpectContinue(); Assertions.assertThrows(NullPointerException.class, () -> interceptor.process(null, null, null)); } @Test - public void testRequestExpectContinueIgnoreNonenclosingRequests() throws Exception { + void testRequestExpectContinueIgnoreNonenclosingRequests() throws Exception { final HttpClientContext context = HttpClientContext.create(); final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/"); final RequestExpectContinue interceptor = new RequestExpectContinue(); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestResponseProcessCookies.java b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestResponseProcessCookies.java index 2b7da2d09..559a8d1cc 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestResponseProcessCookies.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/protocol/TestResponseProcessCookies.java @@ -41,21 +41,21 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestResponseProcessCookies { +class TestResponseProcessCookies { private CookieOrigin cookieOrigin; private CookieSpec cookieSpec; private CookieStore cookieStore; @BeforeEach - public void setUp() throws Exception { + void setUp() { this.cookieOrigin = new CookieOrigin("localhost", 80, "/", false); this.cookieSpec = new RFC6265LaxSpec(); this.cookieStore = new BasicCookieStore(); } @Test - public void testResponseParameterCheck() throws Exception { + void testResponseParameterCheck() { final HttpClientContext context = HttpClientContext.create(); final HttpResponseInterceptor interceptor = ResponseProcessCookies.INSTANCE; Assertions.assertThrows(NullPointerException.class, () -> @@ -63,7 +63,7 @@ public void testResponseParameterCheck() throws Exception { } @Test - public void testContextParameterCheck() throws Exception { + void testContextParameterCheck() { final HttpResponse response = new BasicHttpResponse(200, "OK"); final HttpResponseInterceptor interceptor = ResponseProcessCookies.INSTANCE; Assertions.assertThrows(NullPointerException.class, () -> @@ -71,7 +71,7 @@ public void testContextParameterCheck() throws Exception { } @Test - public void testParseCookies() throws Exception { + void testParseCookies() throws Exception { final HttpResponse response = new BasicHttpResponse(200, "OK"); response.addHeader("Set-Cookie", "name1=value1"); @@ -94,7 +94,7 @@ public void testParseCookies() throws Exception { } @Test - public void testNoCookieOrigin() throws Exception { + void testNoCookieOrigin() throws Exception { final HttpResponse response = new BasicHttpResponse(200, "OK"); response.addHeader("Set-Cookie", "name1=value1"); @@ -112,7 +112,7 @@ public void testNoCookieOrigin() throws Exception { } @Test - public void testNoCookieSpec() throws Exception { + void testNoCookieSpec() throws Exception { final HttpResponse response = new BasicHttpResponse(200, "OK"); response.addHeader("Set-Cookie", "name1=value1"); @@ -130,7 +130,7 @@ public void testNoCookieSpec() throws Exception { } @Test - public void testNoCookieStore() throws Exception { + void testNoCookieStore() throws Exception { final HttpResponse response = new BasicHttpResponse(200, "OK"); response.addHeader("Set-Cookie", "name1=value1"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixListParser.java b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixListParser.java index 7f34d347b..3549751cc 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixListParser.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixListParser.java @@ -37,10 +37,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestPublicSuffixListParser { +class TestPublicSuffixListParser { @Test - public void testParse() throws Exception { + void testParse() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final InputStream in = classLoader.getResourceAsStream("suffixlist.txt"); Assertions.assertNotNull(in); @@ -57,7 +57,7 @@ public void testParse() throws Exception { } @Test - public void testParseByType() throws Exception { + void testParseByType() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final InputStream in = classLoader.getResourceAsStream("suffixlist2.txt"); Assertions.assertNotNull(in); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java index 25ba0f299..c47c9b967 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/psl/TestPublicSuffixMatcher.java @@ -36,14 +36,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TestPublicSuffixMatcher { +class TestPublicSuffixMatcher { private static final String SOURCE_FILE = "suffixlistmatcher.txt"; private PublicSuffixMatcher matcher; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final InputStream in = classLoader.getResourceAsStream(SOURCE_FILE); Assertions.assertNotNull(in); @@ -53,7 +53,7 @@ public void setUp() throws Exception { } @Test - public void testGetDomainRootAnyType() { + void testGetDomainRootAnyType() { // Private Assertions.assertEquals("xx", matcher.getDomainRoot("example.XX")); Assertions.assertEquals("xx", matcher.getDomainRoot("www.example.XX")); @@ -77,7 +77,7 @@ public void testGetDomainRootAnyType() { } @Test - public void testGetDomainRootOnlyPRIVATE() { + void testGetDomainRootOnlyPRIVATE() { // Private Assertions.assertEquals("xx", matcher.getDomainRoot("example.XX", DomainType.PRIVATE)); Assertions.assertEquals("xx", matcher.getDomainRoot("www.example.XX", DomainType.PRIVATE)); @@ -99,7 +99,7 @@ public void testGetDomainRootOnlyPRIVATE() { } @Test - public void testGetDomainRootOnlyICANN() { + void testGetDomainRootOnlyICANN() { // Private Assertions.assertNull(matcher.getDomainRoot("example.XX", DomainType.ICANN)); Assertions.assertNull(matcher.getDomainRoot("www.example.XX", DomainType.ICANN)); @@ -122,7 +122,7 @@ public void testGetDomainRootOnlyICANN() { @Test - public void testMatch() { + void testMatch() { Assertions.assertTrue(matcher.matches(".jp")); Assertions.assertTrue(matcher.matches(".ac.jp")); Assertions.assertTrue(matcher.matches(".any.tokyo.jp")); @@ -133,7 +133,7 @@ public void testMatch() { } @Test - public void testMatchUnicode() { + void testMatchUnicode() { Assertions.assertTrue(matcher.matches(".h\u00E5.no")); // \u00E5 is Assertions.assertTrue(matcher.matches(".xn--h-2fa.no")); Assertions.assertTrue(matcher.matches(".h\u00E5.no")); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/CertificatesToPlayWith.java b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/CertificatesToPlayWith.java index 3e81ea99a..86c90605f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/CertificatesToPlayWith.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/CertificatesToPlayWith.java @@ -40,7 +40,7 @@ * * @since 11-Dec-2006 */ -public class CertificatesToPlayWith { +class CertificatesToPlayWith { /** * CN=foo.com diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java index a38b85f6e..980af710d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDefaultHostnameVerifier.java @@ -50,7 +50,7 @@ /** * Unit tests for {@link org.apache.hc.client5.http.ssl.DefaultHostnameVerifier}. */ -public class TestDefaultHostnameVerifier { +class TestDefaultHostnameVerifier { private DefaultHostnameVerifier impl; private PublicSuffixMatcher publicSuffixMatcher; @@ -59,7 +59,7 @@ public class TestDefaultHostnameVerifier { private static final String PUBLIC_SUFFIX_MATCHER_SOURCE_FILE = "suffixlistmatcher.txt"; @BeforeEach - public void setup() throws IOException { + void setup() throws IOException { impl = new DefaultHostnameVerifier(); // Load the test PublicSuffixMatcher @@ -74,7 +74,7 @@ public void setup() throws IOException { } @Test - public void testVerify() throws Exception { + void testVerify() throws Exception { final CertificateFactory cf = CertificateFactory.getInstance("X.509"); InputStream in; X509Certificate x509; @@ -188,7 +188,7 @@ public void testVerify() throws Exception { } @Test - public void testSubjectAlt() throws Exception { + void testSubjectAlt() throws Exception { final CertificateFactory cf = CertificateFactory.getInstance("X.509"); final InputStream in = new ByteArrayInputStream(CertificatesToPlayWith.X509_MULTIPLE_SUBJECT_ALT); final X509Certificate x509 = (X509Certificate) cf.generateCertificate(in); @@ -210,7 +210,7 @@ public void exceptionPlease(final DefaultHostnameVerifier hv, final String host, } @Test - public void testDomainRootMatching() { + void testDomainRootMatching() { Assertions.assertFalse(DefaultHostnameVerifier.matchDomainRoot("a.b.c", null)); Assertions.assertTrue(DefaultHostnameVerifier.matchDomainRoot("a.b.c", "a.b.c")); @@ -220,7 +220,7 @@ public void testDomainRootMatching() { } @Test - public void testIdentityMatching() { + void testIdentityMatching() { Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("a.b.c", "*.b.c")); Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("a.b.c", "*.b.c")); @@ -269,7 +269,7 @@ public void testIdentityMatching() { } @Test - public void testHTTPCLIENT_1097() { + void testHTTPCLIENT_1097() { Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("a.b.c", "a*.b.c")); Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("a.b.c", "a*.b.c")); @@ -278,13 +278,13 @@ public void testHTTPCLIENT_1097() { } @Test - public void testHTTPCLIENT_1255() { + void testHTTPCLIENT_1255() { Assertions.assertTrue(DefaultHostnameVerifier.matchIdentity("mail.a.b.c.com", "m*.a.b.c.com")); Assertions.assertTrue(DefaultHostnameVerifier.matchIdentityStrict("mail.a.b.c.com", "m*.a.b.c.com")); } @Test - public void testHTTPCLIENT_1997_ANY() { // Only True on all domains + void testHTTPCLIENT_1997_ANY() { // Only True on all domains String domain; // Unknown domain = "dev.b.cloud.a"; @@ -309,7 +309,7 @@ public void testHTTPCLIENT_1997_ANY() { // Only True on all domains } @Test - public void testHTTPCLIENT_1997_ICANN() { // Only True on ICANN domains + void testHTTPCLIENT_1997_ICANN() { // Only True on ICANN domains String domain; // Unknown domain = "dev.b.cloud.a"; @@ -328,7 +328,7 @@ public void testHTTPCLIENT_1997_ICANN() { // Only True on ICANN domains } @Test - public void testHTTPCLIENT_1997_PRIVATE() { // Only True on PRIVATE domains + void testHTTPCLIENT_1997_PRIVATE() { // Only True on PRIVATE domains String domain; // Unknown domain = "dev.b.cloud.a"; @@ -347,7 +347,7 @@ public void testHTTPCLIENT_1997_PRIVATE() { // Only True on PRIVATE domains } @Test - public void testHTTPCLIENT_1997_UNKNOWN() { // Only True on all domains (same as ANY) + void testHTTPCLIENT_1997_UNKNOWN() { // Only True on all domains (same as ANY) String domain; // Unknown domain = "dev.b.cloud.a"; @@ -366,7 +366,7 @@ public void testHTTPCLIENT_1997_UNKNOWN() { // Only True on all domains (same as } @Test // Check compressed IPv6 hostname matching - public void testHTTPCLIENT_1316() throws Exception{ + void testHTTPCLIENT_1316() throws Exception{ final String host1 = "2001:0db8:aaaa:bbbb:cccc:0:0:0001"; DefaultHostnameVerifier.matchIPv6Address(host1, Collections.singletonList(SubjectName.IP("2001:0db8:aaaa:bbbb:cccc:0:0:0001"))); DefaultHostnameVerifier.matchIPv6Address(host1, Collections.singletonList(SubjectName.IP("2001:0db8:aaaa:bbbb:cccc::1"))); @@ -380,7 +380,7 @@ public void testHTTPCLIENT_1316() throws Exception{ } @Test - public void testHTTPCLIENT_2149() throws Exception { + void testHTTPCLIENT_2149() throws Exception { final CertificateFactory cf = CertificateFactory.getInstance("X.509"); final InputStream in = new ByteArrayInputStream(CertificatesToPlayWith.SUBJECT_ALT_IP_ONLY); final X509Certificate x509 = (X509Certificate) cf.generateCertificate(in); @@ -395,7 +395,7 @@ public void testHTTPCLIENT_2149() throws Exception { } @Test - public void testExtractCN() throws Exception { + void testExtractCN() throws Exception { Assertions.assertEquals("blah", DefaultHostnameVerifier.extractCN("cn=blah, ou=blah, o=blah")); Assertions.assertEquals("blah", DefaultHostnameVerifier.extractCN("cn=blah, cn=yada, cn=booh")); Assertions.assertEquals("blah", DefaultHostnameVerifier.extractCN("c = pampa , cn = blah , ou = blah , o = blah")); @@ -411,7 +411,7 @@ public void testExtractCN() throws Exception { } @Test - public void testMatchDNSName() throws Exception { + void testMatchDNSName() throws Exception { DefaultHostnameVerifier.matchDNSName( "host.domain.com", Collections.singletonList(SubjectName.DNS("*.domain.com")), diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDistinguishedNameParser.java b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDistinguishedNameParser.java index 553d57a0b..fde4ae4f0 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDistinguishedNameParser.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/ssl/TestDistinguishedNameParser.java @@ -40,17 +40,17 @@ /** * Unit tests for {@link DistinguishedNameParser}. */ -public class TestDistinguishedNameParser { +class TestDistinguishedNameParser { private DistinguishedNameParser impl; @BeforeEach - public void setup() { + void setup() { impl = DistinguishedNameParser.INSTANCE; } @Test - public void testParseBasic() throws Exception { + void testParseBasic() { assertThat(impl.parse("cn=blah, ou=yada, o=booh"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("cn", "blah"), @@ -59,7 +59,7 @@ public void testParseBasic() throws Exception { } @Test - public void testParseRepeatedElements() throws Exception { + void testParseRepeatedElements() { assertThat(impl.parse("cn=blah, cn=yada, cn=booh"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("cn", "blah"), @@ -68,7 +68,7 @@ public void testParseRepeatedElements() throws Exception { } @Test - public void testParseBlanks() throws Exception { + void testParseBlanks() { assertThat(impl.parse("c = pampa , cn = blah , ou = blah , o = blah"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("c", "pampa"), @@ -78,7 +78,7 @@ public void testParseBlanks() throws Exception { } @Test - public void testParseQuotes() throws Exception { + void testParseQuotes() { assertThat(impl.parse("cn=\"blah\", ou=yada, o=booh"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("cn", "blah"), @@ -87,7 +87,7 @@ public void testParseQuotes() throws Exception { } @Test - public void testParseQuotes2() throws Exception { + void testParseQuotes2() { assertThat(impl.parse("cn=\"blah blah\", ou=yada, o=booh"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("cn", "blah blah"), @@ -96,7 +96,7 @@ public void testParseQuotes2() throws Exception { } @Test - public void testParseQuotes3() throws Exception { + void testParseQuotes3() { assertThat(impl.parse("cn=\"blah, blah\", ou=yada, o=booh"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("cn", "blah, blah"), @@ -105,7 +105,7 @@ public void testParseQuotes3() throws Exception { } @Test - public void testParseEscape() throws Exception { + void testParseEscape() { assertThat(impl.parse("cn=blah\\, blah, ou=yada, o=booh"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("cn", "blah, blah"), @@ -114,7 +114,7 @@ public void testParseEscape() throws Exception { } @Test - public void testParseUnescapedEqual() throws Exception { + void testParseUnescapedEqual() { assertThat(impl.parse("c = cn=uuh, cn=blah, ou=yada, o=booh"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("c", "cn=uuh"), @@ -124,7 +124,7 @@ public void testParseUnescapedEqual() throws Exception { } @Test - public void testParseInvalid() throws Exception { + void testParseInvalid() { assertThat(impl.parse("blah,blah"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("blah", null), @@ -132,7 +132,7 @@ public void testParseInvalid() throws Exception { } @Test - public void testParseInvalid2() throws Exception { + void testParseInvalid2() { assertThat(impl.parse("cn,o=blah"), CoreMatchers.equalTo(Arrays.asList( new BasicNameValuePair("cn", null), diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestBase64.java b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestBase64.java index 53307dbbf..afe5b01c5 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestBase64.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestBase64.java @@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -public class TestBase64 { +class TestBase64 { public static final char CHAR_ZERO = 0; public static final String EMPTY_STR = ""; diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestByteArrayBuilder.java b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestByteArrayBuilder.java index d43709fb9..f59a8e51b 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestByteArrayBuilder.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestByteArrayBuilder.java @@ -35,10 +35,10 @@ /** * {@link ByteArrayBuilder} test cases. */ -public class TestByteArrayBuilder { +class TestByteArrayBuilder { @Test - public void testEmptyBuffer() throws Exception { + void testEmptyBuffer() { final ByteArrayBuilder buffer = new ByteArrayBuilder(); final ByteBuffer byteBuffer = buffer.toByteBuffer(); Assertions.assertNotNull(byteBuffer); @@ -50,7 +50,7 @@ public void testEmptyBuffer() throws Exception { } @Test - public void testAppendBytes() throws Exception { + void testAppendBytes() { final ByteArrayBuilder buffer = new ByteArrayBuilder(); buffer.append(new byte[]{1, 2, 3, 4, 5}); buffer.append(new byte[]{3, 4, 5, 6, 7, 8, 9, 10, 11}, 3, 5); @@ -62,7 +62,7 @@ public void testAppendBytes() throws Exception { } @Test - public void testInvalidAppendBytes() throws Exception { + void testInvalidAppendBytes() { final ByteArrayBuilder buffer = new ByteArrayBuilder(); buffer.append((byte[])null, 0, 0); @@ -75,7 +75,7 @@ public void testInvalidAppendBytes() throws Exception { } @Test - public void testEnsureCapacity() throws Exception { + void testEnsureCapacity() { final ByteArrayBuilder buffer = new ByteArrayBuilder(); buffer.ensureFreeCapacity(10); Assertions.assertEquals(10, buffer.capacity()); @@ -89,7 +89,7 @@ public void testEnsureCapacity() throws Exception { } @Test - public void testAppendText() throws Exception { + void testAppendText() { final ByteArrayBuilder buffer = new ByteArrayBuilder(); buffer.append(new char[]{'1', '2', '3', '4', '5'}); buffer.append(new char[]{'3', '4', '5', '6', '7', '8', '9', 'a', 'b'}, 3, 5); @@ -106,7 +106,7 @@ public void testAppendText() throws Exception { } @Test - public void testInvalidAppendChars() throws Exception { + void testInvalidAppendChars() { final ByteArrayBuilder buffer = new ByteArrayBuilder(); buffer.append((char[])null, 0, 0); @@ -119,7 +119,7 @@ public void testInvalidAppendChars() throws Exception { } @Test - public void testReset() throws Exception { + void testReset() { final ByteArrayBuilder buffer = new ByteArrayBuilder(); buffer.append("abcd"); buffer.append("e"); @@ -137,7 +137,7 @@ public void testReset() throws Exception { } @Test - public void testNonAsciiCharset() throws Exception { + void testNonAsciiCharset() { final int[] germanChars = { 0xE4, 0x2D, 0xF6, 0x2D, 0xFc }; final StringBuilder tmp = new StringBuilder(); for (final int germanChar : germanChars) { diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java index 155068142..67eef8475 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java @@ -44,7 +44,7 @@ /** * Unit tests for {@link DateUtils}. */ -public class TestDateUtils { +class TestDateUtils { private static Instant createInstant(final int year, final Month month, final int day) { return LocalDate.of(year, month, day).atStartOfDay(ZoneId.of("GMT")).toInstant(); @@ -56,7 +56,7 @@ private static Date createDate(final int year, final Month month, final int day) } @Test - public void testBasicDateParse() throws Exception { + void testBasicDateParse() { final Instant instant = createInstant(2005, Month.OCTOBER, 14); Assertions.assertEquals(instant, DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", DateUtils.FORMATTER_RFC1123)); Assertions.assertEquals(instant, DateUtils.parseDate("Friday, 14 Oct 2005 00:00:00 GMT", DateUtils.FORMATTER_RFC1123)); @@ -70,7 +70,7 @@ public void testBasicDateParse() throws Exception { } @Test - public void testDateParseMessage() throws Exception { + void testDateParseMessage() { final HeaderGroup message1 = new HeaderGroup(); message1.setHeader(new BasicHeader(HttpHeaders.DATE, "Fri, 14 Oct 2005 00:00:00 GMT")); Assertions.assertEquals(createInstant(2005, Month.OCTOBER, 14), DateUtils.parseStandardDate(message1, HttpHeaders.DATE)); @@ -82,31 +82,31 @@ public void testDateParseMessage() throws Exception { } @Test - public void testMalformedDate() { + void testMalformedDate() { Assertions.assertNull(DateUtils.parseDate("Fri, 14 Oct 2005 00:00:00 GMT", new DateTimeFormatter[] {})); Assertions.assertNull(DateUtils.parseDate("Thu Feb 22 17:20:18 2024", new DateTimeFormatter[] {})); } @Test - public void testInvalidInput() throws Exception { + void testInvalidInput() { Assertions.assertThrows(NullPointerException.class, () -> DateUtils.parseStandardDate(null)); Assertions.assertThrows(NullPointerException.class, () -> DateUtils.formatStandardDate(null)); } @Test - public void testTwoDigitYearDateParse() throws Exception { + void testTwoDigitYearDateParse() { Assertions.assertEquals(createInstant(2005, Month.OCTOBER, 14), DateUtils.parseDate("Friday, 14-Oct-05 00:00:00 GMT", DateUtils.FORMATTER_RFC1036)); } @Test - public void testParseQuotedDate() throws Exception { + void testParseQuotedDate() { Assertions.assertEquals(createInstant(2005, Month.OCTOBER, 14), DateUtils.parseDate("'Fri, 14 Oct 2005 00:00:00 GMT'", DateUtils.FORMATTER_RFC1123)); } @Test - public void testBasicDateFormat() throws Exception { + void testBasicDateFormat() { final Instant instant = createInstant(2005, Month.OCTOBER, 14); Assertions.assertEquals("Fri, 14 Oct 2005 00:00:00 GMT", DateUtils.formatStandardDate(instant)); Assertions.assertEquals("Fri, 14 Oct 2005 00:00:00 GMT", DateUtils.formatDate(instant, DateUtils.FORMATTER_RFC1123)); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDnsUtils.java b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDnsUtils.java index f8a623abf..2e3f521cd 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDnsUtils.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDnsUtils.java @@ -35,10 +35,10 @@ /** * Unit tests for DnsUtils. */ -public class TestDnsUtils { +class TestDnsUtils { @Test - public void testNormalize() { + void testNormalize() { assertThat(DnsUtils.normalize(null), CoreMatchers.equalTo(null)); assertThat(DnsUtils.normalize(""), CoreMatchers.equalTo("")); assertThat(DnsUtils.normalize("blah"), CoreMatchers.equalTo("blah")); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java index ab4d839c9..87df8aa76 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestURIUtils.java @@ -39,12 +39,12 @@ * This TestCase contains test methods for URI resolving according to RFC 3986. * The examples are listed in section "5.4 Reference Resolution Examples" */ -public class TestURIUtils { +class TestURIUtils { private final URI baseURI = URI.create("http://a/b/c/d;p?q"); @Test - public void testResolve() { + void testResolve() { Assertions.assertEquals("g:h", URIUtils.resolve(this.baseURI, "g:h").toString()); Assertions.assertEquals("http://a/b/c/g", URIUtils.resolve(this.baseURI, "g").toString()); Assertions.assertEquals("http://a/b/c/g", URIUtils.resolve(this.baseURI, "./g").toString()); @@ -107,7 +107,7 @@ public void testResolve() { } @Test - public void testResolveOpaque() { + void testResolveOpaque() { Assertions.assertEquals("example://a/./b/../b/%63/%7bfoo%7d", URIUtils.resolve(this.baseURI, "eXAMPLE://a/./b/../b/%63/%7bfoo%7d").toString()); Assertions.assertEquals("file://localhost/etc/fstab", URIUtils.resolve(this.baseURI, "file://localhost/etc/fstab").toString()); Assertions.assertEquals("file:///etc/fstab", URIUtils.resolve(this.baseURI, "file:///etc/fstab").toString()); @@ -121,7 +121,7 @@ public void testResolveOpaque() { } @Test - public void testExtractHost() throws Exception { + void testExtractHost() throws Exception { Assertions.assertEquals(new HttpHost("localhost"), URIUtils.extractHost(new URI("http://localhost/abcd"))); Assertions.assertEquals(new HttpHost("localhost"), @@ -166,7 +166,7 @@ public void testExtractHost() throws Exception { } @Test - public void testHttpLocationWithRelativeFragment() throws Exception { + void testHttpLocationWithRelativeFragment() throws Exception { final HttpHost target = new HttpHost("http", "localhost", -1); final URI requestURI = new URI("/stuff#blahblah"); @@ -179,7 +179,7 @@ public void testHttpLocationWithRelativeFragment() throws Exception { } @Test - public void testHttpLocationWithAbsoluteFragment() throws Exception { + void testHttpLocationWithAbsoluteFragment() throws Exception { final HttpHost target = new HttpHost("http", "localhost", 80); final URI requestURI = new URIBuilder() @@ -195,7 +195,7 @@ public void testHttpLocationWithAbsoluteFragment() throws Exception { } @Test - public void testHttpLocationRedirect() throws Exception { + void testHttpLocationRedirect() throws Exception { final HttpHost target = new HttpHost("http", "localhost", -1); final URI requestURI = new URI("/People.htm#tim"); @@ -212,7 +212,7 @@ public void testHttpLocationRedirect() throws Exception { } @Test - public void testHttpLocationWithRedirectFragment() throws Exception { + void testHttpLocationWithRedirectFragment() throws Exception { final HttpHost target = new HttpHost("http", "localhost", -1); final URI requestURI = new URI("/~tim"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/validator/TestETag.java b/httpclient5/src/test/java/org/apache/hc/client5/http/validator/TestETag.java index 865683094..0c8430b0e 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/validator/TestETag.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/validator/TestETag.java @@ -29,10 +29,10 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -public class TestETag { +class TestETag { @Test - public void testHashCodeEquals() { + void testHashCodeEquals() { final ETag tag1 = new ETag("this"); final ETag tag2 = new ETag("this"); final ETag tag3 = new ETag("this", ValidatorType.WEAK); @@ -48,14 +48,14 @@ public void testHashCodeEquals() { } @Test - public void testToString() { + void testToString() { Assertions.assertEquals("\"blah\"", new ETag("blah").toString()); Assertions.assertEquals("W/\"blah\"", new ETag("blah", ValidatorType.WEAK).toString()); Assertions.assertEquals("\"\"", new ETag("").toString()); } @Test - public void testParse() { + void testParse() { Assertions.assertEquals(new ETag("blah", ValidatorType.WEAK), ETag.parse(" W/\"blah\" ")); Assertions.assertEquals(new ETag(" huh?"), ETag.parse(" \" huh?\" ")); Assertions.assertEquals(new ETag(" ", ValidatorType.WEAK), ETag.parse("W/\" \"")); @@ -71,7 +71,7 @@ public void testParse() { } @Test - public void testComparison() { + void testComparison() { Assertions.assertFalse(ETag.strongCompare(new ETag("1", ValidatorType.WEAK), new ETag("1", ValidatorType.WEAK))); Assertions.assertTrue(ETag.weakCompare(new ETag("1", ValidatorType.WEAK), new ETag("1", ValidatorType.WEAK))); Assertions.assertFalse(ETag.strongCompare(new ETag("1", ValidatorType.WEAK), new ETag("2", ValidatorType.WEAK))); From 733299c2492904704f3dde0662d88fd2ae7233a4 Mon Sep 17 00:00:00 2001 From: strangelookingnerd <49242855+strangelookingnerd@users.noreply.github.com> Date: Thu, 27 Jun 2024 09:51:47 +0200 Subject: [PATCH 2/3] Fix assertions --- .../hc/client5/http/impl/cache/ConsumableInputStream.java | 1 - .../hc/client5/http/impl/cache/TestRFC5861Compliance.java | 7 ++++--- .../java/org/apache/hc/client5/http/TestHttpRoute.java | 2 +- .../client5/http/classic/methods/TestHttpRequestBase.java | 2 +- .../hc/client5/http/impl/classic/TestRedirectExec.java | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java index 1cd8c3490..e7969f2e5 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/ConsumableInputStream.java @@ -27,7 +27,6 @@ package org.apache.hc.client5.http.impl.cache; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.io.InputStream; import org.apache.hc.core5.io.Closer; diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java index 1d43834ca..cb5c34835 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestRFC5861Compliance.java @@ -28,6 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; @@ -170,7 +171,7 @@ void testStaleIfErrorInResponseYieldsToMustRevalidate() final ClassicHttpResponse result = execute(req2); - assertTrue(HttpStatus.SC_OK != result.getCode()); + assertNotEquals(HttpStatus.SC_OK, result.getCode()); } @Test @@ -193,7 +194,7 @@ void testStaleIfErrorInResponseYieldsToProxyRevalidateForSharedCache() final ClassicHttpResponse result = execute(req2); - assertTrue(HttpStatus.SC_OK != result.getCode()); + assertNotEquals(HttpStatus.SC_OK, result.getCode()); } @Test @@ -216,7 +217,7 @@ void testStaleIfErrorInResponseYieldsToExplicitFreshnessRequest() final ClassicHttpResponse result = execute(req2); - assertTrue(HttpStatus.SC_OK != result.getCode()); + assertNotEquals(HttpStatus.SC_OK, result.getCode()); } @Test diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java b/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java index c1ba0b5eb..6614f4236 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/TestHttpRoute.java @@ -359,7 +359,7 @@ void testHopping() { final HttpHost[] proxies3 = new HttpHost[]{ PROXY3, PROXY1, PROXY2 }; final HttpRoute route3 = new HttpRoute(TARGET1, LOCAL42, proxies3, false, TunnelType.PLAIN, LayerType.LAYERED); - Assertions.assertEquals(route3.getHopCount(), 4, "C: hop count"); + Assertions.assertEquals(4, route3.getHopCount(), "C: hop count"); Assertions.assertEquals(PROXY3 , route3.getHopTarget(0), "C: hop 0"); Assertions.assertEquals(PROXY1 , route3.getHopTarget(1), "C: hop 1"); Assertions.assertEquals(PROXY2 , route3.getHopTarget(2), "C: hop 2"); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java index 7103294ae..7854d8acf 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/classic/methods/TestHttpRequestBase.java @@ -176,7 +176,7 @@ void testOptionMethodGetAllowedMethods() { final Set methods = httpOptions.getAllowedMethods(response); assertAll("Must all pass", () -> assertFalse(methods.isEmpty()), - () -> assertEquals(methods.size(), 3), + () -> assertEquals(3, methods.size()), () -> assertTrue(methods.containsAll(Stream.of("HEAD", "DELETE", "GET") .collect(Collectors.toCollection(HashSet::new)))) ); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java index 4a21390a1..2bbedebe6 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestRedirectExec.java @@ -404,9 +404,9 @@ void testPutSeeOtherRedirect() throws Exception { final ClassicHttpRequest request2 = allValues.get(1); final ClassicHttpRequest request3 = allValues.get(2); Assertions.assertSame(request, request1); - Assertions.assertEquals(request1.getMethod(), "PUT"); - Assertions.assertEquals(request2.getMethod(), "GET"); - Assertions.assertEquals(request3.getMethod(), "GET"); + Assertions.assertEquals("PUT", request1.getMethod()); + Assertions.assertEquals("GET", request2.getMethod()); + Assertions.assertEquals("GET", request3.getMethod()); } private static class HttpRequestMatcher implements ArgumentMatcher { From 3213dac1a5ef367767940b174535ac65928b400a Mon Sep 17 00:00:00 2001 From: strangelookingnerd <49242855+strangelookingnerd@users.noreply.github.com> Date: Thu, 27 Jun 2024 10:49:05 +0200 Subject: [PATCH 3/3] Minor code cleanup --- .../cache/TestByteArrayCacheEntrySerializer.java | 13 ------------- .../cache/TestCachedResponseSuitabilityChecker.java | 3 --- .../http/impl/cache/TestCachingExecChain.java | 2 +- .../TestHttpByteArrayCacheEntrySerializer.java | 4 ++-- .../http/impl/cache/TestProtocolRequirements.java | 2 -- .../async/TestHttp1AsyncStatefulConnManagement.java | 1 - .../testing/sync/TestClientAuthentication.java | 2 -- .../client5/testing/sync/TestConnectionReuse.java | 2 -- .../hc/client5/testing/sync/TestContentCodings.java | 1 - .../testing/sync/TestDefaultClientTlsStrategy.java | 3 --- .../sync/TestFutureRequestExecutionService.java | 1 - .../sync/TestMinimalClientRequestExecution.java | 2 -- .../testing/sync/TestStatefulConnManagement.java | 3 --- .../http/examples/AsyncClientH2ServerPush.java | 2 -- .../examples/AsyncClientHttpExchangeStreaming.java | 2 -- .../http/examples/AsyncClientInterceptors.java | 2 -- .../client5/http/examples/ClientInterceptors.java | 2 -- .../http/impl/classic/TestHttpRequestRetryExec.java | 2 +- .../http/impl/classic/TestMainClientExec.java | 2 +- .../apache/hc/client5/http/utils/TestDateUtils.java | 6 ------ 20 files changed, 5 insertions(+), 52 deletions(-) diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestByteArrayCacheEntrySerializer.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestByteArrayCacheEntrySerializer.java index 57d2d64ad..c46e04702 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestByteArrayCacheEntrySerializer.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestByteArrayCacheEntrySerializer.java @@ -32,10 +32,6 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.math.BigDecimal; import java.time.Instant; import java.util.Date; import java.util.HashSet; @@ -249,15 +245,6 @@ private static void assertIsAllowedClassNameFalse(final String className) { assertFalse(ByteArrayCacheEntrySerializer.RestrictedObjectInputStream.isAllowedClassName(className)); } - private byte[] serializeProhibitedObject() throws IOException { - final BigDecimal bigDecimal = new BigDecimal("1000.00"); - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (ObjectOutputStream oos = new ObjectOutputStream(baos)) { - oos.writeObject(bigDecimal); - } - return baos.toByteArray(); - } - public void readWriteVerify(final HttpCacheStorageEntry writeEntry) throws Exception { // write the entry final byte[] bytes = impl.serialize(writeEntry); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java index 899dc5107..416fe15f3 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java @@ -436,9 +436,6 @@ void testSuitableForGETIfHeadResponseCachingEnabledAndEntryDoesNotSpecifyAReques void testSuitableForHEADIfHeadResponseCachingEnabledAndEntryDoesNotSpecifyARequestMethod() { final HttpRequest headRequest = new BasicHttpRequest("HEAD", "/foo"); impl = new CachedResponseSuitabilityChecker(CacheConfig.custom().build()); - final Header[] headers = { - - }; entry = makeEntry(Method.GET, "/foo", new BasicHeader("Date", DateUtils.formatStandardDate(tenSecondsAgo))); responseCacheControl = ResponseCacheControl.builder() diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java index 9a8592ec1..c76b1ece0 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachingExecChain.java @@ -1279,7 +1279,7 @@ void testNoCacheFieldsRevalidation() throws Exception { Mockito.when(mockExecChain.proceed(Mockito.any(), Mockito.any())).thenReturn(resp2); execute(req2); - final ClassicHttpResponse result = execute(req3); + execute(req3); // Verify that the backend was called to revalidate the response, as per the new logic Mockito.verify(mockExecChain, Mockito.times(5)).proceed(Mockito.any(), Mockito.any()); diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java index 7a60f31db..a3f8dff07 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java @@ -261,7 +261,7 @@ void testInvalidHeaderCacheEntry() { "Cache-control: public, max-age=31536000\n" + "\n" + "Hello World"; - final byte[] bytes2 = content1.getBytes(StandardCharsets.UTF_8); + final byte[] bytes2 = content2.getBytes(StandardCharsets.UTF_8); final ResourceIOException exception2 = Assertions.assertThrows(ResourceIOException.class, () -> httpCacheEntrySerializer.deserialize(bytes2)); Assertions.assertEquals("Invalid cache header format", exception2.getMessage()); @@ -432,7 +432,7 @@ void testDeserializeCacheEntryWithTrailingGarbage() { final byte[] bytes2 = content2.getBytes(StandardCharsets.UTF_8); final ResourceIOException exception2 = Assertions.assertThrows(ResourceIOException.class, () -> httpCacheEntrySerializer.deserialize(bytes2)); - Assertions.assertEquals("Unexpected content at the end of cache content", exception1.getMessage()); + Assertions.assertEquals("Unexpected content at the end of cache content", exception2.getMessage()); } static HeapResource load(final URL resource) throws IOException { diff --git a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java index 02d22a80c..08fb1e2c7 100644 --- a/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java +++ b/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java @@ -465,8 +465,6 @@ void test304GeneratedFromCacheOnWeakValidatorDoesNotIncludeOtherEntityHeaders() @Test void testNotModifiedOfNonCachedEntityShouldRevalidateWithUnconditionalGET() throws Exception { - final Instant now = Instant.now(); - // load cache with cacheable entry final ClassicHttpRequest req1 = new BasicClassicHttpRequest("GET", "/"); final ClassicHttpResponse resp1 = HttpTestUtils.make200Response(); diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java index 651539ff3..7eff2c1bc 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/async/TestHttp1AsyncStatefulConnManagement.java @@ -39,7 +39,6 @@ import org.apache.hc.client5.testing.extension.async.TestAsyncClient; import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.EndpointDetails; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpStatus; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java index d54f25223..c3b0987b5 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestClientAuthentication.java @@ -29,7 +29,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.nio.charset.StandardCharsets; import java.security.SecureRandom; import java.util.Arrays; @@ -71,7 +70,6 @@ import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.HeaderElements; import org.apache.hc.core5.http.HttpEntity; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpResponse; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java index 3b11dd0d3..74f8a0694 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestConnectionReuse.java @@ -28,7 +28,6 @@ package org.apache.hc.client5.testing.sync; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -46,7 +45,6 @@ import org.apache.hc.core5.http.EntityDetails; import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.HeaderElements; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpResponse; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java index 8a5e4c1c1..5103c9756 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestContentCodings.java @@ -50,7 +50,6 @@ import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.HeaderElement; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.URIScheme; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestDefaultClientTlsStrategy.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestDefaultClientTlsStrategy.java index 736e21f6d..6cc605094 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestDefaultClientTlsStrategy.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestDefaultClientTlsStrategy.java @@ -32,9 +32,6 @@ import java.io.IOException; import java.net.InetAddress; import java.net.Socket; -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; import java.util.Objects; import javax.net.ssl.HostnameVerifier; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java index 3a366ca12..1c40f580f 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestFutureRequestExecutionService.java @@ -28,7 +28,6 @@ import static org.hamcrest.MatcherAssert.assertThat; -import java.io.IOException; import java.util.LinkedList; import java.util.Queue; import java.util.concurrent.CancellationException; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java index ad213718e..b15669a57 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestMinimalClientRequestExecution.java @@ -26,7 +26,6 @@ */ package org.apache.hc.client5.testing.sync; -import java.io.IOException; import java.util.HashSet; import java.util.Locale; import java.util.Set; @@ -38,7 +37,6 @@ import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.Header; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpStatus; diff --git a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java index b0d631f77..a4f0273c2 100644 --- a/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java +++ b/httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/TestStatefulConnManagement.java @@ -26,8 +26,6 @@ */ package org.apache.hc.client5.testing.sync; -import java.io.IOException; - import org.apache.hc.client5.http.UserTokenHandler; import org.apache.hc.client5.http.classic.methods.HttpGet; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; @@ -38,7 +36,6 @@ import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.EndpointDetails; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.URIScheme; diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java index 49c752a1f..676aed477 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientH2ServerPush.java @@ -26,7 +26,6 @@ */ package org.apache.hc.client5.http.examples; -import java.io.IOException; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.util.concurrent.Future; @@ -39,7 +38,6 @@ import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder; import org.apache.hc.core5.function.Supplier; import org.apache.hc.core5.http.ContentType; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.impl.routing.RequestRouter; diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java index 79e5acd1f..38685db5d 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java @@ -26,7 +26,6 @@ */ package org.apache.hc.client5.http.examples; -import java.io.IOException; import java.nio.CharBuffer; import java.util.concurrent.Future; @@ -34,7 +33,6 @@ import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient; import org.apache.hc.client5.http.impl.async.HttpAsyncClients; import org.apache.hc.core5.http.ContentType; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.message.BasicHttpRequest; diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java index 3b1dd4c0a..550265b8f 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java @@ -27,7 +27,6 @@ package org.apache.hc.client5.http.examples; -import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.concurrent.Future; @@ -43,7 +42,6 @@ import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.EntityDetails; import org.apache.hc.core5.http.Header; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpRequestInterceptor; import org.apache.hc.core5.http.HttpResponse; diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java index 625624056..9d9f9a66c 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java @@ -27,7 +27,6 @@ package org.apache.hc.client5.http.examples; -import java.io.IOException; import java.util.concurrent.atomic.AtomicLong; import org.apache.hc.client5.http.classic.methods.HttpGet; @@ -38,7 +37,6 @@ import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.EntityDetails; import org.apache.hc.core5.http.Header; -import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpRequestInterceptor; import org.apache.hc.core5.http.HttpStatus; diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java index 1792387d2..5672587c5 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestHttpRequestRetryExec.java @@ -111,7 +111,7 @@ void testRetrySleepOnIOException() throws Exception { final HttpGet request = new HttpGet("/test"); final HttpClientContext context = HttpClientContext.create(); - final ClassicHttpResponse response = Mockito.mock(ClassicHttpResponse.class); + Mockito.mock(ClassicHttpResponse.class); Mockito.when(chain.proceed( Mockito.same(request), diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java index aa40efb93..aa58ff126 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestMainClientExec.java @@ -100,7 +100,7 @@ void testFundamentals() throws Exception { Mockito.any())).thenReturn(response); final ExecChain.Scope scope = new ExecChain.Scope("test", route, request, execRuntime, context); - final ClassicHttpResponse finalResponse = mainClientExec.execute(request, scope, null); + mainClientExec.execute(request, scope, null); Mockito.verify(httpProcessor).process(request, null, context); Mockito.verify(execRuntime).execute(Mockito.eq("test"), Mockito.same(request), Mockito.any(), Mockito.any()); diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java index 67eef8475..531febeef 100644 --- a/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java +++ b/httpclient5/src/test/java/org/apache/hc/client5/http/utils/TestDateUtils.java @@ -33,7 +33,6 @@ import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; -import java.util.Date; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.message.BasicHeader; @@ -50,11 +49,6 @@ private static Instant createInstant(final int year, final Month month, final in return LocalDate.of(year, month, day).atStartOfDay(ZoneId.of("GMT")).toInstant(); } - private static Date createDate(final int year, final Month month, final int day) { - final Instant instant = createInstant(year, month, day); - return new Date(instant.toEpochMilli()); - } - @Test void testBasicDateParse() { final Instant instant = createInstant(2005, Month.OCTOBER, 14);