/** Test adding two non-overlapping settings of the same annotation */ public void testTwoNonOverlappingAnnotations() { init("<p>abcdef</p>"); doc.setAnnotation(2, 4, "style/color", "lola"); doc.setAnnotation(5, 6, "style/color", "lola"); assertOperationResult( "<p>a<?a \"style/color\"=\"lola\"?>bc<?a \"style/color\"?>d" + "<?a \"style/color\"=\"lola\"?>e<?a \"style/color\"?>f</p>"); }
/** Test adding two non-overlapping settings of the same annotation */ public void testTwoNonOverlappingAnnotations() { init("<p>abcdef</p>"); doc.setAnnotation(2, 4, "style/color", "lola"); doc.setAnnotation(5, 6, "style/color", "lola"); assertOperationResult( "<p>a<?a \"style/color\"=\"lola\"?>bc<?a \"style/color\"?>d" + "<?a \"style/color\"=\"lola\"?>e<?a \"style/color\"?>f</p>"); }
/** Test adding two overlapping settings of the same annotation */ public void testTwoOverlappingAnnotations() { init("<p>abcdef</p>"); doc.setAnnotation(2, 4, "style/color", "charlie"); doc.setAnnotation(3, 6, "style/color", "charlie"); assertOperationResult( "<p>a<?a \"style/color\"=\"charlie\"?>bcde<?a \"style/color\"?>f</p>"); }
/** Test adding two overlapping settings of the same annotation */ public void testTwoOverlappingAnnotations() { init("<p>abcdef</p>"); doc.setAnnotation(2, 4, "style/color", "charlie"); doc.setAnnotation(3, 6, "style/color", "charlie"); assertOperationResult( "<p>a<?a \"style/color\"=\"charlie\"?>bcde<?a \"style/color\"?>f</p>"); }
/** * Test that trying to add an annotation with a negative start throws * an IndexOutOfBoundsException. */ public void testNegativeStartSetAnnotationThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.setAnnotation(-1, 4, "style/color", "frub"); // Doh - no exception thrown. Fail the test assert false; } catch (IndexOutOfBoundsException iae) { // expected } }
/** * Test that trying to add an annotation with a negative start throws * an IndexOutOfBoundsException. */ public void testNegativeStartSetAnnotationThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.setAnnotation(-1, 4, "style/color", "frub"); // Doh - no exception thrown. Fail the test assert false; } catch (IndexOutOfBoundsException iae) { // expected } }
/** Test a simple set and unset of an annotation */ public void testSetAndUnsetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 6, "style/color", "maisy"); doc.setAnnotation(0, doc.size(), "style/color", null); assertOperationResult("<p>abcdef</p>"); }
/** Test a simple set and unset of an annotation */ public void testSetAndUnsetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 6, "style/color", "maisy"); doc.setAnnotation(0, doc.size(), "style/color", null); assertOperationResult("<p>abcdef</p>"); }
/** Test a simple set annotation */ public void testSetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 6, "style/color", "stix"); assertOperationResult( "<p>ab<?a \"style/color\"=\"stix\"?>cde<?a \"style/color\"?>f</p>"); }
/** Test that trying to add a zero range annotation does nothing */ public void testZeroRangeSetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 3, "style/color", "blum"); assertOperationResult("<p>abcdef</p>"); }
/** Test that trying to add a zero range annotation does nothing */ public void testZeroRangeSetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 3, "style/color", "blum"); assertOperationResult("<p>abcdef</p>"); }
/** Test a simple set annotation */ public void testSetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(3, 6, "style/color", "stix"); assertOperationResult( "<p>ab<?a \"style/color\"=\"stix\"?>cde<?a \"style/color\"?>f</p>"); }
/** * Test that trying to add an annotation with a negative range throws * an IndexOutOfBoundsException. */ public void testNegativeRangeSetAnnotationThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.setAnnotation(4, 1, "style/color", "slarken"); // Doh - no exception thrown. Fail the test fail(); } catch (IndexOutOfBoundsException iae) { // expected } }
/** * Test that trying to add an annotation with a negative range throws * an IndexOutOfBoundsException. */ public void testNegativeRangeSetAnnotationThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.setAnnotation(4, 1, "style/color", "slarken"); // Doh - no exception thrown. Fail the test fail(); } catch (IndexOutOfBoundsException iae) { // expected } }
/** Test adding an annotation over the whole document */ public void testSetAnnotationOverWholeDocument() { init("<p>abcdef</p>"); doc.setAnnotation(0, doc.size(), "style/color", "flim"); assertOperationResult( "<?a \"style/color\"=\"flim\"?><p>abcdef</p><?a \"style/color\"?>"); }
/** Test adding an annotation over the whole document */ public void testSetAnnotationOverWholeDocument() { init("<p>abcdef</p>"); doc.setAnnotation(0, doc.size(), "style/color", "flim"); assertOperationResult( "<?a \"style/color\"=\"flim\"?><p>abcdef</p><?a \"style/color\"?>"); }
/** * Test that trying to add an annotation with an end past the size throws * an IndexOutOfBoundsException. */ public void testSetAnnotationPastDocEndThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.setAnnotation(1, doc.size() + 1, "style/color", "frub"); // Doh - no exception thrown. Fail the test fail(); } catch (IndexOutOfBoundsException iae) { // expected } }
/** * Test that trying to add an annotation with an end past the size throws * an IndexOutOfBoundsException. */ public void testSetAnnotationPastDocEndThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.setAnnotation(1, doc.size() + 1, "style/color", "frub"); // Doh - no exception thrown. Fail the test fail(); } catch (IndexOutOfBoundsException iae) { // expected } }
/** Test a simple set and reset annotation */ public void testSetAndResetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(0, doc.size(), "style/color", "pato"); doc.resetAnnotation(3, 6, "style/color", "pato"); assertOperationResult( "<p>ab<?a \"style/color\"=\"pato\"?>cde<?a \"style/color\"?>f</p>"); }
/** Test a simple set and reset annotation */ public void testSetAndResetAnnotation() { init("<p>abcdef</p>"); doc.setAnnotation(0, doc.size(), "style/color", "pato"); doc.resetAnnotation(3, 6, "style/color", "pato"); assertOperationResult( "<p>ab<?a \"style/color\"=\"pato\"?>cde<?a \"style/color\"?>f</p>"); }