Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 361926 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoryRoot.java (-6 / +7 lines)
Lines 451-464 Link Here
451
	}
451
	}
452
	
452
	
453
	/*
453
	/*
454
	 * Return the cache key (path) for the given folder path.
454
	 * Return the cache key (path) for the given folder path. For root projects
455
	 * This has been changed to cache the tags directly 
455
	 * it returns the folder the project is mapped to as the tag source (see
456
	 * with the folder to better support non-root projects.
456
	 * TagSource). For non-root projects it returns only the first segment of
457
	 * However, resources in the local workspace use the folder
457
	 * the path because for the time being tag lists are kept for the remote
458
	 * the project is mapped to as the tag source (see TagSource)
458
	 * ancestors of the resource that is a direct child of the remote root (see
459
	 * javadoc for addTags).
459
	 */
460
	 */
460
	private String getCachePathFor(String remotePath) {
461
	private String getCachePathFor(String remotePath) {
461
		return remotePath;
462
		return new Path(null, remotePath).segment(0);
462
	}
463
	}
463
	
464
	
464
	/**
465
	/**
(-)a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/AllUITests.java (+1 lines)
Lines 32-37 Link Here
32
		suite.addTest(CompareOperationTests.suite());
32
		suite.addTest(CompareOperationTests.suite());
33
		suite.addTest(MiscOperationsTests.suite());
33
		suite.addTest(MiscOperationsTests.suite());
34
		suite.addTest(ProjectSetImporterTests.suite());
34
		suite.addTest(ProjectSetImporterTests.suite());
35
		suite.addTest(RepositoriesViewTests.suite());
35
		suite.addTest(EditorTests.suite());
36
		suite.addTest(EditorTests.suite());
36
		suite.addTest(PatchWizardRadioButtonGroupTests.suite());
37
		suite.addTest(PatchWizardRadioButtonGroupTests.suite());
37
		suite.addTest(CVSProjectSetImportTest.suite());
38
		suite.addTest(CVSProjectSetImportTest.suite());
(-)a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java (+165 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.team.tests.ccvs.ui;
12
13
import junit.framework.Test;
14
import junit.framework.TestSuite;
15
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.team.core.TeamException;
20
import org.eclipse.team.internal.ccvs.core.CVSTag;
21
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
22
import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
23
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
24
import org.eclipse.team.internal.ccvs.ui.model.AllRootsElement;
25
import org.eclipse.team.internal.ccvs.ui.model.BranchCategory;
26
import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
27
import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider;
28
import org.eclipse.team.internal.ccvs.ui.model.RemoteModule;
29
import org.eclipse.team.internal.ccvs.ui.model.VersionCategory;
30
import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
31
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
32
import org.eclipse.team.tests.ccvs.core.EclipseTest;
33
34
public class RepositoriesViewTests extends EclipseTest {
35
36
	public RepositoriesViewTests(String testName) {
37
		super(testName);
38
	}
39
40
	protected void setUp() throws Exception {
41
		super.setUp();
42
		// clear repository root cache
43
		RepositoryRoot repositoryRoot = getRepositoryRoot();
44
		String remotePaths[] = repositoryRoot.getKnownRemotePaths();
45
		for (int i = 0; i < remotePaths.length; i++) {
46
			repositoryRoot.removeTags(remotePaths[i],
47
					repositoryRoot.getAllKnownTags(remotePaths[i]));
48
		}
49
50
	}
51
52
	private RepositoryRoot getRepositoryRoot() {
53
		RemoteContentProvider rcp = new RemoteContentProvider();
54
		AllRootsElement are = new AllRootsElement();
55
		Object[] repositoryRoots = rcp.getElements(are);
56
		for (int i = 0; i < repositoryRoots.length; i++) {
57
			RepositoryRoot repositoryRoot = (RepositoryRoot) repositoryRoots[i];
58
			if (getRepository().equals(repositoryRoot.getRoot())) {
59
				return repositoryRoot;
60
			}
61
		}
62
		fail();
63
		return null;
64
	}
65
66
	public static Test suite() {
67
		String testName = System.getProperty("eclipse.cvs.testName");
68
		if (testName == null) {
69
			TestSuite suite = new TestSuite(RepositoriesViewTests.class);
70
			return new CVSTestSetup(suite);
71
		} else {
72
			return new CVSTestSetup(new RepositoriesViewTests(testName));
73
		}
74
	}
75
76
	public void testBranchSubmoduleChildren() throws TeamException,
77
			CoreException {
78
79
		String time = Long.toString(System.currentTimeMillis());
80
		String moduleName = "TestBranchSubmoduleChildrenTestModule" + time;
81
		String branchName = "TestBranchSubmoduleChildrenBranch" + time;
82
		String versionName = "Root_" + branchName;
83
84
		// create project
85
		IProject project = getUniqueTestProject("TestBranchSubmoduleChildrenProject");
86
		buildResources(project, new String[] { "file1.txt" }, true);
87
		// share project under module
88
		shareProject(getRepository(), project,
89
				moduleName + "/" + project.getName(), DEFAULT_MONITOR);
90
		assertValidCheckout(project);
91
92
		// make some changes
93
		addResources(project, new String[] { "folder1/c.txt" }, false);
94
95
		// make branch
96
		CVSTag version = new CVSTag(versionName, CVSTag.VERSION);
97
		CVSTag branch = new CVSTag(branchName, CVSTag.BRANCH);
98
99
		makeBranch(new IResource[] { project }, version, branch, true);
100
		commitProject(project);
101
102
		// refresh branches
103
		CVSUIPlugin
104
				.getPlugin()
105
				.getRepositoryManager()
106
				.refreshDefinedTags(
107
						getRepository().getRemoteFolder(moduleName, null),
108
						true, true, DEFAULT_MONITOR);
109
110
		// check if module is the only branch child
111
		RemoteContentProvider rcp = new RemoteContentProvider();
112
		Object[] categories = rcp.getChildren(getRepositoryRoot());
113
		assertEquals(4, categories.length);
114
		assertTrue(categories[1] instanceof BranchCategory);
115
		Object[] branches = rcp.getChildren(categories[1]);
116
		assertEquals(1, branches.length);
117
		assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
118
				.getName());
119
		Object[] modules = rcp.getChildren(branches[0]);
120
		assertEquals(1, modules.length);
121
		assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
122
	}
123
124
	public void testTagSubmoduleChildren() throws TeamException, CoreException {
125
126
		String time = Long.toString(System.currentTimeMillis());
127
		String moduleName = "TestTagSubmoduleChildrenTestModule" + time;
128
		String versionName = "TestTagSubmoduleChildrenBranch" + time;
129
130
		// create project
131
		IProject project = getUniqueTestProject("TestTagSubmoduleChildrenProject");
132
		buildResources(project, new String[] { "file1.txt" }, true);
133
		// share project under module
134
		shareProject(getRepository(), project,
135
				moduleName + "/" + project.getName(), DEFAULT_MONITOR);
136
		assertValidCheckout(project);
137
138
		// tag project
139
		CVSTag tag = new CVSTag(versionName, CVSTag.VERSION);
140
141
		tagProject(project, tag, true);
142
143
		RemoteContentProvider rcp = new RemoteContentProvider();
144
		Object[] categories = rcp.getChildren(getRepositoryRoot());
145
		assertEquals(4, categories.length);
146
147
		// check if version exists for module
148
		assertTrue(categories[2] instanceof VersionCategory);
149
		Object[] modules = rcp.getChildren(categories[2]);
150
		boolean moduleExists = false;
151
		for (int i = 0; i < modules.length; i++) {
152
			if (modules[i] instanceof RemoteModule
153
					&& ((RemoteModule) (modules[i])).getCVSResource().getName()
154
							.equals(moduleName)) {
155
				moduleExists = true;
156
				Object folders[] = rcp.getChildren(modules[i]);
157
				assertEquals(1, folders.length);
158
				assertEquals(versionName, ((RemoteFolder) folders[0]).getTag()
159
						.getName());
160
			}
161
		}
162
		assertTrue(moduleExists);
163
	}
164
165
}

Return to bug 361926