|
18 | 18 | import static org.junit.jupiter.api.Assertions.assertNull; |
19 | 19 | import static org.junit.jupiter.api.Assertions.assertTrue; |
20 | 20 |
|
| 21 | +import java.io.File; |
| 22 | + |
21 | 23 | import org.junit.jupiter.api.AfterEach; |
22 | 24 | import org.junit.jupiter.api.Test; |
23 | 25 |
|
24 | 26 | import org.eclipse.jdt.testplugin.JavaProjectHelper; |
25 | 27 |
|
26 | 28 | import org.eclipse.core.runtime.CoreException; |
| 29 | +import org.eclipse.core.runtime.IPath; |
| 30 | +import org.eclipse.core.runtime.NullProgressMonitor; |
27 | 31 | import org.eclipse.core.runtime.Path; |
| 32 | +import org.eclipse.core.runtime.Platform; |
| 33 | +import org.eclipse.core.runtime.Plugin; |
28 | 34 |
|
29 | 35 | import org.eclipse.core.resources.IFile; |
30 | 36 | import org.eclipse.core.resources.IFolder; |
31 | 37 | import org.eclipse.core.resources.IProject; |
| 38 | +import org.eclipse.core.resources.IProjectDescription; |
| 39 | +import org.eclipse.core.resources.IWorkspace; |
32 | 40 | import org.eclipse.core.resources.IWorkspaceRoot; |
33 | 41 | import org.eclipse.core.resources.ResourcesPlugin; |
34 | 42 |
|
| 43 | +import org.eclipse.core.filebuffers.tests.FileTool; |
35 | 44 | import org.eclipse.core.filebuffers.tests.ResourceHelper; |
36 | 45 |
|
37 | 46 | import org.eclipse.ui.IEditorInput; |
@@ -104,7 +113,7 @@ public void test2() throws Exception { |
104 | 113 |
|
105 | 114 | @Test |
106 | 115 | public void test3() throws Exception { |
107 | | - fLinkedProject= ResourceHelper.createLinkedProject("P2", JdtTextTestPlugin.getDefault(), new Path("testResources/folderLinkTarget1")); |
| 116 | + fLinkedProject= createLinkedProject("P2", JdtTextTestPlugin.getDefault(), new Path("testResources/folderLinkTarget1")); |
108 | 117 | assertNotNull(fLinkedProject); |
109 | 118 | assertTrue(fLinkedProject.exists()); |
110 | 119 |
|
@@ -147,4 +156,23 @@ private void checkFile(IFile file) throws CoreException { |
147 | 156 | assertNull(provider.getDocument(input)); |
148 | 157 | assertNull(provider.getAnnotationModel(input)); |
149 | 158 | } |
| 159 | + |
| 160 | + private static IProject createLinkedProject(String projectName, Plugin plugin, IPath linkPath) throws CoreException { |
| 161 | + IWorkspace workspace= ResourcesPlugin.getWorkspace(); |
| 162 | + IProject project= workspace.getRoot().getProject(projectName); |
| 163 | + |
| 164 | + IProjectDescription desc= workspace.newProjectDescription(projectName); |
| 165 | + File file= FileTool.getFileInPlugin(plugin, linkPath); |
| 166 | + IPath projectLocation= IPath.fromOSString(file.getAbsolutePath()); |
| 167 | + if (Platform.getLocation().equals(projectLocation)) |
| 168 | + projectLocation= null; |
| 169 | + desc.setLocation(projectLocation); |
| 170 | + |
| 171 | + NullProgressMonitor monitor= new NullProgressMonitor(); |
| 172 | + project.create(desc, monitor); |
| 173 | + if (!project.isOpen()) |
| 174 | + project.open(monitor); |
| 175 | + |
| 176 | + return project; |
| 177 | + } |
150 | 178 | } |
0 commit comments