@Test
    public void requireTooLongIdThrowsWhileParsing()  {
        StringBuilder builder = new StringBuilder("id:ns:type::namespacespecificpart_01");
        for (int i = 0; i < 0x10000; i++) {
            builder.append('n');
        }
        try {
            IdString.createIdString(builder.toString());
            fail();
        } catch (IllegalArgumentException e) {
            assertEquals("Document id length 65572 is longer than max length of 65536", e.getMessage());
        }
        // But there is a backdoor
        assertEquals(65572, IdString.createIdStringLessStrict(builder.toString()).toString().length());
    }
Created with IntelliJ IDEA.
User: magnarn
Date: 10/16/12
Time: 9:10 AM
document/src/test/java/com/yahoo/document/IdIdStringTest.java