RecentSearches implements ActionListener { public void uninstall(JXSearchField searchField) { searchField.removeActionListener(this); if (searchField.getFindPopupMenu() instanceof RecentSearchesPopup) { removeChangeListener((ChangeListener) searchField.getFindPopupMenu()); searchField.setFindPopupMenu(null); } } RecentSearches(String saveName);  RecentSearches(Preferences prefs, String saveName); void put(String searchString); String[] getRecentSearches(); int getLength(); void removeAll(); int getMaxRecents(); void setMaxRecents(int maxRecents); void addChangeListener(ChangeListener l); void removeChangeListener(ChangeListener l); ChangeListener[] getChangeListeners(); void install(JTextField searchField); void uninstall(JXSearchField searchField); @Override void actionPerformed(ActionEvent e);  }
@Test public void testUnInstall() throws Exception { JXSearchField searchField = new JXSearchField("Search"); searchHistory.install(searchField); assertSame(1, searchField.getActionListeners().length); assertSame(1, searchHistory.getChangeListeners().length); searchHistory.uninstall(searchField); assertSame(0, searchField.getActionListeners().length); assertSame(0, searchHistory.getChangeListeners().length); assertNull(searchField.getFindPopupMenu()); }