blob: 83879566015d5f16c3e2005d36a9f417f46b3d3b (
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
|
/*******************************************************************************
* Copyright (C) 2010, 2012 Mathias Kinzler <mathias.kinzler@sap.com> 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
*******************************************************************************/
package org.eclipse.egit.core.test;
import java.io.File;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import org.eclipse.egit.core.Activator;
import org.eclipse.egit.core.op.ConnectProviderOperation;
import org.junit.After;
import org.junit.Before;
public abstract class DualRepositoryTestCase {
protected TestUtils testUtils = new TestUtils();
protected TestRepository repository1;
protected TestRepository repository2;
protected IProject testProject;
@Before
public void beforeTestCase() throws Exception {
// ensure there are no shared Repository instances left
// when starting a new test
Activator.getDefault().getRepositoryCache().clear();
}
@After
public void afterTestCase() throws Exception {
Activator.getDefault().getRepositoryCache().clear();
if (repository1 != null)
repository1.dispose();
if (repository2 != null)
repository2.dispose();
if (testProject != null) {
testProject.close(null);
testProject.delete(false, false, null);
}
testUtils.deleteTempDirs();
}
protected IProject importProject(TestRepository repo, String projectName)
throws Exception {
IProject firstProject = ResourcesPlugin.getWorkspace().getRoot()
.getProject(projectName);
if (firstProject.exists())
firstProject.delete(false, null);
IProjectDescription desc = ResourcesPlugin.getWorkspace()
.newProjectDescription(projectName);
File parentFile = repo.getRepository().getWorkTree();
desc.setLocation(new Path(new File(parentFile, projectName).getPath()));
firstProject.create(desc, null);
firstProject.open(null);
ConnectProviderOperation cop = new ConnectProviderOperation(
firstProject, repo.getRepository().getDirectory());
cop.execute(null);
return firstProject;
}
}
|