diff --git a/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyLaxClientCookieEncoderSpec.groovy b/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyLaxClientCookieEncoderSpec.groovy index 5b145a01368..dd703d0413d 100644 --- a/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyLaxClientCookieEncoderSpec.groovy +++ b/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyLaxClientCookieEncoderSpec.groovy @@ -2,7 +2,6 @@ package io.micronaut.http.netty.cookies import io.micronaut.http.cookie.ClientCookieEncoder import io.micronaut.http.cookie.Cookie - import spock.lang.Specification class NettyLaxClientCookieEncoderSpec extends Specification { @@ -17,4 +16,9 @@ class NettyLaxClientCookieEncoderSpec extends Specification { then: "SID=31d4d96e407aad42" == cookieEncoder.encode(cookie) } + + void "ClientCookieEncoder is NettyLaxClientCookieDecoder"() { + expect: + ClientCookieEncoder.INSTANCE instanceof NettyLaxClientCookieEncoder + } } diff --git a/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyLaxServerCookieDecoderSpec.groovy b/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyLaxServerCookieDecoderSpec.groovy new file mode 100644 index 00000000000..2ad2c8e2117 --- /dev/null +++ b/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyLaxServerCookieDecoderSpec.groovy @@ -0,0 +1,14 @@ +package io.micronaut.http.netty.cookies + +import io.micronaut.core.order.OrderUtil +import io.micronaut.http.cookie.DefaultServerCookieDecoder +import io.micronaut.http.cookie.ServerCookieDecoder +import spock.lang.Specification + +class NettyLaxServerCookieDecoderSpec extends Specification { + + void "ServerCookieDecoder is NettyLaxServerCookieDecoder"() { + expect: + ServerCookieDecoder.INSTANCE instanceof NettyLaxServerCookieDecoder + } +} diff --git a/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyServerCookieEncoderSpec.groovy b/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyServerCookieEncoderSpec.groovy index 9a891027a29..c9d2e43db22 100644 --- a/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyServerCookieEncoderSpec.groovy +++ b/http-netty/src/test/groovy/io/micronaut/http/netty/cookies/NettyServerCookieEncoderSpec.groovy @@ -36,13 +36,19 @@ class NettyServerCookieEncoderSpec extends Specification { when: long maxAge = 2592000 + cookie = Cookie.of("id", "a3fWa").maxAge(maxAge) + String result = cookieEncoder.encode(cookie).get(0) String expected = "id=a3fWa; Max-Age=2592000; " + Cookie.ATTRIBUTE_EXPIRES + "=" + expires(maxAge) String expected2 = "id=a3fWa; Max-Age=2592000; " + Cookie.ATTRIBUTE_EXPIRES + "=" + expires(maxAge + 1) // To prevent flakiness - cookie = Cookie.of("id", "a3fWa").maxAge(maxAge); - String result = cookieEncoder.encode(cookie).get(0); + String expected3 = "id=a3fWa; Max-Age=2592000; " + Cookie.ATTRIBUTE_EXPIRES + "=" + expires(maxAge - 1) // To prevent flakiness then: - expected == result || expected2 == result + expected == result || expected2 == result || expected3 == result + } + + void "ServerCookieEncoder is NettyServerCookieEncoder"() { + expect: + ServerCookieEncoder.INSTANCE instanceof NettyServerCookieEncoder } private static String expires(Long maxAgeSeconds) { diff --git a/http/src/main/resources/META-INF/services/io.micronaut.http.cookie.ClientCookieEncoder b/http/src/main/resources/META-INF/services/io.micronaut.http.cookie.ClientCookieEncoder deleted file mode 100644 index 4f3527ee60b..00000000000 --- a/http/src/main/resources/META-INF/services/io.micronaut.http.cookie.ClientCookieEncoder +++ /dev/null @@ -1 +0,0 @@ -io.micronaut.http.cookie.DefaultClientCookieEncoder \ No newline at end of file diff --git a/http/src/main/resources/META-INF/services/io.micronaut.http.cookie.ServerCookieDecoder b/http/src/main/resources/META-INF/services/io.micronaut.http.cookie.ServerCookieDecoder deleted file mode 100644 index bf132fb4dcc..00000000000 --- a/http/src/main/resources/META-INF/services/io.micronaut.http.cookie.ServerCookieDecoder +++ /dev/null @@ -1 +0,0 @@ -io.micronaut.http.cookie.DefaultServerCookieDecoder \ No newline at end of file diff --git a/http/src/main/resources/META-INF/services/io.micronaut.http.cookie.ServerCookieEncoder b/http/src/main/resources/META-INF/services/io.micronaut.http.cookie.ServerCookieEncoder deleted file mode 100644 index f51cbfd3e69..00000000000 --- a/http/src/main/resources/META-INF/services/io.micronaut.http.cookie.ServerCookieEncoder +++ /dev/null @@ -1 +0,0 @@ -io.micronaut.http.cookie.DefaultServerCookieEncoder \ No newline at end of file diff --git a/http/src/test/java/io/micronaut/http/cookie/DefaultClientCookieEncoderTest.java b/http/src/test/java/io/micronaut/http/cookie/DefaultClientCookieEncoderTest.java index d3a150088be..39addfbfb6a 100644 --- a/http/src/test/java/io/micronaut/http/cookie/DefaultClientCookieEncoderTest.java +++ b/http/src/test/java/io/micronaut/http/cookie/DefaultClientCookieEncoderTest.java @@ -3,8 +3,14 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; class DefaultClientCookieEncoderTest { + @Test + void clientCookieEncoderIsDefaultClientCookieEncoder() { + assertInstanceOf(DefaultClientCookieEncoder.class, ClientCookieEncoder.INSTANCE); + } + @Test void clientCookieEncoding() { ClientCookieEncoder cookieEncoder = new DefaultClientCookieEncoder(); diff --git a/http/src/test/java/io/micronaut/http/cookie/DefaultServerCookieDecoderTest.java b/http/src/test/java/io/micronaut/http/cookie/DefaultServerCookieDecoderTest.java index 02f379d7134..1d91600ad9b 100644 --- a/http/src/test/java/io/micronaut/http/cookie/DefaultServerCookieDecoderTest.java +++ b/http/src/test/java/io/micronaut/http/cookie/DefaultServerCookieDecoderTest.java @@ -7,6 +7,10 @@ import static org.junit.jupiter.api.Assertions.*; class DefaultServerCookieDecoderTest { + @Test + void serverCookieDecoderIsDefaultServerCookieDecoder() { + assertInstanceOf(DefaultServerCookieDecoder.class, ServerCookieDecoder.INSTANCE); + } @Test void testCookieDecoding() { diff --git a/http/src/test/java/io/micronaut/http/cookie/DefaultServerCookieEncoderTest.java b/http/src/test/java/io/micronaut/http/cookie/DefaultServerCookieEncoderTest.java index a75381316a2..4f981dfcc54 100644 --- a/http/src/test/java/io/micronaut/http/cookie/DefaultServerCookieEncoderTest.java +++ b/http/src/test/java/io/micronaut/http/cookie/DefaultServerCookieEncoderTest.java @@ -7,8 +7,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; class DefaultServerCookieEncoderTest { @@ -32,6 +31,11 @@ void encodeCookie() { assertTrue(expected.equals(result) || expected2.equals(result)); } + @Test + void serverCookieEncoderIsDefaultServerCookieEncoder() { + assertInstanceOf(DefaultServerCookieEncoder.class, ServerCookieEncoder.INSTANCE); + } + private static String expires(Long maxAgeSeconds) { ZoneId gmtZone = ZoneId.of("GMT"); LocalDateTime localDateTime = LocalDateTime.now(gmtZone).plusSeconds(maxAgeSeconds);