@Override
    public void deleteWorkspace(Workspace workspace) {
        synchronized (this) {
            Project project = workspace.getProject();
            WorkspaceProviderImpl workspaceProvider = project.getLookup().lookup(WorkspaceProviderImpl.class);

            Workspace toSelectWorkspace = null;
            if (getCurrentWorkspace() == workspace) {
                toSelectWorkspace = workspaceProvider.getPrecedingWorkspace(workspace);
            }

            workspaceProvider.removeWorkspace(workspace);

            //Event
            fireWorkspaceEvent(EventType.CLOSE, workspace);

            if (getCurrentWorkspace() == workspace) {
                //Select the one before, or after
                if (toSelectWorkspace == null) {
                    closeCurrentProject();
                } else {
                    openWorkspace(toSelectWorkspace);
                }
            }
        }
    }
@Test
    public void testDeleteWorkspace() {
        ProjectControllerImpl pc = new ProjectControllerImpl();
        pc.addWorkspaceListener(workspaceListener);
        Project project = pc.newProject();
        Workspace originalWorkspace = pc.getCurrentWorkspace();
        Workspace workspace = pc.newWorkspace(project);
        pc.deleteWorkspace(workspace);

        Assert.assertTrue(workspace.isClosed());
        Assert.assertSame(originalWorkspace, pc.getCurrentWorkspace());
        Assert.assertTrue(project.getWorkspaces().contains(originalWorkspace));
        Mockito.verify(workspaceListener).close(workspace);
        Mockito.verify(workspaceListener, Mockito.never()).unselect(workspace);
    }