aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalToolTestCase.java
blob: 0cc12978a86ad430826e08d7238f605b6546e6e6 (plain)
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
/*
 * Copyright (C) 2020-2021, Simeon Andreev <simeon.danailov.andreev@gmail.com> and others.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0 which is available at
 * https://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
package org.eclipse.jgit.internal.diffmergetool;

import java.io.File;
import java.nio.file.Files;

import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FS_POSIX;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;

/**
 * Base test case for external merge and diff tool tests.
 */
public abstract class ExternalToolTestCase extends RepositoryTestCase {

	protected static final String DEFAULT_CONTENT = "line1";

	protected File localFile;

	protected File remoteFile;

	protected File mergedFile;

	protected File baseFile;

	protected File commandResult;

	@Before
	@Override
	public void setUp() throws Exception {
		super.setUp();

		localFile = writeTrashFile("localFile.txt", DEFAULT_CONTENT + "\n");
		localFile.deleteOnExit();
		remoteFile = writeTrashFile("remoteFile.txt", DEFAULT_CONTENT + "\n");
		remoteFile.deleteOnExit();
		mergedFile = writeTrashFile("mergedFile.txt", "");
		mergedFile.deleteOnExit();
		baseFile = writeTrashFile("baseFile.txt", "");
		baseFile.deleteOnExit();
		commandResult = writeTrashFile("commandResult.txt", "");
		commandResult.deleteOnExit();
	}

	@After
	@Override
	public void tearDown() throws Exception {
		Files.delete(localFile.toPath());
		Files.delete(remoteFile.toPath());
		Files.delete(mergedFile.toPath());
		Files.delete(baseFile.toPath());
		Files.delete(commandResult.toPath());

		super.tearDown();
	}


	protected static void assumePosixPlatform() {
		Assume.assumeTrue(
				"This test can run only in Linux tests",
				FS.DETECTED instanceof FS_POSIX);
	}
}