String iconKey = objectName + ".icon";
Icon expectedIcon = new TestIcon(Color.GREEN);
// Create the required mock objects
IconSource iconSource = (IconSource) EasyMock.createMock(IconSource.class);
IconConfigurable configurable = (IconConfigurable) EasyMock.createMock(IconConfigurable.class);
// Create the configurer with the mock icon source
DefaultApplicationObjectConfigurer configurer = new DefaultApplicationObjectConfigurer(null, null, iconSource,
null);
// Set the expectations for the mock objects. For the first run, we
// don't want the icon
// source to be able to find the icon, so setIcon should be called with
// a null value.
EasyMock.expect(iconSource.getIcon(iconKey)).andReturn(expectedIcon);
configurable.setIcon(expectedIcon);
EasyMock.replay(iconSource);
EasyMock.replay(configurable);
configurer.configure(configurable, objectName);