Skip to content
This repository has been archived by the owner on Jan 4, 2020. It is now read-only.

markenwerk/java-utils-json-handler-replay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Replaying handler for JSON libraries

Build Status Coverage Status Dependency Status Maven Central Issues MIT License

Overview

This library provides a replaying JSON handlers for other JSON processing libraries.

Consult the documentation and the usage description for further information:

Maven

This library is hosted in the Maven Central Repository. You can use it with the following coordinates:

<dependency>
	<groupId>net.markenwerk</groupId>
	<artifactId>utils-json-handler-replay</artifactId>
	<version>1.0.0</version>
</dependency>

Usage

Replaying handler

A RecordingJsonHandler is a JsonHandler that creates a JsonReplay of the described JSON document. A JsonReplay represents a sequence of JsonEvents and is able to replay these events to another JsonHandler.

// a JsonDocument
JsonDocument document = ...

// a JsonHandler
JsonHandler handler = ...

// returns a JsonReplay  
JsonReplay replay = document.handle(new RecordingJsonHandler());

// replay the JsonDocument to the JsonHandler
replay.repplay(handler); 

A RecordingJsonHandler is useful when testing a component that takes a JsonHandler, because the generated JsonReplay can be used to easily check, if the correct callback methods have been called.

// a JsonReplay
JsonReply replay = ...

// check the replay against an expected sequence of JsonEvents
replay.assertEquals(
	new DocumentBeginJsonEvent(),
	new NullJsonEvent(),
	new DocumentBeginJsonEvent(),
);

About

Replaying handler for JSON libraries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages