@Test public void testInvalidKeys() throws IOException { for (String s : Arrays.asList("[", "]", ".", "%", "$", "#", "\n")) { try { jsondb.set("/test"+s, mapper.writeValueAsString(map( "key", "Hiram Chirino" ))); fail("Excpected JsonDBException"); } catch (JsonDBException e) { assertThat(e.getMessage()).startsWith("Invalid key."); } } for (String s : Arrays.asList("[", "]", ".", "%", "$", "#", "/", "\n")) { try { jsondb.set("/test", mapper.writeValueAsString(map( "bad"+s+"key", "Hiram Chirino" ))); fail("Excpected JsonDBException"); } catch (JsonDBException e) { assertThat(e.getMessage()).startsWith("Invalid key."); } } }
@Test public void testInvalidKeys() throws IOException { for (String s : Arrays.asList("[", "]", ".", "%", "$", "#", "\n")) { try { jsondb.set("/test"+s, mapper.writeValueAsString(map( "key", "Hiram Chirino" ))); fail("Excpected JsonDBException"); } catch (JsonDBException e) { assertThat(e.getMessage()).startsWith("Invalid key."); } } for (String s : Arrays.asList("[", "]", ".", "%", "$", "#", "/", "\n")) { try { jsondb.set("/test", mapper.writeValueAsString(map( "bad"+s+"key", "Hiram Chirino" ))); fail("Excpected JsonDBException"); } catch (JsonDBException e) { assertThat(e.getMessage()).startsWith("Invalid key."); } } }