@Override
    public void onRenamed(Item item, String oldName, String newName) {
        // bug 5077308 - Display name field should be cleared when you rename a job.
        if (item instanceof AbstractItem) {
            AbstractItem abstractItem = (AbstractItem) item;
            if (oldName.equals(abstractItem.getDisplayName())) {
                // the user renamed the job, but the old project name which is shown as the
                // displayname if no displayname was set, has been set into the displayname field.
                // This means that the displayname was never set, so we want to set it
                // to null as it was before
                try {
                    LOGGER.info(String.format("onRenamed():Setting displayname to null for item.name=%s", item.getName()));
                    abstractItem.setDisplayName(null);
                }
                catch (IOException ioe) {
                    LOGGER.log(Level.WARNING, String.format("onRenamed():Exception while trying to clear the displayName for Item.name:%s",
                            item.getName()), ioe);
                }
            }
        }
    }
@Test
    public void testOnRenamedOldNameNotEqualDisplayName() throws Exception {
        DisplayNameListener listener = new DisplayNameListener();
        final String oldName = "old job name";
        final String newName = "new job name";
        final String displayName = "the display name";
        StubJob src = new StubJob();
        src.doSetName(newName);
        src.setDisplayName(displayName);

        listener.onRenamed(src, oldName, oldName);

        // make sure displayname is still intact
        assertEquals(displayName, src.getDisplayName());
    }