Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 125951 Details for
Bug 251370
Concurrent Modification Exception in AliasManager.updateAliases due to refresh
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Test 3 (this & bug251408
bug251370-test.txt (text/plain), 9.57 KB, created by
James Blackburn
on 2009-02-17 17:03:13 EST
(
hide
)
Description:
Test 3 (this & bug251408
Filename:
MIME Type:
Creator:
James Blackburn
Created:
2009-02-17 17:03:13 EST
Size:
9.57 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.tests.resources >Index: src/org/eclipse/core/tests/resources/LinkedResourceTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/LinkedResourceTest.java,v >retrieving revision 1.52 >diff -u -r1.52 LinkedResourceTest.java >--- src/org/eclipse/core/tests/resources/LinkedResourceTest.java 17 Nov 2008 04:21:27 -0000 1.52 >+++ src/org/eclipse/core/tests/resources/LinkedResourceTest.java 17 Feb 2009 21:59:18 -0000 >@@ -10,7 +10,10 @@ > *******************************************************************************/ > package org.eclipse.core.tests.resources; > >+import org.eclipse.core.runtime.jobs.Job; >+ > import java.io.*; >+import java.io.File; > import java.net.URI; > import java.util.HashMap; > import junit.framework.Test; >@@ -1640,4 +1643,247 @@ > assertTrue("2.0", link.exists()); > assertTrue("2.1", linkChild.exists()); > } >+ >+ /** >+ * Bug251370 >+ * Updating a .project file within a nested Project causes problems when the project is closed >+ * and then reopened (having moved one of the linked resources) >+ * >+ * This test creates a linked resource between the inner project and outer project. >+ * The first linked resource is relative to a path variable "ROOT" >+ * The second is absolute. >+ * >+ * Overwrite the .project file externally (such that the file is out of sync.). >+ * Problem occurs. >+ */ >+ public void testChangingLinksWithNestedProjects() { >+ // /ExistingProject/foo >+ final String sOverlappingProject = "foo"; >+ final IFolder overlappingFolder = existingProject.getFolder(sOverlappingProject); >+ ensureExistsInFileSystem(overlappingFolder); >+ >+ // /foo -> /ExistingProject/foo >+ final IProject overlappingProject = getWorkspace().getRoot().getProject(sOverlappingProject); >+ IProjectDescription desc = getWorkspace().newProjectDescription(sOverlappingProject); >+ desc.setLocation(overlappingFolder.getLocation()); >+ try { >+ overlappingProject.create(desc, getMonitor()); >+ overlappingProject.open(getMonitor()); >+ assertTrue("0.9",overlappingProject.exists()); >+ } catch (CoreException e) { >+ fail("1.0"); >+ } >+ >+ // Create a path variable for the workspace root >+ try { >+ IPath ROOT = getWorkspace().getRoot().getLocation(); >+ getWorkspace().getPathVariableManager().setValue("ROOT", ROOT); >+ } catch (CoreException e) { >+ fail("1.5"); >+ } >+ >+ // Two linked resource paths: >+ // 1) Uses path variable >+ IPath l1 = new Path("ROOT").append(existingFolderInExistingProject.getFullPath()); >+ // 2) uses absolute path >+ IPath l2 = existingFolderInExistingProject.getLocation(); >+ >+ // Refresh Workspace >+ try { >+ getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); >+ } catch (CoreException e) { >+ fail ("2.0"); >+ } >+ >+ // Create a link to the folder in the existing project (using absolute path) >+ // /foo/linkedFolder -> /ExistingProject/existingFolderInExistingProject >+ IFolder linkedFolder = overlappingProject.getFolder("linkedFolder"); >+ try { >+ linkedFolder.createLink(l1, IResource.REPLACE, getMonitor()); >+ assertTrue("1.9",linkedFolder.exists()); >+ // Back-up .project the file to .project1 >+ overlappingProject.getFile(".project").copy(new Path(".project1"), true, getMonitor()); >+ } catch (CoreException e) { >+ fail("3.0"); >+ } >+ >+ // Change the variable to be relative to the ROOT variable >+ try { >+ linkedFolder.delete(true, getMonitor()); >+ linkedFolder.createLink(l2, IResource.REPLACE, getMonitor()); >+ assertTrue(linkedFolder.exists()); >+ // Back-up .project the file to .project2 >+ overlappingProject.getFile(".project").copy(new Path(".project2"), true, getMonitor()); >+ } catch (CoreException e) { >+ fail("5.0"); >+ } >+ >+ // Switch between the two version of the .project file >+ try { >+ overlappingProject.close(getMonitor()); >+ copyFile(overlappingFolder.getFile(".project1").getLocation().toFile(), >+ overlappingFolder.getFile(".project").getLocation().toFile()); >+ overlappingProject.open(getMonitor()); >+ getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); >+ } catch (CoreException e) { >+ fail ("10.0"); >+ } >+ >+ try { >+ overlappingProject.close(getMonitor()); >+ copyFile(overlappingFolder.getFile(".project2").getLocation().toFile(), >+ overlappingFolder.getFile(".project").getLocation().toFile()); >+ overlappingProject.open(getMonitor()); >+ getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); >+ } catch (CoreException e) { >+ fail ("11.0"); >+ } >+ } >+ >+ /** >+ * Helper method to copy file from source to dest, ensuring that the modification >+ * time has incremented >+ * @param src >+ * @param dst >+ */ >+ private void copyFile(File src, File dst) { >+ long initModificationTime = dst.lastModified(); >+ FileInputStream in = null; >+ FileOutputStream out = null; >+ try { >+ in = new FileInputStream(src); >+ out = new FileOutputStream(dst); >+ byte[] buffer = new byte[8192]; >+ int bytesRead; >+ while ((bytesRead = in.read(buffer)) != -1) >+ out.write(buffer, 0, bytesRead); >+ } catch (Exception e) { >+ fail("Exception copyingFile: " + src.getAbsolutePath() + " -> " + dst.getAbsolutePath()); >+ } finally { >+ if (in != null) >+ try {in.close();} catch (Exception e) {/*Don't care*/} >+ if (out != null) >+ try {out.close();} catch (Exception e) {/*Don't care*/} >+ } >+ >+ while (dst.lastModified() - initModificationTime == 0) { >+ // Unix stat doesn't return granularity < 1000ms :( >+ // If we don't sleep here, and the unit test goes too quickly, we're scuppered. >+ try { >+ Thread.sleep(200); >+ } catch (InterruptedException e) { >+ // Don't care >+ } >+ dst.setLastModified(System.currentTimeMillis()); >+ } >+ } >+ >+ /** >+ * Bug251408 >+ * Updating the .project file of an inner-nested Project causes problems when the the scheduling >+ * rule for the outer project is held but it doesn't contain the scheduling rule for the inner project. >+ * >+ * This test creates a linked resource between the inner project and outer project. >+ * The first linked resource is relative to a path variable "ROOT" >+ * The second is absolute. >+ * >+ * Overwrite the .project file externally (such that the file is out of sync.). >+ * Problem occurs. >+ */ >+ public void testChangingLinksWithNestedProjects2() { >+ // /ExistingProject/foo >+ final String sOverlappingProject = "foo"; >+ final IFolder overlappingFolder = existingProject.getFolder(sOverlappingProject); >+ ensureExistsInFileSystem(overlappingFolder); >+ >+ // /foo -> /ExistingProject/foo >+ final IProject overlappingProject = getWorkspace().getRoot().getProject(sOverlappingProject); >+ IProjectDescription desc = getWorkspace().newProjectDescription(sOverlappingProject); >+ desc.setLocation(overlappingFolder.getLocation()); >+ try { >+ overlappingProject.create(desc, getMonitor()); >+ overlappingProject.open(getMonitor()); >+ assertTrue("0.9",overlappingProject.exists()); >+ } catch (CoreException e) { >+ fail("1.0"); >+ } >+ >+ // Create a path variable for the workspace root >+ try { >+ IPath ROOT = getWorkspace().getRoot().getLocation(); >+ getWorkspace().getPathVariableManager().setValue("ROOT", ROOT); >+ } catch (CoreException e) { >+ fail("1.5"); >+ } >+ >+ // Two linked resource paths: >+ // 1) Uses path variable >+ IPath l1 = new Path("ROOT").append(existingFolderInExistingProject.getFullPath()); >+ // 2) uses absolute path >+ IPath l2 = existingFolderInExistingProject.getLocation(); >+ >+ // Refresh Workspace >+ try { >+ getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); >+ } catch (CoreException e) { >+ fail ("2.0"); >+ } >+ >+ // Create a link to the folder in the existing project (using absolute path) >+ // /foo/linkedFolder -> /ExistingProject/existingFolderInExistingProject >+ IFolder linkedFolder = overlappingProject.getFolder("linkedFolder"); >+ try { >+ linkedFolder.createLink(l1, IResource.REPLACE, getMonitor()); >+ assertTrue("1.9",linkedFolder.exists()); >+ // Back-up .project the file to .project1 >+ overlappingProject.getFile(".project").copy(new Path(".project1"), true, getMonitor()); >+ } catch (CoreException e) { >+ fail("3.0"); >+ } >+ >+ // Change the variable to be relative to the ROOT variable >+ try { >+ linkedFolder.delete(true, getMonitor()); >+ linkedFolder.createLink(l2, IResource.REPLACE, getMonitor()); >+ assertTrue(linkedFolder.exists()); >+ // Back-up .project the file to .project2 >+ overlappingProject.getFile(".project").copy(new Path(".project2"), true, getMonitor()); >+ } catch (CoreException e) { >+ fail("5.0"); >+ } >+ >+ // Refresh Workspace >+ try { >+ getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, getMonitor()); >+ } catch (CoreException e) { >+ fail ("2.0"); >+ } >+ >+ // FIXME if we don't sleep here then there's no issue... >+ try { >+ Thread.sleep(1000); >+ }catch (Exception e){} >+ >+ try { >+ // Now lock the outer project, and overwrite the inner project's >+ // .project file (as might be done by a team provider) >+ Job.getJobManager().beginRule(existingProject, getMonitor()); >+ >+ // Switch between the two version of the .project file >+ try { >+ overlappingFolder.getFile(".project").setContents(overlappingFolder.getFile(".project1").getContents(), true, false, getMonitor()); >+ } catch (CoreException e) { >+ fail ("10.0"); >+ } >+ >+ try { >+ overlappingFolder.getFile(".project").setContents(overlappingFolder.getFile(".project2").getContents(), true, false, getMonitor()); >+ } catch (CoreException e) { >+ fail ("11.0"); >+ } >+ } finally { >+ Job.getJobManager().endRule(existingProject); >+ } >+ } >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 251370
:
115550
|
115557
|
119602
|
125950
| 125951