Source:
private void failureTearDown() throws Exception { Option<String> crossReferencerAdapterFound = Options.newNone(); try { SWTBotUtils.waitAllUiEvents(); if (bot != null) { Shell[] shells = bot.getFinder().getShells(); ArrayList<SWTBotShell> result = new ArrayList<SWTBotShell>(); for (Shell shell : shells) { if (!shell.isDisposed()) { result.add(new SWTBotShell(shell)); } } final SWTBotShell[] foundShells = result.toArray(new SWTBotShell[] {}); for (final SWTBotShell swtBotShell : foundShells) { if (swtBotShell.isOpen()) { for (IWorkbenchWindow w : PlatformUI.getWorkbench().getWorkbenchWindows()) { if (swtBotShell.widget != w.getShell()) { swtBotShell.close(); } } } } } SWTBotUtils.waitAllUiEvents(); closeAllEditors(); SWTBotUtils.waitAllUiEvents(); crossReferencerAdapterFound = checkNoCrossReferenceAdapter(); closeAllSessions(); SWTBotUtils.waitAllUiEvents(); Job.getJobManager().join(ResourceSyncClientNotifier.FAMILY, new NullProgressMonitor()); bot.closeAllEditors(); designerProject = null; SWTBotUtils.waitAllUiEvents(); for (final IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { designerPerspective.deleteProject(project.getName()); } disposeErrorLoggers(); } finally { resetPreferences(); SWTBotUtils.waitAllUiEvents(); UIThreadRunnable.syncExec(new VoidResult() { @Override public void run() { IPreferenceStore preferenceStore = DiagramUIPlugin.getPlugin().getPreferenceStore(); preferenceStore.setValue(IPreferenceConstants.PREF_ENABLE_ANIMATED_ZOOM, defaultEnableAnimatedZoom); preferenceStore.setValue(IPreferenceConstants.PREF_ENABLE_ANIMATED_LAYOUT, defaultEnableAnimatedLayout); } }); setErrorCatchActive(false); assertFalse(crossReferencerAdapterFound.get(), crossReferencerAdapterFound.some()); checkErrors(); } }

Target:
private void failureTearDown() throws Exception { CrossReferenceAdapterDetector crossRefDetector = new CrossReferenceAdapterDetector(); try { SWTBotUtils.waitAllUiEvents(); if (bot != null) { Shell[] shells = bot.getFinder().getShells(); ArrayList<SWTBotShell> result = new ArrayList<SWTBotShell>(); for (Shell shell : shells) { if (!shell.isDisposed()) { result.add(new SWTBotShell(shell)); } } final SWTBotShell[] foundShells = result.toArray(new SWTBotShell[] {}); for (final SWTBotShell swtBotShell : foundShells) { if (swtBotShell.isOpen()) { for (IWorkbenchWindow w : PlatformUI.getWorkbench().getWorkbenchWindows()) { if (swtBotShell.widget != w.getShell()) { swtBotShell.close(); } } } } } SWTBotUtils.waitAllUiEvents(); closeAllEditors(); SWTBotUtils.waitAllUiEvents(); crossRefDetector.checkNoCrossReferenceAdapter(); closeAllSessions(); SWTBotUtils.waitAllUiEvents(); Job.getJobManager().join(ResourceSyncClientNotifier.FAMILY, new NullProgressMonitor()); bot.closeAllEditors(); designerProject = null; SWTBotUtils.waitAllUiEvents(); for (final IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) { designerPerspective.deleteProject(project.getName()); } disposeErrorLoggers(); } finally { resetPreferences(); SWTBotUtils.waitAllUiEvents(); UIThreadRunnable.syncExec(new VoidResult() { @Override public void run() { IPreferenceStore preferenceStore = DiagramUIPlugin.getPlugin().getPreferenceStore(); preferenceStore.setValue(IPreferenceConstants.PREF_ENABLE_ANIMATED_ZOOM, defaultEnableAnimatedZoom); preferenceStore.setValue(IPreferenceConstants.PREF_ENABLE_ANIMATED_LAYOUT, defaultEnableAnimatedLayout); } }); setErrorCatchActive(false); crossRefDetector.assertNoFoundCrossReferenceAdapter(); checkErrors(); } }