-
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.
Merge pull request #40255 from antonwiens/40244-content-type-case-ins…
…ensitive Make resteasy-reactive AbstractJsonMessageBodyReader handle MediaType case insensitive
- Loading branch information
Showing
2 changed files
with
50 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
45 changes: 45 additions & 0 deletions
45
...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,45 @@ | ||
package org.jboss.resteasy.reactive.common.providers.serialisers; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
|
||
import jakarta.ws.rs.WebApplicationException; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.MultivaluedMap; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
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)); | ||
} | ||
} |