diff options
author | Malgorzata Janczarska | 2012-03-13 13:51:46 +0000 |
---|---|---|
committer | Malgorzata Janczarska | 2012-03-13 13:51:46 +0000 |
commit | 78b06e932f107395de4ac4bad9a6113a78639766 (patch) | |
tree | 0de82b0acae224f540305bf67e1d09dc188ac040 /tests/org.eclipse.team.tests.cvs.core | |
parent | 9dc5b700ad5d2dc49a8ff00037ec8f5763cdc2b4 (diff) | |
download | eclipse.platform.team-78b06e932f107395de4ac4bad9a6113a78639766.tar.gz eclipse.platform.team-78b06e932f107395de4ac4bad9a6113a78639766.tar.xz eclipse.platform.team-78b06e932f107395de4ac4bad9a6113a78639766.zip |
CVS cache does not contain precise information about tagsv20120313-1351
Bug: 372862
Change-Id: I80044e6df28f42c3973b7d16d5d7c92f54bcd8cb
Diffstat (limited to 'tests/org.eclipse.team.tests.cvs.core')
3 files changed, 502 insertions, 23 deletions
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java index 90febe083..088227203 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/AllTestsProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -34,6 +34,7 @@ public class AllTestsProvider extends EclipseTest { suite.addTest(WatchEditTest.suite()); suite.addTest(LinkResourcesTest.suite()); suite.addTest(IsModifiedTests.suite()); + suite.addTest(RepositoryRootTest.suite()); return new CVSTestSetup(suite); } } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RepositoryRootTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RepositoryRootTest.java new file mode 100644 index 000000000..98c483863 --- /dev/null +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/RepositoryRootTest.java @@ -0,0 +1,397 @@ +/******************************************************************************* + * Copyright (c) 2012 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.team.tests.ccvs.core.provider; + +import java.util.Arrays; +import java.util.List; + +import junit.framework.Test; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.team.core.TeamException; +import org.eclipse.team.internal.ccvs.core.CVSException; +import org.eclipse.team.internal.ccvs.core.CVSTag; +import org.eclipse.team.internal.ccvs.core.ICVSFolder; +import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; +import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; +import org.eclipse.team.internal.ccvs.ui.repo.RepositoryManager; +import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot; +import org.eclipse.team.tests.ccvs.core.EclipseTest; + +public class RepositoryRootTest extends EclipseTest { + + private RepositoryRoot repositoryRoot; + private RepositoryManager repositoryManager; + + protected void setUp() throws Exception { + super.setUp(); + repositoryManager = CVSUIPlugin.getPlugin().getRepositoryManager(); + repositoryRoot = repositoryManager + .getRepositoryRootFor(getRepository()); + clearRepositoryRootCache(); + } + + public static Test suite() { + return suite(RepositoryRootTest.class); + } + + private void clearRepositoryRootCache() { + String remotePaths[] = repositoryRoot.getKnownRemotePaths(); + for (int i = 0; i < remotePaths.length; i++) { + repositoryRoot.removeTags(remotePaths[i], + repositoryRoot.getAllKnownTags(remotePaths[i])); + } + assertEquals("Repository cache was not cleaned.", 0, + repositoryRoot.getAllKnownTags().length); + } + + private CVSTag[] refreshTags(IProject project) throws TeamException { + return refreshTags(CVSWorkspaceRoot.getCVSFolderFor(project)); + } + + private CVSTag[] refreshTags(ICVSFolder folder) throws TeamException { + return repositoryManager.refreshDefinedTags(folder, true, true, + DEFAULT_MONITOR); + } + + private IProject createProject(String baseName, String repoPrefix) + throws CoreException { + // create project + IProject project = getUniqueTestProject(baseName); + // share project under module + shareProject(getRepository(), project, + repoPrefix == null ? project.getName() + : (repoPrefix + "/" + project.getName()), + DEFAULT_MONITOR); + assertValidCheckout(project); + // add some files + addResources(project, new String[] { "file1.txt" }, true); + return project; + } + + private void assertTags(List knownTags, CVSTag[] tagsToHave, + CVSTag[] tagsNotToHave) { + for (int i = 0; i < tagsToHave.length; i++) { + assertTrue("Missing tag " + tagsToHave[i].getName(), + knownTags.contains(tagsToHave[i])); + } + for (int i = 0; i < tagsNotToHave.length; i++) { + assertFalse("Extraneous tag " + tagsNotToHave[i].getName(), + knownTags.contains(tagsNotToHave[i])); + } + } + + private void assertProjectTags(CVSCacheTestData data) throws CVSException { + // Root should contain all known tags + List knownTags = Arrays.asList(repositoryRoot.getAllKnownTags()); + assertTags(knownTags, + new CVSTag[] { data.branch_1, data.branch_2, data.branch_3, + data.version_1, data.version_2, data.version_3 }, + new CVSTag[0]); + + // Project_1 should contain Branch_1 and Branch_2 + knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(data.project1))); + assertTags(knownTags, new CVSTag[] { data.branch_1, data.branch_2, + data.version_1, data.version_2 }, new CVSTag[] { data.branch_3, + data.version_3 }); + // Project_2 should contain Branch_1 and Branch_3 + knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(data.project2))); + assertTags(knownTags, new CVSTag[] { data.branch_1, data.branch_3, + data.version_1, data.version_3 }, new CVSTag[] { data.branch_2, + data.version_2 }); + } + + private class CVSCacheTestData { + IProject project1; // tagged with Branch_1 and Branch_2 + IProject project2; // tagged with Branch_1 and Branch_3 + CVSTag branch_1; + CVSTag branch_2; + CVSTag branch_3; + CVSTag version_1; + CVSTag version_2; + CVSTag version_3; + + private void init(String project1Path, String project2Path) + throws CoreException { + project1 = createProject("Project_1", project1Path); + project2 = createProject("Project_2", project2Path); + branch_1 = new CVSTag("Branch_1" + System.currentTimeMillis(), + CVSTag.BRANCH); + version_1 = new CVSTag("Root_" + branch_1.getName(), CVSTag.VERSION); + branch_2 = new CVSTag("Branch_2" + System.currentTimeMillis(), + CVSTag.BRANCH); + version_2 = new CVSTag("Root_" + branch_2.getName(), CVSTag.VERSION); + branch_3 = new CVSTag("Branch_3" + System.currentTimeMillis(), + CVSTag.BRANCH); + version_3 = new CVSTag("Root_" + branch_3.getName(), CVSTag.VERSION); + + makeBranch(new IResource[] { project1, project2 }, version_1, + branch_1, true); + makeBranch(new IResource[] { project1 }, version_2, branch_2, true); + makeBranch(new IResource[] { project2 }, version_3, branch_3, true); + } + + public CVSCacheTestData(String project1Path, String project2Path) + throws CoreException { + init(project1Path, project2Path); + } + } + + public void testProjectsAtRoot() throws CoreException { + CVSCacheTestData data = new CVSCacheTestData(null, null); + + // verify that tags are correct after creating branches + assertProjectTags(data); + + clearRepositoryRootCache(); + refreshTags(data.project1); + refreshTags(data.project2); + assertProjectTags(data); + } + + public void testProjectsInSubmodule() throws CoreException { + String submodule = "Submodule_1" + System.currentTimeMillis(); + CVSCacheTestData data = new CVSCacheTestData(submodule, submodule); + ICVSFolder submoduleFolder = repositoryRoot.getRemoteFolder(submodule, + null, getMonitor()); + + // verify that tags are correct after creating branches + assertProjectTags(data); + + clearRepositoryRootCache(); + refreshTags(data.project1); + refreshTags(data.project2); + assertProjectTags(data); + // verify that parent module has tags from both projects + List knownTags = Arrays.asList(repositoryManager + .getKnownTags(submoduleFolder)); + assertTags(knownTags, + new CVSTag[] { data.branch_1, data.branch_2, data.branch_3, + data.version_1, data.version_2, data.version_3 }, + new CVSTag[0]); + + clearRepositoryRootCache(); + refreshTags(submoduleFolder); + assertProjectTags(data); + // verify that parent module has tags from both projects + knownTags = Arrays.asList(repositoryManager + .getKnownTags(submoduleFolder)); + assertTags(knownTags, + new CVSTag[] { data.branch_1, data.branch_2, data.branch_3, + data.version_1, data.version_2, data.version_3 }, + new CVSTag[0]); + } + + public void testProjectsInTwoSubmodules() throws CoreException { + String submodule1 = "Submodule_1" + System.currentTimeMillis(); + String submodule2 = "Submodule_2" + System.currentTimeMillis(); + CVSCacheTestData data = new CVSCacheTestData(submodule1, submodule2); + ICVSFolder submoduleFolder1 = repositoryRoot.getRemoteFolder( + submodule1, null, getMonitor()); + ICVSFolder submoduleFolder2 = repositoryRoot.getRemoteFolder( + submodule2, null, getMonitor()); + + // verify that tags are correct after creating branches + assertProjectTags(data); + + clearRepositoryRootCache(); + refreshTags(data.project1); + refreshTags(data.project2); + assertProjectTags(data); + // verify that parent modules have tags from subordinate project, but + // not the other project + List knownTags = Arrays.asList(repositoryManager + .getKnownTags(submoduleFolder1)); + assertTags(knownTags, new CVSTag[] { data.branch_1, data.branch_2, + data.version_1, data.version_2 }, new CVSTag[] { data.branch_3, + data.version_3 }); + knownTags = Arrays.asList(repositoryManager + .getKnownTags(submoduleFolder2)); + assertTags(knownTags, new CVSTag[] { data.branch_1, data.branch_3, + data.version_1, data.version_3 }, new CVSTag[] { data.branch_2, + data.version_2 }); + // clear the cache, refresh it only one for submodule and verify if tags + // are correct + clearRepositoryRootCache(); + refreshTags(submoduleFolder1); + + // verify that correct tags where added to this submodule + knownTags = Arrays.asList(repositoryManager + .getKnownTags(submoduleFolder1)); + assertTags(knownTags, new CVSTag[] { data.branch_1, data.branch_2, + data.version_1, data.version_2 }, new CVSTag[] { data.branch_3, + data.version_3 }); + // verify if only tags from the first submodule are known + knownTags = Arrays.asList(repositoryRoot.getAllKnownTags()); + assertTags(knownTags, new CVSTag[] { data.branch_1, data.branch_2, + data.version_1, data.version_2 }, new CVSTag[] { data.branch_3, + data.version_3 }); + + refreshTags(submoduleFolder2); + // verify tags for the second submodule + knownTags = Arrays.asList(repositoryManager + .getKnownTags(submoduleFolder2)); + assertTags(knownTags, new CVSTag[] { data.branch_1, data.branch_3, + data.version_1, data.version_3 }, new CVSTag[] { data.branch_2, + data.version_2 }); + // verify if tags are merged correctly + assertProjectTags(data); + } + + public void testNestedProjects() throws CoreException { + IProject superProject = createProject("SuperProject", (String) null); + CVSTag superProjectBranch = new CVSTag("Branch_" + + superProject.getName(), CVSTag.BRANCH); + CVSTag superProjectVersion = new CVSTag("Root_" + + superProjectBranch.getName(), CVSTag.VERSION); + makeBranch(new IResource[] { superProject }, superProjectVersion, + superProjectBranch, true); + // subProject1 and subProject2 are nested in superProject + // each of them has its own tags + IProject subProject1 = createProject("SubProject_1", + superProject.getName()); + CVSTag subProject1Branch = new CVSTag( + "Branch_" + subProject1.getName(), CVSTag.BRANCH); + CVSTag subProject1Version = new CVSTag("Root_" + + subProject1Branch.getName(), CVSTag.VERSION); + makeBranch(new IResource[] { subProject1 }, subProject1Version, + subProject1Branch, true); + IProject subProject2 = createProject("SubProject_2", + superProject.getName()); + CVSTag subProject2Branch = new CVSTag( + "Branch_" + subProject2.getName(), CVSTag.BRANCH); + CVSTag subProject2Version = new CVSTag("Root_" + + subProject2Branch.getName(), CVSTag.VERSION); + makeBranch(new IResource[] { subProject2 }, subProject2Version, + subProject2Branch, true); + // check if subProjects have tags from superProject but not tags from + // each other, check if superProject has tags from all subProjects + List knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(superProject))); + assertTags(knownTags, new CVSTag[] { superProjectBranch, + superProjectVersion, subProject1Branch, subProject1Version, + subProject2Branch, subProject2Version }, new CVSTag[0]); + knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(subProject1))); + assertTags(knownTags, new CVSTag[] { superProjectBranch, + superProjectVersion, subProject1Branch, subProject1Version }, + new CVSTag[] { subProject2Branch, subProject2Version }); + knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(subProject2))); + assertTags(knownTags, new CVSTag[] { superProjectBranch, + superProjectVersion, subProject2Branch, subProject2Version }, + new CVSTag[] { subProject1Branch, subProject1Version }); + // remove tag from one of the subProjects, check if it was not removed + // from the other subProject, check if superProject still has this tag + repositoryManager.removeTags( + CVSWorkspaceRoot.getCVSFolderFor(subProject1), new CVSTag[] { + superProjectBranch, superProjectVersion }); + knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(superProject))); + assertTags(knownTags, new CVSTag[] { superProjectBranch, + superProjectVersion, subProject1Branch, subProject1Version, + subProject2Branch, subProject2Version }, new CVSTag[0]); + knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(subProject1))); + assertTags(knownTags, new CVSTag[] { subProject1Branch, + subProject1Version }, new CVSTag[] { subProject2Branch, + subProject2Version }); + knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(subProject2))); + assertTags(knownTags, new CVSTag[] { superProjectBranch, + superProjectVersion, subProject2Branch, subProject2Version }, + new CVSTag[] { subProject1Branch, subProject1Version }); + } + + public void testTagsForSubfolder() throws TeamException, CoreException { + IProject project = createProject("Project_1", (String) null); + String folderName = "testFolder"; + addResources(project, new String[] { folderName + "/", + folderName + "/testFile.txt" }, true); + IFolder folder = project.getFolder(folderName); + CVSTag branch1 = new CVSTag("Branch_1" + System.currentTimeMillis(), + CVSTag.BRANCH); + CVSTag version1 = new CVSTag("Root_" + branch1.getName(), + CVSTag.VERSION); + makeBranch(new IResource[] { project }, version1, branch1, true); + // verify if project's tags are known for subfolder + ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor(folder); + List knownTags = Arrays.asList(repositoryManager + .getKnownTags(cvsFolder)); + assertTags(knownTags, new CVSTag[] { branch1, version1 }, new CVSTag[0]); + // verify if removing tags from subfolder is correctly handled + repositoryManager.removeTags(cvsFolder, new CVSTag[] { branch1, + version1 }); + knownTags = Arrays.asList(repositoryManager.getKnownTags(cvsFolder)); + assertTags(knownTags, new CVSTag[0], new CVSTag[] { branch1, version1 }); + // verify if after refreshing tags are back for both project and its + // subfolder + refreshTags(cvsFolder); + knownTags = Arrays.asList(repositoryManager.getKnownTags(cvsFolder)); + assertTags(knownTags, new CVSTag[] { branch1, version1 }, new CVSTag[0]); + knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(project))); + assertTags(knownTags, new CVSTag[] { branch1, version1 }, new CVSTag[0]); + } + + public void testRefreshProjectUsingAutoRefreshFile() throws CoreException { + IProject project = createProject("Project_1", (String) null); + String autoRefreshFileName = "sampleAuthoRefresh.txt"; + String notAutoRefreshFileName = "notAutoRefresh.txt"; + addResources(project, new String[] { autoRefreshFileName, + notAutoRefreshFileName }, true); + IFile autoRefreshFile = project.getFile(autoRefreshFileName); + IFile notAutoRefreshFile = project.getFile(notAutoRefreshFileName); + repositoryManager.setAutoRefreshFiles( + CVSWorkspaceRoot.getCVSFolderFor(project), + new String[] { CVSWorkspaceRoot.getCVSResourceFor( + autoRefreshFile).getRepositoryRelativePath() }); + CVSTag branch1 = new CVSTag("Branch_1" + System.currentTimeMillis(), + CVSTag.BRANCH); + CVSTag version1 = new CVSTag("Root_" + branch1.getName(), + CVSTag.VERSION); + // branch the auto refresh file + makeBranch(new IResource[] { autoRefreshFile }, version1, branch1, true); + CVSTag branch2 = new CVSTag("Branch_2" + System.currentTimeMillis(), + CVSTag.BRANCH); + CVSTag version2 = new CVSTag("Root_" + branch2.getName(), + CVSTag.VERSION); + // branch not auto refresh file + makeBranch(new IResource[] { notAutoRefreshFile }, version2, branch2, + true); + + clearRepositoryRootCache(); + refreshTags(project); + + // cache should contain branches from auto refresh file, but no branches + // from other files + List knownTags = Arrays.asList(repositoryManager + .getKnownTags(CVSWorkspaceRoot.getCVSFolderFor(project))); + assertTags(knownTags, new CVSTag[] { branch1, version1 }, new CVSTag[] { + branch2, version2 }); + } + + public void testProjectWithNoTags() throws CoreException { + IProject project = createProject("Project_1", (String) null); + CVSTag knownTags[] = repositoryManager.getKnownTags(CVSWorkspaceRoot + .getCVSFolderFor(project)); + assertEquals(0, knownTags.length); + knownTags = refreshTags(project); + assertEquals(0, knownTags.length); + } + +} diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java index 3e9528d42..a710e1d8a 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java @@ -1,5 +1,5 @@ /*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
+ * Copyright (c) 2011, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,7 +20,6 @@ import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.model.AllRootsElement;
import org.eclipse.team.internal.ccvs.ui.model.BranchCategory;
import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
@@ -87,23 +86,14 @@ public class RepositoriesViewTests extends EclipseTest { moduleName + "/" + project.getName(), DEFAULT_MONITOR);
assertValidCheckout(project);
- // make some changes
- addResources(project, new String[] { "folder1/c.txt" }, false);
+ // add some files
+ addResources(project, new String[] { "file1.txt" }, true);
// make branch
CVSTag version = new CVSTag(versionName, CVSTag.VERSION);
CVSTag branch = new CVSTag(branchName, CVSTag.BRANCH);
makeBranch(new IResource[] { project }, version, branch, true);
- commitProject(project);
-
- // refresh branches
- CVSUIPlugin
- .getPlugin()
- .getRepositoryManager()
- .refreshDefinedTags(
- getRepository().getRemoteFolder(moduleName, null),
- true, true, DEFAULT_MONITOR);
// check if module is the only branch child
RemoteContentProvider rcp = new RemoteContentProvider();
@@ -117,6 +107,15 @@ public class RepositoriesViewTests extends EclipseTest { Object[] modules = rcp.getChildren(branches[0]);
assertEquals(1, modules.length);
assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
+
+ // check if after refresh module is still the only branch child
+ branches = rcp.getChildren(categories[1]);
+ assertEquals(1, branches.length);
+ assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
+ .getName());
+ modules = rcp.getChildren(branches[0]);
+ assertEquals(1, modules.length);
+ assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
}
public void testTagSubmoduleChildren() throws TeamException, CoreException {
@@ -140,15 +139,6 @@ public class RepositoriesViewTests extends EclipseTest { tagProject(project, tag, true);
- // refresh branches for module
- // TODO Remove when Bug 372862 is committed, adding tag for submodule
- // should automatically add it to module
- CVSUIPlugin
- .getPlugin()
- .getRepositoryManager()
- .refreshDefinedTags(
- getRepository().getRemoteFolder(moduleName, null),
- true, true, DEFAULT_MONITOR);
RemoteContentProvider rcp = new RemoteContentProvider();
Object[] categories = rcp.getChildren(getRepositoryRoot());
@@ -170,4 +160,95 @@ public class RepositoriesViewTests extends EclipseTest { }
fail(moduleName + " not found");
}
+
+ public void testTagsOnDifferentLevels() throws CoreException {
+ String time = Long.toString(System.currentTimeMillis());
+ String firstModule = "Module_1" + time;
+ String secondModule = "Module_2" + time;
+ String secondModulePath = firstModule + "/" + secondModule;
+ // Create repository data
+ // Module_1/Project_1
+ IProject project1 = getUniqueTestProject("Project_1");
+ shareProject(getRepository(), project1,
+ firstModule + "/" + project1.getName(), DEFAULT_MONITOR);
+ // Module_1/Module_2/Project_2
+ IProject project2 = getUniqueTestProject("Project_2");
+ shareProject(getRepository(), project2, secondModulePath + "/"
+ + project2.getName(), DEFAULT_MONITOR);
+ // Module_1/Module_2/Project_3
+ IProject project3 = getUniqueTestProject("Project_3");
+ shareProject(getRepository(), project3, secondModulePath + "/"
+ + project3.getName(), DEFAULT_MONITOR);
+ // Module_1/Project_4
+ IProject project4 = getUniqueTestProject("Project_4");
+ shareProject(getRepository(), project4,
+ firstModule + "/" + project4.getName(), DEFAULT_MONITOR);
+
+ // Create branches
+ String branch1 = "Branch_1" + time;
+ String version1 = "Root_" + branch1;
+ String branch2 = "Branch_2" + time;
+ String version2 = "Root_" + branch2;
+
+ // Tag projects:
+ // Module_1/Project_1 -> [Branch_1][Branch_2]
+ // Module_1/Module_2/Project_2 -> [Branch_1][Branch_2]
+ // Module_1/Module_2/Project_3 -> [Branch_2]
+ // Module_1/Project_4 -> [Branch_4]
+ makeBranch(new IResource[] { project1, project2 }, new CVSTag(version1,
+ CVSTag.VERSION), new CVSTag(branch1, CVSTag.BRANCH), true);
+ makeBranch(new IResource[] { project1, project2, project2, project4 },
+ new CVSTag(version2, CVSTag.VERSION), new CVSTag(branch2,
+ CVSTag.BRANCH), true);
+
+ // verify if tree structure is built from cache
+ RemoteContentProvider rcp = new RemoteContentProvider();
+ Object[] categories = rcp.getChildren(getRepositoryRoot());
+ assertEquals(4, categories.length);
+ assertTrue(categories[1] instanceof BranchCategory);
+ Object[] branches = rcp.getChildren(categories[1]);
+ assertEquals(2, branches.length); // should be [Branch_1] and [Branch_2]
+ CVSTagElement branch1Element;
+ CVSTagElement branch2Element;
+ if (((CVSTagElement) branches[0]).getTag().getName().equals(branch1)) {
+ branch1Element = (CVSTagElement) branches[0];
+ branch2Element = (CVSTagElement) branches[1];
+ } else {
+ branch1Element = (CVSTagElement) branches[1];
+ branch2Element = (CVSTagElement) branches[0];
+ }
+ Object[] modules = rcp.getChildren(branch1Element);
+ assertEquals(1, modules.length); // should be [Branch_1]/Module_1
+ assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
+ modules = rcp.getChildren(modules[0]);
+ // should contain:
+ // [Branch_1]/Module_1/Project_1
+ // [Branch_1]/Module_1/Module_2
+ assertEquals(2, modules.length);
+ for (int i = 0; i < modules.length; i++) {
+ if (((RemoteResource) (modules[i])).getName().equals(
+ project1.getName())) {
+ // Project_1 should have contents retrieved from CVS
+ assertTrue(rcp.hasChildren(modules[i]));
+ } else if (((RemoteResource) (modules[i])).getName().equals(
+ secondModule)) {
+ // should be only [Branch_1]/Module_1/Module_2/Project_2.
+ // [Branch_1]/Module_1/Module_2/Project_3 should NOT be on the
+ // list, it is not branched with Branch_1
+ Object[] module2Children = rcp.getChildren(modules[i]);
+ assertEquals(1, module2Children.length);
+ assertEquals(project2.getName(),
+ ((RemoteResource) module2Children[0]).getName());
+ }
+ }
+ modules = rcp.getChildren(branch2Element);
+ assertEquals(1, modules.length); // should be [Branch_2]/Module_1
+ assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
+ // should contain:
+ // [Branch_2]/Module_1/Project_1
+ // [Branch_2]/Module_1/Module_2
+ // [Branch_2]/Module_1/Project_4
+ modules = rcp.getChildren(modules[0]);
+ assertEquals(3, modules.length);
+ }
}
|