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 339990 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/team/tests/ccvs/core/cvsresources/EclipseSynchronizerTest.java (+98 lines)
Lines 11-16 Link Here
11
package org.eclipse.team.tests.ccvs.core.cvsresources;
11
package org.eclipse.team.tests.ccvs.core.cvsresources;
12
12
13
13
14
import java.util.ArrayList;
14
import java.util.Arrays;
15
import java.util.Arrays;
15
import java.util.HashSet;
16
import java.util.HashSet;
16
import java.util.Iterator;
17
import java.util.Iterator;
Lines 41-50 Link Here
41
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
42
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
42
import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
43
import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
43
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
44
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
45
import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
44
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
46
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
45
import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
47
import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo;
46
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
48
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
47
import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
49
import org.eclipse.team.internal.ccvs.core.util.SyncFileWriter;
50
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
51
import org.eclipse.team.internal.ccvs.ui.model.AllRootsElement;
52
import org.eclipse.team.internal.ccvs.ui.model.BranchCategory;
53
import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
54
import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider;
48
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
55
import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
49
import org.eclipse.team.tests.ccvs.core.EclipseTest;
56
import org.eclipse.team.tests.ccvs.core.EclipseTest;
50
57
Lines 917-920 Link Here
917
		assertTrue(!sync.getResourceSync(file21).getRevision().equals(revision));
924
		assertTrue(!sync.getResourceSync(file21).getRevision().equals(revision));
918
		
925
		
919
	}
926
	}
927
	
928
	private String moduleName;
929
	private String branchName;
930
	
931
	public void testBug339990() throws TeamException, CoreException {
932
933
		// create project
934
		IProject project = getUniqueTestProject("Bug339990Project");
935
		buildResources(project, new String[] { "file1.txt" }, true);
936
		// share project under module
937
		shareProject(getRepository(), project,
938
				moduleName + "/" + project.getName(), DEFAULT_MONITOR);
939
		assertValidCheckout(project);
940
941
		// make some changes
942
		addResources(project, new String[] { "folder1/c.txt" }, false);
943
		deleteResources(project, new String[] { "folder1/b.txt" }, false);
944
		changeResources(project, new String[] { "file1.txt" }, false);
945
946
		// make branch
947
		CVSTag version = new CVSTag("Root_" + branchName, CVSTag.VERSION);
948
		CVSTag branch = new CVSTag(branchName, CVSTag.BRANCH);
949
950
		makeBranch(new IResource[] { project }, version, branch, true);
951
		commitProject(project);
952
953
		// refresh branches
954
		CVSUIPlugin
955
				.getPlugin()
956
				.getRepositoryManager()
957
				.refreshDefinedTags(
958
						getRepository().getRemoteFolder(moduleName, null),
959
						true, true, DEFAULT_MONITOR);
960
961
		// check if module is the only branch child
962
		RemoteContentProvider rcp = new RemoteContentProvider();
963
		AllRootsElement are = new AllRootsElement();
964
		Object[] elements = rcp.getElements(are);
965
		for (int i = 0; i < elements.length; i++) {
966
			Object o = elements[i];
967
			List branchChildren = collectBranchChildren(branchName, rcp, o, 0);
968
			assertEquals(1, branchChildren.size());
969
			Iterator branchIterator = branchChildren.iterator();
970
			while (branchIterator.hasNext()) {
971
				Object module = branchIterator.next();
972
				assertTrue(module instanceof RemoteResource);
973
				assertEquals(moduleName, ((RemoteResource) module).getName());
974
			}
975
976
		}
977
	}
978
979
	private List collectBranchChildren(String branchName,
980
			RemoteContentProvider rcp, Object o, int depth) {
981
		List ret = new ArrayList();
982
		boolean branchCategory = (o instanceof BranchCategory);
983
		if (depth == 1 && !branchCategory) {
984
			return ret;
985
		}
986
		if (branchCategory) {
987
			BranchCategory b = (BranchCategory) o;
988
			Object[] branches = rcp.getChildren(b);
989
			for (int j = 0; j < branches.length; j++) {
990
				if (branches[j] instanceof CVSTagElement) {
991
					CVSTagElement el = (CVSTagElement) branches[j];
992
					if (el.getTag().getName().equals(branchName)) {
993
						Object[] modules = rcp.getChildren(el);
994
						return Arrays.asList(modules);
995
					}
996
997
				}
998
			}
999
			return ret;
1000
		}
1001
		++depth;
1002
		if (rcp.hasChildren(o)) {
1003
			Object[] children = rcp.getChildren(o);
1004
			for (int j = 0; j < children.length; j++) {
1005
				ret.addAll(collectBranchChildren(branchName, rcp, children[j],
1006
						depth));
1007
			}
1008
		}
1009
		return ret;
1010
	}
1011
1012
	protected void setUp() throws Exception {
1013
		String time = Long.toString(System.currentTimeMillis());
1014
		moduleName = "Bug339990TestModule" + time;
1015
		branchName = "Bug339990branch" + time;
1016
		super.setUp();
1017
	}
920
}
1018
}

Return to bug 339990