public class BasicJsonTester
extends java.lang.Object
public class ExampleObjectJsonTests { private BasicJsonTester json = new BasicJsonTester(getClass()); @Test public void testWriteJson() throws IOException { assertThat(json.from("example.json")).extractingJsonPathStringValue("@.name") .isEqualTo("Spring"); } }See
AbstractJsonMarshalTester
for more details.Modifier | Constructor and Description |
---|---|
protected |
BasicJsonTester()
Create a new uninitialized
BasicJsonTester instance. |
|
BasicJsonTester(java.lang.Class<?> resourceLoadClass)
Create a new
BasicJsonTester instance that will load resources as UTF-8. |
|
BasicJsonTester(java.lang.Class<?> resourceLoadClass,
java.nio.charset.Charset charset)
Create a new
BasicJsonTester instance. |
Modifier and Type | Method and Description |
---|---|
JsonContent<java.lang.Object> |
from(byte[] source)
Create JSON content from the specified JSON bytes.
|
JsonContent<java.lang.Object> |
from(java.lang.CharSequence source)
Create JSON content from the specified String source.
|
JsonContent<java.lang.Object> |
from(java.io.File source)
Create JSON content from the specified JSON file.
|
JsonContent<java.lang.Object> |
from(java.io.InputStream source)
Create JSON content from the specified JSON input stream.
|
JsonContent<java.lang.Object> |
from(org.springframework.core.io.Resource source)
Create JSON content from the specified JSON resource.
|
JsonContent<java.lang.Object> |
from(java.lang.String path,
java.lang.Class<?> resourceLoadClass)
Create JSON content from the specified resource path.
|
protected void |
initialize(java.lang.Class<?> resourceLoadClass)
Initialize the marshal tester for use, configuring it to load JSON resources as
UTF-8.
|
protected void |
initialize(java.lang.Class<?> resourceLoadClass,
java.nio.charset.Charset charset)
Initialize the marshal tester for use.
|
protected BasicJsonTester()
BasicJsonTester
instance.public BasicJsonTester(java.lang.Class<?> resourceLoadClass)
BasicJsonTester
instance that will load resources as UTF-8.resourceLoadClass
- the source class used to load resourcespublic BasicJsonTester(java.lang.Class<?> resourceLoadClass, java.nio.charset.Charset charset)
BasicJsonTester
instance.resourceLoadClass
- the source class used to load resourcescharset
- the charset used to load resourcesprotected final void initialize(java.lang.Class<?> resourceLoadClass)
resourceLoadClass
- the source class used when loading relative classpath
resourcesprotected final void initialize(java.lang.Class<?> resourceLoadClass, java.nio.charset.Charset charset)
resourceLoadClass
- the source class used when loading relative classpath
resourcescharset
- the charset used when loading relative classpath resourcespublic JsonContent<java.lang.Object> from(java.lang.CharSequence source)
.json
, the name of a resource to be loaded
using resourceLoadClass
.source
- the JSON content or a .json
resource namepublic JsonContent<java.lang.Object> from(java.lang.String path, java.lang.Class<?> resourceLoadClass)
path
- the path of the resource to loadresourceLoadClass
- the source class used to load the resourcepublic JsonContent<java.lang.Object> from(byte[] source)
source
- the bytes of JSONpublic JsonContent<java.lang.Object> from(java.io.File source)
source
- the file containing JSONpublic JsonContent<java.lang.Object> from(java.io.InputStream source)
source
- the input stream containing JSONpublic JsonContent<java.lang.Object> from(org.springframework.core.io.Resource source)
source
- the resource containing JSON