summaryrefslogtreecommitdiffstats
path: root/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'document/src/test/java/com/yahoo/document/DocumentIdTestCase.java')
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentIdTestCase.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
index a0c5da52ff7..4cc4e75ea78 100644
--- a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
@@ -2,6 +2,7 @@
package com.yahoo.document;
import com.yahoo.document.idstring.IdIdString;
+import com.yahoo.document.idstring.IdString;
import com.yahoo.vespa.objects.BufferSerializer;
import org.junit.Before;
import org.junit.Rule;
@@ -256,4 +257,20 @@ public class DocumentIdTestCase {
}
}
+ @Test
+ public void testTooLongDocId() {
+ StringBuilder sb = new StringBuilder("id:ns:type::");
+ for(int i=0; i < 0x10000; i++) {
+ sb.append('x');
+ }
+ try {
+ new DocumentId(sb.toString());
+ fail("Expected an IllegalArgumentException to be thrown");
+ } catch (IllegalArgumentException ex) {
+ assertTrue(ex.getMessage().contains("However if you have already fed a document earlier on and want to remove it, " +
+ "you can do so by calling new DocumentId(IdString.createIdStringLessStrict()) that will bypass this restriction."));
+ }
+ assertEquals(65548, new DocumentId(IdString.createIdStringLessStrict(sb.toString())).toString().length());
+ }
+
}