@Test
public void testDuplicateKeys()
{

    JsonObject jsonObj = new JsonObject(2)
                                .add(new DupStr(1), 0)
                                .add(new DupStr(2), 1);
    try{
        jsonObj.toJSON();
        fail("Expected a DuplicatePropertyNameException to be thrown");
    }catch ( DuplicatePropertyNameException e ){
        assertThat(e.getMessage(), is("Property x occurs twice in the same object."));
    }
}