fixed UI tests
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/builder/IntentProjectListener.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/builder/IntentProjectListener.java
index a10314c..8a0895a 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/builder/IntentProjectListener.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/builder/IntentProjectListener.java
@@ -152,10 +152,12 @@
*/
public void handleClosedProject(IProject project) {
IntentProjectManager projectManager = IntentProjectManager.getInstance(project, false);
- try {
- projectManager.disconnect();
- } catch (RepositoryConnectionException e) {
- IntentUiLogger.logError(e);
+ if (projectManager != null) { // should not happen
+ try {
+ projectManager.disconnect();
+ } catch (RepositoryConnectionException e) {
+ IntentUiLogger.logError(e);
+ }
}
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/launcher/IntentProjectManager.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/launcher/IntentProjectManager.java
index d99291c..ae8f6ae 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/launcher/IntentProjectManager.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/launcher/IntentProjectManager.java
@@ -178,14 +178,14 @@
}
});
- repository.closeSession();
+ projectManagers.remove(project);
compilerClient.dispose();
synchronizerClient.dispose();
indexerClient.dispose();
refresher.dispose();
- projectManagers.remove(project);
+ repository.closeSession();
}
/**
@@ -235,15 +235,11 @@
* @param project
* the Intent project to get the Repository from
* @return the {@link Repository} associated to the given Intent project
+ * @throws RepositoryConnectionException
+ * if the repository cannot be created
*/
- public static Repository getRepository(IProject project) {
- try {
- return getInstance(project, true).getRepository();
- } catch (RepositoryConnectionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
+ public static Repository getRepository(IProject project) throws RepositoryConnectionException {
+ return getInstance(project, true).getRepository();
}
/**
diff --git a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/navigator/OpenEditorAction.java b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/navigator/OpenEditorAction.java
index 0e81e0f..a50feda 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/navigator/OpenEditorAction.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/navigator/OpenEditorAction.java
@@ -18,7 +18,9 @@
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.mylyn.docs.intent.client.ui.ide.launcher.IntentProjectManager;
+import org.eclipse.mylyn.docs.intent.client.ui.logger.IntentUiLogger;
import org.eclipse.mylyn.docs.intent.client.ui.utils.IntentEditorOpener;
+import org.eclipse.mylyn.docs.intent.collab.repository.RepositoryConnectionException;
import org.eclipse.mylyn.docs.intent.core.document.IntentGenericElement;
import org.eclipse.mylyn.docs.intent.core.indexer.IntentIndexEntry;
@@ -54,9 +56,13 @@
final IntentGenericElement element = getIndexEntryFromSelection();
if (element != null && element.eResource() != null) {
- IntentEditorOpener.openIntentEditor(
- IntentProjectManager.getRepository(findProjectForModelURI(element.eResource().getURI())),
- element, false, element, forceNewEditor);
+ try {
+ IntentEditorOpener.openIntentEditor(IntentProjectManager
+ .getRepository(findProjectForModelURI(element.eResource().getURI())), element, false,
+ element, forceNewEditor);
+ } catch (RepositoryConnectionException e) {
+ IntentUiLogger.logError(e);
+ }
}
}
diff --git a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/repository/WorkspaceSessionDeltaVisitor.java b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/repository/WorkspaceSessionDeltaVisitor.java
index 84a7fc0..e3597cf 100644
--- a/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/repository/WorkspaceSessionDeltaVisitor.java
+++ b/plugins/org.eclipse.mylyn.docs.intent.collab.ide/src/org/eclipse/mylyn/docs/intent/collab/ide/repository/WorkspaceSessionDeltaVisitor.java
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.Path;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.mylyn.docs.intent.collab.ide.adapters.WorkspaceAdapter;
@@ -57,6 +58,7 @@
* the path indicating the location of the listened WorkspaceRepository
*/
public WorkspaceSessionDeltaVisitor(WorkspaceAdapter repositoryAdapter, Path repositoryPath) {
+ Assert.isNotNull(repositoryAdapter);
this.repositoryAdapter = repositoryAdapter;
this.changedResources = new ArrayList<Resource>();
this.removedResources = new ArrayList<Resource>();
diff --git a/plugins/org.eclipse.mylyn.docs.intent/dev/launchconfigs/tests/UI-TestSuite.launch b/plugins/org.eclipse.mylyn.docs.intent/dev/launchconfigs/tests/UI-TestSuite.launch
index cab9923..caeaef7 100644
--- a/plugins/org.eclipse.mylyn.docs.intent/dev/launchconfigs/tests/UI-TestSuite.launch
+++ b/plugins/org.eclipse.mylyn.docs.intent/dev/launchconfigs/tests/UI-TestSuite.launch
@@ -19,6 +19,9 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/project/ProjectTest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/project/ProjectTest.java
index 79cf24b..47eaf3b 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/project/ProjectTest.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/unit/project/ProjectTest.java
@@ -37,6 +37,13 @@
/**
* Ensures that a project can be closed.
*/
+ public void testDeleteProject() {
+ // already managed by tearDown()
+ }
+
+ /**
+ * Ensures that a project can be closed.
+ */
public void testCloseProject() {
try {
intentProject.close(new NullProgressMonitor());
diff --git a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AbstractUITest.java b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AbstractUITest.java
index c9daf00..42fd3b5 100644
--- a/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AbstractUITest.java
+++ b/tests/org.eclipse.mylyn.docs.intent.client.ui.test/src/org/eclipse/mylyn/docs/intent/client/ui/test/util/AbstractUITest.java
@@ -17,16 +17,17 @@
import junit.framework.TestCase;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.mylyn.docs.intent.client.ui.IntentEditorActivator;
import org.eclipse.mylyn.docs.intent.client.ui.editor.IntentEditor;
import org.eclipse.mylyn.docs.intent.client.ui.ide.builder.ToggleNatureAction;
import org.eclipse.mylyn.docs.intent.client.ui.ide.launcher.IDEApplicationManager;
@@ -52,7 +53,7 @@
*
* @author <a href="mailto:alex.lagarde@obeo.fr">Alex Lagarde</a>
*/
-public abstract class AbstractUITest extends TestCase {
+public abstract class AbstractUITest extends TestCase implements ILogListener {
public static final String INTENT_NEW_PROJECT_WIZARD_ID = "org.eclipse.mylyn.docs.intent.client.ui.ide.wizards.NewIntentProjectWizard";
@@ -73,6 +74,7 @@
protected void setUp() throws Exception {
super.setUp();
closeWelcomePage();
+ IntentEditorActivator.getDefault().getLog().addLogListener(this);
}
/**
@@ -83,8 +85,9 @@
@Override
protected void tearDown() throws Exception {
if (intentProject != null) {
- intentProject.delete(true, new NullProgressMonitor());
+ intentProject.delete(true, true, new NullProgressMonitor());
}
+ IntentEditorActivator.getDefault().getLog().removeLogListener(this);
super.tearDown();
}
@@ -126,8 +129,8 @@
// Step 3 : initializing all useful informations
intentProject = project;
- repository = IntentProjectManager.getRepository(project);
try {
+ repository = IntentProjectManager.getRepository(project);
repositoryAdapter = RepositoryCreatorHolder.getCreator()
.createRepositoryAdapterForRepository(repository);
} catch (RepositoryConnectionException e) {
@@ -166,14 +169,8 @@
private static IProject createProject(final String projectName, IProgressMonitor monitor)
throws CoreException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- IPath location = project.getFullPath();
if (!project.exists()) {
- IProjectDescription desc = project.getWorkspace().newProjectDescription(projectName);
- if (location != null && ResourcesPlugin.getWorkspace().getRoot().getLocation().equals(location)) {
- location = null;
- }
- desc.setLocation(location);
- project.create(desc, monitor);
+ project.create(monitor);
project.open(monitor);
}
if (!project.isOpen()) {
@@ -259,4 +256,15 @@
throw error;
}
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.core.runtime.ILogListener#logging(org.eclipse.core.runtime.IStatus, java.lang.String)
+ */
+ public void logging(IStatus status, String plugin) {
+ if (status.getSeverity() == IStatus.ERROR) {
+ fail(status.getMessage());
+ }
+ }
}