Skip to main content
summaryrefslogtreecommitdiffstats
blob: fd9080cc8829e9820a6a2e98af6ef856ace2989f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package org.eclipse.team.tests.ccvs.core.compatible;
/*
 * (c) Copyright IBM Corp. 2000, 2002.
 * All Rights Reserved.
 */
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.team.tests.ccvs.core.JUnitTestCase;

public class ModuleTest extends JUnitTestCase {
	SameResultEnv env1;
	SameResultEnv env2;
	
	public ModuleTest(String arg) {
		super(arg);
		env1 = new SameResultEnv(arg + "checkout1");
		env2 = new SameResultEnv(arg + "checkout2");
	}

	public static void main(String[] args) {	
		run(ModuleTest.class);
	}

	public void setUp() throws Exception {
		env1.setUp();
		env2.setUp();

		// Set the project to the content we need ...
		env1.magicDeleteRemote("CVSROOT/modules");
		env1.magicDeleteRemote("CVSROOT/modules,v");
		env1.magicSetUpRepo("proj2",new String[]{"a.txt","f1/b.txt","f1/c.txt","f2/d.txt","f2/f3/e.txt"});
		env2.deleteFile("proj2");
	}
	
	public void tearDown() throws Exception {
		env1.tearDown();
		env2.tearDown();
	}
	
	public static Test suite() {
		TestSuite suite = new TestSuite(ModuleTest.class);
		return new CompatibleTestSetup(suite);
	}	
	
	private void setUpModuleFile(String[] change) throws Exception {
		
		// Write the modules-file
		env1.execute("co",EMPTY_ARGS,new String[]{"CVSROOT"});
		env1.writeToFile("CVSROOT/modules",change);
		
		// Send it up to the server
		env1.execute("add",new String[]{"-m","m"},new String[]{"modules"},"CVSROOT");
		env1.execute("ci",new String[]{"-m","m"},new String[]{"CVSROOT"});
		env1.deleteFile("CVSROOT");		
	}
	
	public void testSimpleModule() throws Exception {
		setUpModuleFile(new String[]{"mod1 proj2"});
		env1.execute("co",EMPTY_ARGS,new String[]{"mod1"});
		env1.appendToFile("mod1/a.txt", new String[] { "Append" });
		env1.execute("ci",new String[]{"-m","m"},new String[]{"mod1"});
		env1.execute("update",EMPTY_ARGS,new String[]{"mod1"});
	}

	public void testCompositeModule() throws Exception {
		setUpModuleFile(new String[]{	"mod1-f1 proj2/f1",
										"mod1-f2 proj2/f2",
										"mod1f &mod1-f1 &mod1-f2"});
		
		env1.execute("co",EMPTY_ARGS,new String[]{"mod1f"});
		env1.appendToFile("mod1f/mod1-f1/b.txt", new String[] { "Append" });
		env1.execute("ci",new String[]{"-m","m"},new String[]{"mod1f"});
		env1.execute("update",EMPTY_ARGS,new String[]{"mod1f"});
	}

	public void testCompositeAliasModule() throws Exception {
		setUpModuleFile(new String[]{"mod1-f1 proj2/f1",
										"mod1t proj2/f1 b.txt",
										"mod1-f2 &proj2/f2 &mod1t",
										"mod1f -a mod1-f1 mod1-f2"});
		
		env1.execute("co",EMPTY_ARGS,new String[]{"mod1f"});
		env1.appendToFile("mod1-f1/b.txt", new String[] { "Append" });
		env1.execute("ci",new String[]{"-m","m"},new String[]{"mod1-f1","mod1-f2"});
		env1.execute("update",EMPTY_ARGS,new String[]{"mod1-f1","mod1-f2"});
	}
}

Back to the top