View Javadoc
1   /*
2    * Copyright (C) 2020-2021, Simeon Andreev <simeon.danailov.andreev@gmail.com> and others.
3    *
4    * This program and the accompanying materials are made available under the
5    * terms of the Eclipse Distribution License v. 1.0 which is available at
6    * https://www.eclipse.org/org/documents/edl-v10.php.
7    *
8    * SPDX-License-Identifier: BSD-3-Clause
9    */
10  package org.eclipse.jgit.internal.diffmergetool;
11  
12  import java.io.File;
13  import java.nio.file.Files;
14  
15  import org.eclipse.jgit.junit.RepositoryTestCase;
16  import org.eclipse.jgit.util.FS;
17  import org.eclipse.jgit.util.FS_POSIX;
18  import org.junit.After;
19  import org.junit.Assume;
20  import org.junit.Before;
21  
22  /**
23   * Base test case for external merge and diff tool tests.
24   */
25  public abstract class ExternalToolTestCase extends RepositoryTestCase {
26  
27  	protected static final String DEFAULT_CONTENT = "line1";
28  
29  	protected File localFile;
30  
31  	protected File remoteFile;
32  
33  	protected File mergedFile;
34  
35  	protected File baseFile;
36  
37  	protected File commandResult;
38  
39  	@Before
40  	@Override
41  	public void setUp() throws Exception {
42  		super.setUp();
43  
44  		localFile = writeTrashFile("localFile.txt", DEFAULT_CONTENT + "\n");
45  		localFile.deleteOnExit();
46  		remoteFile = writeTrashFile("remoteFile.txt", DEFAULT_CONTENT + "\n");
47  		remoteFile.deleteOnExit();
48  		mergedFile = writeTrashFile("mergedFile.txt", "");
49  		mergedFile.deleteOnExit();
50  		baseFile = writeTrashFile("baseFile.txt", "");
51  		baseFile.deleteOnExit();
52  		commandResult = writeTrashFile("commandResult.txt", "");
53  		commandResult.deleteOnExit();
54  	}
55  
56  	@After
57  	@Override
58  	public void tearDown() throws Exception {
59  		Files.delete(localFile.toPath());
60  		Files.delete(remoteFile.toPath());
61  		Files.delete(mergedFile.toPath());
62  		Files.delete(baseFile.toPath());
63  		Files.delete(commandResult.toPath());
64  
65  		super.tearDown();
66  	}
67  
68  
69  	protected static void assumePosixPlatform() {
70  		Assume.assumeTrue(
71  				"This test can run only in Linux tests",
72  				FS.DETECTED instanceof FS_POSIX);
73  	}
74  }