/** * Test that trying to reset an annotation with a negative start throws * an IndexOutOfBoundsException. */ public void testNegativeStartResetAnnotationThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.resetAnnotation(-1, 4, "style/color", "frub"); // Doh - no exception thrown. Fail the test assert false; } catch (IndexOutOfBoundsException iae) { // expected } }
/** * Test that trying to reset an annotation with a negative start throws * an IndexOutOfBoundsException. */ public void testNegativeStartResetAnnotationThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.resetAnnotation(-1, 4, "style/color", "frub"); // Doh - no exception thrown. Fail the test assert false; } catch (IndexOutOfBoundsException iae) { // expected } }
/** Test a simple reset annotation */ public void testResetAnnotation() { init("<p>abcdef</p>"); doc.resetAnnotation(3, 6, "style/color", "pocoyo"); assertOperationResult( "<p>ab<?a \"style/color\"=\"pocoyo\"?>cde<?a \"style/color\"?>f</p>"); }
/** Test a simple reset annotation */ public void testResetAnnotation() { init("<p>abcdef</p>"); doc.resetAnnotation(3, 6, "style/color", "pocoyo"); assertOperationResult( "<p>ab<?a \"style/color\"=\"pocoyo\"?>cde<?a \"style/color\"?>f</p>"); }
/** * Test that trying to reset an annotation with an end bigger than the document * an IndexOutOfBoundsException. */ public void testResetAnnotationPastDocEndThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.resetAnnotation(1, doc.size() + 1, "style/color", "frub"); // Doh - no exception thrown. Fail the test assert false; } catch (IndexOutOfBoundsException iae) { // expected } }
/** * Test that trying to reset an annotation with an end bigger than the document * an IndexOutOfBoundsException. */ public void testResetAnnotationPastDocEndThrowsException() throws Exception { init("<p>abcdef</p>"); try { doc.resetAnnotation(1, doc.size() + 1, "style/color", "frub"); // Doh - no exception thrown. Fail the test assert false; } 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>"); }
/** * Test that using a zero range reset annotation clears the annotation over * the whole document. */ public void testZeroRangeResetAnnotationClearsDocument() { init("<p>abcdef</p>"); doc.setAnnotation(1, 4, "style/color", "spot"); doc.resetAnnotation(0, 0, "style/color", "spot"); assertOperationResult("<p>abcdef</p>"); init("<p>abcdef</p>"); doc.setAnnotation(1, 4, "style/color", "spot"); doc.resetAnnotation(2, 2, "style/color", "spot"); assertOperationResult("<p>abcdef</p>"); init("<p>abcdef</p>"); doc.setAnnotation(1, 4, "style/color", "spot"); doc.resetAnnotation(doc.size(), doc.size(), "style/color", "spot"); assertOperationResult("<p>abcdef</p>"); }
/** * Test that using a zero range reset annotation clears the annotation over * the whole document. */ public void testZeroRangeResetAnnotationClearsDocument() { init("<p>abcdef</p>"); doc.setAnnotation(1, 4, "style/color", "spot"); doc.resetAnnotation(0, 0, "style/color", "spot"); assertOperationResult("<p>abcdef</p>"); init("<p>abcdef</p>"); doc.setAnnotation(1, 4, "style/color", "spot"); doc.resetAnnotation(2, 2, "style/color", "spot"); assertOperationResult("<p>abcdef</p>"); init("<p>abcdef</p>"); doc.setAnnotation(1, 4, "style/color", "spot"); doc.resetAnnotation(doc.size(), doc.size(), "style/color", "spot"); assertOperationResult("<p>abcdef</p>"); }