public class BasicJsonTester extends 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(Class<?> resourceLoadClass)
Create a new
BasicJsonTester instance that will load resources as UTF-8. |
|
BasicJsonTester(Class<?> resourceLoadClass,
Charset charset)
Create a new
BasicJsonTester instance. |
Modifier and Type | Method and Description |
---|---|
JsonContent<Object> |
from(byte[] source)
Create JSON content from the specified JSON bytes.
|
JsonContent<Object> |
from(CharSequence source)
Create JSON content from the specified String source.
|
JsonContent<Object> |
from(File source)
Create JSON content from the specified JSON file.
|
JsonContent<Object> |
from(InputStream source)
Create JSON content from the specified JSON input stream.
|
JsonContent<Object> |
from(Resource source)
Create JSON content from the specified JSON resource.
|
JsonContent<Object> |
from(String path,
Class<?> resourceLoadClass)
Create JSON content from the specified resource path.
|
protected void |
initialize(Class<?> resourceLoadClass)
Initialize the marshal tester for use, configuring it to load JSON resources as
UTF-8.
|
protected void |
initialize(Class<?> resourceLoadClass,
Charset charset)
Initialize the marshal tester for use.
|
protected BasicJsonTester()
BasicJsonTester
instance.public BasicJsonTester(Class<?> resourceLoadClass)
BasicJsonTester
instance that will load resources as UTF-8.resourceLoadClass
- the source class used to load resourcespublic BasicJsonTester(Class<?> resourceLoadClass, Charset charset)
BasicJsonTester
instance.resourceLoadClass
- the source class used to load resourcescharset
- the charset used to load resourcesprotected final void initialize(Class<?> resourceLoadClass)
resourceLoadClass
- the source class used when loading relative classpath
resourcesprotected final void initialize(Class<?> resourceLoadClass, Charset charset)
resourceLoadClass
- the source class used when loading relative classpath
resourcescharset
- the charset used when loading relative classpath resourcespublic JsonContent<Object> from(CharSequence source)
.json
, the name of a resource to be loaded
using resourceLoadClass
.source
- the JSON content or a .json
resource namepublic JsonContent<Object> from(String path, Class<?> resourceLoadClass)
path
- the path of the resource to loadresourceLoadClass
- the source class used to load the resourcepublic JsonContent<Object> from(byte[] source)
source
- the bytes of JSONpublic JsonContent<Object> from(File source)
source
- the file containing JSONpublic JsonContent<Object> from(InputStream source)
source
- the input stream containing JSONpublic JsonContent<Object> from(Resource source)
source
- the resource containing JSONCopyright © 2019 Pivotal Software, Inc.. All rights reserved.