public void testSimpleValidString() throws Exception {
  JsonFactory jsonF=new JsonFactory();
  DataFormatDetector detector=new DataFormatDetector(jsonF);
  final String JSON="\"JSON!\"";
  DataFormatMatcher matcher=detector.findFormat(new ByteArrayInputStream(JSON.getBytes("UTF-8")));
  assertTrue(matcher.hasMatch());
  assertEquals("JSON",matcher.getMatchedFormatName());
  assertSame(jsonF,matcher.getMatch());
  assertEquals(MatchStrength.WEAK_MATCH,matcher.getMatchStrength());
  JsonParser jp=matcher.createParserWithMatch();
  assertToken(JsonToken.VALUE_STRING,jp.nextToken());
  assertEquals("JSON!",jp.getText());
  assertNull(jp.nextToken());
  jp.close();
}

public void testSimpleValidString ( ) throws Exception { JsonFactory jsonF = new JsonFactory ( ) ; DataFormatDetector detector = new DataFormatDetector ( jsonF ) ; final String JSON = "\"JSON!\"" ; DataFormatMatcher matcher = detector . findFormat ( new ByteArrayInputStream ( JSON . getBytes ( "UTF-8" ) ) ) ; assertTrue ( matcher . hasMatch ( ) ) ; assertEquals ( "JSON" , matcher . getMatchedFormatName ( ) ) ; assertSame ( jsonF , matcher . getMatch ( ) ) ; assertEquals ( MatchStrength . WEAK_MATCH , matcher . getMatchStrength ( ) ) ; JsonParser jp = matcher . createParserWithMatch ( ) ; assertToken ( JsonToken . VALUE_STRING , jp . nextToken ( ) ) ; assertEquals ( "JSON!" , jp . getText ( ) ) ; assertNull ( jp . nextToken ( ) ) ; jp . close ( ) ; }
while json string is not a strong match alone , it should be detected unless some better match is available
