@Test
public void putOnce() {

    JSONObject obj = new JSONObject();
    assertSame(obj, obj.putOnce("foo", "bar"));
    assertJSONEx(() -> obj.putOnce("foo", "baz"), "Duplicate key \"foo\"");
    assertEquals("bar", obj.getString("foo"));
}