-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change abstractjsonmessagebodyreader to use lowercase mediatype for e…
…asier and more clear matching
- Loading branch information
antonwiens
committed
Apr 24, 2024
1 parent
e7ede18
commit 5b70a2f
Showing
2 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...oss/resteasy/reactive/common/providers/serialisers/AbstractJsonMessageBodyReaderTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.jboss.resteasy.reactive.common.providers.serialisers; | ||
|
||
import jakarta.ws.rs.WebApplicationException; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.MultivaluedMap; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class AbstractJsonMessageBodyReaderTest { | ||
|
||
class TestReader extends AbstractJsonMessageBodyReader { | ||
@Override | ||
public Object readFrom(Class<Object> aClass, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> multivaluedMap, InputStream inputStream) throws IOException, WebApplicationException { | ||
return null; | ||
} | ||
} | ||
|
||
@Test | ||
void isReadableCaseInsensitive() { | ||
final TestReader testReader = new TestReader(); | ||
assertFalse(testReader.isReadable(new MediaType("application", "jso"), Object.class)); | ||
assertFalse(testReader.isReadable(new MediaType("application", "json+anything"), Object.class)); | ||
assertFalse(testReader.isReadable(new MediaType("test", "json"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("test", "test+json"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("test", "x-ndjson"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("application", "test+json"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("application", "json"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("Application", "Json"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("appliCAtion", "json"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("application", "jSOn"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("application", "test+json"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("application", "x-ndjson"), Object.class)); | ||
assertTrue(testReader.isReadable(new MediaType("applIcation", "x-ndjson"), Object.class)); | ||
} | ||
} |