public void testSimpleValidObject() throws Exception
{
JsonFactory jsonF = new JsonFactory();
DataFormatDetector detector = new DataFormatDetector(jsonF);
final String JSON = "{ \"field\" : true }";
DataFormatMatcher matcher = detector.findFormat(new ByteArrayInputStream(JSON.getBytes("UTF-8")));
// should have match
assertTrue(matcher.hasMatch());
assertEquals("JSON", matcher.getMatchedFormatName());
assertSame(jsonF, matcher.getMatch());
// no "certain" match with JSON, but solid:
assertEquals(MatchStrength.SOLID_MATCH, matcher.getMatchStrength());
// and thus:
JsonParser jp = matcher.createParserWithMatch();
assertToken(JsonToken.START_OBJECT, jp.nextToken());
assertToken(JsonToken.FIELD_NAME, jp.nextToken());
assertEquals("field", jp.getCurrentName());
assertToken(JsonToken.VALUE_TRUE, jp.nextToken());
assertToken(JsonToken.END_OBJECT, jp.nextToken());