Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RESTEASY-2347] added property check and related unit test
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 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
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
43 changes: 43 additions & 0 deletions
43
testsuite/unit-tests/src/test/java/org/jboss/resteasy/test/providers/JsonBindingTest.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,43 @@ | ||
package org.jboss.resteasy.test.providers; | ||
|
||
import org.jboss.resteasy.plugins.providers.jsonb.JsonBindingProvider; | ||
import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters; | ||
import javax.ws.rs.core.MediaType; | ||
import org.junit.Test; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
/** | ||
* Check when ResteasyConfiguration.class is null in JsonBindingProvider | ||
* system property is checked and the property is set accordingly. | ||
* There are integration tests that check the properly setting when | ||
* a ResteasyConfiguration.class is provided. | ||
*/ | ||
public class JsonBindingTest { | ||
private MediaType mediaType = new MediaType("application", "json"); | ||
|
||
@Test | ||
public void testUseJSONB() throws Exception | ||
{ | ||
String origValue = System.getProperty(ResteasyContextParameters.RESTEASY_PREFER_JACKSON_OVER_JSONB); | ||
|
||
System.setProperty(ResteasyContextParameters.RESTEASY_PREFER_JACKSON_OVER_JSONB, "true"); | ||
JsonBindingProvider jbp = new JsonBindingProvider(); | ||
boolean result = jbp.isReadable(null, null, null, mediaType); | ||
|
||
if (origValue == null) { | ||
System.setProperty(ResteasyContextParameters.RESTEASY_PREFER_JACKSON_OVER_JSONB, ""); | ||
} else { | ||
System.setProperty(ResteasyContextParameters.RESTEASY_PREFER_JACKSON_OVER_JSONB, origValue); | ||
} | ||
assertFalse(result); | ||
} | ||
|
||
@Test | ||
public void testUseJACKSON() throws Exception | ||
{ | ||
JsonBindingProvider jbp = new JsonBindingProvider(); | ||
boolean result = jbp.isReadable(null, null, null, mediaType); | ||
assertTrue(result); | ||
} | ||
} |