mirror of
https://github.com/jwtk/jjwt.git
synced 2025-02-16 19:04:44 +00:00
Fix locator paths and added tests.
This commit is contained in:
parent
486305f6c3
commit
134f25b536
@ -34,7 +34,7 @@ public class RuntimeClasspathDeserializerLocator<T> implements InstanceLocator<D
|
||||
return Classes.newInstance("io.jsonwebtoken.io.JacksonDeserializer");
|
||||
} else if (isAvailable("io.jsonwebtoken.io.OrgJsonDeserializer")) {
|
||||
return Classes.newInstance("io.jsonwebtoken.io.OrgJsonDeserializer");
|
||||
} else if (isAvailable("com.google.gson.GsonBuilder")) {
|
||||
} else if (isAvailable("io.jsonwebtoken.io.GsonDeSerializer")) {
|
||||
return Classes.newInstance("io.jsonwebtoken.io.GsonDeSerializer");
|
||||
} else {
|
||||
throw new IllegalStateException("Unable to discover any JSON Deserializer implementations on the classpath.");
|
||||
|
@ -34,7 +34,7 @@ public class RuntimeClasspathSerializerLocator implements InstanceLocator<Serial
|
||||
return Classes.newInstance("io.jsonwebtoken.io.JacksonSerializer");
|
||||
} else if (isAvailable("io.jsonwebtoken.io.OrgJsonSerializer")) {
|
||||
return Classes.newInstance("io.jsonwebtoken.io.OrgJsonSerializer");
|
||||
} else if (isAvailable("com.google.gson.GsonBuilder")) {
|
||||
} else if (isAvailable("io.jsonwebtoken.io.GsonSerializer")) {
|
||||
return Classes.newInstance("io.jsonwebtoken.io.GsonSerializer");
|
||||
} else {
|
||||
throw new IllegalStateException("Unable to discover any JSON Serializer implementations on the classpath.");
|
||||
|
@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import io.jsonwebtoken.io.Deserializer
|
||||
import io.jsonwebtoken.io.JacksonDeserializer
|
||||
import io.jsonwebtoken.io.OrgJsonDeserializer
|
||||
import io.jsonwebtoken.io.GsonDeserializer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@ -96,4 +97,23 @@ class RuntimeClasspathDeserializerLocatorTest {
|
||||
def deserializer = locator.getInstance()
|
||||
assertTrue deserializer instanceof OrgJsonDeserializer
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGson() {
|
||||
def locator = new RuntimeClasspathDeserializerLocator() {
|
||||
@Override
|
||||
protected boolean isAvailable(String fqcn) {
|
||||
if (JacksonDeserializer.class.getName().equals(fqcn)) {
|
||||
return false; //skip it to allow the Gson impl to be created
|
||||
}
|
||||
if (OrgJsonDeserializer.class.getName().equals(fqcn)) {
|
||||
return false; //skip it to allow the Gson impl to be created
|
||||
}
|
||||
return super.isAvailable(fqcn)
|
||||
}
|
||||
}
|
||||
|
||||
def deserializer = locator.getInstance()
|
||||
assertTrue deserializer instanceof GsonDeserializer
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package io.jsonwebtoken.impl.io
|
||||
import io.jsonwebtoken.io.Serializer
|
||||
import io.jsonwebtoken.io.JacksonSerializer
|
||||
import io.jsonwebtoken.io.OrgJsonSerializer
|
||||
import io.jsonwebtoken.io.GsonSerializer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@ -95,4 +96,23 @@ class RuntimeClasspathSerializerLocatorTest {
|
||||
def serializer = locator.getInstance()
|
||||
assertTrue serializer instanceof OrgJsonSerializer
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGson() {
|
||||
def locator = new RuntimeClasspathSerializerLocator() {
|
||||
@Override
|
||||
protected boolean isAvailable(String fqcn) {
|
||||
if (JacksonSerializer.class.getName().equals(fqcn)) {
|
||||
return false //skip it to allow the Gson impl to be created
|
||||
}
|
||||
if (OrgJsonSerializer.class.getName().equals(fqcn)) {
|
||||
return false //skip it to allow the Gson impl to be created
|
||||
}
|
||||
return super.isAvailable(fqcn)
|
||||
}
|
||||
}
|
||||
|
||||
def serializer = locator.getInstance()
|
||||
assertTrue serializer instanceof GsonSerializer
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user