|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2004, 2008 Eugene Kuleshov and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* Eugene Kuleshov - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
|
| 12 |
package org.eclipse.mylyn.sandbox.tests; |
| 13 |
|
| 14 |
import junit.framework.TestCase; |
| 15 |
|
| 16 |
import org.eclipse.core.resources.IProject; |
| 17 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; |
| 18 |
import org.eclipse.mylyn.sandbox.tests.util.PdeProject; |
| 19 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
| 20 |
|
| 21 |
/** |
| 22 |
* @author Eugene Kuleshov |
| 23 |
*/ |
| 24 |
public class EclipseTaskRepositoryLinkProviderTest extends TestCase { |
| 25 |
|
| 26 |
public void testEclipsePluginProject() throws Exception { |
| 27 |
TaskRepository repo1 = TasksUiPlugin.getRepositoryManager().getRepository("https://bugs.eclipse.org/bugs"); |
| 28 |
assertNotNull("Eclipse.org repository is not found", repo1); |
| 29 |
|
| 30 |
String mf = "Manifest-Version: 1.0\n" + // |
| 31 |
"Bundle-ManifestVersion: 2\n" + // |
| 32 |
"Bundle-Name: Mylyn PDE Tests 1\n" + // |
| 33 |
"Bundle-SymbolicName: org.eclipse.mylyn.pde.tests1\n" + // |
| 34 |
"Bundle-Version: 1.0.0\n" + // |
| 35 |
"Bundle-Vendor: Eclipse.org\n" + // |
| 36 |
"Bundle-RequiredExecutionEnvironment: J2SE-1.3\n"; |
| 37 |
|
| 38 |
PdeProject pdeProject = new PdeProject("eclipsePluginProject"); |
| 39 |
pdeProject.createPlugin(mf); |
| 40 |
|
| 41 |
IProject project = pdeProject.getProject(); |
| 42 |
|
| 43 |
TasksUiPlugin tasksUiPlugin = TasksUiPlugin.getDefault(); |
| 44 |
|
| 45 |
TaskRepository repo2 = tasksUiPlugin.getRepositoryForResource(project); |
| 46 |
assertEquals(repo1, repo2); |
| 47 |
|
| 48 |
assertFalse(tasksUiPlugin.canSetRepositoryForResource(project)); |
| 49 |
|
| 50 |
pdeProject.delete(); |
| 51 |
} |
| 52 |
|
| 53 |
public void testAcmePluginProject() throws Exception { |
| 54 |
TaskRepository repo1 = TasksUiPlugin.getRepositoryManager().getRepository("https://bugs.eclipse.org/bugs"); |
| 55 |
assertNotNull("Eclipse.org repository is not found", repo1); |
| 56 |
|
| 57 |
String mf = "Manifest-Version: 1.0\n" + // |
| 58 |
"Bundle-ManifestVersion: 2\n" + // |
| 59 |
"Bundle-Name: Mylyn PDE Tests 2\n" + // |
| 60 |
"Bundle-SymbolicName: org.eclpse.mylyn.pde.tests2\n" + // |
| 61 |
"Bundle-Version: 1.0.0\n" + // |
| 62 |
"Bundle-Vendor: Acme.org\n" + // |
| 63 |
"Bundle-RequiredExecutionEnvironment: J2SE-1.3\n"; |
| 64 |
|
| 65 |
PdeProject pdeProject = new PdeProject("acmePluginProject"); |
| 66 |
pdeProject.createPlugin(mf); |
| 67 |
|
| 68 |
TaskRepository repo2 = TasksUiPlugin.getDefault().getRepositoryForResource(pdeProject.getProject()); |
| 69 |
|
| 70 |
pdeProject.delete(); |
| 71 |
|
| 72 |
assertNull("Not expected to find repository " + repo2, repo2); |
| 73 |
} |
| 74 |
|
| 75 |
public void testEclipseFeatureProject() throws Exception { |
| 76 |
TaskRepository repo1 = TasksUiPlugin.getRepositoryManager().getRepository("https://bugs.eclipse.org/bugs"); |
| 77 |
assertNotNull("Eclipse.org repository is not found", repo1); |
| 78 |
|
| 79 |
String feature = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + // |
| 80 |
"<feature\n" + // |
| 81 |
" id=\"org.eclipse.mylyn.pde.tests2_feature\"\n" + // |
| 82 |
" label=\"Mylyn PDE Test Feature 2\"\n" + // |
| 83 |
" version=\"2.3.0.qualifier\"\n" + // |
| 84 |
" provider-name=\"Eclipse.org\">" + // |
| 85 |
"</feature>"; |
| 86 |
|
| 87 |
PdeProject pdeProject = new PdeProject("eclipseFeatureProject"); |
| 88 |
pdeProject.createFeature(feature); |
| 89 |
|
| 90 |
IProject project = pdeProject.getProject(); |
| 91 |
|
| 92 |
TasksUiPlugin tasksUiPlugin = TasksUiPlugin.getDefault(); |
| 93 |
|
| 94 |
TaskRepository repo2 = tasksUiPlugin.getRepositoryForResource(project); |
| 95 |
assertEquals(repo1, repo2); |
| 96 |
|
| 97 |
assertFalse(tasksUiPlugin.canSetRepositoryForResource(project)); |
| 98 |
|
| 99 |
pdeProject.delete(); |
| 100 |
} |
| 101 |
|
| 102 |
public void testAcmeFeatureProject() throws Exception { |
| 103 |
TaskRepository repo1 = TasksUiPlugin.getRepositoryManager().getRepository("https://bugs.eclipse.org/bugs"); |
| 104 |
assertNotNull("Eclipse.org repository is not found", repo1); |
| 105 |
|
| 106 |
String feature = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + // |
| 107 |
"<feature\n" + // |
| 108 |
" id=\"org.eclipse.mylyn.pde.tests2_feature\"\n" + // |
| 109 |
" label=\"Mylyn PDE Test Feature 2\"\n" + // |
| 110 |
" version=\"2.3.0.qualifier\"\n" + // |
| 111 |
" provider-name=\"Acme.org\">" + // |
| 112 |
"</feature>"; |
| 113 |
|
| 114 |
PdeProject pdeProject = new PdeProject("acmeFeatureProject"); |
| 115 |
pdeProject.createFeature(feature); |
| 116 |
|
| 117 |
TaskRepository repo2 = TasksUiPlugin.getDefault().getRepositoryForResource(pdeProject.getProject()); |
| 118 |
|
| 119 |
pdeProject.delete(); |
| 120 |
|
| 121 |
assertNull("Not expected to find repository " + repo2, repo2); |
| 122 |
} |
| 123 |
|
| 124 |
} |