diff options
Diffstat (limited to 'tests/org.eclipse.team.tests.cvs.core/src/org/eclipse')
29 files changed, 2093 insertions, 2093 deletions
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java index 59bcb3340..fd5f21920 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSClientException.java @@ -17,11 +17,11 @@ import org.eclipse.team.internal.ccvs.core.CVSException; public class CVSClientException extends CVSException { /** - * Comment for <code>serialVersionUID</code> - */ - private static final long serialVersionUID = 1L; + * Comment for <code>serialVersionUID</code> + */ + private static final long serialVersionUID = 1L; - public CVSClientException(String message) { + public CVSClientException(String message) { super(message); } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java index d7ef72b33..bc3180255 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/CVSTestSetup.java @@ -33,10 +33,10 @@ public class CVSTestSetup extends TestSetup { public static final int WAIT_FACTOR; public static final int COMPRESSION_LEVEL; public static final boolean FAIL_IF_EXCEPTION_LOGGED; - public static final boolean RECORD_PROTOCOL_TRAFFIC; - public static final boolean ENSURE_SEQUENTIAL_ACCESS; - public static final boolean FAIL_ON_BAD_DIFF; - public static final int TIMEOUT = 600; + public static final boolean RECORD_PROTOCOL_TRAFFIC; + public static final boolean ENSURE_SEQUENTIAL_ACCESS; + public static final boolean FAIL_ON_BAD_DIFF; + public static final int TIMEOUT = 600; public static CVSRepositoryLocation repository; public static CVSTestLogListener logListener; @@ -52,9 +52,9 @@ public class CVSTestSetup extends TestSetup { WAIT_FACTOR = Integer.parseInt(System.getProperty("eclipse.cvs.waitFactor", "1")); COMPRESSION_LEVEL = Integer.parseInt(System.getProperty("eclipse.cvs.compressionLevel", "0")); FAIL_IF_EXCEPTION_LOGGED = Boolean.valueOf(System.getProperty("eclipse.cvs.failLog", "true")).booleanValue(); - RECORD_PROTOCOL_TRAFFIC = Boolean.valueOf(System.getProperty("eclipse.cvs.recordProtocolTraffic", "false")).booleanValue(); - ENSURE_SEQUENTIAL_ACCESS = Boolean.valueOf(System.getProperty("eclipse.cvs.sequentialAccess", "false")).booleanValue(); - FAIL_ON_BAD_DIFF = Boolean.valueOf(System.getProperty("eclipse.cvs.failOnBadDiff", "false")).booleanValue(); + RECORD_PROTOCOL_TRAFFIC = Boolean.valueOf(System.getProperty("eclipse.cvs.recordProtocolTraffic", "false")).booleanValue(); + ENSURE_SEQUENTIAL_ACCESS = Boolean.valueOf(System.getProperty("eclipse.cvs.sequentialAccess", "false")).booleanValue(); + FAIL_ON_BAD_DIFF = Boolean.valueOf(System.getProperty("eclipse.cvs.failOnBadDiff", "false")).booleanValue(); } public static void loadProperties() { diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java index 4e9a3bf89..89a823af7 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java @@ -107,9 +107,9 @@ import org.eclipse.ui.internal.decorators.DecoratorManager; public class EclipseTest extends ResourceTest { private static final int LOCK_WAIT_TIME = 1000; - private static final String CVS_TEST_LOCK_FILE = ".lock"; - private static final String CVS_TEST_LOCK_PROJECT = "cvsTestLock"; - protected static IProgressMonitor DEFAULT_MONITOR = new NullProgressMonitor(); + private static final String CVS_TEST_LOCK_FILE = ".lock"; + private static final String CVS_TEST_LOCK_PROJECT = "cvsTestLock"; + protected static IProgressMonitor DEFAULT_MONITOR = new NullProgressMonitor(); protected static final int RANDOM_CONTENT_SIZE = 3876; protected static String eol = System.getProperty("line.separator"); private static boolean modelSync = true; @@ -220,12 +220,12 @@ public class EclipseTest extends ResourceTest { protected void addResources(IResource[] newResources) throws CoreException { if (newResources.length == 0) return; ResourceMapping[] mappings = asResourceMappers(newResources, IResource.DEPTH_INFINITE); - add(mappings); + add(mappings); } - protected void add(ResourceMapping[] mappings) throws CVSException { - executeHeadless(new AddOperation(null, mappings)); - } + protected void add(ResourceMapping[] mappings) throws CVSException { + executeHeadless(new AddOperation(null, mappings)); + } /** * Perform a CVS edit of the given resources @@ -346,49 +346,49 @@ public class EclipseTest extends ResourceTest { /** * Update the resources from an existing container with the changes from the CVS repository */ - protected IResource[] updateResources(IResource[] resources, boolean ignoreLocalChanges) throws CVSException { - LocalOption[] options = Command.NO_LOCAL_OPTIONS; + protected IResource[] updateResources(IResource[] resources, boolean ignoreLocalChanges) throws CVSException { + LocalOption[] options = Command.NO_LOCAL_OPTIONS; if(ignoreLocalChanges) { options = new LocalOption[] {Update.IGNORE_LOCAL_CHANGES}; } - ResourceMapping[] mappers = asResourceMappers(resources, IResource.DEPTH_INFINITE); + ResourceMapping[] mappers = asResourceMappers(resources, IResource.DEPTH_INFINITE); update(mappers, options); return resources; - } + } - /** - * Update the resources contained in the given mappers. - */ - protected void update(ResourceMapping[] mappings, LocalOption[] options) throws CVSException { - if (options == null) - options = Command.NO_LOCAL_OPTIONS; - if (isModelSyncEnabled() && options == Command.NO_LOCAL_OPTIONS) { - executeHeadless(new ModelUpdateOperation(null, mappings, false) { - @Override + /** + * Update the resources contained in the given mappers. + */ + protected void update(ResourceMapping[] mappings, LocalOption[] options) throws CVSException { + if (options == null) + options = Command.NO_LOCAL_OPTIONS; + if (isModelSyncEnabled() && options == Command.NO_LOCAL_OPTIONS) { + executeHeadless(new ModelUpdateOperation(null, mappings, false) { + @Override protected boolean isAttemptHeadlessMerge() { - return true; - } - @Override + return true; + } + @Override protected void handlePreviewRequest() { - // Don't preview anything - } - @Override + // Don't preview anything + } + @Override protected void handleNoChanges() { - // Do nothing - } - @Override + // Do nothing + } + @Override protected void handleValidationFailure(IStatus status) { - // Do nothing - } - @Override + // Do nothing + } + @Override protected void handleMergeFailure(IStatus status) { - // Do nothing - } - }); - } else { - executeHeadless(new UpdateOperation(null, mappings, options, null)); - } - } + // Do nothing + } + }); + } else { + executeHeadless(new UpdateOperation(null, mappings, options, null)); + } + } protected void replace(IContainer container, String[] hierarchy, CVSTag tag, boolean recurse) throws CoreException { IResource[] resources = getResources(container, hierarchy); @@ -400,31 +400,31 @@ public class EclipseTest extends ResourceTest { executeHeadless(op); } - protected void replace(ResourceMapping[] mappings) throws CVSException { - if (isModelSyncEnabled()) { - executeHeadless(new ModelReplaceOperation(null, mappings, false) { - @Override + protected void replace(ResourceMapping[] mappings) throws CVSException { + if (isModelSyncEnabled()) { + executeHeadless(new ModelReplaceOperation(null, mappings, false) { + @Override protected boolean promptForOverwrite() { - return true; - } - @Override + return true; + } + @Override protected void handlePreviewRequest() { - // Don't prompt - } - @Override + // Don't prompt + } + @Override protected void handleMergeFailure(IStatus status) { - // Don't prompt - } - @Override + // Don't prompt + } + @Override protected void handleValidationFailure(IStatus status) { - // Don't prompt - } - }); - } else { - executeHeadless(new ReplaceOperation(null, mappings, null)); - } - } - + // Don't prompt + } + }); + } else { + executeHeadless(new ReplaceOperation(null, mappings, null)); + } + } + public void updateProject(IProject project, CVSTag tag, boolean ignoreLocalChanges) throws TeamException { if (tag == null) { ResourceMapping[] mappings = asResourceMappers(new IResource[] { project }, IResource.DEPTH_INFINITE); @@ -468,51 +468,51 @@ public class EclipseTest extends ResourceTest { protected void commitResources(IResource[] resources, int depth, String message) throws TeamException, CoreException { if (resources.length == 0) return; ResourceMapping[] resourceMappers = asResourceMappers(resources, depth); - commit(resourceMappers, message); + commit(resourceMappers, message); } - /** - * Commit the resources contained by the mappers. - */ - protected void commit(ResourceMapping[] mappers, String message) throws CVSException { - executeHeadless(new CommitOperation(null, mappers, new Command.LocalOption[0], message)); - } + /** + * Commit the resources contained by the mappers. + */ + protected void commit(ResourceMapping[] mappers, String message) throws CVSException { + executeHeadless(new CommitOperation(null, mappers, new Command.LocalOption[0], message)); + } - /** - * Convert the resources to a resource mapper that traverses the resources - * to the specified depth. - * @param resources the resource - * @return a resource mapper for traversing the resources to the depth specified - */ - protected ResourceMapping[] asResourceMappers(IResource[] resources, int depth) { - return WorkspaceResourceMapper.asResourceMappers(resources, depth); - } - - protected ICVSResource asCVSResource(IResource resource) { - return CVSWorkspaceRoot.getCVSResourceFor(resource); - } - + /** + * Convert the resources to a resource mapper that traverses the resources + * to the specified depth. + * @param resources the resource + * @return a resource mapper for traversing the resources to the depth specified + */ + protected ResourceMapping[] asResourceMappers(IResource[] resources, int depth) { + return WorkspaceResourceMapper.asResourceMappers(resources, depth); + } + + protected ICVSResource asCVSResource(IResource resource) { + return CVSWorkspaceRoot.getCVSResourceFor(resource); + } + /** * Commit the resources from an existing container to the CVS repository */ public void tagProject(IProject project, CVSTag tag, boolean force) throws TeamException { ResourceMapping[] mappings = RepositoryProviderOperation.asResourceMappers(new IResource[] {project}); - tag(mappings, tag, force); + tag(mappings, tag, force); } - /** - * Tag the resources contained in the given mappings - */ - protected void tag(ResourceMapping[] mappings, CVSTag tag, boolean force) throws TeamException { - ITagOperation op = new TagOperation((IWorkbenchPart)null, mappings); - runTag(op, tag, force); - } + /** + * Tag the resources contained in the given mappings + */ + protected void tag(ResourceMapping[] mappings, CVSTag tag, boolean force) throws TeamException { + ITagOperation op = new TagOperation((IWorkbenchPart)null, mappings); + runTag(op, tag, force); + } public void tagRemoteResource(ICVSRemoteResource resource, CVSTag tag, boolean force) throws TeamException { ITagOperation op = new TagInRepositoryOperation(null, new ICVSRemoteResource[] {resource}); runTag(op, tag, force); } - + protected void runTag(ITagOperation op, CVSTag tag, boolean force) throws TeamException { op.setTag(tag); if (force) op.moveTag(); @@ -531,15 +531,15 @@ public class EclipseTest extends ResourceTest { } public void makeBranch(IResource[] resources, CVSTag version, CVSTag branch, boolean update) throws CVSException { ResourceMapping[] mappings = asResourceMappers(resources, IResource.DEPTH_INFINITE); - branch(mappings, version, branch, update); + branch(mappings, version, branch, update); } - protected void branch(ResourceMapping[] mappings, CVSTag version, CVSTag branch, boolean update) throws CVSException { - BranchOperation op = new BranchOperation(null, mappings); - op.setTags(version, branch, update); - executeHeadless(op); - } - + protected void branch(ResourceMapping[] mappings, CVSTag version, CVSTag branch, boolean update) throws CVSException { + BranchOperation op = new BranchOperation(null, mappings); + op.setTags(version, branch, update); + executeHeadless(op); + } + /** * Return a collection of resources defined by hierarchy. The resources * are added to the workspace and to the file system. If the manage flag is true, the @@ -555,7 +555,7 @@ public class EclipseTest extends ResourceTest { for (int i = 0; i < result.length; i++) { if (result[i].getType() == IResource.FILE) // 3786 bytes is the average size of Eclipse Java files! - ((IFile) result[i]).setContents(getRandomContents(RANDOM_CONTENT_SIZE), true, false, null); + ((IFile) result[i]).setContents(getRandomContents(RANDOM_CONTENT_SIZE), true, false, null); } return result; } @@ -596,8 +596,8 @@ public class EclipseTest extends ResourceTest { } protected IProject checkoutProject(IProject project, String moduleName, CVSTag tag) throws TeamException { - if (project == null) - project = getWorkspace().getRoot().getProject(new Path(moduleName).lastSegment()); + if (project == null) + project = getWorkspace().getRoot().getProject(new Path(moduleName).lastSegment()); checkout(getRepository(), project, moduleName, tag, DEFAULT_MONITOR); return project; } @@ -670,16 +670,16 @@ public class EclipseTest extends ResourceTest { * Compare resources by casting them to their prpoer type */ protected void assertEquals(IPath parent, ICVSResource resource1, ICVSResource resource2, boolean includeTimestamps, boolean includeTags) throws CoreException, CVSException, IOException { - if ((resource1 == null && resource2 == null) - || (resource1 == null && ! resource2.exists()) - || (resource2 == null && ! resource1.exists())) - return; - if (resource1 == null && resource2 != null) { - fail("Expected no resource for " + resource2.getRepositoryRelativePath() + " but there was one"); - } - if (resource2 == null && resource1 != null) { - fail("Expected resource " + resource1.getRepositoryRelativePath() + " was missing"); - } + if ((resource1 == null && resource2 == null) + || (resource1 == null && ! resource2.exists()) + || (resource2 == null && ! resource1.exists())) + return; + if (resource1 == null && resource2 != null) { + fail("Expected no resource for " + resource2.getRepositoryRelativePath() + " but there was one"); + } + if (resource2 == null && resource1 != null) { + fail("Expected resource " + resource1.getRepositoryRelativePath() + " was missing"); + } assertEquals("Resource types do not match for " + parent.append(resource1.getName()), resource1.isFolder(), resource2.isFolder()); if (!resource1.isFolder()) assertEquals(parent, (ICVSFile)resource1, (ICVSFile)resource2, includeTimestamps, includeTags); @@ -1076,17 +1076,17 @@ public class EclipseTest extends ResourceTest { public static void waitForIgnoreFileHandling() { waitForJobCompletion(SyncFileChangeListener.getDeferredHandler().getEventHandlerJob()); - waitForDecorator(); + waitForDecorator(); } - protected static void waitForDecorator() { - // Wait for the decorator job - Job[] decorators = Job.getJobManager().find(DecoratorManager.FAMILY_DECORATE); - for (int i = 0; i < decorators.length; i++) { - Job job = decorators[i]; - waitForJobCompletion(job); - } - } + protected static void waitForDecorator() { + // Wait for the decorator job + Job[] decorators = Job.getJobManager().find(DecoratorManager.FAMILY_DECORATE); + for (int i = 0; i < decorators.length; i++) { + Job job = decorators[i]; + waitForJobCompletion(job); + } + } public static void waitForSubscriberInputHandling(SubscriberSyncInfoCollector input) { input.waitForCollector(new IProgressMonitor() { @@ -1136,14 +1136,14 @@ public class EclipseTest extends ResourceTest { if (ex instanceof InvocationTargetException) throw CVSException.wrapException(ex); } - - @Override + + @Override protected void setUp() throws Exception { - RepositoryProviderOperation.consultModelsWhenBuildingScope = false; - if (CVSTestSetup.ENSURE_SEQUENTIAL_ACCESS) - obtainCVSServerLock(); - super.setUp(); - } + RepositoryProviderOperation.consultModelsWhenBuildingScope = false; + if (CVSTestSetup.ENSURE_SEQUENTIAL_ACCESS) + obtainCVSServerLock(); + super.setUp(); + } @Override protected void tearDown() throws Exception { @@ -1165,153 +1165,153 @@ public class EclipseTest extends ResourceTest { } TestUtil.cleanUp(); } - - private void obtainCVSServerLock() { - IProject project = null; - boolean firstTry = true; - while (project == null) { - try { - project = checkoutProject(null, CVS_TEST_LOCK_PROJECT , null); - } catch (TeamException e) { - // The checkout of the lock project failed so lets create it if it doesn't exist - if (firstTry) { - try { - createTestLockProject(DEFAULT_MONITOR); - } catch (TeamException e1) { - // We couldn't check out the project or create it - // It's possible someone beat us to it so we'll try the checkout again. - } - } else { - // We tried twice to check out the project and failed. - // Lets just go ahead and run but we'll log the fact that we couldn't get the lock - write(new CVSStatus(IStatus.ERROR, "Could not obtain the CVS server lock. The test will containue but any performance timings may be affected", e), 0); - return; - } - firstTry = false; - } - } - if (project != null) { - IFile lockFile = project.getFile(CVS_TEST_LOCK_FILE); - boolean obtained = false; - int attempts = 0; - while (!obtained) { - attempts++; - if (lockFile.exists()) { - // If the file exists, check if the lock has expired - if (hasExpired(lockFile)) { - try { - overwriteLock(lockFile); - return; - } catch (CoreException e) { - // Ignore the error and continue - } - } - } else { - try { - writeLock(lockFile); - return; - } catch (CoreException e) { - // Ignore the error, since it probably means someone beat us to it. - } - } - // Wait for a while before testing the lock again - try { - Thread.sleep(LOCK_WAIT_TIME); - } catch (InterruptedException e) { - // Ignore - } - try { - // Update the lockfile in case someone else got to it first - replace(new IResource[] { lockFile }, null, true); - } catch (CoreException e) { - // An error updated is not recoverable so just continue - write(new CVSStatus(IStatus.ERROR, "Could not obtain the CVS server lock. The test will continue but any performance timings may be affected", e), 0); - return; - } - if (attempts > MAX_LOCK_ATTEMPTS) { - write(new CVSStatus(IStatus.ERROR, "Could not obtain the CVS server lock. The test will continue but any performance timings may be affected", new Exception()), 0); - return; - } - } - } - } - - private boolean hasExpired(IFile lockFile) { - long timestamp = lockFile.getLocalTimeStamp(); - return System.currentTimeMillis() - timestamp > LOCK_EXPIRATION_THRESHOLD; - } + + private void obtainCVSServerLock() { + IProject project = null; + boolean firstTry = true; + while (project == null) { + try { + project = checkoutProject(null, CVS_TEST_LOCK_PROJECT , null); + } catch (TeamException e) { + // The checkout of the lock project failed so lets create it if it doesn't exist + if (firstTry) { + try { + createTestLockProject(DEFAULT_MONITOR); + } catch (TeamException e1) { + // We couldn't check out the project or create it + // It's possible someone beat us to it so we'll try the checkout again. + } + } else { + // We tried twice to check out the project and failed. + // Lets just go ahead and run but we'll log the fact that we couldn't get the lock + write(new CVSStatus(IStatus.ERROR, "Could not obtain the CVS server lock. The test will containue but any performance timings may be affected", e), 0); + return; + } + firstTry = false; + } + } + if (project != null) { + IFile lockFile = project.getFile(CVS_TEST_LOCK_FILE); + boolean obtained = false; + int attempts = 0; + while (!obtained) { + attempts++; + if (lockFile.exists()) { + // If the file exists, check if the lock has expired + if (hasExpired(lockFile)) { + try { + overwriteLock(lockFile); + return; + } catch (CoreException e) { + // Ignore the error and continue + } + } + } else { + try { + writeLock(lockFile); + return; + } catch (CoreException e) { + // Ignore the error, since it probably means someone beat us to it. + } + } + // Wait for a while before testing the lock again + try { + Thread.sleep(LOCK_WAIT_TIME); + } catch (InterruptedException e) { + // Ignore + } + try { + // Update the lockfile in case someone else got to it first + replace(new IResource[] { lockFile }, null, true); + } catch (CoreException e) { + // An error updated is not recoverable so just continue + write(new CVSStatus(IStatus.ERROR, "Could not obtain the CVS server lock. The test will continue but any performance timings may be affected", e), 0); + return; + } + if (attempts > MAX_LOCK_ATTEMPTS) { + write(new CVSStatus(IStatus.ERROR, "Could not obtain the CVS server lock. The test will continue but any performance timings may be affected", new Exception()), 0); + return; + } + } + } + } + + private boolean hasExpired(IFile lockFile) { + long timestamp = lockFile.getLocalTimeStamp(); + return System.currentTimeMillis() - timestamp > LOCK_EXPIRATION_THRESHOLD; + } - private void overwriteLock(IFile lockFile) throws CoreException { - lockFile.setContents(getLockContents(), true, true, null); - commitResources(new IResource[] { lockFile }, IResource.DEPTH_ZERO); - } + private void overwriteLock(IFile lockFile) throws CoreException { + lockFile.setContents(getLockContents(), true, true, null); + commitResources(new IResource[] { lockFile }, IResource.DEPTH_ZERO); + } - private void writeLock(IFile lockFile) throws CoreException { - lockFile.create(getLockContents(), false, null); - addResources(new IResource[] { lockFile }); - commitResources(new IResource[] { lockFile }, IResource.DEPTH_ZERO); - } + private void writeLock(IFile lockFile) throws CoreException { + lockFile.create(getLockContents(), false, null); + addResources(new IResource[] { lockFile }); + commitResources(new IResource[] { lockFile }, IResource.DEPTH_ZERO); + } - private InputStream getLockContents() { - lockId = Long.toString(System.currentTimeMillis()); - return new ByteArrayInputStream(lockId.getBytes()); - } + private InputStream getLockContents() { + lockId = Long.toString(System.currentTimeMillis()); + return new ByteArrayInputStream(lockId.getBytes()); + } - private void createTestLockProject(IProgressMonitor monitor) throws TeamException { - CVSRepositoryLocation repository = getRepository(); - RemoteFolderTree root = new RemoteFolderTree(null, repository, Path.EMPTY.toString(), null); - RemoteFolderTree child = new RemoteFolderTree(root, CVS_TEST_LOCK_PROJECT, repository, new Path(null, root.getRepositoryRelativePath()).append(CVS_TEST_LOCK_PROJECT).toString(), null); - root.setChildren(new ICVSRemoteResource[] { child }); - Session s = new Session(repository, root); - s.open(monitor, true /* open for modification */); - try { - IStatus status = Command.ADD.execute(s, - Command.NO_GLOBAL_OPTIONS, - Command.NO_LOCAL_OPTIONS, - new String[] { CVS_TEST_LOCK_PROJECT }, - null, - monitor); - // If we get a warning, the operation most likely failed so check that the status is OK - if (status.getCode() == CVSStatus.SERVER_ERROR || ! status.isOK()) { - throw new CVSServerException(status); - } - } finally { - s.close(); - } - } - + private void createTestLockProject(IProgressMonitor monitor) throws TeamException { + CVSRepositoryLocation repository = getRepository(); + RemoteFolderTree root = new RemoteFolderTree(null, repository, Path.EMPTY.toString(), null); + RemoteFolderTree child = new RemoteFolderTree(root, CVS_TEST_LOCK_PROJECT, repository, new Path(null, root.getRepositoryRelativePath()).append(CVS_TEST_LOCK_PROJECT).toString(), null); + root.setChildren(new ICVSRemoteResource[] { child }); + Session s = new Session(repository, root); + s.open(monitor, true /* open for modification */); + try { + IStatus status = Command.ADD.execute(s, + Command.NO_GLOBAL_OPTIONS, + Command.NO_LOCAL_OPTIONS, + new String[] { CVS_TEST_LOCK_PROJECT }, + null, + monitor); + // If we get a warning, the operation most likely failed so check that the status is OK + if (status.getCode() == CVSStatus.SERVER_ERROR || ! status.isOK()) { + throw new CVSServerException(status); + } + } finally { + s.close(); + } + } + private void releaseCVSServerLock() { - if (lockId != null) { - try { - IProject project = getWorkspace().getRoot().getProject(CVS_TEST_LOCK_PROJECT); - // Update the project and verify we still have the lock - IFile file = project.getFile(CVS_TEST_LOCK_FILE); - String id = getFileContents(file); - if (id.equals(lockId)) { - // We have the lock so let's free it (but first check if someone preempted us) - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); - byte[] bytes = cvsFile.getSyncBytes(); - if (bytes != null) { - String revision = ResourceSyncInfo.getRevision(bytes); - updateResources(new IResource[] { file }, true); - bytes = cvsFile.getSyncBytes(); - if (bytes == null || !ResourceSyncInfo.getRevision(bytes).equals(revision)) { - write(new CVSStatus(IStatus.ERROR, "The CVS server lock expired while this test was running. Any performance timings may be affected", new Exception()), 0); - return; - } - } - // Delete the lock file and commit - deleteResources(project, new String[] { CVS_TEST_LOCK_FILE }, true); - } - } catch (CoreException e) { - write(e.getStatus(), 0); - } catch (IOException e) { - write(new CVSStatus(IStatus.ERROR, "An error occurred while reading the lock file", e), 0); - } - } - } + if (lockId != null) { + try { + IProject project = getWorkspace().getRoot().getProject(CVS_TEST_LOCK_PROJECT); + // Update the project and verify we still have the lock + IFile file = project.getFile(CVS_TEST_LOCK_FILE); + String id = getFileContents(file); + if (id.equals(lockId)) { + // We have the lock so let's free it (but first check if someone preempted us) + ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(file); + byte[] bytes = cvsFile.getSyncBytes(); + if (bytes != null) { + String revision = ResourceSyncInfo.getRevision(bytes); + updateResources(new IResource[] { file }, true); + bytes = cvsFile.getSyncBytes(); + if (bytes == null || !ResourceSyncInfo.getRevision(bytes).equals(revision)) { + write(new CVSStatus(IStatus.ERROR, "The CVS server lock expired while this test was running. Any performance timings may be affected", new Exception()), 0); + return; + } + } + // Delete the lock file and commit + deleteResources(project, new String[] { CVS_TEST_LOCK_FILE }, true); + } + } catch (CoreException e) { + write(e.getStatus(), 0); + } catch (IOException e) { + write(new CVSStatus(IStatus.ERROR, "An error occurred while reading the lock file", e), 0); + } + } + } - protected void write(IStatus status, int indent) { + protected void write(IStatus status, int indent) { PrintStream output = System.out; indent(output, indent); output.println("Severity: " + status.getSeverity()); @@ -1471,54 +1471,54 @@ public class EclipseTest extends ResourceTest { } } - protected void assertStatusContainsCode(IStatus status, int code) { - if (status.isMultiStatus()) { - IStatus[] children = status.getChildren(); - for (int i = 0; i < children.length; i++) { - IStatus child = children[i]; - if (child.getCode() == code) - return; - } - fail("Expected status code was not present"); - } else { - assertEquals("Status code is not what is expected", status.getCode(), code); - } - } + protected void assertStatusContainsCode(IStatus status, int code) { + if (status.isMultiStatus()) { + IStatus[] children = status.getChildren(); + for (int i = 0; i < children.length; i++) { + IStatus child = children[i]; + if (child.getCode() == code) + return; + } + fail("Expected status code was not present"); + } else { + assertEquals("Status code is not what is expected", status.getCode(), code); + } + } - @Override + @Override protected void runTest() throws Throwable { - if (!CVSTestSetup.RECORD_PROTOCOL_TRAFFIC) { - super.runTest(); - return; - } - ByteArrayOutputStream os = new ByteArrayOutputStream(); - Policy.recorder = new PrintStream(os); - try { - try { - // Override the runTest method in order to print the entire trace of a - // test that failed due to a CoreException including nested exceptions - super.runTest(); - } catch (CoreException e) { - e.printStackTrace(); - write(e.getStatus(), 0); - throw e; - } - } catch (Throwable e) { - // Transfer the recorded debug info to stdout - Policy.recorder.close(); - System.out.println(new String(os.toByteArray())); - throw e; - } finally { - Policy.recorder.close(); - Policy.recorder = null; - } - } - - @Override + if (!CVSTestSetup.RECORD_PROTOCOL_TRAFFIC) { + super.runTest(); + return; + } + ByteArrayOutputStream os = new ByteArrayOutputStream(); + Policy.recorder = new PrintStream(os); + try { + try { + // Override the runTest method in order to print the entire trace of a + // test that failed due to a CoreException including nested exceptions + super.runTest(); + } catch (CoreException e) { + e.printStackTrace(); + write(e.getStatus(), 0); + throw e; + } + } catch (Throwable e) { + // Transfer the recorded debug info to stdout + Policy.recorder.close(); + System.out.println(new String(os.toByteArray())); + throw e; + } finally { + Policy.recorder.close(); + Policy.recorder = null; + } + } + + @Override protected void cleanup() throws CoreException { ensureDoesNotExistInWorkspace(getWorkspace().getRoot()); getWorkspace().save(true, null); //don't leak builder jobs, since they may affect subsequent tests waitForBuild(); - } + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java index 5fe096cbd..56f048de5 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/TestsUserAuthenticator.java @@ -39,10 +39,10 @@ public class TestsUserAuthenticator implements IUserAuthenticator { return prompt; } - @Override + @Override public boolean promptForHostKeyChange(ICVSRepositoryLocation location) { - return false; - } + return false; + } @Override public Map<ICVSRepositoryLocation, List<String>> promptToConfigureRepositoryLocations(Map<ICVSRepositoryLocation, List<String>> alternativeMap) { diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/AllTestsCompatibility.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/AllTestsCompatibility.java index 9e8a9592b..75ba49ab2 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/AllTestsCompatibility.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/AllTestsCompatibility.java @@ -22,7 +22,7 @@ public class AllTestsCompatibility extends TestSuite { suite.addTest(BasicTest.suite()); suite.addTest(ConflictTest.suite()); suite.addTest(ModuleTest.suite()); - return new CompatibleTestSetup(suite); + return new CompatibleTestSetup(suite); } public AllTestsCompatibility(String name) { diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTestsCVSResources.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTestsCVSResources.java index 8490b1c76..c1d76e126 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTestsCVSResources.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/AllTestsCVSResources.java @@ -24,7 +24,7 @@ public class AllTestsCVSResources extends EclipseTest { suite.addTest(EclipseFolderTest.suite()); suite.addTest(ResourceSyncBytesTest.suite()); suite.addTest(CVSURITest.suite()); - return suite; + return suite; } public AllTestsCVSResources(String name) { diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java index 2104dfcc8..7fe12176f 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/cvsresources/ResourceSyncInfoTest.java @@ -183,22 +183,22 @@ public class ResourceSyncInfoTest extends EclipseTest { } public void testRepositoryLocationFormats() throws CVSException { - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user@host:/home/path"), "/home/path"); - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user:password@host:/home/path"), "/home/path"); - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:host:/home/path"), "/home/path"); - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user@host:1234/home/path"), "/home/path"); - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user:password@host:1234/home/path"), "/home/path"); - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:host:1234/home/path"), "/home/path"); - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user@host/home/path"), "/home/path"); - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user:password@host/home/path"), "/home/path"); - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:host/home/path"), "/home/path"); - assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user@domain:password@host/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user@host:/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user:password@host:/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:host:/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user@host:1234/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user:password@host:1234/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:host:1234/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user@host/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user:password@host/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:host/home/path"), "/home/path"); + assertPathCorrect(CVSRepositoryLocation.fromString(":pserver:user@domain:password@host/home/path"), "/home/path"); } - private void assertPathCorrect(CVSRepositoryLocation location, String string) throws CVSException { - assertEquals(location.getRootDirectory(), string); - FolderSyncInfo info = new FolderSyncInfo("childPath", location.getLocation(), null, false); - assertEquals(info.getRemoteLocation(), string + '/' + "childPath"); - - } + private void assertPathCorrect(CVSRepositoryLocation location, String string) throws CVSException { + assertEquals(location.getRootDirectory(), string); + FolderSyncInfo info = new FolderSyncInfo("childPath", location.getLocation(), null, false); + assertEquals(info.getRemoteLocation(), string + '/' + "childPath"); + + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/ResourceMapperTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/ResourceMapperTests.java index 433c56932..6194cc4b6 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/ResourceMapperTests.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/ResourceMapperTests.java @@ -79,369 +79,369 @@ import junit.framework.Test; public class ResourceMapperTests extends EclipseTest { - public ResourceMapperTests() { - super(); - } - - public ResourceMapperTests(String name) { - super(name); - } - - public static Test suite() { - return suite(ResourceMapperTests.class); - } - - /** - * Update the resources contained in the given mappers and ensure that the - * update was performed properly by comparing the result with the reference projects. - * @throws Exception - */ - protected void update(ResourceMapping mapper, LocalOption[] options) throws Exception { - SyncInfoTree incomingSet = getIncoming(mapper.getProjects()); - update(new ResourceMapping[] { mapper }, options); - assertUpdate(mapper, incomingSet); - } - - /** - * Replace the resources contained in the given mappers and ensure that the - * update was performed properly by comparing the result with the reference projects. - * @throws Exception - */ - protected void replace(ResourceMapping mapper) throws Exception { - SyncInfoTree incomingSet = getIncoming(mapper.getProjects()); - replace(new ResourceMapping[] { mapper }); - assertUpdate(mapper, incomingSet); - } - - /** - * Commit and check that all resources in containing project that should have been committed were and - * that any not contained by the mappers were not. - * @throws CoreException - * @see org.eclipse.team.tests.ccvs.core.EclipseTest#commit(org.eclipse.core.resources.mapping.IResourceMapper[], java.lang.String) - */ - protected void commit(ResourceMapping mapper, String message) throws CoreException { - SyncInfoTree set = getOutgoing(mapper.getProjects()); - commit(new ResourceMapping[] { mapper }, message); - assertCommit(mapper, set); - } - - /** - * Tag the given resource mappings and assert that only the resources - * within the mapping were tagged. - * @throws CoreException - */ - protected void tag(ResourceMapping mapping, CVSTag tag) throws CoreException { - tag(new ResourceMapping[] { mapping }, tag, false); - assertTagged(mapping, tag); - } - - /** - * Branch the resources in the given mapping. - * @throws CoreException - * @throws IOException - */ - protected void branch(ResourceMapping mapping, CVSTag branch) throws CoreException, IOException { - CVSTag version = new CVSTag("Root_" + branch.getName(), CVSTag.VERSION); - branch(new ResourceMapping[] { mapping }, version, branch, true /* update */); - assertTagged(mapping, version); - assertBranched(mapping, branch); - } - - /** - * Add any resources contained by the mapping - * @param mapping - * @throws CoreException - */ - protected void add(ResourceMapping mapping) throws CoreException { - SyncInfoTree set = getUnaddedResource(mapping); - add(new ResourceMapping[] { mapping }); - assertAdded(mapping, set); - } - - private void assertAdded(ResourceMapping mapping, final SyncInfoTree set) throws CoreException { - // Assert that all resources covered by the mapping are now under version control (i.e. are in-sync) - // Remove the resources contained in the mapping from the set of unadded resources. - visit(mapping, ResourceMappingContext.LOCAL_CONTEXT, (IResourceVisitor) resource -> { - ICVSResource cvsResource = getCVSResource(resource); - assertTrue("Resource was not added but should have been: " + resource.getFullPath(), - (cvsResource.isManaged() - || (cvsResource.isFolder() - && ((ICVSFolder)cvsResource).isCVSFolder()))); - set.remove(resource); - return true; + public ResourceMapperTests() { + super(); + } + + public ResourceMapperTests(String name) { + super(name); + } + + public static Test suite() { + return suite(ResourceMapperTests.class); + } + + /** + * Update the resources contained in the given mappers and ensure that the + * update was performed properly by comparing the result with the reference projects. + * @throws Exception + */ + protected void update(ResourceMapping mapper, LocalOption[] options) throws Exception { + SyncInfoTree incomingSet = getIncoming(mapper.getProjects()); + update(new ResourceMapping[] { mapper }, options); + assertUpdate(mapper, incomingSet); + } + + /** + * Replace the resources contained in the given mappers and ensure that the + * update was performed properly by comparing the result with the reference projects. + * @throws Exception + */ + protected void replace(ResourceMapping mapper) throws Exception { + SyncInfoTree incomingSet = getIncoming(mapper.getProjects()); + replace(new ResourceMapping[] { mapper }); + assertUpdate(mapper, incomingSet); + } + + /** + * Commit and check that all resources in containing project that should have been committed were and + * that any not contained by the mappers were not. + * @throws CoreException + * @see org.eclipse.team.tests.ccvs.core.EclipseTest#commit(org.eclipse.core.resources.mapping.IResourceMapper[], java.lang.String) + */ + protected void commit(ResourceMapping mapper, String message) throws CoreException { + SyncInfoTree set = getOutgoing(mapper.getProjects()); + commit(new ResourceMapping[] { mapper }, message); + assertCommit(mapper, set); + } + + /** + * Tag the given resource mappings and assert that only the resources + * within the mapping were tagged. + * @throws CoreException + */ + protected void tag(ResourceMapping mapping, CVSTag tag) throws CoreException { + tag(new ResourceMapping[] { mapping }, tag, false); + assertTagged(mapping, tag); + } + + /** + * Branch the resources in the given mapping. + * @throws CoreException + * @throws IOException + */ + protected void branch(ResourceMapping mapping, CVSTag branch) throws CoreException, IOException { + CVSTag version = new CVSTag("Root_" + branch.getName(), CVSTag.VERSION); + branch(new ResourceMapping[] { mapping }, version, branch, true /* update */); + assertTagged(mapping, version); + assertBranched(mapping, branch); + } + + /** + * Add any resources contained by the mapping + * @param mapping + * @throws CoreException + */ + protected void add(ResourceMapping mapping) throws CoreException { + SyncInfoTree set = getUnaddedResource(mapping); + add(new ResourceMapping[] { mapping }); + assertAdded(mapping, set); + } + + private void assertAdded(ResourceMapping mapping, final SyncInfoTree set) throws CoreException { + // Assert that all resources covered by the mapping are now under version control (i.e. are in-sync) + // Remove the resources contained in the mapping from the set of unadded resources. + visit(mapping, ResourceMappingContext.LOCAL_CONTEXT, (IResourceVisitor) resource -> { + ICVSResource cvsResource = getCVSResource(resource); + assertTrue("Resource was not added but should have been: " + resource.getFullPath(), + (cvsResource.isManaged() + || (cvsResource.isFolder() + && ((ICVSFolder)cvsResource).isCVSFolder()))); + set.remove(resource); + return true; }); - // Assert that the remaining unadded resources are still unadded - SyncInfo[] infos = set.getSyncInfos(); - for (SyncInfo info : infos) { - ICVSResource cvsResource = getCVSResource(info.getLocal()); - assertTrue("Resource was added but should not have been: " + info.getLocal().getFullPath(), !cvsResource.isManaged()); - } - } - - /* - * Need to ensure that only the resources contained in the mapping - * have the branch tag associated with them. - */ + // Assert that the remaining unadded resources are still unadded + SyncInfo[] infos = set.getSyncInfos(); + for (SyncInfo info : infos) { + ICVSResource cvsResource = getCVSResource(info.getLocal()); + assertTrue("Resource was added but should not have been: " + info.getLocal().getFullPath(), !cvsResource.isManaged()); + } + } + + /* + * Need to ensure that only the resources contained in the mapping + * have the branch tag associated with them. + */ private void assertBranched(ResourceMapping mapping, CVSTag branch) throws CoreException { - // First, make sure the proper resources are tagged in the repo - assertTagged(mapping, branch); - // Now make sure the proper local files are tagged + // First, make sure the proper resources are tagged in the repo + assertTagged(mapping, branch); + // Now make sure the proper local files are tagged final Map<String, ICVSResource> remotes = getTaggedRemoteFilesByPath(mapping, branch); final Map<String, ICVSFile> locals = getTaggedLocalFilesByPath(mapping, branch); for (Iterator<String> iter = remotes.keySet().iterator(); iter.hasNext();) { - String key = iter.next(); - ICVSRemoteFile remote = (ICVSRemoteFile)remotes.get(key); - ICVSFile local = locals.get(key); - assertNotNull("Remotely tagged resource was not tagged locally: " + remote.getRepositoryRelativePath(), local); - assertEquals(local.getIResource().getParent().getFullPath(), remote, local, false, false /* include tags */); - assertEquals("Remotely tagged resource was not tagged locally: " + remote.getRepositoryRelativePath(), branch, local.getSyncInfo().getTag()); - locals.remove(key); - iter.remove(); - } - // The remote map should be empty after traversal - for (Object element : remotes.keySet()) { - String path = (String) element; - fail("Remote file " + path + " was tagged remotely but not locally."); - } - // The local map should be empty after traversal - for (Object element : locals.keySet()) { - String path = (String) element; - fail("Local file " + path + " was tagged locally but not remotely."); - } - } - - private void assertTagged(ResourceMapping mapping, final CVSTag tag) throws CoreException { + String key = iter.next(); + ICVSRemoteFile remote = (ICVSRemoteFile)remotes.get(key); + ICVSFile local = locals.get(key); + assertNotNull("Remotely tagged resource was not tagged locally: " + remote.getRepositoryRelativePath(), local); + assertEquals(local.getIResource().getParent().getFullPath(), remote, local, false, false /* include tags */); + assertEquals("Remotely tagged resource was not tagged locally: " + remote.getRepositoryRelativePath(), branch, local.getSyncInfo().getTag()); + locals.remove(key); + iter.remove(); + } + // The remote map should be empty after traversal + for (Object element : remotes.keySet()) { + String path = (String) element; + fail("Remote file " + path + " was tagged remotely but not locally."); + } + // The local map should be empty after traversal + for (Object element : locals.keySet()) { + String path = (String) element; + fail("Local file " + path + " was tagged locally but not remotely."); + } + } + + private void assertTagged(ResourceMapping mapping, final CVSTag tag) throws CoreException { final Map<String, ICVSResource> tagged = getTaggedRemoteFilesByPath(mapping, tag); - // Visit all the resources in the traversal and ensure that they are tagged - visit(mapping, ResourceMappingContext.LOCAL_CONTEXT, (IResourceVisitor) resource -> { - if (resource.getType() == IResource.FILE) { - ICVSRemoteFile file = popRemote(resource, tagged); - assertNotNull("Resource was not tagged: " + resource.getFullPath(), file); - } - return true; + // Visit all the resources in the traversal and ensure that they are tagged + visit(mapping, ResourceMappingContext.LOCAL_CONTEXT, (IResourceVisitor) resource -> { + if (resource.getType() == IResource.FILE) { + ICVSRemoteFile file = popRemote(resource, tagged); + assertNotNull("Resource was not tagged: " + resource.getFullPath(), file); + } + return true; }); - + for (String path : tagged.keySet()) { - fail("Remote file " + path + " was tagged but should not have been."); + fail("Remote file " + path + " was tagged but should not have been."); } - } + } private Map<String, ICVSFile> getTaggedLocalFilesByPath(ResourceMapping mapping, final CVSTag branch) throws CoreException { final Map<String, ICVSFile> tagged = new HashMap<>(); - IProject[] projects = mapping.getProjects(); - for (IProject project : projects) { - project.accept(resource -> { - if (resource.getType() == IResource.FILE) { - ICVSFile file = (ICVSFile)getCVSResource(resource); - ResourceSyncInfo info = file.getSyncInfo(); - if (info != null && info.getTag() != null && info.getTag().equals(branch)) { - tagged.put(file.getRepositoryRelativePath(), file); - } - } - return true; + IProject[] projects = mapping.getProjects(); + for (IProject project : projects) { + project.accept(resource -> { + if (resource.getType() == IResource.FILE) { + ICVSFile file = (ICVSFile)getCVSResource(resource); + ResourceSyncInfo info = file.getSyncInfo(); + if (info != null && info.getTag() != null && info.getTag().equals(branch)) { + tagged.put(file.getRepositoryRelativePath(), file); + } + } + return true; }); - } - return tagged; - } - + } + return tagged; + } + private Map<String, ICVSResource> getTaggedRemoteFilesByPath(ResourceMapping mapping, final CVSTag tag) throws CVSException { - IProject[] projects = mapping.getProjects(); - ICVSResource[] remotes = getRemoteTrees(projects, tag); + IProject[] projects = mapping.getProjects(); + ICVSResource[] remotes = getRemoteTrees(projects, tag); final Map<String, ICVSResource> tagged = getFilesByPath(remotes); - return tagged; - } + return tagged; + } - private ICVSResource[] getRemoteTrees(IProject[] projects, CVSTag tag) throws CVSException { + private ICVSResource[] getRemoteTrees(IProject[] projects, CVSTag tag) throws CVSException { List<ICVSResource> result = new ArrayList<>(); - for (IProject project : projects) { - RemoteFolderTree tree = RemoteFolderTreeBuilder.buildRemoteTree(getRepository(), project, tag, DEFAULT_MONITOR); - result.add(tree); - } - return result.toArray(new ICVSResource[result.size()]); - } + for (IProject project : projects) { + RemoteFolderTree tree = RemoteFolderTreeBuilder.buildRemoteTree(getRepository(), project, tag, DEFAULT_MONITOR); + result.add(tree); + } + return result.toArray(new ICVSResource[result.size()]); + } private Map<String, ICVSResource> getFilesByPath(ICVSResource[] remotes) throws CVSException { Map<String, ICVSResource> result = new HashMap<>(); - for (ICVSResource resource : remotes) { - collectFiles(resource, result); - } - return result; - } + for (ICVSResource resource : remotes) { + collectFiles(resource, result); + } + return result; + } private void collectFiles(ICVSResource resource, Map<String, ICVSResource> result) throws CVSException { - if (resource.isFolder()) { - ICVSResource[] members = ((ICVSFolder)resource).members(ICVSFolder.ALL_EXISTING_MEMBERS); - for (ICVSResource member : members) { - collectFiles(member, result); - } - } else { - result.put(resource.getRepositoryRelativePath(), resource); - } - } + if (resource.isFolder()) { + ICVSResource[] members = ((ICVSFolder)resource).members(ICVSFolder.ALL_EXISTING_MEMBERS); + for (ICVSResource member : members) { + collectFiles(member, result); + } + } else { + result.put(resource.getRepositoryRelativePath(), resource); + } + } private ICVSRemoteFile popRemote(IResource resource, Map<String, ICVSResource> tagged) throws CVSException { - ICVSResource cvsResource = getCVSResource(resource); - ICVSRemoteFile remote = (ICVSRemoteFile)tagged.get(cvsResource.getRepositoryRelativePath()); - if (remote != null) { - tagged.remove(remote.getRepositoryRelativePath()); - } - return remote; - } - - private ResourceMapping asResourceMapping(final IResource[] resources, final int depth) { - return new ResourceMapping() { - private Object object = new Object(); - @Override + ICVSResource cvsResource = getCVSResource(resource); + ICVSRemoteFile remote = (ICVSRemoteFile)tagged.get(cvsResource.getRepositoryRelativePath()); + if (remote != null) { + tagged.remove(remote.getRepositoryRelativePath()); + } + return remote; + } + + private ResourceMapping asResourceMapping(final IResource[] resources, final int depth) { + return new ResourceMapping() { + private Object object = new Object(); + @Override public Object getModelObject() { - return object; - } - @Override + return object; + } + @Override public IProject[] getProjects() { - return getProjects(resources); - } - private IProject[] getProjects(IResource[] resources) { + return getProjects(resources); + } + private IProject[] getProjects(IResource[] resources) { Set<IProject> projects = new HashSet<>(); - for (IResource resource : resources) { - projects.add(resource.getProject()); - } - return projects.toArray(new IProject[projects.size()]); - } - @Override + for (IResource resource : resources) { + projects.add(resource.getProject()); + } + return projects.toArray(new IProject[projects.size()]); + } + @Override public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException { - return new ResourceTraversal[] { - new ResourceTraversal(resources, depth, IResource.NONE) - }; - } + return new ResourceTraversal[] { + new ResourceTraversal(resources, depth, IResource.NONE) + }; + } @Override public String getModelProviderId() { return "org.eclipse.team.tests.cvs.core.modelProvider"; } - }; - } - - private void assertUpdate(ResourceMapping mapper, final SyncInfoTree set) throws Exception { - final Exception[] exception = new Exception[] { null }; - visit(mapper, new SyncInfoSetTraveralContext(set), (IResourceVisitor) resource -> { - SyncInfo info = set.getSyncInfo(resource); - if (info != null) { - set.remove(resource); - try { - // Assert that the local sync info matches the remote info - assertEquals(resource.getParent().getFullPath(), getCVSResource(resource), (ICVSResource)info.getRemote(), false, false); - } catch (CVSException e1) { - exception[0] = e1; - } catch (CoreException e2) { - exception[0] = e2; - } catch (IOException e3) { - exception[0] = e3; - } - } - return true; + }; + } + + private void assertUpdate(ResourceMapping mapper, final SyncInfoTree set) throws Exception { + final Exception[] exception = new Exception[] { null }; + visit(mapper, new SyncInfoSetTraveralContext(set), (IResourceVisitor) resource -> { + SyncInfo info = set.getSyncInfo(resource); + if (info != null) { + set.remove(resource); + try { + // Assert that the local sync info matches the remote info + assertEquals(resource.getParent().getFullPath(), getCVSResource(resource), (ICVSResource)info.getRemote(), false, false); + } catch (CVSException e1) { + exception[0] = e1; + } catch (CoreException e2) { + exception[0] = e2; + } catch (IOException e3) { + exception[0] = e3; + } + } + return true; }); - if (exception[0] != null) throw exception[0]; - - // check the the state of the remaining resources has not changed - assertUnchanged(set); - } - - private void assertCommit(ResourceMapping mapper, final SyncInfoTree set) throws CoreException { - visit(mapper, new SyncInfoSetTraveralContext(set), (IResourceVisitor) resource -> { - SyncInfo info = set.getSyncInfo(resource); - if (info != null) { - set.remove(resource); - assertTrue("Committed resource is not in-sync: " + resource.getFullPath(), getSyncInfo(resource).getKind() == SyncInfo.IN_SYNC); - } - return true; + if (exception[0] != null) throw exception[0]; + + // check the the state of the remaining resources has not changed + assertUnchanged(set); + } + + private void assertCommit(ResourceMapping mapper, final SyncInfoTree set) throws CoreException { + visit(mapper, new SyncInfoSetTraveralContext(set), (IResourceVisitor) resource -> { + SyncInfo info = set.getSyncInfo(resource); + if (info != null) { + set.remove(resource); + assertTrue("Committed resource is not in-sync: " + resource.getFullPath(), getSyncInfo(resource).getKind() == SyncInfo.IN_SYNC); + } + return true; }); - // check the the state of the remaining resources has not changed - assertUnchanged(set); - } - - /* - * Assert that the state of the resources in the set have not changed - */ - private void assertUnchanged(SyncInfoTree set) throws TeamException { - //TODO: Need to refresh the subscriber since flush of remote state is deep - CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().refresh(set.getResources(), IResource.DEPTH_ZERO, DEFAULT_MONITOR); - SyncInfo[] infos = set.getSyncInfos(); - for (SyncInfo info : infos) { - assertUnchanged(info); - } - } - - private void assertUnchanged(SyncInfo info) throws TeamException { - SyncInfo current = getSyncInfo(info.getLocal()); - assertEquals("The sync info changed for " + info.getLocal().getFullPath(), info, current); - } - - private SyncInfo getSyncInfo(IResource local) throws TeamException { - return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().getSyncInfo(local); - } - - private SyncInfoTree getIncoming(IProject[] projects) throws TeamException { - CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().refresh(projects, IResource.DEPTH_INFINITE, DEFAULT_MONITOR); - SyncInfoTree set = getAllOutOfSync(projects); - set.removeOutgoingNodes(); - set.removeConflictingNodes(); - return set; - } - - private SyncInfoTree getOutgoing(IProject[] projects) { - SyncInfoTree set = getAllOutOfSync(projects); - set.removeIncomingNodes(); - set.removeConflictingNodes(); - return set; - } - - private SyncInfoTree getUnaddedResource(ResourceMapping mapping) { - SyncInfoTree set = getAllOutOfSync(mapping.getProjects()); - set.selectNodes(new FastSyncInfoFilter() { - @Override + // check the the state of the remaining resources has not changed + assertUnchanged(set); + } + + /* + * Assert that the state of the resources in the set have not changed + */ + private void assertUnchanged(SyncInfoTree set) throws TeamException { + //TODO: Need to refresh the subscriber since flush of remote state is deep + CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().refresh(set.getResources(), IResource.DEPTH_ZERO, DEFAULT_MONITOR); + SyncInfo[] infos = set.getSyncInfos(); + for (SyncInfo info : infos) { + assertUnchanged(info); + } + } + + private void assertUnchanged(SyncInfo info) throws TeamException { + SyncInfo current = getSyncInfo(info.getLocal()); + assertEquals("The sync info changed for " + info.getLocal().getFullPath(), info, current); + } + + private SyncInfo getSyncInfo(IResource local) throws TeamException { + return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().getSyncInfo(local); + } + + private SyncInfoTree getIncoming(IProject[] projects) throws TeamException { + CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().refresh(projects, IResource.DEPTH_INFINITE, DEFAULT_MONITOR); + SyncInfoTree set = getAllOutOfSync(projects); + set.removeOutgoingNodes(); + set.removeConflictingNodes(); + return set; + } + + private SyncInfoTree getOutgoing(IProject[] projects) { + SyncInfoTree set = getAllOutOfSync(projects); + set.removeIncomingNodes(); + set.removeConflictingNodes(); + return set; + } + + private SyncInfoTree getUnaddedResource(ResourceMapping mapping) { + SyncInfoTree set = getAllOutOfSync(mapping.getProjects()); + set.selectNodes(new FastSyncInfoFilter() { + @Override public boolean select(SyncInfo info) { - try { - if (info.getLocal().getType() != IResource.PROJECT && info.getRemote() == null && info.getBase() == null) { - ICVSResource resource = getCVSResource(info.getLocal()); - return !resource.isManaged(); - } - } catch (CVSException e) { - fail(e.getMessage()); - } - return false; - } - }); - return set; - } - - private SyncInfoTree getAllOutOfSync(IProject[] projects) { - SyncInfoTree set = new SyncInfoTree(); - CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().collectOutOfSync(projects, IResource.DEPTH_INFINITE, set, DEFAULT_MONITOR); - return set; - } - - private IResourceDiffTree getAllDiffs(IProject[] projects) throws CoreException { - final ResourceDiffTree tree = new ResourceDiffTree(); - CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().accept(projects, IResource.DEPTH_INFINITE, delta -> { + try { + if (info.getLocal().getType() != IResource.PROJECT && info.getRemote() == null && info.getBase() == null) { + ICVSResource resource = getCVSResource(info.getLocal()); + return !resource.isManaged(); + } + } catch (CVSException e) { + fail(e.getMessage()); + } + return false; + } + }); + return set; + } + + private SyncInfoTree getAllOutOfSync(IProject[] projects) { + SyncInfoTree set = new SyncInfoTree(); + CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().collectOutOfSync(projects, IResource.DEPTH_INFINITE, set, DEFAULT_MONITOR); + return set; + } + + private IResourceDiffTree getAllDiffs(IProject[] projects) throws CoreException { + final ResourceDiffTree tree = new ResourceDiffTree(); + CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().accept(projects, IResource.DEPTH_INFINITE, delta -> { tree.add(delta); return true; }); - return tree; - } - - private void visit(ResourceMapping mapper, ResourceMappingContext context, IResourceVisitor visitor) throws CoreException { - ResourceTraversal[] traversals = mapper.getTraversals(context, null); - for (ResourceTraversal traversal : traversals) { - visit(traversal, context, visitor); - } - } - - private void visit(ResourceTraversal traversal, ResourceMappingContext context, IResourceVisitor visitor) throws CoreException { - IResource[] resources = traversal.getResources(); - for (IResource resource : resources) { - visit(resource, visitor, context, traversal.getDepth()); - } - } + return tree; + } + + private void visit(ResourceMapping mapper, ResourceMappingContext context, IResourceVisitor visitor) throws CoreException { + ResourceTraversal[] traversals = mapper.getTraversals(context, null); + for (ResourceTraversal traversal : traversals) { + visit(traversal, context, visitor); + } + } + + private void visit(ResourceTraversal traversal, ResourceMappingContext context, IResourceVisitor visitor) throws CoreException { + IResource[] resources = traversal.getResources(); + for (IResource resource : resources) { + visit(resource, visitor, context, traversal.getDepth()); + } + } private void visit(IResource resource, IResourceVisitor visitor, ResourceMappingContext context, int depth) throws CoreException { @@ -458,7 +458,7 @@ public class ResourceMapperTests extends EclipseTest { depth == IResource.DEPTH_ONE ? IResource.DEPTH_ZERO : IResource.DEPTH_INFINITE); } } - + private boolean isTimeout(Throwable e) { if (e == null) { return false; @@ -487,34 +487,34 @@ public class ResourceMapperTests extends EclipseTest { return isTimeout(e.getCause()); } - public void testUpdate() throws Exception { - try{ - // Create a test project, import it into cvs and check it out - IProject project = createProject("testUpdate", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); + public void testUpdate() throws Exception { + try{ + // Create a test project, import it into cvs and check it out + IProject project = createProject("testUpdate", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); - // Check the project out under a different name - IProject copy = checkoutCopy(project, "-copy"); - - // Perform some operations on the copy and commit them all - addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false); - setContentsAndEnsureModified(copy.getFile("changed.txt")); - deleteResources(new IResource[] {copy.getFile("deleted.txt")}); - setContentsAndEnsureModified(copy.getFile("folder1/a.txt")); - setContentsAndEnsureModified(copy.getFile("folder1/subfolder1/c.txt")); - commit(asResourceMapping(new IResource[] { copy }, IResource.DEPTH_INFINITE), "A commit message"); - - // Update the project using depth one and ensure we got only what was asked for - update(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE), null); - - // Update a subfolder using depth one and ensure we got only what was asked for - update(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE), null); - - // Update the specific file - update(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO), null); - - // Update the remaining resources - update(asResourceMapping(new IResource[] { project.getFolder("folder2") }, IResource.DEPTH_INFINITE), null); - assertEquals(project, copy); + // Check the project out under a different name + IProject copy = checkoutCopy(project, "-copy"); + + // Perform some operations on the copy and commit them all + addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false); + setContentsAndEnsureModified(copy.getFile("changed.txt")); + deleteResources(new IResource[] {copy.getFile("deleted.txt")}); + setContentsAndEnsureModified(copy.getFile("folder1/a.txt")); + setContentsAndEnsureModified(copy.getFile("folder1/subfolder1/c.txt")); + commit(asResourceMapping(new IResource[] { copy }, IResource.DEPTH_INFINITE), "A commit message"); + + // Update the project using depth one and ensure we got only what was asked for + update(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE), null); + + // Update a subfolder using depth one and ensure we got only what was asked for + update(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE), null); + + // Update the specific file + update(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO), null); + + // Update the remaining resources + update(asResourceMapping(new IResource[] { project.getFolder("folder2") }, IResource.DEPTH_INFINITE), null); + assertEquals(project, copy); } catch (Exception e) { if (isTimeout(e)) { //TODO see Bug 399375 @@ -524,37 +524,37 @@ public class ResourceMapperTests extends EclipseTest { } throw e; } - } - - public void testReplace() throws Exception { - try{ - // Create a test project, import it into cvs and check it out - IProject project = createProject("testReplace", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); + } + + public void testReplace() throws Exception { + try{ + // Create a test project, import it into cvs and check it out + IProject project = createProject("testReplace", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); - // Check the project out under a different name - IProject copy = checkoutCopy(project, "-copy"); - - // Perform some operations on the copy and commit them all - addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false); - setContentsAndEnsureModified(copy.getFile("changed.txt")); - deleteResources(new IResource[] {copy.getFile("deleted.txt")}); - setContentsAndEnsureModified(copy.getFile("folder1/a.txt")); - setContentsAndEnsureModified(copy.getFile("folder1/subfolder1/c.txt")); - commit(asResourceMapping(new IResource[] { copy }, IResource.DEPTH_INFINITE), "A commit message"); - - // Update the project using depth one and ensure we got only what was asked for - replace(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE)); - - // Update a subfolder using depth one and ensure we got only what was asked for - deleteResources(new IResource[] {project.getFile("folder1/b.txt")}); - replace(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE)); - - // Update the specific file - replace(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO)); - - // Update the remaining resources - replace(asResourceMapping(new IResource[] { project.getFolder("folder2") }, IResource.DEPTH_INFINITE)); - assertEquals(project, copy); + // Check the project out under a different name + IProject copy = checkoutCopy(project, "-copy"); + + // Perform some operations on the copy and commit them all + addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false); + setContentsAndEnsureModified(copy.getFile("changed.txt")); + deleteResources(new IResource[] {copy.getFile("deleted.txt")}); + setContentsAndEnsureModified(copy.getFile("folder1/a.txt")); + setContentsAndEnsureModified(copy.getFile("folder1/subfolder1/c.txt")); + commit(asResourceMapping(new IResource[] { copy }, IResource.DEPTH_INFINITE), "A commit message"); + + // Update the project using depth one and ensure we got only what was asked for + replace(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE)); + + // Update a subfolder using depth one and ensure we got only what was asked for + deleteResources(new IResource[] {project.getFile("folder1/b.txt")}); + replace(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE)); + + // Update the specific file + replace(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO)); + + // Update the remaining resources + replace(asResourceMapping(new IResource[] { project.getFolder("folder2") }, IResource.DEPTH_INFINITE)); + assertEquals(project, copy); } catch (Exception e) { if (isTimeout(e)) { //TODO see Bug 399375 @@ -564,100 +564,100 @@ public class ResourceMapperTests extends EclipseTest { } throw e; } - } + } - public void testCommit() throws Exception { + public void testCommit() throws Exception { if (TeamCVSTestPlugin.IS_UNSTABLE_TEST && Util.isMac()) return; - // Create a test project, import it into cvs and check it out - IProject project = createProject("testCommit", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); - - // Perform some operations on the copy and commit only the top level - addResources(project, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false); - setContentsAndEnsureModified(project.getFile("changed.txt")); - deleteResources(new IResource[] {project.getFile("deleted.txt")}); - setContentsAndEnsureModified(project.getFile("folder1/a.txt")); - setContentsAndEnsureModified(project.getFile("folder1/subfolder1/c.txt")); - - // Commit the project shallow - commit(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE), "A commit message"); - - // Commit a subfolder shallow - commit(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE), "A commit message"); - - // Now commit the file specifically - commit(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO), "A commit message"); - - // Now commit the rest - commit(asResourceMapping(new IResource[] { project.getFolder("folder2") }, IResource.DEPTH_INFINITE), "A commit message"); - - // Check the project out under a different name - IProject copy = checkoutCopy(project, "-copy"); - assertEquals(project, copy); - } - - public void testTag() throws Exception { - // Create a test project, import it into cvs and check it out - IProject project = createProject("testTag", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); - - tag(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE), new CVSTag("v1", CVSTag.VERSION)); - tag(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE), new CVSTag("v2", CVSTag.VERSION)); - tag(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO), new CVSTag("v3", CVSTag.VERSION)); - tag(asResourceMapping(new IResource[] { project}, IResource.DEPTH_INFINITE), new CVSTag("v4", CVSTag.VERSION)); - } - - public void testBranch() throws Exception { + // Create a test project, import it into cvs and check it out + IProject project = createProject("testCommit", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); + + // Perform some operations on the copy and commit only the top level + addResources(project, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false); + setContentsAndEnsureModified(project.getFile("changed.txt")); + deleteResources(new IResource[] {project.getFile("deleted.txt")}); + setContentsAndEnsureModified(project.getFile("folder1/a.txt")); + setContentsAndEnsureModified(project.getFile("folder1/subfolder1/c.txt")); + + // Commit the project shallow + commit(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE), "A commit message"); + + // Commit a subfolder shallow + commit(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE), "A commit message"); + + // Now commit the file specifically + commit(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO), "A commit message"); + + // Now commit the rest + commit(asResourceMapping(new IResource[] { project.getFolder("folder2") }, IResource.DEPTH_INFINITE), "A commit message"); + + // Check the project out under a different name + IProject copy = checkoutCopy(project, "-copy"); + assertEquals(project, copy); + } + + public void testTag() throws Exception { + // Create a test project, import it into cvs and check it out + IProject project = createProject("testTag", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); + + tag(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE), new CVSTag("v1", CVSTag.VERSION)); + tag(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE), new CVSTag("v2", CVSTag.VERSION)); + tag(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO), new CVSTag("v3", CVSTag.VERSION)); + tag(asResourceMapping(new IResource[] { project}, IResource.DEPTH_INFINITE), new CVSTag("v4", CVSTag.VERSION)); + } + + public void testBranch() throws Exception { if (TeamCVSTestPlugin.IS_UNSTABLE_TEST) return; - // Create a test project, import it into cvs and check it out - IProject project = createProject("testBranch", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); - - branch(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE), new CVSTag("b1", CVSTag.BRANCH)); - branch(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE), new CVSTag("b2", CVSTag.BRANCH)); - branch(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO), new CVSTag("b3", CVSTag.BRANCH)); - branch(asResourceMapping(new IResource[] { project }, IResource.DEPTH_INFINITE), new CVSTag("b4", CVSTag.BRANCH)); - } - - public void testAdd() throws TeamException, CoreException { - // Create an empty project - IProject project = createProject("testAdd", new String[] { }); - // add some resources - buildResources(project, new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }, false); - // add them to CVS - add(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE)); - add(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE)); - add(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO)); - add(asResourceMapping(new IResource[] { project }, IResource.DEPTH_INFINITE)); - } - - public void testCacheBase() throws TeamException, CoreException { + // Create a test project, import it into cvs and check it out + IProject project = createProject("testBranch", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); + + branch(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE), new CVSTag("b1", CVSTag.BRANCH)); + branch(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE), new CVSTag("b2", CVSTag.BRANCH)); + branch(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO), new CVSTag("b3", CVSTag.BRANCH)); + branch(asResourceMapping(new IResource[] { project }, IResource.DEPTH_INFINITE), new CVSTag("b4", CVSTag.BRANCH)); + } + + public void testAdd() throws TeamException, CoreException { + // Create an empty project + IProject project = createProject("testAdd", new String[] { }); + // add some resources + buildResources(project, new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }, false); + // add them to CVS + add(asResourceMapping(new IResource[] { project }, IResource.DEPTH_ONE)); + add(asResourceMapping(new IResource[] { project.getFolder("folder1") }, IResource.DEPTH_ONE)); + add(asResourceMapping(new IResource[] { project.getFile("folder1/subfolder1/c.txt") }, IResource.DEPTH_ZERO)); + add(asResourceMapping(new IResource[] { project }, IResource.DEPTH_INFINITE)); + } + + public void testCacheBase() throws TeamException, CoreException { if (TeamCVSTestPlugin.IS_UNSTABLE_TEST && Util.isMac()) return; - IProject project = createProject("testCacheBase", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); - IProject copy = checkoutCopy(project, "-copy"); - - // First, make some local changes and then cache the bases - setContentsAndEnsureModified(project.getFile("changed.txt"), "Uncommitted text"); - setContentsAndEnsureModified(project.getFile("folder1/b.txt")); - project.getFile("deleted.txt").delete(false, true, null); - try { - cacheBase(project, true /* cache for outgoing and conflicting */); - cacheBase(project, false /* cache for conflicting only*/); - - // Next, retry after releasing some changes (to ensure proper contents are fetched) - setContentsAndEnsureModified(copy.getFile("changed.txt"), "Text comited from the copy"); - commitProject(copy); - cacheBase(project, true /* cache for outgoing and conflicting */); - cacheBase(project, false /* cache for conflicting only */); - } catch (TeamException e) { - // see bug 325553 - logIfCausedByInterruptedIOException(e); - } - } + IProject project = createProject("testCacheBase", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); + IProject copy = checkoutCopy(project, "-copy"); + + // First, make some local changes and then cache the bases + setContentsAndEnsureModified(project.getFile("changed.txt"), "Uncommitted text"); + setContentsAndEnsureModified(project.getFile("folder1/b.txt")); + project.getFile("deleted.txt").delete(false, true, null); + try { + cacheBase(project, true /* cache for outgoing and conflicting */); + cacheBase(project, false /* cache for conflicting only*/); + + // Next, retry after releasing some changes (to ensure proper contents are fetched) + setContentsAndEnsureModified(copy.getFile("changed.txt"), "Text comited from the copy"); + commitProject(copy); + cacheBase(project, true /* cache for outgoing and conflicting */); + cacheBase(project, false /* cache for conflicting only */); + } catch (TeamException e) { + // see bug 325553 + logIfCausedByInterruptedIOException(e); + } + } private void logIfCausedByInterruptedIOException(TeamException e) throws TeamException { @@ -683,18 +683,18 @@ public class ResourceMapperTests extends EclipseTest { throw e; } - public void testCacheRemote() throws TeamException, CoreException { - IProject project = createProject("testCacheRemote", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); - IProject copy = checkoutCopy(project, "-copy"); - - // Make some remote changes - setContentsAndEnsureModified(copy.getFile("changed.txt"), "Uncommitted text"); - setContentsAndEnsureModified(copy.getFile("folder1/b.txt")); - commitProject(copy); - // Delete a local file - project.getFile("deleted.txt").delete(false, true, null); - cacheRemote(project); - } + public void testCacheRemote() throws TeamException, CoreException { + IProject project = createProject("testCacheRemote", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder1/subfolder1/c.txt" }); + IProject copy = checkoutCopy(project, "-copy"); + + // Make some remote changes + setContentsAndEnsureModified(copy.getFile("changed.txt"), "Uncommitted text"); + setContentsAndEnsureModified(copy.getFile("folder1/b.txt")); + commitProject(copy); + // Delete a local file + project.getFile("deleted.txt").delete(false, true, null); + cacheRemote(project); + } private void cacheRemote(IProject project) throws CoreException { clearCache(project); @@ -779,35 +779,35 @@ public class ResourceMapperTests extends EclipseTest { } } } - + public void testBug134517() throws Exception { - IProject project = createProject("testBug134517", new String[] { "file1.txt", "file2.txt"}); - IProject copy = checkoutCopy(project, "-copy"); - addResources(copy, new String[] { "file0.txt", - "new_folder1/", "new_folder1/file2.txt", "new_folder1/new_folder2/", - "new_folder1/new_folder2/new_folder3/", "new_folder1/new_folder2/new_folder3/file3.txt" }, true); - IResource[] resources = new IResource[] { - project.getFile("file0.txt"), - project.getFile("file1.txt"), - project.getFile("new_folder1/file2.txt"), - project.getFile("new_folder1/new_folder2/new_folder3/file3.txt") - }; - update(asResourceMapping(resources, IResource.DEPTH_ZERO), null); - assertEquals(project, copy); + IProject project = createProject("testBug134517", new String[] { "file1.txt", "file2.txt"}); + IProject copy = checkoutCopy(project, "-copy"); + addResources(copy, new String[] { "file0.txt", + "new_folder1/", "new_folder1/file2.txt", "new_folder1/new_folder2/", + "new_folder1/new_folder2/new_folder3/", "new_folder1/new_folder2/new_folder3/file3.txt" }, true); + IResource[] resources = new IResource[] { + project.getFile("file0.txt"), + project.getFile("file1.txt"), + project.getFile("new_folder1/file2.txt"), + project.getFile("new_folder1/new_folder2/new_folder3/file3.txt") + }; + update(asResourceMapping(resources, IResource.DEPTH_ZERO), null); + assertEquals(project, copy); } public void testDeepNewFolder() throws Exception { - IProject project = createProject("testBug134517", new String[] { "file1.txt", "file2.txt"}); - IProject copy = checkoutCopy(project, "-copy"); - addResources(copy, new String[] { - "new_folder1/", - "new_folder1/new_folder2/", - "new_folder1/new_folder2/new_folder3/", - "new_folder1/new_folder2/new_folder3/file3.txt" }, true); - IResource[] resources = new IResource[] { - project.getFolder("new_folder1/new_folder2/new_folder3/") - }; - update(asResourceMapping(resources, IResource.DEPTH_INFINITE), null); - assertEquals(project, copy); + IProject project = createProject("testBug134517", new String[] { "file1.txt", "file2.txt"}); + IProject copy = checkoutCopy(project, "-copy"); + addResources(copy, new String[] { + "new_folder1/", + "new_folder1/new_folder2/", + "new_folder1/new_folder2/new_folder3/", + "new_folder1/new_folder2/new_folder3/file3.txt" }, true); + IResource[] resources = new IResource[] { + project.getFolder("new_folder1/new_folder2/new_folder3/") + }; + update(asResourceMapping(resources, IResource.DEPTH_INFINITE), null); + assertEquals(project, copy); } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SyncInfoSetTraveralContext.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SyncInfoSetTraveralContext.java index 2345e6638..8ca792e84 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SyncInfoSetTraveralContext.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/mappings/SyncInfoSetTraveralContext.java @@ -39,45 +39,45 @@ import org.eclipse.team.core.variants.IResourceVariant; * locally. */ public class SyncInfoSetTraveralContext extends RemoteResourceMappingContext { - - SyncInfoTree set; - - public SyncInfoSetTraveralContext(SyncInfoSet set) { - this.set = new SyncInfoTree(); - this.set.addAll(set); - } + + SyncInfoTree set; + + public SyncInfoSetTraveralContext(SyncInfoSet set) { + this.set = new SyncInfoTree(); + this.set.addAll(set); + } - protected SyncInfo getSyncInfo(IFile file) { - return set.getSyncInfo(file); - } - - public boolean contentDiffers(IFile file, IProgressMonitor monitor) { - return getSyncInfo(file) != null; - } + protected SyncInfo getSyncInfo(IFile file) { + return set.getSyncInfo(file); + } + + public boolean contentDiffers(IFile file, IProgressMonitor monitor) { + return getSyncInfo(file) != null; + } - @Override + @Override public IStorage fetchRemoteContents(IFile file, IProgressMonitor monitor) throws CoreException { - SyncInfo info = getSyncInfo(file); - if (info == null) - return null; - IResourceVariant remote = info.getRemote(); - if (remote == null) - return null; - return remote.getStorage(monitor); - } + SyncInfo info = getSyncInfo(file); + if (info == null) + return null; + IResourceVariant remote = info.getRemote(); + if (remote == null) + return null; + return remote.getStorage(monitor); + } - @Override + @Override public IResource[] fetchMembers(IContainer container, IProgressMonitor monitor) throws CoreException { Set<IResource> members = new HashSet<>(); - members.addAll(Arrays.asList(container.members(false))); - members.addAll(Arrays.asList(set.members(container))); - return members.toArray(new IResource[members.size()]); - } + members.addAll(Arrays.asList(container.members(false))); + members.addAll(Arrays.asList(set.members(container))); + return members.toArray(new IResource[members.size()]); + } - @Override + @Override public void refresh(ResourceTraversal[] traversals, int flags, IProgressMonitor monitor) throws CoreException { - // Do nothing - } + // Do nothing + } @Override public boolean isThreeWay() { @@ -105,13 +105,13 @@ public class SyncInfoSetTraveralContext extends RemoteResourceMappingContext { @Override public IStorage fetchBaseContents(IFile file, IProgressMonitor monitor) throws CoreException { - SyncInfo info = getSyncInfo(file); - if (info == null) - return null; - IResourceVariant base = info.getBase(); - if (base == null) - return null; - return base.getStorage(monitor); + SyncInfo info = getSyncInfo(file); + if (info == null) + return null; + IResourceVariant base = info.getBase(); + if (base == null) + return null; + return base.getStorage(monitor); } @Override diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java index ee22b33aa..c78911653 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java @@ -513,13 +513,13 @@ public class CVSProviderTest extends EclipseTest { IProject project = createProject("test33984", new String[] { "a.txt", "b.txt" }); setContentsAndEnsureModified(project.getFile("a.txt"), "line 1"); - setContentsAndEnsureModified(project.getFile("b.txt"), ("line 1" + EOL + "line 2" + EOL + "line3")); + setContentsAndEnsureModified(project.getFile("b.txt"), ("line 1" + EOL + "line 2" + EOL + "line3")); Map<IFile, KSubstOption> kMode = new HashMap<>(); kMode.put(project.getFile("a.txt"), Command.KSUBST_TEXT); kMode.put(project.getFile("b.txt"), Command.KSUBST_TEXT); getProvider(project).setKeywordSubstitution(kMode, "", null); - + commitProject(project); @@ -531,7 +531,7 @@ public class CVSProviderTest extends EclipseTest { // TEST 1: simulate modifying same file by different users // b.txt has non-conflicting changes setContentsAndEnsureModified(copy.getFile("b.txt"), ("line 1a" + EOL + "line 2" + EOL + "line3")); - + commitProject(copy); // user updates which would cause a merge with conflict, a commit should not be allowed @@ -542,7 +542,7 @@ public class CVSProviderTest extends EclipseTest { // TEST 2: a.txt has conflicting changes setContentsAndEnsureModified(copy.getFile("a.txt"), "line 1dfgdfne3"); - + commitProject(copy); // user updates which would cause a merge with conflict, a commit should not be allowed @@ -591,7 +591,7 @@ public class CVSProviderTest extends EclipseTest { assertTrue(status.isOK()); } - private IStatus executeCommand(IProject project, Update update, LocalOption[] options) throws CVSException { + private IStatus executeCommand(IProject project, Update update, LocalOption[] options) throws CVSException { Session session = new Session(getRepository(), CVSWorkspaceRoot.getCVSFolderFor(project)); session.open(DEFAULT_MONITOR); try { @@ -607,81 +607,81 @@ public class CVSProviderTest extends EclipseTest { } } - + private void setOnlyLookAtTimestamps(boolean b) { CVSUIPlugin.getPlugin().getPreferenceStore().setValue(ICVSUIConstants.PREF_CONSIDER_CONTENTS, !b); } - public void testUpdateWithNoChange() throws TeamException, CoreException { - IProject project = createProject(new String[] { "a.txt"}); - setContentsAndEnsureModified(project.getFile("a.txt"), "contents"); - commitProject(project); - setOnlyLookAtTimestamps(true); - // set the contents to the same value but ensure the local timestamp is different - setContentsAndEnsureModified(project.getFile("a.txt"), "contents"); - // Update and ensure file timestamp is what is was before out edit - updateProject(project, null, false); - Date modDate = CVSWorkspaceRoot.getCVSFileFor(project.getFile("a.txt")).getSyncInfo().getTimeStamp(); - assertEquals("Timestamp was not properly reset", modDate, CVSWorkspaceRoot.getCVSFileFor(project.getFile("a.txt")).getTimeStamp()); - setOnlyLookAtTimestamps(false); - } - - public void testBinaryAddition() throws CoreException { - // See bug 132255 - KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); - try { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); - IProject project = createProject(new String[] { "a.txt"}); - IProject copy = checkoutCopy(project, "-copy"); - create(copy.getFile("binaryFile"), true); - setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); - addResources(new IResource[] { copy.getFile("binaryFile") }); - commitProject(copy); - updateProject(project, null, false); - assertContentsEqual(copy.getFile("binaryFile"), project.getFile("binaryFile")); - } finally { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); - } - } - - public void testDeletedPhantom139250() throws CoreException { - IProject project = createProject(new String[] { "a.txt"}); - // Create a phantom folder that is mapped to a remote folder - // but for which no remote exists - ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project.getFolder("phantom")); - ICVSFolder projectFolder = CVSWorkspaceRoot.getCVSFolderFor(project); - FolderSyncInfo projectInfo = projectFolder.getFolderSyncInfo(); - String repo = Util.appendPath(projectInfo.getRepository(), "phantom"); - FolderSyncInfo info = new FolderSyncInfo(repo, projectInfo.getRoot(), projectInfo.getTag(), false); - folder.setFolderSyncInfo(info); - updateProject(project, null, false); - } - - public void testUpdateOfDeletedFile140007() throws CoreException { - IProject project = createProject(new String[] { "a.txt"}); - IProject copy = checkoutCopy(project, "-copy"); - deleteResources(copy, new String[] { "a.txt"}, true); - updateResources(project, new String[] { "a.txt"}, false); - } - - public void testUpdateOfRemotelyRemovedFile() throws CoreException, IOException { - IProject project = createProject(new String[] { "a.txt"}); - IProject copy = checkoutCopy(project, "-copy"); - //Create a file and add it to version control (but don't commit) - addResources(copy, new String[] { "b.txt"}, false); - // Change the revision of the file so it appears to exist remotely - ICVSFile file = CVSWorkspaceRoot.getCVSFileFor(copy.getFile("b.txt")); - byte[] syncBytes = file.getSyncBytes(); - syncBytes = ResourceSyncInfo.setRevision(syncBytes, "1.1"); - file.setSyncBytes(syncBytes, ICVSFile.UNKNOWN); - file.checkedIn(null, true); - // Update the project and verify that the file gets removed - updateProject(copy, null, false); - assertEquals(project, copy); - - } - - public void testMergeWithTrailingLineFeeds() throws CoreException, IOException { + public void testUpdateWithNoChange() throws TeamException, CoreException { + IProject project = createProject(new String[] { "a.txt"}); + setContentsAndEnsureModified(project.getFile("a.txt"), "contents"); + commitProject(project); + setOnlyLookAtTimestamps(true); + // set the contents to the same value but ensure the local timestamp is different + setContentsAndEnsureModified(project.getFile("a.txt"), "contents"); + // Update and ensure file timestamp is what is was before out edit + updateProject(project, null, false); + Date modDate = CVSWorkspaceRoot.getCVSFileFor(project.getFile("a.txt")).getSyncInfo().getTimeStamp(); + assertEquals("Timestamp was not properly reset", modDate, CVSWorkspaceRoot.getCVSFileFor(project.getFile("a.txt")).getTimeStamp()); + setOnlyLookAtTimestamps(false); + } + + public void testBinaryAddition() throws CoreException { + // See bug 132255 + KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); + try { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); + IProject project = createProject(new String[] { "a.txt"}); + IProject copy = checkoutCopy(project, "-copy"); + create(copy.getFile("binaryFile"), true); + setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); + addResources(new IResource[] { copy.getFile("binaryFile") }); + commitProject(copy); + updateProject(project, null, false); + assertContentsEqual(copy.getFile("binaryFile"), project.getFile("binaryFile")); + } finally { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); + } + } + + public void testDeletedPhantom139250() throws CoreException { + IProject project = createProject(new String[] { "a.txt"}); + // Create a phantom folder that is mapped to a remote folder + // but for which no remote exists + ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project.getFolder("phantom")); + ICVSFolder projectFolder = CVSWorkspaceRoot.getCVSFolderFor(project); + FolderSyncInfo projectInfo = projectFolder.getFolderSyncInfo(); + String repo = Util.appendPath(projectInfo.getRepository(), "phantom"); + FolderSyncInfo info = new FolderSyncInfo(repo, projectInfo.getRoot(), projectInfo.getTag(), false); + folder.setFolderSyncInfo(info); + updateProject(project, null, false); + } + + public void testUpdateOfDeletedFile140007() throws CoreException { + IProject project = createProject(new String[] { "a.txt"}); + IProject copy = checkoutCopy(project, "-copy"); + deleteResources(copy, new String[] { "a.txt"}, true); + updateResources(project, new String[] { "a.txt"}, false); + } + + public void testUpdateOfRemotelyRemovedFile() throws CoreException, IOException { + IProject project = createProject(new String[] { "a.txt"}); + IProject copy = checkoutCopy(project, "-copy"); + //Create a file and add it to version control (but don't commit) + addResources(copy, new String[] { "b.txt"}, false); + // Change the revision of the file so it appears to exist remotely + ICVSFile file = CVSWorkspaceRoot.getCVSFileFor(copy.getFile("b.txt")); + byte[] syncBytes = file.getSyncBytes(); + syncBytes = ResourceSyncInfo.setRevision(syncBytes, "1.1"); + file.setSyncBytes(syncBytes, ICVSFile.UNKNOWN); + file.checkedIn(null, true); + // Update the project and verify that the file gets removed + updateProject(copy, null, false); + assertEquals(project, copy); + + } + + public void testMergeWithTrailingLineFeeds() throws CoreException, IOException { IProject project = createProject("testFileConflict", new String[] { "file1.txt"}); // Set the contents of file1.txt to ensure proper merging // Ensure there is a trailing LF @@ -701,56 +701,56 @@ public class CVSProviderTest extends EclipseTest { assertTrue("File contents are not correct after merge", compareContent( new ByteArrayInputStream(("line0" + eol + "line1" + eol + "line2" + eol + "line2.5" + eol + "line3" + eol).getBytes()), project.getFile("file1.txt").getContents())); - } - - public void testRevertToBaseHeadTag() throws CoreException, IOException{ - IProject project = createProject("testRevertToBase", new String[] {"file1.txt"}); - setContentsAndEnsureModified(project.getFile("file1.txt"), "line1" + eol + "line2" + eol + "line3" + eol); - commitProject(project); - IProject copy = checkoutCopy(project, "-copy"); - appendText(project.getFile("file1.txt"), "line0" + eol, true); - updateProject(project, CVSTag.BASE, true); - assertTrue("File has changed after revert to base", - compareContent(new ByteArrayInputStream(("line1" + eol + "line2" + eol + "line3" + eol).getBytes()), - project.getFile("file1.txt").getContents())); - assertEquals(getRepositoryProvider(copy), getRepositoryProvider(project), false, true); - } - - private CVSTeamProvider getRepositoryProvider(IProject project) { + } + + public void testRevertToBaseHeadTag() throws CoreException, IOException{ + IProject project = createProject("testRevertToBase", new String[] {"file1.txt"}); + setContentsAndEnsureModified(project.getFile("file1.txt"), "line1" + eol + "line2" + eol + "line3" + eol); + commitProject(project); + IProject copy = checkoutCopy(project, "-copy"); + appendText(project.getFile("file1.txt"), "line0" + eol, true); + updateProject(project, CVSTag.BASE, true); + assertTrue("File has changed after revert to base", + compareContent(new ByteArrayInputStream(("line1" + eol + "line2" + eol + "line3" + eol).getBytes()), + project.getFile("file1.txt").getContents())); + assertEquals(getRepositoryProvider(copy), getRepositoryProvider(project), false, true); + } + + private CVSTeamProvider getRepositoryProvider(IProject project) { return (CVSTeamProvider)RepositoryProvider.getProvider(project); } public void testRevertToBaseNonHeadTag() throws CoreException, IOException{ - IProject project = createProject("testRevertToBaseNonHead", new String[] {"file1.txt"}); - setContentsAndEnsureModified(project.getFile("file1.txt"), "line1" + eol + "line2" + eol); - commitProject(project); - tagProject(project, new CVSTag("testtag", CVSTag.BRANCH), true); - appendText(project.getFile("file1.txt"), "line3" + eol, true); - commitProject(project); - IProject copy = checkoutCopy(project, "-copy"); - appendText(copy.getFile("file1.txt"), "line0" + eol, true); - updateProject(copy, CVSTag.BASE, true); - assertTrue("File has changed after revert to base", - compareContent(new ByteArrayInputStream(("line3" + eol + "line1" + eol + "line2" + eol).getBytes()), - copy.getFile("file1.txt").getContents())); - assertEquals(getRepositoryProvider(project), getRepositoryProvider(copy), false, true); - } - - public void testSwitchTagForModifiedFile()throws CoreException, IOException { - // it's a similar scenario as in https://bugs.eclipse.org/bugs/show_bug.cgi?id=192392 - // create a project - IProject project = createProject("testSwitchTagForModifiedFile", new String[] {"file"}); - commitProject(project); - // tag it - CVSTag tag = new CVSTag("A", CVSTag.BRANCH); - tagProject(project, tag, true); - // modify a file - appendText(project.getFile("file"), "changed in head" + eol, false); - // switch to the tag - updateProject(project, tag, false); - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(project.getFile("file")); - // we expect the file to have the same tag used when switching - assertEquals(tag, cvsFile.getSyncInfo().getTag()); - } + IProject project = createProject("testRevertToBaseNonHead", new String[] {"file1.txt"}); + setContentsAndEnsureModified(project.getFile("file1.txt"), "line1" + eol + "line2" + eol); + commitProject(project); + tagProject(project, new CVSTag("testtag", CVSTag.BRANCH), true); + appendText(project.getFile("file1.txt"), "line3" + eol, true); + commitProject(project); + IProject copy = checkoutCopy(project, "-copy"); + appendText(copy.getFile("file1.txt"), "line0" + eol, true); + updateProject(copy, CVSTag.BASE, true); + assertTrue("File has changed after revert to base", + compareContent(new ByteArrayInputStream(("line3" + eol + "line1" + eol + "line2" + eol).getBytes()), + copy.getFile("file1.txt").getContents())); + assertEquals(getRepositoryProvider(project), getRepositoryProvider(copy), false, true); + } + + public void testSwitchTagForModifiedFile()throws CoreException, IOException { + // it's a similar scenario as in https://bugs.eclipse.org/bugs/show_bug.cgi?id=192392 + // create a project + IProject project = createProject("testSwitchTagForModifiedFile", new String[] {"file"}); + commitProject(project); + // tag it + CVSTag tag = new CVSTag("A", CVSTag.BRANCH); + tagProject(project, tag, true); + // modify a file + appendText(project.getFile("file"), "changed in head" + eol, false); + // switch to the tag + updateProject(project, tag, false); + ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor(project.getFile("file")); + // we expect the file to have the same tag used when switching + assertEquals(tag, cvsFile.getSyncInfo().getTag()); + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ImportTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ImportTest.java index ac5cbb540..1c1a3773f 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ImportTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/ImportTest.java @@ -136,19 +136,19 @@ public class ImportTest extends EclipseTest { assertEquals(project, copy, true, true); // 1. Delete the project but not it's contents and checkout the project again - waitForDecorator(); + waitForDecorator(); project.delete(false, false, DEFAULT_MONITOR); project = checkoutProject(project, null, null); assertEquals(project, copy, true, true); // 2. Delete the project and its contents and use the module name instead of the project - waitForDecorator(); + waitForDecorator(); project.delete(true, false, DEFAULT_MONITOR); project = checkoutProject(null, project.getName(), null); assertEquals(project, copy, true, true); // 3. Create a project in a custom location and check out over it - waitForDecorator(); + waitForDecorator(); project.delete(true, false, DEFAULT_MONITOR); IProjectDescription desc = ResourcesPlugin.getWorkspace().newProjectDescription(project.getName()); //desc.setLocation(new Path("C:\\temp\\project")); @@ -157,7 +157,7 @@ public class ImportTest extends EclipseTest { assertEquals(project, copy, true, true); // 4. Checkout something that doesn't contain a .project - waitForDecorator(); + waitForDecorator(); project.delete(true, false, DEFAULT_MONITOR); project = checkoutProject(null, project.getName() + "/folder1", null); //assertEquals(project, copy.getFolder("folder1")); diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java index 98ca3a9b1..691337d83 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RemoteResourceTest.java @@ -213,8 +213,8 @@ public class RemoteResourceTest extends EclipseTest { * Test the fetching of the contents of an empty file */ public void testEmptyFile() throws TeamException, CoreException, IOException { - - // Create a project with an empty file + + // Create a project with an empty file IProject project = createProject("testEmptyFile", new String[] { "file.txt"}); IFile file = project.getFile("file.txt"); setContentsAndEnsureModified(file, ""); @@ -227,14 +227,14 @@ public class RemoteResourceTest extends EclipseTest { count++; } assertTrue("Remote file should be empty", count==0); - } - - /* - * Test the fetching of the contents from multiple remote revisions of a file - */ - public void testFileRevisions() throws TeamException, CoreException, IOException { - - // Create a project with an empty file + } + + /* + * Test the fetching of the contents from multiple remote revisions of a file + */ + public void testFileRevisions() throws TeamException, CoreException, IOException { + + // Create a project with an empty file IProject project = createProject("testFileRevisions", new String[] { "file.txt"}); setContentsAndEnsureModified(project.getFile("file.txt"), "hi there"); commitResources(project, new String[] {"file.txt"}); @@ -268,7 +268,7 @@ public class RemoteResourceTest extends EclipseTest { assertEquals("the contents of revision 1.3 are not equal", contents, "bye there"); } } - } + } public void testFileRevisionsForBranches() throws TeamException, CoreException { // Create a project with an empty file @@ -490,21 +490,21 @@ public class RemoteResourceTest extends EclipseTest { assertEquals(CVSTag.VENDOR_REVISION, logEntry.getBranches()[0].getBranchRevision()); } - public void testExists() throws TeamException, CoreException { - IProject project = createProject("testExists", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt", "folder2/folder3/", "folder2/folder3/b.txt", "folder2/folder3/c.txt"}); - ICVSRemoteResource resource1 = CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("file1.txt")); - assertTrue(resource1.exists(DEFAULT_MONITOR)); - ICVSRemoteResource resource2 = CVSWorkspaceRoot.getRemoteResourceFor(project.getFolder("folder2/folder3/")); - assertTrue(resource2.exists(DEFAULT_MONITOR)); - deleteResources(project, new String[] {"file1.txt", "folder2/folder3/b.txt", "folder2/folder3/c.txt" }, true); - assertTrue( ! resource1.exists(DEFAULT_MONITOR)); - assertTrue(resource2.exists(DEFAULT_MONITOR)); - if (CVSTestSetup.INITIALIZE_REPO) { - CVSTestSetup.executeRemoteCommand(getRepository(), "rm -rf " + ((ICVSFolder)resource2).getFolderSyncInfo().getRemoteLocation()); - assertTrue( ! resource2.exists(DEFAULT_MONITOR)); - } - } - + public void testExists() throws TeamException, CoreException { + IProject project = createProject("testExists", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/a.txt", "folder2/folder3/", "folder2/folder3/b.txt", "folder2/folder3/c.txt"}); + ICVSRemoteResource resource1 = CVSWorkspaceRoot.getRemoteResourceFor(project.getFile("file1.txt")); + assertTrue(resource1.exists(DEFAULT_MONITOR)); + ICVSRemoteResource resource2 = CVSWorkspaceRoot.getRemoteResourceFor(project.getFolder("folder2/folder3/")); + assertTrue(resource2.exists(DEFAULT_MONITOR)); + deleteResources(project, new String[] {"file1.txt", "folder2/folder3/b.txt", "folder2/folder3/c.txt" }, true); + assertTrue( ! resource1.exists(DEFAULT_MONITOR)); + assertTrue(resource2.exists(DEFAULT_MONITOR)); + if (CVSTestSetup.INITIALIZE_REPO) { + CVSTestSetup.executeRemoteCommand(getRepository(), "rm -rf " + ((ICVSFolder)resource2).getFolderSyncInfo().getRemoteLocation()); + assertTrue( ! resource2.exists(DEFAULT_MONITOR)); + } + } + // /** // * Test building a sync tree using the RemoteFolderTreeBuilder using a remote resource as the // * starting point instead of a local one. @@ -521,26 +521,26 @@ public class RemoteResourceTest extends EclipseTest { // checkoutProject(project, name, null); // assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project), tree, false, true); // } - - public void testCheckoutIntoRemoteFolder() throws CoreException, IOException, CVSException, InvocationTargetException, InterruptedException { - IProject project = createProject(new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/folder3/b.txt", "folder2/folder3/c.txt"}); - - ICVSRemoteFolder remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project); - remote = checkoutRemote(remote); - assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project), remote, false, true); - - // Try a version - CVSTag tag = new CVSTag("v1", CVSTag.VERSION); - tagProject(project, tag, false); - IProject copy = checkoutCopy(project, tag); - setContentsAndEnsureModified(project.getFile("file1.txt")); - commitProject(project); - remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project); - ((RemoteFolder)remote).setTag(tag); - remote = checkoutRemote(remote); - assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(copy), remote, false, true); - } - + + public void testCheckoutIntoRemoteFolder() throws CoreException, IOException, CVSException, InvocationTargetException, InterruptedException { + IProject project = createProject(new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/folder3/b.txt", "folder2/folder3/c.txt"}); + + ICVSRemoteFolder remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project); + remote = checkoutRemote(remote); + assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(project), remote, false, true); + + // Try a version + CVSTag tag = new CVSTag("v1", CVSTag.VERSION); + tagProject(project, tag, false); + IProject copy = checkoutCopy(project, tag); + setContentsAndEnsureModified(project.getFile("file1.txt")); + commitProject(project); + remote = (ICVSRemoteFolder)CVSWorkspaceRoot.getRemoteResourceFor(project); + ((RemoteFolder)remote).setTag(tag); + remote = checkoutRemote(remote); + assertEquals(Path.EMPTY, CVSWorkspaceRoot.getCVSResourceFor(copy), remote, false, true); + } + public void testBug244425() throws CVSException, CoreException, IOException { IProject projectHead = createProject("test", new String[] { "a/", diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java index 4466b2304..a682ec377 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSChangeSetTests.java @@ -42,7 +42,7 @@ import org.eclipse.ui.PartInitException; public class CVSChangeSetTests extends CVSSyncSubscriberTest { public static Test suite() { - return suite(CVSChangeSetTests.class); + return suite(CVSChangeSetTests.class); } public CVSChangeSetTests() { @@ -53,140 +53,140 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest { super(name); } - private void assertIncomingChangesInSets(IFile[][] files, String[] messages) throws CoreException { - // Get the workspace subscriber which also creates a participant and page in the sync view - Subscriber workspaceSubscriber = getWorkspaceSubscriber(); - refresh(workspaceSubscriber); - ISynchronizeModelElement root = getModelRoot(workspaceSubscriber); - ChangeSetDiffNode[] nodes = getCheckedInChangeSetNodes(root); - assertNodesInViewer(workspaceSubscriber, nodes); - assertEquals("The number of change sets in the sync view do not match the expected number", messages.length, nodes.length); - for (int i = 0; i < messages.length; i++) { - String message = messages[i]; - ChangeSetDiffNode node = getCommitSetFor(root, message); - assertNotNull("The commit set for '" + message + "' is not in the sync view", node); - List<IResource> filesInSet = new ArrayList<>(); - getFileChildren(node, filesInSet); - assertTrue("The number of files in the set do not match the expected number", files[i].length == filesInSet.size()); - for (int j = 0; j < files[i].length; j++) { - IFile file = files[i][j]; - assertTrue("File " + file.getFullPath() + " is not in the set", filesInSet.contains(file)); - } - } - } + private void assertIncomingChangesInSets(IFile[][] files, String[] messages) throws CoreException { + // Get the workspace subscriber which also creates a participant and page in the sync view + Subscriber workspaceSubscriber = getWorkspaceSubscriber(); + refresh(workspaceSubscriber); + ISynchronizeModelElement root = getModelRoot(workspaceSubscriber); + ChangeSetDiffNode[] nodes = getCheckedInChangeSetNodes(root); + assertNodesInViewer(workspaceSubscriber, nodes); + assertEquals("The number of change sets in the sync view do not match the expected number", messages.length, nodes.length); + for (int i = 0; i < messages.length; i++) { + String message = messages[i]; + ChangeSetDiffNode node = getCommitSetFor(root, message); + assertNotNull("The commit set for '" + message + "' is not in the sync view", node); + List<IResource> filesInSet = new ArrayList<>(); + getFileChildren(node, filesInSet); + assertTrue("The number of files in the set do not match the expected number", files[i].length == filesInSet.size()); + for (int j = 0; j < files[i].length; j++) { + IFile file = files[i][j]; + assertTrue("File " + file.getFullPath() + " is not in the set", filesInSet.contains(file)); + } + } + } - private void assertNodesInViewer(Subscriber workspaceSubscriber, ChangeSetDiffNode[] nodes) throws PartInitException { - ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); - SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); - TreeViewer viewer = (TreeViewer)page.getViewer(); - Tree tree = viewer.getTree(); - List<ChangeSetDiffNode> nodeList = new ArrayList<>(); - nodeList.addAll(Arrays.asList(nodes)); - TreeItem[] items = tree.getItems(); - removeTreeItemsFromList(nodeList, items); - assertTrue("Not all nodes are visible in the view", nodeList.isEmpty()); - } + private void assertNodesInViewer(Subscriber workspaceSubscriber, ChangeSetDiffNode[] nodes) throws PartInitException { + ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); + SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); + TreeViewer viewer = (TreeViewer)page.getViewer(); + Tree tree = viewer.getTree(); + List<ChangeSetDiffNode> nodeList = new ArrayList<>(); + nodeList.addAll(Arrays.asList(nodes)); + TreeItem[] items = tree.getItems(); + removeTreeItemsFromList(nodeList, items); + assertTrue("Not all nodes are visible in the view", nodeList.isEmpty()); + } - private void removeTreeItemsFromList(List<?> nodeList, TreeItem[] items) { - for (int i = 0; i < items.length; i++) { - TreeItem item = items[i]; - nodeList.remove(item.getData()); - TreeItem[] children = item.getItems(); - removeTreeItemsFromList(nodeList, children); - } - } + private void removeTreeItemsFromList(List<?> nodeList, TreeItem[] items) { + for (int i = 0; i < items.length; i++) { + TreeItem item = items[i]; + nodeList.remove(item.getData()); + TreeItem[] children = item.getItems(); + removeTreeItemsFromList(nodeList, children); + } + } - private ChangeSetDiffNode[] getCheckedInChangeSetNodes(ISynchronizeModelElement root) { - List<ChangeSetDiffNode> result = new ArrayList<>(); - IDiffElement[] children = root.getChildren(); - for (int i = 0; i < children.length; i++) { - IDiffElement element = children[i]; - if (element instanceof ChangeSetDiffNode) { - ChangeSetDiffNode node = (ChangeSetDiffNode)element; - if (node.getSet() instanceof CheckedInChangeSet) { - result.add(node); - } - } - } - return result.toArray(new ChangeSetDiffNode[result.size()]); - } - - private ChangeSetDiffNode[] getActiveChangeSetNodes(ISynchronizeModelElement root) { - List<ChangeSetDiffNode> result = new ArrayList<>(); - IDiffElement[] children = root.getChildren(); - for (int i = 0; i < children.length; i++) { - IDiffElement element = children[i]; - if (element instanceof ChangeSetDiffNode) { - ChangeSetDiffNode node = (ChangeSetDiffNode)element; - if (node.getSet() instanceof ActiveChangeSet) { - result.add(node); - } - } - } - return result.toArray(new ChangeSetDiffNode[result.size()]); - } + private ChangeSetDiffNode[] getCheckedInChangeSetNodes(ISynchronizeModelElement root) { + List<ChangeSetDiffNode> result = new ArrayList<>(); + IDiffElement[] children = root.getChildren(); + for (int i = 0; i < children.length; i++) { + IDiffElement element = children[i]; + if (element instanceof ChangeSetDiffNode) { + ChangeSetDiffNode node = (ChangeSetDiffNode)element; + if (node.getSet() instanceof CheckedInChangeSet) { + result.add(node); + } + } + } + return result.toArray(new ChangeSetDiffNode[result.size()]); + } + + private ChangeSetDiffNode[] getActiveChangeSetNodes(ISynchronizeModelElement root) { + List<ChangeSetDiffNode> result = new ArrayList<>(); + IDiffElement[] children = root.getChildren(); + for (int i = 0; i < children.length; i++) { + IDiffElement element = children[i]; + if (element instanceof ChangeSetDiffNode) { + ChangeSetDiffNode node = (ChangeSetDiffNode)element; + if (node.getSet() instanceof ActiveChangeSet) { + result.add(node); + } + } + } + return result.toArray(new ChangeSetDiffNode[result.size()]); + } - /** - * Adds IFiles to the list - */ - private void getFileChildren(ISynchronizeModelElement node, List<IResource> list) { - IResource resource = node.getResource(); - if (resource != null && resource.getType() == IResource.FILE) { - list.add(resource); - } - IDiffElement[] children = node.getChildren(); - for (int i = 0; i < children.length; i++) { - IDiffElement child = children[i]; - getFileChildren((ISynchronizeModelElement)child, list); - } - return; - } + /** + * Adds IFiles to the list + */ + private void getFileChildren(ISynchronizeModelElement node, List<IResource> list) { + IResource resource = node.getResource(); + if (resource != null && resource.getType() == IResource.FILE) { + list.add(resource); + } + IDiffElement[] children = node.getChildren(); + for (int i = 0; i < children.length; i++) { + IDiffElement child = children[i]; + getFileChildren((ISynchronizeModelElement)child, list); + } + return; + } - private ChangeSetDiffNode getCommitSetFor(ISynchronizeModelElement root, String message) { - IDiffElement[] children = root.getChildren(); - for (int i = 0; i < children.length; i++) { - IDiffElement element = children[i]; - if (element instanceof ChangeSetDiffNode) { - ChangeSetDiffNode node = (ChangeSetDiffNode)element; - if (node.getSet().getComment().equals(message)) { - return node; - } - } - } - return null; - } + private ChangeSetDiffNode getCommitSetFor(ISynchronizeModelElement root, String message) { + IDiffElement[] children = root.getChildren(); + for (int i = 0; i < children.length; i++) { + IDiffElement element = children[i]; + if (element instanceof ChangeSetDiffNode) { + ChangeSetDiffNode node = (ChangeSetDiffNode)element; + if (node.getSet().getComment().equals(message)) { + return node; + } + } + } + return null; + } - private void refresh(Subscriber workspaceSubscriber) throws TeamException { - workspaceSubscriber.refresh(workspaceSubscriber.roots(), IResource.DEPTH_INFINITE, DEFAULT_MONITOR); - } + private void refresh(Subscriber workspaceSubscriber) throws TeamException { + workspaceSubscriber.refresh(workspaceSubscriber.roots(), IResource.DEPTH_INFINITE, DEFAULT_MONITOR); + } - private void enableChangeSets(Subscriber workspaceSubscriber) throws PartInitException { - ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); - SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); - ChangeSetModelManager manager = (ChangeSetModelManager)page.getConfiguration().getProperty(SynchronizePageConfiguration.P_MODEL_MANAGER); - manager.setCommitSetsEnabled(true); - page.getConfiguration().setMode(ISynchronizePageConfiguration.BOTH_MODE); - } + private void enableChangeSets(Subscriber workspaceSubscriber) throws PartInitException { + ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); + SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); + ChangeSetModelManager manager = (ChangeSetModelManager)page.getConfiguration().getProperty(SynchronizePageConfiguration.P_MODEL_MANAGER); + manager.setCommitSetsEnabled(true); + page.getConfiguration().setMode(ISynchronizePageConfiguration.BOTH_MODE); + } - private void enableCheckedInChangeSets(Subscriber workspaceSubscriber) throws PartInitException { - enableChangeSets(workspaceSubscriber); - ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); - SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); - page.getConfiguration().setMode(ISynchronizePageConfiguration.INCOMING_MODE); - } - - private void enableActiveChangeSets(Subscriber workspaceSubscriber) throws PartInitException { - enableChangeSets(workspaceSubscriber); - ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); - SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); - page.getConfiguration().setMode(ISynchronizePageConfiguration.OUTGOING_MODE); - } - - /* - * Wait until all the background handlers have settled and then return the root element in the sync view - */ - private ISynchronizeModelElement getModelRoot(Subscriber workspaceSubscriber) throws CoreException { - IProgressMonitor eventLoopProgressMonitor = new IProgressMonitor() { + private void enableCheckedInChangeSets(Subscriber workspaceSubscriber) throws PartInitException { + enableChangeSets(workspaceSubscriber); + ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); + SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); + page.getConfiguration().setMode(ISynchronizePageConfiguration.INCOMING_MODE); + } + + private void enableActiveChangeSets(Subscriber workspaceSubscriber) throws PartInitException { + enableChangeSets(workspaceSubscriber); + ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); + SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); + page.getConfiguration().setMode(ISynchronizePageConfiguration.OUTGOING_MODE); + } + + /* + * Wait until all the background handlers have settled and then return the root element in the sync view + */ + private ISynchronizeModelElement getModelRoot(Subscriber workspaceSubscriber) throws CoreException { + IProgressMonitor eventLoopProgressMonitor = new IProgressMonitor() { public void beginTask(String name, int totalWork) { } public void done() { @@ -206,218 +206,218 @@ public class CVSChangeSetTests extends CVSSyncSubscriberTest { while (Display.getCurrent().readAndDispatch()) {} } }; - SubscriberParticipantSyncInfoSource.getCollector(workspaceSubscriber); - ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); - ChangeSetCapability capability = ((IChangeSetProvider)participant).getChangeSetCapability(); - SubscriberChangeSetManager activeManager = (SubscriberChangeSetManager)capability.getActiveChangeSetManager(); - activeManager.waitUntilDone(eventLoopProgressMonitor); - SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); - ChangeSetModelManager manager = (ChangeSetModelManager)page.getConfiguration().getProperty(SynchronizePageConfiguration.P_MODEL_MANAGER); - AbstractSynchronizeModelProvider provider = (AbstractSynchronizeModelProvider)manager.getActiveModelProvider(); - provider.waitUntilDone(eventLoopProgressMonitor); - return provider.getModelRoot(); - } + SubscriberParticipantSyncInfoSource.getCollector(workspaceSubscriber); + ISynchronizeParticipant participant = SubscriberParticipantSyncInfoSource.getParticipant(workspaceSubscriber); + ChangeSetCapability capability = ((IChangeSetProvider)participant).getChangeSetCapability(); + SubscriberChangeSetManager activeManager = (SubscriberChangeSetManager)capability.getActiveChangeSetManager(); + activeManager.waitUntilDone(eventLoopProgressMonitor); + SubscriberParticipantPage page = (SubscriberParticipantPage)SubscriberParticipantSyncInfoSource.getSyncViewPage(participant); + ChangeSetModelManager manager = (ChangeSetModelManager)page.getConfiguration().getProperty(SynchronizePageConfiguration.P_MODEL_MANAGER); + AbstractSynchronizeModelProvider provider = (AbstractSynchronizeModelProvider)manager.getActiveModelProvider(); + provider.waitUntilDone(eventLoopProgressMonitor); + return provider.getModelRoot(); + } - private ActiveChangeSetManager getActiveChangeSetManager() { - return CVSUIPlugin.getPlugin().getChangeSetManager(); - } - - /* - * Assert that the given resources make up the given set both directly - * and by what is displayed in the sync view. - */ - private void assertInActiveSet(IResource[] resources, ActiveChangeSet set) throws CoreException { - assertResourcesAreTheSame(resources, set.getResources(), true); - ISynchronizeModelElement root = getModelRoot(((SubscriberChangeSetManager)getActiveChangeSetManager()).getSubscriber()); - ChangeSetDiffNode node = getChangeSetNodeFor(root, set); - assertNotNull("Change set " + set.getTitle() + " did not appear in the sync view", node); - IResource[] outOfSync = getOutOfSyncResources(node); - assertResourcesAreTheSame(resources, outOfSync, true); - // Assert that all active sets are visible in the view - ChangeSet[] sets = getActiveChangeSetManager().getSets(); - for (int i = 0; i < sets.length; i++) { - ChangeSet changeSet = sets[i]; - node = getChangeSetNodeFor(root, changeSet); - assertNotNull("The node for set " + set.getName() + " is not in the view", node); - - } - ChangeSetDiffNode[] nodes = getActiveChangeSetNodes(root); - assertNodesInViewer(getWorkspaceSubscriber(), nodes); - } - - private ChangeSetDiffNode getChangeSetNodeFor(ISynchronizeModelElement root, ChangeSet set) { - IDiffElement[] children = root.getChildren(); - for (int i = 0; i < children.length; i++) { - IDiffElement element = children[i]; - if (element instanceof ChangeSetDiffNode) { - ChangeSetDiffNode node = (ChangeSetDiffNode)element; - if (node.getSet() == set) { - return node; - } - } - } - return null; - } + private ActiveChangeSetManager getActiveChangeSetManager() { + return CVSUIPlugin.getPlugin().getChangeSetManager(); + } + + /* + * Assert that the given resources make up the given set both directly + * and by what is displayed in the sync view. + */ + private void assertInActiveSet(IResource[] resources, ActiveChangeSet set) throws CoreException { + assertResourcesAreTheSame(resources, set.getResources(), true); + ISynchronizeModelElement root = getModelRoot(((SubscriberChangeSetManager)getActiveChangeSetManager()).getSubscriber()); + ChangeSetDiffNode node = getChangeSetNodeFor(root, set); + assertNotNull("Change set " + set.getTitle() + " did not appear in the sync view", node); + IResource[] outOfSync = getOutOfSyncResources(node); + assertResourcesAreTheSame(resources, outOfSync, true); + // Assert that all active sets are visible in the view + ChangeSet[] sets = getActiveChangeSetManager().getSets(); + for (int i = 0; i < sets.length; i++) { + ChangeSet changeSet = sets[i]; + node = getChangeSetNodeFor(root, changeSet); + assertNotNull("The node for set " + set.getName() + " is not in the view", node); + + } + ChangeSetDiffNode[] nodes = getActiveChangeSetNodes(root); + assertNodesInViewer(getWorkspaceSubscriber(), nodes); + } + + private ChangeSetDiffNode getChangeSetNodeFor(ISynchronizeModelElement root, ChangeSet set) { + IDiffElement[] children = root.getChildren(); + for (int i = 0; i < children.length; i++) { + IDiffElement element = children[i]; + if (element instanceof ChangeSetDiffNode) { + ChangeSetDiffNode node = (ChangeSetDiffNode)element; + if (node.getSet() == set) { + return node; + } + } + } + return null; + } - private IResource[] getOutOfSyncResources(ISynchronizeModelElement element) { - ArrayList<SyncInfo> arrayList = new ArrayList<>(); - getOutOfSync(element, arrayList); - SyncInfo[] infos = arrayList.toArray(new SyncInfo[arrayList.size()]); - IResource[] resources = getResources(infos); - return resources; - } + private IResource[] getOutOfSyncResources(ISynchronizeModelElement element) { + ArrayList<SyncInfo> arrayList = new ArrayList<>(); + getOutOfSync(element, arrayList); + SyncInfo[] infos = arrayList.toArray(new SyncInfo[arrayList.size()]); + IResource[] resources = getResources(infos); + return resources; + } - private IResource[] getResources(SyncInfo[] infos) { - IResource[] resources = new IResource[infos.length]; - for (int i = 0; i < resources.length; i++) { - resources[i] = infos[i].getLocal(); - } - return resources; - } + private IResource[] getResources(SyncInfo[] infos) { + IResource[] resources = new IResource[infos.length]; + for (int i = 0; i < resources.length; i++) { + resources[i] = infos[i].getLocal(); + } + return resources; + } - private void getOutOfSync(ISynchronizeModelElement node, List<SyncInfo> list) { - SyncInfo info = getSyncInfo(node); - if (info != null && info.getKind() != SyncInfo.IN_SYNC) { - list.add(info); - } - IDiffElement[] children = node.getChildren(); - for (int i = 0; i < children.length; i++) { - IDiffElement child = children[i]; - getOutOfSync((ISynchronizeModelElement)child, list); - } - return; - } - - private SyncInfo getSyncInfo(ISynchronizeModelElement node) { - if (node instanceof IAdaptable) { - return ((IAdaptable)node).getAdapter(SyncInfo.class); - } - return null; - } + private void getOutOfSync(ISynchronizeModelElement node, List<SyncInfo> list) { + SyncInfo info = getSyncInfo(node); + if (info != null && info.getKind() != SyncInfo.IN_SYNC) { + list.add(info); + } + IDiffElement[] children = node.getChildren(); + for (int i = 0; i < children.length; i++) { + IDiffElement child = children[i]; + getOutOfSync((ISynchronizeModelElement)child, list); + } + return; + } + + private SyncInfo getSyncInfo(ISynchronizeModelElement node) { + if (node instanceof IAdaptable) { + return ((IAdaptable)node).getAdapter(SyncInfo.class); + } + return null; + } - private void assertResourcesAreTheSame(IResource[] resources1, IResource[] resources2, boolean doNotAllowExtra) { - if (doNotAllowExtra) { - if (resources1.length != resources2.length) { - System.out.println("Expected"); - for (int i = 0; i < resources1.length; i++) { - IResource resource = resources1[i]; - System.out.println(resource.getFullPath().toString()); - } - System.out.println("Actual"); - for (int i = 0; i < resources2.length; i++) { - IResource resource = resources2[i]; - System.out.println(resource.getFullPath().toString()); - } - } - assertEquals("The number of resources do not match the expected number", resources1.length, resources2.length); - } - for (int i = 0; i < resources1.length; i++) { - IResource resource = resources1[i]; - boolean found = false; - for (int j = 0; j < resources2.length; j++) { - IResource resource2 = resources2[j]; - if (resource2.equals(resource)) { - found = true; - break; - } - } - assertTrue("Expected resource " + resource.getFullPath().toString() + " was not present", found); - } - } + private void assertResourcesAreTheSame(IResource[] resources1, IResource[] resources2, boolean doNotAllowExtra) { + if (doNotAllowExtra) { + if (resources1.length != resources2.length) { + System.out.println("Expected"); + for (int i = 0; i < resources1.length; i++) { + IResource resource = resources1[i]; + System.out.println(resource.getFullPath().toString()); + } + System.out.println("Actual"); + for (int i = 0; i < resources2.length; i++) { + IResource resource = resources2[i]; + System.out.println(resource.getFullPath().toString()); + } + } + assertEquals("The number of resources do not match the expected number", resources1.length, resources2.length); + } + for (int i = 0; i < resources1.length; i++) { + IResource resource = resources1[i]; + boolean found = false; + for (int j = 0; j < resources2.length; j++) { + IResource resource2 = resources2[j]; + if (resource2.equals(resource)) { + found = true; + break; + } + } + assertTrue("Expected resource " + resource.getFullPath().toString() + " was not present", found); + } + } - /* - * Assert that the given resources make up the root set - * displayed in the sync view. The root set is those - * resources that are not part of an active change set. - */ - private void assertInRootSet(IResource[] resources) throws CoreException { - ISynchronizeModelElement[] nodes = getNonChangeSetRoots(getModelRoot(((SubscriberChangeSetManager)getActiveChangeSetManager()).getSubscriber())); - List<SyncInfo> list = new ArrayList<>(); - for (int i = 0; i < nodes.length; i++) { - ISynchronizeModelElement element = nodes[i]; - getOutOfSync(element, list); - } - IResource[] outOfSync = getResources(list.toArray(new SyncInfo[list.size()])); - // Only require that the expected resources are there but allow extra. - // This is required because of junk left over from previous tests. - // This means there is a bug somewhere. But where? - assertResourcesAreTheSame(resources, outOfSync, false /* allow extra out-of-sync resources */); - - } - - private ISynchronizeModelElement[] getNonChangeSetRoots(ISynchronizeModelElement modelRoot) { - List<ISynchronizeModelElement> result = new ArrayList<>(); - IDiffElement[] children = modelRoot.getChildren(); - for (int i = 0; i < children.length; i++) { - IDiffElement element = children[i]; - if (!(element instanceof ChangeSetDiffNode)) { - result.add((ISynchronizeModelElement) element); - } - } - return result.toArray(new ISynchronizeModelElement[result.size()]); - } + /* + * Assert that the given resources make up the root set + * displayed in the sync view. The root set is those + * resources that are not part of an active change set. + */ + private void assertInRootSet(IResource[] resources) throws CoreException { + ISynchronizeModelElement[] nodes = getNonChangeSetRoots(getModelRoot(((SubscriberChangeSetManager)getActiveChangeSetManager()).getSubscriber())); + List<SyncInfo> list = new ArrayList<>(); + for (int i = 0; i < nodes.length; i++) { + ISynchronizeModelElement element = nodes[i]; + getOutOfSync(element, list); + } + IResource[] outOfSync = getResources(list.toArray(new SyncInfo[list.size()])); + // Only require that the expected resources are there but allow extra. + // This is required because of junk left over from previous tests. + // This means there is a bug somewhere. But where? + assertResourcesAreTheSame(resources, outOfSync, false /* allow extra out-of-sync resources */); + + } + + private ISynchronizeModelElement[] getNonChangeSetRoots(ISynchronizeModelElement modelRoot) { + List<ISynchronizeModelElement> result = new ArrayList<>(); + IDiffElement[] children = modelRoot.getChildren(); + for (int i = 0; i < children.length; i++) { + IDiffElement element = children[i]; + if (!(element instanceof ChangeSetDiffNode)) { + result.add((ISynchronizeModelElement) element); + } + } + return result.toArray(new ISynchronizeModelElement[result.size()]); + } - public void testSimpleCommit() throws CoreException { - enableCheckedInChangeSets(getWorkspaceSubscriber()); - - IProject project = createProject(new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); - - // Modify a file in a copy - IProject copy = checkoutCopy(project, CVSTag.DEFAULT); - setContentsAndEnsureModified(copy.getFile("file1.txt")); - String message1 = "Commit 1"; - commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE, message1); - assertIncomingChangesInSets(new IFile[][] {{ project.getFile("file1.txt") }}, new String[] {message1}); - - // Modify the copy some more - setContentsAndEnsureModified(copy.getFile("file2.txt")); - setContentsAndEnsureModified(copy.getFile("folder1/a.txt")); - String message2 = "Commit 2"; - commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE, message2); - assertIncomingChangesInSets(new IFile[][] { - { project.getFile("file1.txt") }, - { project.getFile("file2.txt"), project.getFile("folder1/a.txt") } - }, new String[] {message1, message2}); - - // Modify the copy some more - setContentsAndEnsureModified(copy.getFile("file2.txt")); - String message3 = "Commit 3"; - commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE, message3); - assertIncomingChangesInSets(new IFile[][] { - { project.getFile("file1.txt") }, - { project.getFile("folder1/a.txt") }, - { project.getFile("file2.txt")} - }, new String[] {message1, message2, message3}); - - // Now commit the files in one of the sets and ensure it is removed from the view - updateResources(new IResource[] { project.getFile("file1.txt")}, false); - assertIncomingChangesInSets(new IFile[][] { - { project.getFile("folder1/a.txt") }, - { project.getFile("file2.txt")} - }, new String[] {message2, message3}); + public void testSimpleCommit() throws CoreException { + enableCheckedInChangeSets(getWorkspaceSubscriber()); + + IProject project = createProject(new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); + + // Modify a file in a copy + IProject copy = checkoutCopy(project, CVSTag.DEFAULT); + setContentsAndEnsureModified(copy.getFile("file1.txt")); + String message1 = "Commit 1"; + commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE, message1); + assertIncomingChangesInSets(new IFile[][] {{ project.getFile("file1.txt") }}, new String[] {message1}); + + // Modify the copy some more + setContentsAndEnsureModified(copy.getFile("file2.txt")); + setContentsAndEnsureModified(copy.getFile("folder1/a.txt")); + String message2 = "Commit 2"; + commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE, message2); + assertIncomingChangesInSets(new IFile[][] { + { project.getFile("file1.txt") }, + { project.getFile("file2.txt"), project.getFile("folder1/a.txt") } + }, new String[] {message1, message2}); + + // Modify the copy some more + setContentsAndEnsureModified(copy.getFile("file2.txt")); + String message3 = "Commit 3"; + commitResources(new IResource[] {copy}, IResource.DEPTH_INFINITE, message3); + assertIncomingChangesInSets(new IFile[][] { + { project.getFile("file1.txt") }, + { project.getFile("folder1/a.txt") }, + { project.getFile("file2.txt")} + }, new String[] {message1, message2, message3}); + + // Now commit the files in one of the sets and ensure it is removed from the view + updateResources(new IResource[] { project.getFile("file1.txt")}, false); + assertIncomingChangesInSets(new IFile[][] { + { project.getFile("folder1/a.txt") }, + { project.getFile("file2.txt")} + }, new String[] {message2, message3}); } - public void testSimpleActiveChangeSet() throws CoreException { - IProject project = createProject(new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); - // Enable Change Sets - enableActiveChangeSets(getWorkspaceSubscriber()); - // Add a folder and file - IFolder newFolder = project.getFolder("folder2"); - newFolder.create(false, true, null); - IFile newFile = newFolder.getFile("file.txt"); - newFile.create(new ByteArrayInputStream("Hi There".getBytes()), false, null); - // Create an active commit set and assert that it appears in the sync view - ActiveChangeSetManager manager = getActiveChangeSetManager(); - ActiveChangeSet set = manager.createSet("test", new IDiff[0]); - manager.add(set); - assertInActiveSet(new IResource[] { }, set); - assertInRootSet(new IResource[] {newFolder, newFile}); - // Add the new file to the set and assert that the file is in the set and the folder is still at the root - set.add(new IResource[] { newFile }); - assertInActiveSet(new IResource[] { newFile }, set); - assertInRootSet(new IResource[] {newFolder }); - // Add the folder to the set - set.add(new IResource[] { newFolder }); - assertInActiveSet(new IResource[] { newFolder, newFile }, set); - } + public void testSimpleActiveChangeSet() throws CoreException { + IProject project = createProject(new String[] { "file1.txt", "file2.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); + // Enable Change Sets + enableActiveChangeSets(getWorkspaceSubscriber()); + // Add a folder and file + IFolder newFolder = project.getFolder("folder2"); + newFolder.create(false, true, null); + IFile newFile = newFolder.getFile("file.txt"); + newFile.create(new ByteArrayInputStream("Hi There".getBytes()), false, null); + // Create an active commit set and assert that it appears in the sync view + ActiveChangeSetManager manager = getActiveChangeSetManager(); + ActiveChangeSet set = manager.createSet("test", new IDiff[0]); + manager.add(set); + assertInActiveSet(new IResource[] { }, set); + assertInRootSet(new IResource[] {newFolder, newFile}); + // Add the new file to the set and assert that the file is in the set and the folder is still at the root + set.add(new IResource[] { newFile }); + assertInActiveSet(new IResource[] { newFile }, set); + assertInRootSet(new IResource[] {newFolder }); + // Add the folder to the set + set.add(new IResource[] { newFolder }); + assertInActiveSet(new IResource[] { newFolder, newFile }, set); + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSCompareSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSCompareSubscriberTest.java index f90fe7f8b..b1b1bbc14 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSCompareSubscriberTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSCompareSubscriberTest.java @@ -125,58 +125,58 @@ public class CVSCompareSubscriberTest extends CVSSyncSubscriberTest { SyncInfo.DELETION}); } - public void testBinaryAddition() throws CoreException { - // See bug 132255 - KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); - try { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); - IProject project = createProject(new String[] { "a.txt"}); + public void testBinaryAddition() throws CoreException { + // See bug 132255 + KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); + try { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); + IProject project = createProject(new String[] { "a.txt"}); // Checkout and branch a copy CVSTag v1 = new CVSTag("v1", CVSTag.VERSION); // Add a binary file that contains LFs - IProject copy = checkoutCopy(project, "-copy"); - create(copy.getFile("binaryFile"), true); - setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); - addResources(new IResource[] { copy.getFile("binaryFile") }); - commitProject(copy); - // Tag the project - tagProject(copy, v1, false); - // Compare with the tag and merge the changes - CVSCompareSubscriber subscriber = getSyncInfoSource().createCompareSubscriber(project, v1); - getSyncInfoSource().refresh(subscriber, project); - getSyncInfoSource().overrideAndUpdateResources(subscriber, false, new IResource[] { project.getFile("binaryFile") }); - assertContentsEqual(copy.getFile("binaryFile"), project.getFile("binaryFile")); - } finally { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); - } - } - - public void testBinaryMarkAsMerged() throws CoreException, InvocationTargetException, InterruptedException { - // See bug 132255 - KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); - try { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); - IProject project = createProject(new String[] { "a.txt"}); + IProject copy = checkoutCopy(project, "-copy"); + create(copy.getFile("binaryFile"), true); + setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); + addResources(new IResource[] { copy.getFile("binaryFile") }); + commitProject(copy); + // Tag the project + tagProject(copy, v1, false); + // Compare with the tag and merge the changes + CVSCompareSubscriber subscriber = getSyncInfoSource().createCompareSubscriber(project, v1); + getSyncInfoSource().refresh(subscriber, project); + getSyncInfoSource().overrideAndUpdateResources(subscriber, false, new IResource[] { project.getFile("binaryFile") }); + assertContentsEqual(copy.getFile("binaryFile"), project.getFile("binaryFile")); + } finally { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); + } + } + + public void testBinaryMarkAsMerged() throws CoreException, InvocationTargetException, InterruptedException { + // See bug 132255 + KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); + try { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); + IProject project = createProject(new String[] { "a.txt"}); // Checkout and branch a copy CVSTag v1 = new CVSTag("v1", CVSTag.VERSION); // Add a binary file that contains LFs - IProject copy = checkoutCopy(project, "-copy"); - create(copy.getFile("binaryFile"), true); - setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); - addResources(new IResource[] { copy.getFile("binaryFile") }); - commitProject(copy); - // Tag the project - tagProject(copy, v1, false); - // Add the same file to the project but don't share it - create(project.getFile("binaryFile"), true); - setContentsAndEnsureModified(project.getFile("binaryFile"), "/n/nSome Content\n\n"); - // Compare with the tag and merge the changes - CVSCompareSubscriber subscriber = getSyncInfoSource().createCompareSubscriber(project, v1); - getSyncInfoSource().refresh(subscriber, project); - getSyncInfoSource().markAsMerged(subscriber, new IResource[] { project.getFile("binaryFile") }); - assertIsBinary(project.getFile("binaryFile")); - } finally { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); - } - } + IProject copy = checkoutCopy(project, "-copy"); + create(copy.getFile("binaryFile"), true); + setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); + addResources(new IResource[] { copy.getFile("binaryFile") }); + commitProject(copy); + // Tag the project + tagProject(copy, v1, false); + // Add the same file to the project but don't share it + create(project.getFile("binaryFile"), true); + setContentsAndEnsureModified(project.getFile("binaryFile"), "/n/nSome Content\n\n"); + // Compare with the tag and merge the changes + CVSCompareSubscriber subscriber = getSyncInfoSource().createCompareSubscriber(project, v1); + getSyncInfoSource().refresh(subscriber, project); + getSyncInfoSource().markAsMerged(subscriber, new IResource[] { project.getFile("binaryFile") }); + assertIsBinary(project.getFile("binaryFile")); + } finally { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); + } + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java index 21c3ba380..d95f428ce 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java @@ -219,12 +219,12 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testMergableConflicts", subscriber, project, new String[] { "file1.txt", "file2.txt"}, true, new int[] { - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.CHANGE}); + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.CHANGE}); // Perform a merge mergeResources(subscriber, project, new String[] { - "file1.txt", + "file1.txt", "file2.txt"}, false /* allow overwrite */); @@ -232,8 +232,8 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testMergableConflicts", getWorkspaceSubscriber(), project, new String[] { "file1.txt", "file2.txt"}, true, new int[] { - SyncInfo.OUTGOING | SyncInfo.CHANGE, - SyncInfo.OUTGOING | SyncInfo.CHANGE}); + SyncInfo.OUTGOING | SyncInfo.CHANGE, + SyncInfo.OUTGOING | SyncInfo.CHANGE}); //TODO: How do we know if the right thing happened to the file contents? } @@ -272,12 +272,12 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testUnmergableConflicts", subscriber, project, new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"}, true, new int[] { - SyncInfo.IN_SYNC, /* TODO: is this OK */ - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.ADDITION, - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.CHANGE}); + SyncInfo.IN_SYNC, /* TODO: is this OK */ + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.ADDITION, + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.CHANGE}); // TODO: Should actually perform the merge and check the results // However, this would require the changes to be redone @@ -289,12 +289,12 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testUnmergableConflicts", subscriber, project, new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"}, true, new int[] { - SyncInfo.IN_SYNC, /* TODO: is this OK */ - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.ADDITION, - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.CHANGE}); + SyncInfo.IN_SYNC, /* TODO: is this OK */ + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.ADDITION, + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.CHANGE}); // Perform a merge mergeResources(subscriber, project, new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"}, true /* allow overwrite */); @@ -303,11 +303,11 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testUnmergableConflicts", getWorkspaceSubscriber(), project, new String[] { "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"}, true, new int[] { - SyncInfo.OUTGOING | SyncInfo.CHANGE, - SyncInfo.OUTGOING | SyncInfo.CHANGE, - SyncInfo.OUTGOING | SyncInfo.CHANGE, - SyncInfo.OUTGOING | SyncInfo.DELETION, - SyncInfo.OUTGOING | SyncInfo.ADDITION}); + SyncInfo.OUTGOING | SyncInfo.CHANGE, + SyncInfo.OUTGOING | SyncInfo.CHANGE, + SyncInfo.OUTGOING | SyncInfo.CHANGE, + SyncInfo.OUTGOING | SyncInfo.DELETION, + SyncInfo.OUTGOING | SyncInfo.ADDITION}); assertDeleted("testUnmergableConflicts", project, new String[] { "delete.txt" }); //TODO: How do we know if the right thing happend to the file contents? @@ -343,12 +343,12 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testLocalScrub", subscriber, project, new String[] { "delete.txt", "file1.txt", "works.txt", "addition.txt", "folder1/a.txt", "folder1/b.txt"}, true, new int[] { - SyncInfo.INCOMING | SyncInfo.DELETION, - SyncInfo.INCOMING | SyncInfo.CHANGE, - SyncInfo.INCOMING | SyncInfo.CHANGE, - SyncInfo.INCOMING | SyncInfo.ADDITION, - SyncInfo.INCOMING | SyncInfo.DELETION, - SyncInfo.INCOMING | SyncInfo.CHANGE}); + SyncInfo.INCOMING | SyncInfo.DELETION, + SyncInfo.INCOMING | SyncInfo.CHANGE, + SyncInfo.INCOMING | SyncInfo.CHANGE, + SyncInfo.INCOMING | SyncInfo.ADDITION, + SyncInfo.INCOMING | SyncInfo.DELETION, + SyncInfo.INCOMING | SyncInfo.CHANGE}); //Refresh project to make sure we delete all existing files. See bug 403309 project.refreshLocal(IProject.DEPTH_INFINITE, DEFAULT_MONITOR); @@ -528,11 +528,11 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testMarkAsMergedConflicts", subscriber, project, new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt"}, true, new int[] { - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.CHANGE, - SyncInfo.CONFLICTING | SyncInfo.ADDITION, - SyncInfo.CONFLICTING | SyncInfo.CHANGE}); + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + SyncInfo.CONFLICTING | SyncInfo.ADDITION, + SyncInfo.CONFLICTING | SyncInfo.CHANGE}); markAsMerged(subscriber, project, new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt"}); @@ -540,11 +540,11 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testMarkAsMerged", subscriber, project, new String[] { "delete.txt", "file1.txt", "file2.txt", "addition.txt", "folder1/a.txt"}, true, new int[] { - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC}); + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC}); } @Override @@ -656,59 +656,59 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest { assertContentsEqual(project, branchedProject); } - public void testBinaryAddition() throws CoreException { - // See bug 132255 - KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); - try { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); - IProject project = createProject(new String[] { "a.txt"}); + public void testBinaryAddition() throws CoreException { + // See bug 132255 + KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); + try { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); + IProject project = createProject(new String[] { "a.txt"}); // Checkout and branch a copy CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION); CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH); IProject branchedProject = branchProject(project, root, branch); // Add a binary file to the branch that contains LFs - create(branchedProject.getFile("binaryFile"), true); - setContentsAndEnsureModified(branchedProject.getFile("binaryFile"), "/n/n\n\n"); - addResources(new IResource[] { branchedProject.getFile("binaryFile") }); - commitProject(branchedProject); - // Merge the addition with HEAD - CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch); - getSyncInfoSource().refresh(subscriber, project); - getSyncInfoSource().updateResources(subscriber, new IResource[] { project.getFile("binaryFile") }); - assertContentsEqual(branchedProject.getFile("binaryFile"), project.getFile("binaryFile")); - } finally { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); - } - } - - public void testBinaryMarkAsMerged() throws CoreException, InvocationTargetException, InterruptedException { - // See bug 132255 - KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); - try { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); - IProject project = createProject(new String[] { "a.txt"}); + create(branchedProject.getFile("binaryFile"), true); + setContentsAndEnsureModified(branchedProject.getFile("binaryFile"), "/n/n\n\n"); + addResources(new IResource[] { branchedProject.getFile("binaryFile") }); + commitProject(branchedProject); + // Merge the addition with HEAD + CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch); + getSyncInfoSource().refresh(subscriber, project); + getSyncInfoSource().updateResources(subscriber, new IResource[] { project.getFile("binaryFile") }); + assertContentsEqual(branchedProject.getFile("binaryFile"), project.getFile("binaryFile")); + } finally { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); + } + } + + public void testBinaryMarkAsMerged() throws CoreException, InvocationTargetException, InterruptedException { + // See bug 132255 + KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); + try { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); + IProject project = createProject(new String[] { "a.txt"}); // Checkout and branch a copy CVSTag root = new CVSTag("root_branch1", CVSTag.VERSION); CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH); IProject branchedProject = branchProject(project, root, branch); // Add a binary file to the branch that contains LFs - create(branchedProject.getFile("binaryFile"), true); - setContentsAndEnsureModified(branchedProject.getFile("binaryFile"), "/n/n\n\n"); - addResources(new IResource[] { branchedProject.getFile("binaryFile") }); - commitProject(branchedProject); - // Add the same file to the project but don't share it - create(project.getFile("binaryFile"), true); - setContentsAndEnsureModified(project.getFile("binaryFile"), "/n/nSome Content\n\n"); - // Merge the addition with HEAD - CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch); - getSyncInfoSource().refresh(subscriber, project); - getSyncInfoSource().markAsMerged(subscriber, new IResource[] { project.getFile("binaryFile") }); - assertIsBinary(project.getFile("binaryFile")); - } finally { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); - } - } - + create(branchedProject.getFile("binaryFile"), true); + setContentsAndEnsureModified(branchedProject.getFile("binaryFile"), "/n/n\n\n"); + addResources(new IResource[] { branchedProject.getFile("binaryFile") }); + commitProject(branchedProject); + // Add the same file to the project but don't share it + create(project.getFile("binaryFile"), true); + setContentsAndEnsureModified(project.getFile("binaryFile"), "/n/nSome Content\n\n"); + // Merge the addition with HEAD + CVSMergeSubscriber subscriber = getSyncInfoSource().createMergeSubscriber(project, root, branch); + getSyncInfoSource().refresh(subscriber, project); + getSyncInfoSource().markAsMerged(subscriber, new IResource[] { project.getFile("binaryFile") }); + assertIsBinary(project.getFile("binaryFile")); + } finally { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); + } + } + public void testMergeNewFileToBranch() throws InvocationTargetException, InterruptedException, CoreException { // Create a project IProject project = createProject(new String[] {"file1.txt"}); diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java index bd0c14a73..b45c7aa2a 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java @@ -455,41 +455,41 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { } public void testOverideAndUpdateSimple() throws CVSException, CoreException, IOException { - IProject project = createProject("testOutgoingChangesOverideAndUpdate", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); + IProject project = createProject("testOutgoingChangesOverideAndUpdate", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); - // Make some modifications - setContentsAndEnsureModified(project.getFile("folder1/a.txt")); - addResources(project, new String[] { "folder2/folder3/add.txt" }, false); - deleteResources(project, new String[] {"folder1/b.txt"}, false); + // Make some modifications + setContentsAndEnsureModified(project.getFile("folder1/a.txt")); + addResources(project, new String[] { "folder2/folder3/add.txt" }, false); + deleteResources(project, new String[] {"folder1/b.txt"}, false); - // Get the sync tree for the project - assertSyncEquals("testOutgoingChangesOverwrite", project, - new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"}, - true, new int[] { - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC, - SyncInfo.OUTGOING | SyncInfo.CHANGE, - SyncInfo.OUTGOING | SyncInfo.DELETION, - SyncInfo.IN_SYNC, /* adding a folder creates it remotely */ - SyncInfo.IN_SYNC, /* adding a folder creates it remotely */ - SyncInfo.OUTGOING | SyncInfo.ADDITION}); + // Get the sync tree for the project + assertSyncEquals("testOutgoingChangesOverwrite", project, + new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"}, + true, new int[] { + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC, + SyncInfo.OUTGOING | SyncInfo.CHANGE, + SyncInfo.OUTGOING | SyncInfo.DELETION, + SyncInfo.IN_SYNC, /* adding a folder creates it remotely */ + SyncInfo.IN_SYNC, /* adding a folder creates it remotely */ + SyncInfo.OUTGOING | SyncInfo.ADDITION}); - // Revert the changes - overrideAndUpdate(project, new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"}, true /* should prompt */); + // Revert the changes + overrideAndUpdate(project, new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"}, true /* should prompt */); - // Ensure we're in sync - assertSyncEquals("testOutgoingChangesOverwrite", project, - new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"}, - true, new int[] { - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC}); + // Ensure we're in sync + assertSyncEquals("testOutgoingChangesOverwrite", project, + new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder2/", "folder2/folder3/", "folder2/folder3/add.txt"}, + true, new int[] { + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC, + SyncInfo.IN_SYNC}); - // Ensure deleted resource is re-created - assertExistsInWorkspace("testOutgoingChangesOverwrite", project.getFile(new Path("folder1/b.txt"))); + // Ensure deleted resource is re-created + assertExistsInWorkspace("testOutgoingChangesOverwrite", project.getFile(new Path("folder1/b.txt"))); // Test conflicting changes IProject copy = checkoutCopy(project, "-copy"); @@ -649,7 +649,7 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { update( project, new String[] {"file1.txt"}); - + assertSyncEquals("testFileConflict", project, new String[] { "file1.txt", "folder1/", "folder1/a.txt"}, true, new int[] { @@ -911,7 +911,7 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { SyncInfo.INCOMING | SyncInfo.ADDITION, SyncInfo.INCOMING | SyncInfo.ADDITION}); } - + /* * Test that a deleted file can still be deleted through the team provider */ @@ -982,9 +982,9 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { SyncInfo.IN_SYNC, SyncInfo.IN_SYNC}); } - - public void testSyncOnBranch() throws CoreException { - + + public void testSyncOnBranch() throws CoreException { + // Create a test project and a branch IProject project = createProject(new String[] { "file1.txt", "file2.txt", "file3.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); CVSTag branch = new CVSTag("branch1", CVSTag.BRANCH); @@ -1019,8 +1019,8 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { SyncInfo.INCOMING | SyncInfo.ADDITION, SyncInfo.INCOMING | SyncInfo.ADDITION, SyncInfo.INCOMING | SyncInfo.ADDITION}); - } - + } + public void testRenameProject() throws CoreException { String[] resourceNames = new String[] { "changed.txt", "folder1/", "folder1/a.txt" }; int[] inSync = new int[] {SyncInfo.IN_SYNC, SyncInfo.IN_SYNC, SyncInfo.IN_SYNC}; @@ -1078,9 +1078,9 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testFolderDeletion sync check", project, new String[] { "folder1/", "folder1/a.txt", "folder1/folder2/", "folder1/folder2/file.txt"}, true, new int[] { SyncInfo.IN_SYNC, - SyncInfo.OUTGOING | SyncInfo.DELETION, - SyncInfo.IN_SYNC, - SyncInfo.OUTGOING | SyncInfo.DELETION}); + SyncInfo.OUTGOING | SyncInfo.DELETION, + SyncInfo.IN_SYNC, + SyncInfo.OUTGOING | SyncInfo.DELETION}); // commit folder1/a.txt commit(project, new String[] { "folder1/a.txt" }); @@ -1089,8 +1089,8 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testFolderDeletion sync check", project, new String[] { "folder1/", "folder1/folder2/", "folder1/folder2/file.txt"}, true, new int[] { SyncInfo.IN_SYNC, - SyncInfo.IN_SYNC, - SyncInfo.OUTGOING | SyncInfo.DELETION}); + SyncInfo.IN_SYNC, + SyncInfo.OUTGOING | SyncInfo.DELETION}); assertDeleted("testFolderDeletion", project, new String[] {"folder1/a.txt"}); // Commit folder1/folder2/file.txt @@ -1100,10 +1100,10 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { assertDeleted("testFolderDeletion", project, new String[] {"folder1/", "folder1/folder2/", "folder1/folder2/file.txt"}); } /** - * There is special handling required when building a sync tree for a tag when there are undiscovered folders - * that only contain other folders. - */ - public void testTagRetrievalForFolderWithNoFile() throws TeamException, CoreException { + * There is special handling required when building a sync tree for a tag when there are undiscovered folders + * that only contain other folders. + */ + public void testTagRetrievalForFolderWithNoFile() throws TeamException, CoreException { IProject project = createProject("testTagRetrievalForFolderWithNoFile", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt"}); // Checkout, branch and modify a copy IProject copy = checkoutCopy(project, "-copy"); @@ -1115,15 +1115,15 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { // Fetch the tree corresponding to the branch using the original as the base. // XXX This will fail for CVSNT with directory pruning on refresh(getSubscriber(), project); - } - - public void testIgnoredResource() throws CoreException, TeamException { + } + + public void testIgnoredResource() throws CoreException, TeamException { // Create a test project (which commits it as well) IProject project = createProject("testIgnoredResource", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); // Create a new file without adding it to version control buildResources(project, new String[] {"ignored.txt"}, false); - + // Get the sync tree for the project assertSyncEquals("testIgnoredResource", project, new String[] { "ignored.txt"}, @@ -1138,29 +1138,29 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { true, new int[] { SyncInfo.IN_SYNC, SyncInfo.OUTGOING | SyncInfo.ADDITION}); - } + } public void testRenameUnshared() throws CoreException, TeamException { - // Create a test project (which commits it as well) - IProject project = createProject("testRenameUnshared", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); - - // Create a new file without adding it to version control - buildResources(project, new String[] {"oldName.txt"}, false); - - // Get the sync tree for the project - assertSyncEquals("testRenameUnshared", project, - new String[] { "oldName.txt" }, - true, new int[] {SyncInfo.OUTGOING | SyncInfo.ADDITION}); + // Create a test project (which commits it as well) + IProject project = createProject("testRenameUnshared", new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"}); + + // Create a new file without adding it to version control + buildResources(project, new String[] {"oldName.txt"}, false); + + // Get the sync tree for the project + assertSyncEquals("testRenameUnshared", project, + new String[] { "oldName.txt" }, + true, new int[] {SyncInfo.OUTGOING | SyncInfo.ADDITION}); - IFile rename = project.getFile("oldName.txt"); - rename.move(new Path("newName.txt"), false, false, DEFAULT_MONITOR); + IFile rename = project.getFile("oldName.txt"); + rename.move(new Path("newName.txt"), false, false, DEFAULT_MONITOR); - assertDeleted("testRenameUnshared", project, new String[] {"oldName.txt"}); + assertDeleted("testRenameUnshared", project, new String[] {"oldName.txt"}); - assertSyncEquals("testRenameUnshared", project, - new String[] { "newName.txt"}, - true, new int[] { - SyncInfo.OUTGOING | SyncInfo.ADDITION}); + assertSyncEquals("testRenameUnshared", project, + new String[] { "newName.txt"}, + true, new int[] { + SyncInfo.OUTGOING | SyncInfo.ADDITION}); } public void testOutgoingEmptyFolder() throws CoreException, TeamException { @@ -1209,9 +1209,9 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { // The files should show up as outgoing deletions assertSyncEquals("testConflictingFolderDeletion sync check", project, - new String[] { "folder1/", "folder1/a.txt", "folder1/b.txt"}, - true, new int[] { - SyncInfo.IN_SYNC, + new String[] { "folder1/", "folder1/a.txt", "folder1/b.txt"}, + true, new int[] { + SyncInfo.IN_SYNC, SyncInfo.IN_SYNC, /* conflicting deletions are handled automatically */ SyncInfo.IN_SYNC}); } @@ -1233,7 +1233,7 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { assertSyncEquals("testProjectClose sync check", project, new String[] { "file1.txt"}, true, new int[] { - SyncInfo.OUTGOING | SyncInfo.CHANGE, + SyncInfo.OUTGOING | SyncInfo.CHANGE, }); project.close(null); @@ -1396,61 +1396,61 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { assertTrue(project.getFile("file1.txt").exists()); } - public void testBinaryAddition() throws CoreException { - // See bug 132255 - KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); - try { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); - IProject project = createProject(new String[] { "a.txt"}); + public void testBinaryAddition() throws CoreException { + // See bug 132255 + KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); + try { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); + IProject project = createProject(new String[] { "a.txt"}); // Checkout a copy - IProject copy = checkoutCopy(project, "-copy"); + IProject copy = checkoutCopy(project, "-copy"); // Add a binary file that contains LFs - create(copy.getFile("binaryFile"), true); - setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); - addResources(new IResource[] { copy.getFile("binaryFile") }); - commitProject(copy); - // Update - getSyncInfoSource().refresh(getSubscriber(), project); - getSyncInfoSource().updateResources(getSubscriber(), new IResource[] { project.getFile("binaryFile") }); - assertContentsEqual(copy.getFile("binaryFile"), project.getFile("binaryFile")); - } finally { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); - } - } - - public void testBinaryMarkAsMerged() throws CoreException, InvocationTargetException, InterruptedException { - KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); - try { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); - IProject project = createProject(new String[] { "a.txt"}); + create(copy.getFile("binaryFile"), true); + setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); + addResources(new IResource[] { copy.getFile("binaryFile") }); + commitProject(copy); + // Update + getSyncInfoSource().refresh(getSubscriber(), project); + getSyncInfoSource().updateResources(getSubscriber(), new IResource[] { project.getFile("binaryFile") }); + assertContentsEqual(copy.getFile("binaryFile"), project.getFile("binaryFile")); + } finally { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); + } + } + + public void testBinaryMarkAsMerged() throws CoreException, InvocationTargetException, InterruptedException { + KSubstOption option = CVSProviderPlugin.getPlugin().getDefaultTextKSubstOption(); + try { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(Command.KSUBST_TEXT_KEYWORDS_ONLY); + IProject project = createProject(new String[] { "a.txt"}); // Checkout a copy - IProject copy = checkoutCopy(project, "-copy"); + IProject copy = checkoutCopy(project, "-copy"); // Add a binary file to the copy and commit - create(copy.getFile("binaryFile"), true); - setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); - addResources(new IResource[] { copy.getFile("binaryFile") }); - commitProject(copy); - // Add the same file to the project but don't share it - create(project.getFile("binaryFile"), true); - setContentsAndEnsureModified(project.getFile("binaryFile"), "/n/nSome Content\n\n"); - // Sync and mark as merged - getSyncInfoSource().refresh(getSubscriber(), project); - getSyncInfoSource().markAsMerged(getSubscriber(), new IResource[] { project.getFile("binaryFile") }); - assertIsBinary(project.getFile("binaryFile")); - } finally { - CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); - } - } - - public void testDisabledDirectoryDiscovery() throws CoreException { - // Create a project and disable new directory discovery - IProject project = createProject(new String[] { "file1.txt"}); - setFetchAbsentDirectories(project, false); - - IProject copy = checkoutCopy(project, "-copy"); - addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, true); - - // The new subfolder (folder2) and its contents should not have sync info (i.e. in_sync) + create(copy.getFile("binaryFile"), true); + setContentsAndEnsureModified(copy.getFile("binaryFile"), "/n/n\n\n"); + addResources(new IResource[] { copy.getFile("binaryFile") }); + commitProject(copy); + // Add the same file to the project but don't share it + create(project.getFile("binaryFile"), true); + setContentsAndEnsureModified(project.getFile("binaryFile"), "/n/nSome Content\n\n"); + // Sync and mark as merged + getSyncInfoSource().refresh(getSubscriber(), project); + getSyncInfoSource().markAsMerged(getSubscriber(), new IResource[] { project.getFile("binaryFile") }); + assertIsBinary(project.getFile("binaryFile")); + } finally { + CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option); + } + } + + public void testDisabledDirectoryDiscovery() throws CoreException { + // Create a project and disable new directory discovery + IProject project = createProject(new String[] { "file1.txt"}); + setFetchAbsentDirectories(project, false); + + IProject copy = checkoutCopy(project, "-copy"); + addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, true); + + // The new subfolder (folder2) and its contents should not have sync info (i.e. in_sync) assertSyncEquals("testDisabledDirectoryDiscovery", project, new String[] {"file1.txt", "added.txt", "folder2/", "folder2/added.txt" }, true, new int[] { @@ -1459,7 +1459,7 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { SyncInfo.IN_SYNC, SyncInfo.IN_SYNC }); - } + } private void setFetchAbsentDirectories(IProject project, boolean fetch) throws CVSException { RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId()); diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java index 02dd4d60a..e91264443 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/SyncInfoSource.java @@ -104,10 +104,10 @@ public class SyncInfoSource { /** * Refresh the subscriber for the given resources */ - public void refresh(Subscriber subscriber, IResource[] resources) throws TeamException { - subscriber.refresh(resources, IResource.DEPTH_INFINITE, DEFAULT_MONITOR); - } - + public void refresh(Subscriber subscriber, IResource[] resources) throws TeamException { + subscriber.refresh(resources, IResource.DEPTH_INFINITE, DEFAULT_MONITOR); + } + protected void assertProjectRemoved(Subscriber subscriber, IProject project) { IResource[] roots = subscriber.roots(); for (int i = 0; i < roots.length; i++) { @@ -147,8 +147,8 @@ public class SyncInfoSource { assertDiffKindEquals(message, subscriber, resource, SyncInfoToDiffConverter.asDiffFlags(syncKind)); } Assert.assertTrue(message + ": improper sync state for " + resource + " expected " + - SyncInfo.kindToString(kindOther) + " but was " + - SyncInfo.kindToString(kind), kind == kindOther); + SyncInfo.kindToString(kindOther) + " but was " + + SyncInfo.kindToString(kind), kind == kindOther); } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java index f9df87569..937d8704c 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/TestUpdateOperation.java @@ -59,10 +59,10 @@ class TestUpdateOperation extends WorkspaceUpdateOperation { UpdateOnlyMergableOperation operation = new UpdateOnlyMergableOperation(getPart(), project, resources, localOptions) { @Override public ISynchronizationScope buildScope(IProgressMonitor monitor) throws InterruptedException, CVSException { - if (getScopeManager() == null) { - // manager = createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings()); - ReflectionUtils.setField(this, "manager", createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings())); - BuildScopeOperation op = new BuildScopeOperation(getPart(), getScopeManager()) { + if (getScopeManager() == null) { + // manager = createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings()); + ReflectionUtils.setField(this, "manager", createScopeManager(consultModelsWhenBuildingScope && consultModelsForMappings())); + BuildScopeOperation op = new BuildScopeOperation(getPart(), getScopeManager()) { @Override protected boolean promptForInputChange(String requestPreviewMessage, IProgressMonitor monitor) { return false; // do not prompt @@ -73,8 +73,8 @@ class TestUpdateOperation extends WorkspaceUpdateOperation { } catch (InvocationTargetException e) { throw CVSException.wrapException(e); } - } - return getScope(); + } + return getScope(); } }; operation.run(monitor); diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CommitSetTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CommitSetTests.java index 2e98c7369..cea7238a4 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CommitSetTests.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/CommitSetTests.java @@ -42,169 +42,169 @@ public class CommitSetTests extends EclipseTest { private List<ChangeSet> addedSets = new ArrayList<>(); private List<ChangeSet> removedSets = new ArrayList<>(); private IChangeSetChangeListener listener = new IChangeSetChangeListener() { - @Override + @Override public void setAdded(ChangeSet set) { - addedSets.add(set); - } - @Override + addedSets.add(set); + } + @Override public void setRemoved(ChangeSet set) { - removedSets.add(set); - } - @Override + removedSets.add(set); + } + @Override public void nameChanged(ChangeSet set) { - // TODO Auto-generated method stub + // TODO Auto-generated method stub - } - @Override + } + @Override public void defaultSetChanged(ChangeSet oldDefault, ChangeSet set) { - // TODO Auto-generated method stub - - } - @Override + // TODO Auto-generated method stub + + } + @Override public void resourcesChanged(ChangeSet set, IPath[] paths) { - // TODO Auto-generated method stub - - } - }; + // TODO Auto-generated method stub + + } + }; - public static Test suite() { + public static Test suite() { return suite(CommitSetTests.class); } - public CommitSetTests() { - super(); - } - - public CommitSetTests(String name) { - super(name); - } - - /** - * Create a commit set and verify that it was created and contains the supplied files - * @param title the title of the new set - * @param files the files for the new set - * @return the newly create commit set - * @throws TeamException - */ - protected ActiveChangeSet createCommitSet(String title, IFile[] files, boolean manageSet) throws CoreException { - assertIsModified(getName(), files); - ActiveChangeSetManager manager = CVSUIPlugin.getPlugin().getChangeSetManager(); - ActiveChangeSet set = manager.createSet(title, files); - assertEquals("Not all files were added to the set", files.length, set.getResources().length); - if (manageSet) { - manager.add(set); - waitForSetAddedEvent(set); - } - return set; - } + public CommitSetTests() { + super(); + } + + public CommitSetTests(String name) { + super(name); + } + + /** + * Create a commit set and verify that it was created and contains the supplied files + * @param title the title of the new set + * @param files the files for the new set + * @return the newly create commit set + * @throws TeamException + */ + protected ActiveChangeSet createCommitSet(String title, IFile[] files, boolean manageSet) throws CoreException { + assertIsModified(getName(), files); + ActiveChangeSetManager manager = CVSUIPlugin.getPlugin().getChangeSetManager(); + ActiveChangeSet set = manager.createSet(title, files); + assertEquals("Not all files were added to the set", files.length, set.getResources().length); + if (manageSet) { + manager.add(set); + waitForSetAddedEvent(set); + } + return set; + } - /** - * Commit the files in the given set to the repository - * and ensure that the files are in the proper state - * @param set the commit set - * @throws CVSException - */ - protected void commit(ActiveChangeSet set) throws CoreException { - boolean isManaged = setIsManaged(set); - commitResources(set.getResources(), IResource.DEPTH_ZERO); - if (isManaged) { - // Committing the set should remove it from the manager - waitForSetRemovedEvent(set); - } - } - - private boolean setIsManaged(ActiveChangeSet set) { - return CVSUIPlugin.getPlugin().getChangeSetManager().contains(set); - } + /** + * Commit the files in the given set to the repository + * and ensure that the files are in the proper state + * @param set the commit set + * @throws CVSException + */ + protected void commit(ActiveChangeSet set) throws CoreException { + boolean isManaged = setIsManaged(set); + commitResources(set.getResources(), IResource.DEPTH_ZERO); + if (isManaged) { + // Committing the set should remove it from the manager + waitForSetRemovedEvent(set); + } + } + + private boolean setIsManaged(ActiveChangeSet set) { + return CVSUIPlugin.getPlugin().getChangeSetManager().contains(set); + } - private void waitForSetAddedEvent(ActiveChangeSet set) { - int count = 0; - while (count < 5) { - if (addedSets.contains(set)) { - addedSets.remove(set); - return; - } - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // keep going - } - count++; - } - fail("Did not receive expected set added event"); - } + private void waitForSetAddedEvent(ActiveChangeSet set) { + int count = 0; + while (count < 5) { + if (addedSets.contains(set)) { + addedSets.remove(set); + return; + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // keep going + } + count++; + } + fail("Did not receive expected set added event"); + } - private void waitForSetRemovedEvent(ActiveChangeSet set) { - int count = 0; - while (count < 5) { - if (removedSets.contains(set)) { - removedSets.remove(set); - return; - } - try { - while (Display.getCurrent().readAndDispatch()) {} - Thread.sleep(1000); - } catch (InterruptedException e) { - // keep going - } - count++; - } - fail("Did not receive expected set removed event"); - } - + private void waitForSetRemovedEvent(ActiveChangeSet set) { + int count = 0; + while (count < 5) { + if (removedSets.contains(set)) { + removedSets.remove(set); + return; + } + try { + while (Display.getCurrent().readAndDispatch()) {} + Thread.sleep(1000); + } catch (InterruptedException e) { + // keep going + } + count++; + } + fail("Did not receive expected set removed event"); + } + @Override - protected void setUp() throws Exception { - super.setUp(); - CVSUIPlugin.getPlugin().getChangeSetManager().addListener(listener); - } - + protected void setUp() throws Exception { + super.setUp(); + CVSUIPlugin.getPlugin().getChangeSetManager().addListener(listener); + } + @Override - protected void tearDown() throws Exception { - super.tearDown(); - CVSUIPlugin.getPlugin().getChangeSetManager().removeListener(listener); - } - - /** - * Test a simple commit of a commit set. The set being committed is not managed. - * @throws CoreException - * @throws IOException - * @throws TeamException - */ - public void testSimpleCommit() throws TeamException, CoreException, IOException { - IProject project = createProject(new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" }); - setContentsAndEnsureModified(project.getFile("changed.txt")); - deleteResources(project, new String[] { "deleted.txt" }, false /* don't commit */); - addResources(project, new String[] { "added.txt" }, false /* don't commit */); - - IFile[] files = new IFile[] { - project.getFile("changed.txt"), - project.getFile("deleted.txt"), - project.getFile("added.txt")}; - ActiveChangeSet set = createCommitSet("testSimpleCommit", files, false /* do not manage the set */); - commit(set); - assertLocalStateEqualsRemote(project); - } - - /** - * Test a managed commit of a commit set. The set being committed is managed - * and should be removed once the commit succeeds. - * @throws CoreException - * @throws IOException - * @throws TeamException - */ - public void testManagedCommit() throws TeamException, CoreException, IOException { - IProject project = createProject(new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" }); - setContentsAndEnsureModified(project.getFile("changed.txt")); - deleteResources(project, new String[] { "deleted.txt" }, false /* don't commit */); - addResources(project, new String[] { "added.txt" }, false /* don't commit */); - - IFile[] files = new IFile[] { - project.getFile("changed.txt"), - project.getFile("deleted.txt"), - project.getFile("added.txt")}; - ActiveChangeSet set = createCommitSet("testSimpleCommit", files, true /* manage the set */); - commit(set); - assertLocalStateEqualsRemote(project); - } + protected void tearDown() throws Exception { + super.tearDown(); + CVSUIPlugin.getPlugin().getChangeSetManager().removeListener(listener); + } + + /** + * Test a simple commit of a commit set. The set being committed is not managed. + * @throws CoreException + * @throws IOException + * @throws TeamException + */ + public void testSimpleCommit() throws TeamException, CoreException, IOException { + IProject project = createProject(new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" }); + setContentsAndEnsureModified(project.getFile("changed.txt")); + deleteResources(project, new String[] { "deleted.txt" }, false /* don't commit */); + addResources(project, new String[] { "added.txt" }, false /* don't commit */); + + IFile[] files = new IFile[] { + project.getFile("changed.txt"), + project.getFile("deleted.txt"), + project.getFile("added.txt")}; + ActiveChangeSet set = createCommitSet("testSimpleCommit", files, false /* do not manage the set */); + commit(set); + assertLocalStateEqualsRemote(project); + } + + /** + * Test a managed commit of a commit set. The set being committed is managed + * and should be removed once the commit succeeds. + * @throws CoreException + * @throws IOException + * @throws TeamException + */ + public void testManagedCommit() throws TeamException, CoreException, IOException { + IProject project = createProject(new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" }); + setContentsAndEnsureModified(project.getFile("changed.txt")); + deleteResources(project, new String[] { "deleted.txt" }, false /* don't commit */); + addResources(project, new String[] { "added.txt" }, false /* don't commit */); + + IFile[] files = new IFile[] { + project.getFile("changed.txt"), + project.getFile("deleted.txt"), + project.getFile("added.txt")}; + ActiveChangeSet set = createCommitSet("testSimpleCommit", files, true /* manage the set */); + commit(set); + assertLocalStateEqualsRemote(project); + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ModelParticipantSyncInfoSource.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ModelParticipantSyncInfoSource.java index 20d6a61cd..4961b670c 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ModelParticipantSyncInfoSource.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ModelParticipantSyncInfoSource.java @@ -553,21 +553,21 @@ public class ModelParticipantSyncInfoSource extends ParticipantSyncInfoSource { } private ModelSynchronizePage getPage(Subscriber subscriber) { - try { - ModelSynchronizeParticipant participant = getParticipant(subscriber); - if (participant == null) - throw new AssertionFailedError("The participant for " + subscriber.getName() + " could not be retrieved"); - IWorkbenchPage activePage = TeamUIPlugin.getActivePage(); - ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID); - IPage page = ((SynchronizeView)view).getPage(participant); - if (page instanceof ModelSynchronizePage) { - ModelSynchronizePage subscriberPage = (ModelSynchronizePage)page; - return subscriberPage; - } - } catch (PartInitException e) { - throw new AssertionFailedError("Cannot show sync view in active page"); - } - throw new AssertionFailedError("The page for " + subscriber.getName() + " could not be retrieved"); + try { + ModelSynchronizeParticipant participant = getParticipant(subscriber); + if (participant == null) + throw new AssertionFailedError("The participant for " + subscriber.getName() + " could not be retrieved"); + IWorkbenchPage activePage = TeamUIPlugin.getActivePage(); + ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID); + IPage page = ((SynchronizeView)view).getPage(participant); + if (page instanceof ModelSynchronizePage) { + ModelSynchronizePage subscriberPage = (ModelSynchronizePage)page; + return subscriberPage; + } + } catch (PartInitException e) { + throw new AssertionFailedError("Cannot show sync view in active page"); + } + throw new AssertionFailedError("The page for " + subscriber.getName() + " could not be retrieved"); } @Override @@ -584,7 +584,7 @@ public class ModelParticipantSyncInfoSource extends ParticipantSyncInfoSource { assertTreeMatchesDiffs(rootItems, copy); } - private void assertTreeMatchesDiffs(TreeItem[] rootItems, ResourceDiffTree copy) { + private void assertTreeMatchesDiffs(TreeItem[] rootItems, ResourceDiffTree copy) { assertItemsInDiffTree(rootItems, copy); if (!copy.isEmpty()) { new AssertionFailedError("Viewer is not showing all diffs"); @@ -592,10 +592,10 @@ public class ModelParticipantSyncInfoSource extends ParticipantSyncInfoSource { } private void assertItemsInDiffTree(TreeItem[] items, ResourceDiffTree copy) { - if (items == null || items.length == 0) { - return; - } - for (TreeItem item : items) { + if (items == null || items.length == 0) { + return; + } + for (TreeItem item : items) { assertItemInTree(item, copy); } @@ -623,15 +623,15 @@ public class ModelParticipantSyncInfoSource extends ParticipantSyncInfoSource { } private TreeItem[] getTreeItems(Subscriber subscriber) { - ModelSynchronizePage page = getPage(subscriber); - Viewer v = page.getViewer(); - if (v instanceof TreeViewer) { - TreeViewer treeViewer = (TreeViewer)v; - treeViewer.expandAll(); - Tree t = (treeViewer).getTree(); - return t.getItems(); - } - throw new AssertionFailedError("The tree for " + subscriber.getName() + " could not be retrieved"); - } + ModelSynchronizePage page = getPage(subscriber); + Viewer v = page.getViewer(); + if (v instanceof TreeViewer) { + TreeViewer treeViewer = (TreeViewer)v; + treeViewer.expandAll(); + Tree t = (treeViewer).getTree(); + return t.getItems(); + } + throw new AssertionFailedError("The tree for " + subscriber.getName() + " could not be retrieved"); + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ParticipantSyncInfoSource.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ParticipantSyncInfoSource.java index f29eaefcd..76818f070 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ParticipantSyncInfoSource.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/ParticipantSyncInfoSource.java @@ -33,13 +33,13 @@ import org.eclipse.ui.part.IPage; public class ParticipantSyncInfoSource extends SyncInfoSource { - public static ISynchronizePage getSyncViewPage(ISynchronizeParticipant participant) throws PartInitException { + public static ISynchronizePage getSyncViewPage(ISynchronizeParticipant participant) throws PartInitException { IWorkbenchPage activePage = TeamUIPlugin.getActivePage(); ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID); IPage page = ((SynchronizeView)view).getPage(participant); return (ISynchronizePage)page; } - + public ParticipantSyncInfoSource() { IWorkbenchPage activePage = TeamUIPlugin.getActivePage(); try { @@ -91,13 +91,13 @@ public class ParticipantSyncInfoSource extends SyncInfoSource { * @param subscriber the subscriber */ public void assertViewMatchesModel(Subscriber subscriber) { - // Default is to do nothing. Subclasses may override + // Default is to do nothing. Subclasses may override } - public void refresh(Subscriber subscriber, IResource[] resources) - throws TeamException { - super.refresh(subscriber, resources); + public void refresh(Subscriber subscriber, IResource[] resources) + throws TeamException { + super.refresh(subscriber, resources); assertViewMatchesModel(subscriber); - } + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/PerspectiveFactory.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/PerspectiveFactory.java index 6593a2821..1c261e7f4 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/PerspectiveFactory.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/PerspectiveFactory.java @@ -18,11 +18,11 @@ import org.eclipse.ui.IPerspectiveFactory; public class PerspectiveFactory implements IPerspectiveFactory { - public void createInitialLayout(IPageLayout layout) { - String editorArea = layout.getEditorArea(); - /* IFolderLayout top = */ - layout.createFolder("top", IPageLayout.LEFT, 0.40f, editorArea); //$NON-NLS-1$ - layout.setEditorAreaVisible(true); - } + public void createInitialLayout(IPageLayout layout) { + String editorArea = layout.getEditorArea(); + /* IFolderLayout top = */ + layout.createFolder("top", IPageLayout.LEFT, 0.40f, editorArea); //$NON-NLS-1$ + layout.setEditorAreaVisible(true); + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SubscriberParticipantSyncInfoSource.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SubscriberParticipantSyncInfoSource.java index a7e1eec16..d70fa95d3 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SubscriberParticipantSyncInfoSource.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/SubscriberParticipantSyncInfoSource.java @@ -134,10 +134,10 @@ public class SubscriberParticipantSyncInfoSource extends ParticipantSyncInfoSour if (participant == null) return null; SubscriberSyncInfoCollector syncInfoCollector = participant.getSubscriberSyncInfoCollector(); EclipseTest.waitForSubscriberInputHandling(syncInfoCollector); - SubscriberParticipantPage page = getPage(subscriber); - SynchronizeModelManager manager = (SynchronizeModelManager)page.getConfiguration().getProperty(SynchronizePageConfiguration.P_MODEL_MANAGER); - AbstractSynchronizeModelProvider provider = (AbstractSynchronizeModelProvider)manager.getActiveModelProvider(); - provider.waitUntilDone(new IProgressMonitor() { + SubscriberParticipantPage page = getPage(subscriber); + SynchronizeModelManager manager = (SynchronizeModelManager)page.getConfiguration().getProperty(SynchronizePageConfiguration.P_MODEL_MANAGER); + AbstractSynchronizeModelProvider provider = (AbstractSynchronizeModelProvider)manager.getActiveModelProvider(); + provider.waitUntilDone(new IProgressMonitor() { @Override public void beginTask(String name, int totalWork) { } @@ -211,91 +211,91 @@ public class SubscriberParticipantSyncInfoSource extends ParticipantSyncInfoSour return findSyncInfo(root, resource); } - private SyncInfo findSyncInfo(ISynchronizeModelElement node, IResource resource) { - if (node instanceof SyncInfoModelElement) { - SyncInfoModelElement element = (SyncInfoModelElement)node; - if (element.getResource().equals(resource)) { - return element.getSyncInfo(); - } - } - IDiffElement[] children = node.getChildren(); - for (IDiffElement element : children) { - ISynchronizeModelElement child = (ISynchronizeModelElement)element; - SyncInfo info = findSyncInfo(child, resource); - if (info != null) - return info; - } - return null; - } - - @Override + private SyncInfo findSyncInfo(ISynchronizeModelElement node, IResource resource) { + if (node instanceof SyncInfoModelElement) { + SyncInfoModelElement element = (SyncInfoModelElement)node; + if (element.getResource().equals(resource)) { + return element.getSyncInfo(); + } + } + IDiffElement[] children = node.getChildren(); + for (IDiffElement element : children) { + ISynchronizeModelElement child = (ISynchronizeModelElement)element; + SyncInfo info = findSyncInfo(child, resource); + if (info != null) + return info; + } + return null; + } + + @Override public void assertViewMatchesModel(Subscriber subscriber) { - // Getting the collector waits for the subscriber input handlers - getCollector(subscriber); + // Getting the collector waits for the subscriber input handlers + getCollector(subscriber); ISynchronizeModelElement root = getModelRoot(subscriber); TreeItem[] rootItems = getTreeItems(subscriber); assertMatchingTrees(root, rootItems, root.getChildren()); - } + } - private ISynchronizeModelElement getModelRoot(Subscriber subscriber) { - SubscriberParticipantPage page = getPage(subscriber); - return ((TreeViewerAdvisor)page.getViewerAdvisor()).getModelManager().getModelRoot(); - } - - private TreeItem[] getTreeItems(Subscriber subscriber) { - SubscriberParticipantPage page = getPage(subscriber); - Viewer v = page.getViewer(); - if (v instanceof TreeViewer) { - TreeViewer treeViewer = (TreeViewer)v; - treeViewer.expandAll(); - Tree t = (treeViewer).getTree(); - return t.getItems(); - } - throw new AssertionFailedError("The tree for " + subscriber.getName() + " could not be retrieved"); - } + private ISynchronizeModelElement getModelRoot(Subscriber subscriber) { + SubscriberParticipantPage page = getPage(subscriber); + return ((TreeViewerAdvisor)page.getViewerAdvisor()).getModelManager().getModelRoot(); + } + + private TreeItem[] getTreeItems(Subscriber subscriber) { + SubscriberParticipantPage page = getPage(subscriber); + Viewer v = page.getViewer(); + if (v instanceof TreeViewer) { + TreeViewer treeViewer = (TreeViewer)v; + treeViewer.expandAll(); + Tree t = (treeViewer).getTree(); + return t.getItems(); + } + throw new AssertionFailedError("The tree for " + subscriber.getName() + " could not be retrieved"); + } - private static SubscriberParticipantPage getPage(Subscriber subscriber) { - try { - SubscriberParticipant participant = getParticipant(subscriber); - if (participant == null) - throw new AssertionFailedError("The participant for " + subscriber.getName() + " could not be retrieved"); - IWorkbenchPage activePage = TeamUIPlugin.getActivePage(); - ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID); - IPage page = ((SynchronizeView)view).getPage(participant); - if (page instanceof SubscriberParticipantPage) { - SubscriberParticipantPage subscriberPage = (SubscriberParticipantPage)page; - return subscriberPage; - } - } catch (PartInitException e) { - throw new AssertionFailedError("Cannot show sync view in active page"); - } - throw new AssertionFailedError("The page for " + subscriber.getName() + " could not be retrieved"); - } - - private void assertMatchingTrees(IDiffElement parent, TreeItem[] items, IDiffElement[] children) { - if ((items == null || items.length == 0) && (children == null || children.length == 0)) { - // No children in either case so just return - return; - } - if (items == null || children == null || items.length != children.length) { - throw new AssertionFailedError("The number of children of " + parent.getName() + " is " + - (children == null ? 0: children.length) + " but the view has " + - (items == null ? 0 : items.length)); - } - for (IDiffElement element : children) { - TreeItem foundItem = null; - for (TreeItem item : items) { - if (item.getData() == element) { - foundItem = item; - break; - } - } - if (foundItem == null) { - throw new AssertionFailedError("Element" + element.getName() + " is in the model but not in the view"); - } else { - assertMatchingTrees(element, foundItem.getItems(), ((IDiffContainer)element).getChildren()); - } - } - - } + private static SubscriberParticipantPage getPage(Subscriber subscriber) { + try { + SubscriberParticipant participant = getParticipant(subscriber); + if (participant == null) + throw new AssertionFailedError("The participant for " + subscriber.getName() + " could not be retrieved"); + IWorkbenchPage activePage = TeamUIPlugin.getActivePage(); + ISynchronizeView view = (ISynchronizeView)activePage.showView(ISynchronizeView.VIEW_ID); + IPage page = ((SynchronizeView)view).getPage(participant); + if (page instanceof SubscriberParticipantPage) { + SubscriberParticipantPage subscriberPage = (SubscriberParticipantPage)page; + return subscriberPage; + } + } catch (PartInitException e) { + throw new AssertionFailedError("Cannot show sync view in active page"); + } + throw new AssertionFailedError("The page for " + subscriber.getName() + " could not be retrieved"); + } + + private void assertMatchingTrees(IDiffElement parent, TreeItem[] items, IDiffElement[] children) { + if ((items == null || items.length == 0) && (children == null || children.length == 0)) { + // No children in either case so just return + return; + } + if (items == null || children == null || items.length != children.length) { + throw new AssertionFailedError("The number of children of " + parent.getName() + " is " + + (children == null ? 0: children.length) + " but the view has " + + (items == null ? 0 : items.length)); + } + for (IDiffElement element : children) { + TreeItem foundItem = null; + for (TreeItem item : items) { + if (item.getData() == element) { + foundItem = item; + break; + } + } + if (foundItem == null) { + throw new AssertionFailedError("Element" + element.getName() + " is in the model but not in the view"); + } else { + assertMatchingTrees(element, foundItem.getItems(), ((IDiffContainer)element).getChildren()); + } + } + + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/AllBenchmarkTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/AllBenchmarkTests.java index a95e8edae..59f4c5cfe 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/AllBenchmarkTests.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/AllBenchmarkTests.java @@ -32,7 +32,7 @@ public class AllBenchmarkTests extends EclipseTest { TestSuite suite = new TestSuite(); suite.addTest(WorkflowTests.suite()); suite.addTest(SyncTests.suite()); - // TODO: Enable decorators? + // TODO: Enable decorators? return new CVSTestSetup(suite); } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTest.java index e8fd6b18a..ebb4434da 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTest.java @@ -43,9 +43,9 @@ import org.eclipse.ui.handlers.IHandlerService; public abstract class BenchmarkTest extends EclipseTest { private HashMap<String, PerformanceMeter> groups; - private PerformanceMeter currentMeter; + private PerformanceMeter currentMeter; - protected BenchmarkTest() { + protected BenchmarkTest() { } protected BenchmarkTest(String name) { @@ -63,30 +63,30 @@ public abstract class BenchmarkTest extends EclipseTest { return project; } - /** - * @param string - */ - protected void startTask(String string) { - // TODO Auto-generated method stub - - } - /** - * - */ + * @param string + */ + protected void startTask(String string) { + // TODO Auto-generated method stub + + } + + /** + * + */ protected void endTask() { - // TODO Auto-generated method stub - - } + // TODO Auto-generated method stub + + } - /** - * Create a set of performance meters that can be started with the - * startGroup method. - * @param performance_groups - */ + /** + * Create a set of performance meters that can be started with the + * startGroup method. + * @param performance_groups + */ protected void setupGroups(String[] performance_groups) { - setupGroups(performance_groups, null, false); - } + setupGroups(performance_groups, null, false); + } protected void setupGroups(String[] performance_groups, String globalName, boolean global) { groups = new HashMap<>(); @@ -103,127 +103,127 @@ public abstract class BenchmarkTest extends EclipseTest { // Use a meter for each group, provides fine grain results for (String suffix : performance_groups) { meter = perf.createPerformanceMeter(perf.getDefaultScenarioId(this) + suffix); - Performance.getDefault().setComment(meter, Performance.EXPLAINS_DEGRADATION_COMMENT, "The current setup for the CVS test does not provide reliable timings. Only consistent test failures over time can be considered significant."); + Performance.getDefault().setComment(meter, Performance.EXPLAINS_DEGRADATION_COMMENT, "The current setup for the CVS test does not provide reliable timings. Only consistent test failures over time can be considered significant."); groups.put(suffix, meter); // if (globalName != null) { // perf.tagAsSummary(meter, suffix, Dimension.ELAPSED_PROCESS); // } } } - } - - /** + } + + /** * Commit the performance meters that were created by setupGroups and * started and stopped using startGroup/endGroup */ - protected void commitGroups(boolean global) { + protected void commitGroups(boolean global) { for (PerformanceMeter meter : groups.values()) { - meter.commit(); - if(global) - break; - } - } - - @Override + meter.commit(); + if(global) + break; + } + } + + @Override protected void setUp() throws Exception { - super.setUp(); - setModelSync(false); - } - - @Override + super.setUp(); + setModelSync(false); + } + + @Override protected void tearDown() throws Exception { - try { - if (groups != null) { - Performance perf = Performance.getDefault(); - try { + try { + if (groups != null) { + Performance perf = Performance.getDefault(); + try { for (PerformanceMeter meter : groups.values()) { perf.assertPerformanceInRelativeBand(meter, Dimension.ELAPSED_PROCESS, -100, 20); - } - } finally { + } + } finally { for (PerformanceMeter meter : groups.values()) { - meter.dispose(); - } - } - groups = null; - } - } finally { - super.tearDown(); - } - } - - /** - * Start the meter that was created for the given key - * @param string - */ - protected void startGroup(String key) { - assertNull(currentMeter); - currentMeter = groups.get(key); - currentMeter.start(); - } - + meter.dispose(); + } + } + groups = null; + } + } finally { + super.tearDown(); + } + } + /** - * End the current meter - */ + * Start the meter that was created for the given key + * @param string + */ + protected void startGroup(String key) { + assertNull(currentMeter); + currentMeter = groups.get(key); + currentMeter.start(); + } + + /** + * End the current meter + */ protected void endGroup() { - currentMeter.stop(); - currentMeter = null; - } + currentMeter.stop(); + currentMeter = null; + } protected void disableLog() { - // TODO: + // TODO: } protected void enableLog() { - // TODO: + // TODO: } protected void syncResources(SyncInfoSource source, Subscriber subscriber, IResource[] resources) throws TeamException { - startTask("Synchronize with Repository action"); - source.refresh(subscriber, resources); - endTask(); + startTask("Synchronize with Repository action"); + source.refresh(subscriber, resources); + endTask(); } - /** - * @param resources - * @param string - * @throws CoreException - * @throws TeamException - */ - protected void syncCommitResources(SyncInfoSource source, IResource[] resources, String comment) throws TeamException, CoreException { - startTask("Synchronize outgoing changes"); - syncResources(source, source.createWorkspaceSubscriber(), resources); - endTask(); - // TODO: Commit all outgoing changes that are children of the given resource - // by extracting them from the subscriber sync set - startTask("Commit outgoing changes"); - commitResources(resources, IResource.DEPTH_INFINITE); - endTask(); - } - - /** - * @param resources - * @throws TeamException - */ - protected void syncUpdateResources(SyncInfoSource source, IResource[] resources) throws TeamException { - startTask("Synchronize incoming changes"); - syncResources(source, source.createWorkspaceSubscriber(), resources); - endTask(); - // TODO: Update all incoming changes that are children of the given resource - // by extracting them from the subscriber sync set - startTask("Update incoming changes"); - updateResources(resources, false); - endTask(); - } - - protected void openEmptyPerspective() throws WorkbenchException { - // First close any open perspectives + /** + * @param resources + * @param string + * @throws CoreException + * @throws TeamException + */ + protected void syncCommitResources(SyncInfoSource source, IResource[] resources, String comment) throws TeamException, CoreException { + startTask("Synchronize outgoing changes"); + syncResources(source, source.createWorkspaceSubscriber(), resources); + endTask(); + // TODO: Commit all outgoing changes that are children of the given resource + // by extracting them from the subscriber sync set + startTask("Commit outgoing changes"); + commitResources(resources, IResource.DEPTH_INFINITE); + endTask(); + } + + /** + * @param resources + * @throws TeamException + */ + protected void syncUpdateResources(SyncInfoSource source, IResource[] resources) throws TeamException { + startTask("Synchronize incoming changes"); + syncResources(source, source.createWorkspaceSubscriber(), resources); + endTask(); + // TODO: Update all incoming changes that are children of the given resource + // by extracting them from the subscriber sync set + startTask("Update incoming changes"); + updateResources(resources, false); + endTask(); + } + + protected void openEmptyPerspective() throws WorkbenchException { + // First close any open perspectives IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class); try { handlerService.executeCommand( "org.eclipse.ui.window.closeAllPerspectives", null); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e1) { } - // Now open our empty perspective - PlatformUI.getWorkbench().showPerspective("org.eclipse.team.tests.cvs.ui.perspective1", PlatformUI.getWorkbench().getActiveWorkbenchWindow()); - } + // Now open our empty perspective + PlatformUI.getWorkbench().showPerspective("org.eclipse.team.tests.cvs.ui.perspective1", PlatformUI.getWorkbench().getActiveWorkbenchWindow()); + } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTestSetup.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTestSetup.java index 2247ccd2c..fd6e8e311 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTestSetup.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/BenchmarkTestSetup.java @@ -32,7 +32,7 @@ public class BenchmarkTestSetup extends CVSTestSetup { // Static initializer for constants static { - try { + try { LOOP_COUNT = Integer.valueOf(System.getProperty("eclipse.cvs.loopCount", "6")).intValue(); } catch (NumberFormatException e1) { LOOP_COUNT = 1; diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/Bug152581Test.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/Bug152581Test.java index 90c89a3f5..aa9ceb720 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/Bug152581Test.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/Bug152581Test.java @@ -38,8 +38,8 @@ public class Bug152581Test extends BenchmarkTest { private static final String OLD_SYNCHRONIZE_GROUP_SUFFIX2 = "OldSynchronize2"; private static final String NEW_SYNCHRONIZE_GROUP_SUFFIX2 = "NewSynchronize2"; private static final String UPDATE_GROUP_SUFFIX2 = "Update2"; - private static final String[] PERFORMANCE_GROUPS = new String[] {OLD_SYNCHRONIZE_GROUP_SUFFIX, NEW_SYNCHRONIZE_GROUP_SUFFIX, UPDATE_GROUP_SUFFIX, OLD_SYNCHRONIZE_GROUP_SUFFIX2, NEW_SYNCHRONIZE_GROUP_SUFFIX2, UPDATE_GROUP_SUFFIX2}; - + private static final String[] PERFORMANCE_GROUPS = new String[] {OLD_SYNCHRONIZE_GROUP_SUFFIX, NEW_SYNCHRONIZE_GROUP_SUFFIX, UPDATE_GROUP_SUFFIX, OLD_SYNCHRONIZE_GROUP_SUFFIX2, NEW_SYNCHRONIZE_GROUP_SUFFIX2, UPDATE_GROUP_SUFFIX2}; + public Bug152581Test() { super(); } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/SyncTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/SyncTests.java index 6b1393fdb..77e3d43bc 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/SyncTests.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/SyncTests.java @@ -28,7 +28,7 @@ public class SyncTests extends BenchmarkTest { private static final String ADDED_GROUP_SUFFIX = "AddedFiles"; private static final String REMOVED_GROUP_SUFFIX = "RemovedFiles"; private static final String MODIFIED_GROUP_SUFFIX = "ModifiedFiles"; - private static final String[] PERFORMANCE_GROUPS = new String[] {ADDED_GROUP_SUFFIX, MODIFIED_GROUP_SUFFIX, REMOVED_GROUP_SUFFIX}; + private static final String[] PERFORMANCE_GROUPS = new String[] {ADDED_GROUP_SUFFIX, MODIFIED_GROUP_SUFFIX, REMOVED_GROUP_SUFFIX}; public SyncTests() { super(); @@ -41,10 +41,10 @@ public class SyncTests extends BenchmarkTest { public static Test suite() { return suite(SyncTests.class); } - - public void testSync100NoUI() throws Exception { - runTestSync(100, "CVS Synchronize No UI", false, new SyncInfoSource()); - } + + public void testSync100NoUI() throws Exception { + runTestSync(100, "CVS Synchronize No UI", false, new SyncInfoSource()); + } protected IProject setupOutProject() throws Exception { IProject project = createUniqueProject(BenchmarkTestSetup.SMALL_ZIP_FILE); @@ -57,9 +57,9 @@ public class SyncTests extends BenchmarkTest { * A parallel project is used to generate incoming changes. */ protected void runTestSync(int size, String globalName, boolean global, SyncInfoSource source) throws Exception { - openEmptyPerspective(); - setupGroups(PERFORMANCE_GROUPS, globalName, global); - for (int i = 0; i < BenchmarkTestSetup.LOOP_COUNT; i++) { + openEmptyPerspective(); + setupGroups(PERFORMANCE_GROUPS, globalName, global); + for (int i = 0; i < BenchmarkTestSetup.LOOP_COUNT; i++) { final SequenceGenerator gen = new SequenceGenerator(); // setup out project then move it out of the way @@ -90,7 +90,7 @@ public class SyncTests extends BenchmarkTest { syncCommitResources(source, new IResource[] { outProject }, ""); syncUpdateResources(source, new IResource[] { inProject }); endGroup(); - } - commitGroups(global); + } + commitGroups(global); } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/WorkflowTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/WorkflowTests.java index 1959a54d5..f236a8212 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/WorkflowTests.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/benchmark/WorkflowTests.java @@ -30,24 +30,24 @@ public class WorkflowTests extends BenchmarkTest { private int FILE_SIZE_MEAN = 16384; private int FILE_SIZE_VARIANCE = 12288; private int PROB_BINARY = 5; - private static final String SHARE_PROJECT = "Share"; - private static final String CHECKOUT_PROJECT = "Checkout"; - private static final String COMMIT1 = "Commit1"; - private static final String COMMIT2 = "Commit2"; - private static final String COMMIT3 = "Commit3"; - private static final String COMMIT4 = "Commit4"; - private static final String UPDATE1 = "Update1"; - private static final String UPDATE2 = "Update2"; - private static final String UPDATE3 = "Update3"; - private static final String UPDATE4 = "Update4"; - private static final String REPLACE1 = "Replace1"; - private static final String REPLACE2 = "Replace2"; - private static final String REPLACE3 = "Replace3"; - private static final String TAG1 = "Tag1"; - private static final String[] PERFORMANCE_GROUPS = new String[] { - SHARE_PROJECT, CHECKOUT_PROJECT, COMMIT1, COMMIT2, COMMIT3, COMMIT4, - UPDATE1, UPDATE2, UPDATE3, UPDATE4, REPLACE1, REPLACE2, REPLACE3, TAG1 - }; + private static final String SHARE_PROJECT = "Share"; + private static final String CHECKOUT_PROJECT = "Checkout"; + private static final String COMMIT1 = "Commit1"; + private static final String COMMIT2 = "Commit2"; + private static final String COMMIT3 = "Commit3"; + private static final String COMMIT4 = "Commit4"; + private static final String UPDATE1 = "Update1"; + private static final String UPDATE2 = "Update2"; + private static final String UPDATE3 = "Update3"; + private static final String UPDATE4 = "Update4"; + private static final String REPLACE1 = "Replace1"; + private static final String REPLACE2 = "Replace2"; + private static final String REPLACE3 = "Replace3"; + private static final String TAG1 = "Tag1"; + private static final String[] PERFORMANCE_GROUPS = new String[] { + SHARE_PROJECT, CHECKOUT_PROJECT, COMMIT1, COMMIT2, COMMIT3, COMMIT4, + UPDATE1, UPDATE2, UPDATE3, UPDATE4, REPLACE1, REPLACE2, REPLACE3, TAG1 + }; public WorkflowTests() { super(); @@ -60,29 +60,29 @@ public class WorkflowTests extends BenchmarkTest { public static Test suite() { return suite(WorkflowTests.class); } - - public void testBigWorkflowNoUI() throws Exception { - runWorkflowTests("testBigWithNoUI", BenchmarkTestSetup.BIG_ZIP_FILE, "CVS Workflow No UI", BenchmarkTestSetup.LOOP_COUNT, false, new SyncInfoSource()); - } - protected void waitForBuild() { - super.waitForBuild(); - // Ensure that we can obtrain the worksapce lock before continuing - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - try { - Job.getJobManager().beginRule(root, null); - } finally { - Job.getJobManager().endRule(root); - } - } - + public void testBigWorkflowNoUI() throws Exception { + runWorkflowTests("testBigWithNoUI", BenchmarkTestSetup.BIG_ZIP_FILE, "CVS Workflow No UI", BenchmarkTestSetup.LOOP_COUNT, false, new SyncInfoSource()); + } + + protected void waitForBuild() { + super.waitForBuild(); + // Ensure that we can obtrain the worksapce lock before continuing + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + try { + Job.getJobManager().beginRule(root, null); + } finally { + Job.getJobManager().endRule(root); + } + } + /** * Runs a series of incoming and outgoing workflow-related tests. */ protected void runWorkflowTests(String name, File initialContents, String globalName, int loopCount, boolean global, SyncInfoSource source) throws Exception { - openEmptyPerspective(); - setupGroups(PERFORMANCE_GROUPS, globalName, global); - for (int i = 0; i < loopCount; i++) { + openEmptyPerspective(); + setupGroups(PERFORMANCE_GROUPS, globalName, global); + for (int i = 0; i < loopCount; i++) { final SequenceGenerator gen = new SequenceGenerator(); IProject outProject = createAndImportProject(name, initialContents); @@ -183,7 +183,7 @@ public class WorkflowTests extends BenchmarkTest { startGroup(REPLACE3); replace(new IResource[] { inProject }, null, true); endGroup(); - } - commitGroups(global); + } + commitGroups(global); } } |