|
16 | 16 | package io.jsonwebtoken.impl |
17 | 17 |
|
18 | 18 | import com.fasterxml.jackson.databind.ObjectMapper |
| 19 | +import io.jsonwebtoken.JwtParser |
19 | 20 | import io.jsonwebtoken.Jwts |
20 | 21 | import io.jsonwebtoken.SignatureAlgorithm |
21 | 22 | import io.jsonwebtoken.io.Decoder |
22 | 23 | import io.jsonwebtoken.io.DecodingException |
23 | 24 | import io.jsonwebtoken.io.DeserializationException |
24 | 25 | import io.jsonwebtoken.io.Deserializer |
25 | 26 | import io.jsonwebtoken.security.Keys |
| 27 | +import org.hamcrest.CoreMatchers |
26 | 28 | import org.junit.Test |
27 | 29 |
|
| 30 | +import static org.easymock.EasyMock.niceMock |
28 | 31 | import static org.junit.Assert.assertEquals |
29 | 32 | import static org.junit.Assert.assertSame |
| 33 | +import static org.hamcrest.MatcherAssert.assertThat |
30 | 34 |
|
31 | 35 | // NOTE to the casual reader: even though this test class appears mostly empty, the DefaultJwtParserBuilder |
32 | 36 | // implementation is tested to 100% coverage. The vast majority of its tests are in the JwtsTest class. This class |
@@ -92,4 +96,25 @@ class DefaultJwtParserBuilderTest { |
92 | 96 | assertEquals DefaultJwtParserBuilder.MAX_CLOCK_SKEW_ILLEGAL_MSG, expected.message |
93 | 97 | } |
94 | 98 | } |
| 99 | + |
| 100 | + @Test |
| 101 | + void testDefaultDecoder() { |
| 102 | + JwtParser parser = new DefaultJwtParserBuilder().build() |
| 103 | + assertThat parser.jwtParser.deserializer, CoreMatchers.instanceOf(JwtDeserializer) |
| 104 | + |
| 105 | + // TODO: When the ImmutableJwtParser replaces the default implementation this test will need updating, something like: |
| 106 | + // assertThat parser.deserializer, CoreMatchers.instanceOf(JwtDeserializer) |
| 107 | + } |
| 108 | + |
| 109 | + @Test |
| 110 | + void testUserSetDecoderWrapsImplementation() { |
| 111 | + Deserializer deserializer = niceMock(Deserializer) |
| 112 | + JwtParser parser = new DefaultJwtParserBuilder() |
| 113 | + .deserializeJsonWith(deserializer) |
| 114 | + .build() |
| 115 | + |
| 116 | + // TODO: When the ImmutableJwtParser replaces the default implementation this test will need updating |
| 117 | + assertThat parser.jwtParser.deserializer, CoreMatchers.instanceOf(JwtDeserializer) |
| 118 | + assertSame deserializer, parser.jwtParser.deserializer.deserializer |
| 119 | + } |
95 | 120 | } |
0 commit comments