mirror of https://github.com/jwtk/jjwt.git
Gson Serializer/Deserializer are now correctly registered service when found on the classpath
Added test to other serializer implementations as well Fixes: #563
This commit is contained in:
parent
0fd59efc93
commit
111633fa88
|
@ -5,6 +5,7 @@
|
||||||
This patch release:
|
This patch release:
|
||||||
|
|
||||||
* Fixes issue when using Java 9+ `Map.of` with JacksonDeserializer which resulted in an NullPointerException
|
* Fixes issue when using Java 9+ `Map.of` with JacksonDeserializer which resulted in an NullPointerException
|
||||||
|
* Fixes issue preventing Gson seralizer/deserializer implementation from being detected automatically
|
||||||
|
|
||||||
### 0.11.0
|
### 0.11.0
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,22 @@ package io.jsonwebtoken.gson.io
|
||||||
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import io.jsonwebtoken.io.DeserializationException
|
import io.jsonwebtoken.io.DeserializationException
|
||||||
|
import io.jsonwebtoken.io.Deserializer
|
||||||
import io.jsonwebtoken.lang.Strings
|
import io.jsonwebtoken.lang.Strings
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*
|
import static org.easymock.EasyMock.*
|
||||||
import static org.junit.Assert.*
|
import static org.junit.Assert.*
|
||||||
|
import static org.hamcrest.CoreMatchers.instanceOf
|
||||||
|
|
||||||
class GsonDeserializerTest {
|
class GsonDeserializerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadService() {
|
||||||
|
def deserializer = ServiceLoader.load(Deserializer).iterator().next()
|
||||||
|
assertThat(deserializer, instanceOf(GsonDeserializer))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDefaultConstructor() {
|
void testDefaultConstructor() {
|
||||||
def deserializer = new GsonDeserializer()
|
def deserializer = new GsonDeserializer()
|
||||||
|
|
|
@ -15,16 +15,25 @@
|
||||||
*/
|
*/
|
||||||
package io.jsonwebtoken.gson.io
|
package io.jsonwebtoken.gson.io
|
||||||
|
|
||||||
|
import io.jsonwebtoken.io.Deserializer
|
||||||
|
import io.jsonwebtoken.io.Serializer
|
||||||
import io.jsonwebtoken.lang.Strings
|
import io.jsonwebtoken.lang.Strings
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*
|
import static org.easymock.EasyMock.*
|
||||||
import static org.junit.Assert.*
|
import static org.junit.Assert.*
|
||||||
|
import static org.hamcrest.CoreMatchers.instanceOf
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import io.jsonwebtoken.io.SerializationException
|
import io.jsonwebtoken.io.SerializationException
|
||||||
|
|
||||||
class GsonSerializerTest {
|
class GsonSerializerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadService() {
|
||||||
|
def serializer = ServiceLoader.load(Serializer).iterator().next()
|
||||||
|
assertThat(serializer, instanceOf(GsonSerializer))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDefaultConstructor() {
|
void testDefaultConstructor() {
|
||||||
def serializer = new GsonSerializer()
|
def serializer = new GsonSerializer()
|
||||||
|
|
|
@ -17,6 +17,7 @@ package io.jsonwebtoken.jackson.io
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
import io.jsonwebtoken.io.DeserializationException
|
import io.jsonwebtoken.io.DeserializationException
|
||||||
|
import io.jsonwebtoken.io.Deserializer
|
||||||
import io.jsonwebtoken.io.Encoders
|
import io.jsonwebtoken.io.Encoders
|
||||||
import io.jsonwebtoken.jackson.io.stubs.CustomBean
|
import io.jsonwebtoken.jackson.io.stubs.CustomBean
|
||||||
import io.jsonwebtoken.lang.Maps
|
import io.jsonwebtoken.lang.Maps
|
||||||
|
@ -25,8 +26,14 @@ import org.junit.Test
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*
|
import static org.easymock.EasyMock.*
|
||||||
import static org.junit.Assert.*
|
import static org.junit.Assert.*
|
||||||
|
import static org.hamcrest.CoreMatchers.instanceOf
|
||||||
|
|
||||||
class JacksonDeserializerTest {
|
class JacksonDeserializerTest {
|
||||||
|
@Test
|
||||||
|
void loadService() {
|
||||||
|
def deserializer = ServiceLoader.load(Deserializer).iterator().next()
|
||||||
|
assertThat(deserializer, instanceOf(JacksonDeserializer))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDefaultConstructor() {
|
void testDefaultConstructor() {
|
||||||
|
|
|
@ -18,14 +18,22 @@ package io.jsonwebtoken.jackson.io
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException
|
import com.fasterxml.jackson.core.JsonProcessingException
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper
|
import com.fasterxml.jackson.databind.ObjectMapper
|
||||||
import io.jsonwebtoken.io.SerializationException
|
import io.jsonwebtoken.io.SerializationException
|
||||||
|
import io.jsonwebtoken.io.Serializer
|
||||||
import io.jsonwebtoken.lang.Strings
|
import io.jsonwebtoken.lang.Strings
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
import static org.easymock.EasyMock.*
|
import static org.easymock.EasyMock.*
|
||||||
import static org.junit.Assert.*
|
import static org.junit.Assert.*
|
||||||
|
import static org.hamcrest.CoreMatchers.instanceOf
|
||||||
|
|
||||||
class JacksonSerializerTest {
|
class JacksonSerializerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadService() {
|
||||||
|
def serializer = ServiceLoader.load(Serializer).iterator().next()
|
||||||
|
assertThat(serializer, instanceOf(JacksonSerializer))
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDefaultConstructor() {
|
void testDefaultConstructor() {
|
||||||
def serializer = new JacksonSerializer()
|
def serializer = new JacksonSerializer()
|
||||||
|
|
|
@ -16,13 +16,21 @@
|
||||||
package io.jsonwebtoken.orgjson.io
|
package io.jsonwebtoken.orgjson.io
|
||||||
|
|
||||||
import io.jsonwebtoken.io.DeserializationException
|
import io.jsonwebtoken.io.DeserializationException
|
||||||
|
import io.jsonwebtoken.io.Deserializer
|
||||||
import io.jsonwebtoken.lang.Strings
|
import io.jsonwebtoken.lang.Strings
|
||||||
import io.jsonwebtoken.orgjson.io.OrgJsonDeserializer
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.instanceOf
|
||||||
import static org.junit.Assert.*
|
import static org.junit.Assert.*
|
||||||
|
|
||||||
class OrgJsonDeserializerTest {
|
class OrgJsonDeserializerTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadService() {
|
||||||
|
def deserializer = ServiceLoader.load(Deserializer).iterator().next()
|
||||||
|
assertThat(deserializer, instanceOf(OrgJsonDeserializer))
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException)
|
@Test(expected=IllegalArgumentException)
|
||||||
void testNullArgument() {
|
void testNullArgument() {
|
||||||
def d = new OrgJsonDeserializer()
|
def d = new OrgJsonDeserializer()
|
||||||
|
|
|
@ -17,15 +17,16 @@ package io.jsonwebtoken.orgjson.io
|
||||||
|
|
||||||
import io.jsonwebtoken.SignatureAlgorithm
|
import io.jsonwebtoken.SignatureAlgorithm
|
||||||
import io.jsonwebtoken.io.SerializationException
|
import io.jsonwebtoken.io.SerializationException
|
||||||
|
import io.jsonwebtoken.io.Serializer
|
||||||
import io.jsonwebtoken.lang.DateFormats
|
import io.jsonwebtoken.lang.DateFormats
|
||||||
import io.jsonwebtoken.lang.Strings
|
import io.jsonwebtoken.lang.Strings
|
||||||
import io.jsonwebtoken.orgjson.io.OrgJsonSerializer
|
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.json.JSONString
|
import org.json.JSONString
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
import static org.junit.Assert.*
|
import static org.junit.Assert.*
|
||||||
|
import static org.hamcrest.CoreMatchers.instanceOf
|
||||||
|
|
||||||
class OrgJsonSerializerTest {
|
class OrgJsonSerializerTest {
|
||||||
|
|
||||||
|
@ -41,6 +42,12 @@ class OrgJsonSerializerTest {
|
||||||
return new String(bytes, Strings.UTF_8)
|
return new String(bytes, Strings.UTF_8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loadService() {
|
||||||
|
def serializer = ServiceLoader.load(Serializer).iterator().next()
|
||||||
|
assertThat(serializer, instanceOf(OrgJsonSerializer))
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected = SerializationException)
|
@Test(expected = SerializationException)
|
||||||
void testInvalidArgument() {
|
void testInvalidArgument() {
|
||||||
s.serialize(new Object())
|
s.serialize(new Object())
|
||||||
|
|
Loading…
Reference in New Issue