// using the textField in a TextComponentMatcherEditor will install a DocumentListener
TextComponentMatcherEditor<String> textMatcherEditor = new TextComponentMatcherEditor<String>(textField, GlazedLists.toStringTextFilterator(), true);
assertEquals(originalDocumentAListenerCount+1, documentA.getDocumentListeners().length);
assertEquals(originalDocumentBListenerCount, documentB.getDocumentListeners().length);
TextMatcher textMatcher = (TextMatcher) textMatcherEditor.getMatcher();
assertEquals("documentA", textMatcher.getSearchTerms()[0].getText());
// replace DocumentA with DocumentB, which should update the filter with the text from DocumentB
textField.setDocument(documentB);
assertEquals(0, documentA.getDocumentListeners().length);
assertEquals(originalDocumentBListenerCount+3, documentB.getDocumentListeners().length);
textMatcher = (TextMatcher) textMatcherEditor.getMatcher();
assertEquals("documentB", textMatcher.getSearchTerms()[0].getText());
// changing the text in DocumentB should alter the filter
documentB.replace(0, documentB.getLength(), "blah", null);
textMatcher = (TextMatcher) textMatcherEditor.getMatcher();
assertEquals("blah", textMatcher.getSearchTerms()[0].getText());
}