VectorDataMultiLevelImage extends DefaultMultiLevelImage implements ProductNodeListener { @Override public void dispose() { VectorDataNode vectorDataNode = vectorDataReference.get(); if (vectorDataNode != null) { Product product = vectorDataNode.getProduct(); if (product != null) { product.removeProductNodeListener(this); } } vectorDataReference.clear(); super.dispose(); } VectorDataMultiLevelImage(MultiLevelSource multiLevelSource, final VectorDataNode vectorDataNode); @Override Shape getImageShape(int level); @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 listenerIsRemoved() { image.dispose(); assertFalse(Arrays.asList(product.getProductNodeListeners()).contains(image)); }