VirtualBandMultiLevelImage extends DefaultMultiLevelImage implements ProductNodeListener { @Override public void dispose() { for (final Product key : nodeMap.keySet()) { key.removeProductNodeListener(this); } nodeMap.clear(); super.dispose(); } VirtualBandMultiLevelImage(MultiLevelSource multiLevelSource, String expression, Product product); @Override void dispose(); @Override void nodeChanged(ProductNodeEvent event); @Override void nodeDataChanged(ProductNodeEvent event); @Override void nodeAdded(ProductNodeEvent event); @Override void nodeRemoved(ProductNodeEvent event);  }
@Test public void listenersAreRemoved() { image.dispose(); assertFalse(Arrays.asList(p.getProductNodeListeners()).contains(image)); assertFalse(Arrays.asList(q.getProductNodeListeners()).contains(image)); }