Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » My editor is filtered out during junit test, any ideas why?
My editor is filtered out during junit test, any ideas why? [message #545440] Wed, 07 July 2010 19:09
Jeff Johnston is currently offline Jeff JohnstonFriend
Messages: 202
Registered: July 2009
Senior Member
I have a junit test which creates a project, then creates a file: "" inside the project. The junit test performs an openEditor and verifies the editor is a special editor (AutomakeEditor) that I have set up for files.

	public void testAutomakeEditorAssociation() throws Exception {
		project = ProjectTools.createProject("testProjectAET");
		if(project == null) {
            fail("Unable to create test project");
        } NullProgressMonitor());
		IFile makefileAmFile = tools.createFile(project, "", "");
		IWorkbench workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();

		IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
					.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
		assertTrue(openEditor instanceof AutomakeEditor);
		project.delete(true, false, ProjectTools.getMonitor());

The assert regarding the openEditor being an instance of AutomakeEditor is failing for me every time when running the test as a Junit plugin test directly from Eclipse. A Text editor is being returned. This same test succeeds under automatic test runs that have been set up under Hudson for both Helios and Galileo (I am running Helios 3.6 Classic freshly downloaded from on my system).

I debugged and found that the filename to editor association is correct (it finds my AutomakeEditor), but the editor is being filtered out because the isEnabled() check below found in WorkbenchActivityHelper returns false due to the identifier not being enabled.

	public static final boolean filterItem(Object object) {
		if (object instanceof IPluginContribution) {
			IPluginContribution contribution = (IPluginContribution) object;
			IWorkbenchActivitySupport workbenchActivitySupport = PlatformUI
			IIdentifier identifier = workbenchActivitySupport
			if (!identifier.isEnabled()) {
				return true;
		return false;

If I run a child Eclipse application with all plug-ins, editing a file works as expected (my AutomakeEditor is clearly being used as is evident with the icon being used). However, checking out the test case into the child Eclipse workspace and running it results in the same failure with a Text editor coming back from openEditor every time..

Any ideas why the filtering could be occurring? Is the test flawed?
Previous Topic:Losing events from post selection listener
Next Topic:Include one directory from one java project into current project
Goto Forum:

Current Time: Fri Apr 27 07:06:45 GMT 2018

Powered by FUDForum. Page generated in 0.01875 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software