/** Checks the copy and clone methods for PlantComposites. */ @Test public void checkCopying() { // Initialize objects for testing. PlantComposite object = new PlantComposite(); PlantComposite copy = new PlantComposite(); PlantComposite clone = null; // Set up the object. object.addPlantComponent(new PlantComponent("bumblebee")); // Make sure the objects are not equal before copying. assertFalse(object == copy); assertFalse(object.equals(copy)); // Copy the object. copy.copy(object); // Make sure the references are different but contents the same. assertFalse(object == copy); assertTrue(object.equals(copy)); // Do the same for the clone operation. // Make sure the objects are not equal before copying. assertFalse(object == clone); assertFalse(object.equals(clone)); // Clone the object. clone = (PlantComposite) object.clone(); // Make sure the references are different but contents the same. assertFalse(object == clone); assertTrue(object.equals(clone)); assertFalse(copy == clone); assertTrue(copy.equals(clone)); return; }