public ApiView(Document doc, Wavelet wavelet) { this.doc = doc; this.wavelet = wavelet; parse(doc); }
public void testTextMatcherDeletingTheFirstChar() { ApiView apiView = createApiViewFromXml("1 1 1"); DocumentHitIterator it = new DocumentHitIterator.TextMatcher(apiView, "1", -1); for (int i = 0; i < 3; i++) { Range r = it.next(); assertEquals(i + 1, r.getStart()); apiView.delete(1, 2); it.shift(1, -1); } assertNull(it.next()); }
private int countHits(DocumentHitIterator it) { int res = 0; while (it.next() != null) { res++; } return res; }
/** * Pretend we're shifting in the manner of INSERT_AFTER */ public void testTextMatcherShiftInsertAfter() { ApiView apiView = createApiViewFromXml("1 1 1"); DocumentHitIterator it = new DocumentHitIterator.TextMatcher(apiView, "1", -1); for (int i = 0; i < 3; i++) { Range r = it.next(); assertEquals(i * 3 + 1, r.getStart()); apiView.insert(r.getEnd(), "1"); it.shift(r.getEnd(), 1); } assertNull(it.next()); }
public void testTextMatcherWithoutShift() { ApiView apiView = createApiViewFromXml("1 1 1"); DocumentHitIterator it = new DocumentHitIterator.TextMatcher(apiView, "1", -1); for (int i = 0; i < 3; i++) { Range r = it.next(); assertEquals(i * 2 + 1, r.getStart()); assertEquals(i * 2 + 2, r.getEnd()); } assertNull(it.next()); }
public void testSingleshot() { Range range = new Range(0, 10); DocumentHitIterator it = new DocumentHitIterator.Singleshot(range); Range first = it.next(); assertEquals(range, first); assertNull(it.next()); }
/** * Test that the passed xml string deserializes into exactly two elements and * that the second element is the one we're after and serialized back to the * passed xml. */ private void convertBackAndForth(String xml) { Element element = createApiElementFromXml(xml); String resultXml = ElementSerializer.apiElementToXml(element).getXmlString(); assertEquals(xml, resultXml); }
public void testGadgetSerialization() throws Exception { convertBackAndForth("<gadget url=\"http://www.example.com/gadget.xml\"></gadget>"); convertBackAndForth("<gadget url=\"http://www.example.com/gadget.xml\">" + "<pref value=\"value\"></pref>" + "</gadget>"); convertBackAndForth("<gadget url=\"http://www.example.com/gadget.xml\">" + "<state name=\"key\" value=\"value\"></state>" + "</gadget>"); }
public void testTextMatcherDeletingTheFirstChar() { ApiView apiView = createApiViewFromXml("1 1 1"); DocumentHitIterator it = new DocumentHitIterator.TextMatcher(apiView, "1", -1); for (int i = 0; i < 3; i++) { Range r = it.next(); assertEquals(i + 1, r.getStart()); apiView.delete(1, 2); it.shift(1, -1); } assertNull(it.next()); }
/** * Pretend we're shifting in the manner of INSERT_AFTER */ public void testTextMatcherShiftInsertAfter() { ApiView apiView = createApiViewFromXml("1 1 1"); DocumentHitIterator it = new DocumentHitIterator.TextMatcher(apiView, "1", -1); for (int i = 0; i < 3; i++) { Range r = it.next(); assertEquals(i * 3 + 1, r.getStart()); apiView.insert(r.getEnd(), "1"); it.shift(r.getEnd(), 1); } assertNull(it.next()); }
public void testTextMatcherWithoutShift() { ApiView apiView = createApiViewFromXml("1 1 1"); DocumentHitIterator it = new DocumentHitIterator.TextMatcher(apiView, "1", -1); for (int i = 0; i < 3; i++) { Range r = it.next(); assertEquals(i * 2 + 1, r.getStart()); assertEquals(i * 2 + 2, r.getEnd()); } assertNull(it.next()); }
public void testSingleshot() { Range range = new Range(0, 10); DocumentHitIterator it = new DocumentHitIterator.Singleshot(range); Range first = it.next(); assertEquals(range, first); assertNull(it.next()); }
/** * Test that the passed xml string deserializes into exactly two elements and * that the second element is the one we're after and serialized back to the * passed xml. */ private void convertBackAndForth(String xml) { Element element = createApiElementFromXml(xml); String resultXml = ElementSerializer.apiElementToXml(element).getXmlString(); assertEquals(xml, resultXml); }
public void testGadgetSerialization() throws Exception { convertBackAndForth("<gadget url=\"http://www.example.com/gadget.xml\"></gadget>"); convertBackAndForth("<gadget url=\"http://www.example.com/gadget.xml\">" + "<pref value=\"value\"></pref>" + "</gadget>"); convertBackAndForth("<gadget url=\"http://www.example.com/gadget.xml\">" + "<state name=\"key\" value=\"value\"></state>" + "</gadget>"); }
private int countHits(DocumentHitIterator it) { int res = 0; while (it.next() != null) { res++; } return res; }
public void testButtonSerialization() { convertBackAndForth( "<button name=\"button\"><caption>button</caption><events></events></button>"); }
public void testRadiogroupSerialization() { convertBackAndForth("<radiogroup name=\"rgroup\"></radiogroup>"); }
public void testTextareaSerialization() { convertBackAndForth( "<textarea name=\"lbl\"><line></line>line 1<line></line>line 2</textarea>"); }
public void testRadiogroupSerialization() { convertBackAndForth("<radiogroup name=\"rgroup\"></radiogroup>"); }
public void testTextareaSerialization() { convertBackAndForth( "<textarea name=\"lbl\"><line></line>line 1<line></line>line 2</textarea>"); }