Skip to content

Commit 80cd605

Browse files
committed
Mods so unit tests work correctly when using the release plugin.
1 parent eb92965 commit 80cd605

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/test/java/org/gitlab4j/api/TestUtils.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.gitlab4j.api;
22

3+
import java.io.File;
34
import java.io.FileInputStream;
45
import java.io.IOException;
56
import java.io.InputStream;
@@ -27,12 +28,26 @@ public static String getReaderContentAsString(Reader reader) throws IOException
2728
return (out.toString());
2829
}
2930

30-
3131
private static Properties testProperties;
3232
static {
3333

34+
// Get the maven basedir, we use it to locate the properties for the unit tests
35+
String basedir = (String) System.getProperties().get("basedir");
36+
37+
// If we are performing a release in target/checkout, trim off the target/checkout directory from basedir
38+
if (basedir != null && (basedir.endsWith("target/checkout") || basedir.endsWith("target\\checkout"))) {
39+
basedir = basedir.substring(0, basedir.length() - 15);
40+
}
41+
42+
File propertiesFile = new File(basedir, "test-gitlab4j.properties");
43+
if (!propertiesFile.exists()) {
44+
propertiesFile = new File((String) System.getProperties().get("user.home"), "test-gitlab4j.properties");
45+
}
46+
47+
System.out.println("test-gitlab4j.properties location: " + propertiesFile.getAbsolutePath());
48+
3449
testProperties = new Properties();
35-
try (InputStream input = new FileInputStream("test-gitlab4j.properties")) {
50+
try (InputStream input = new FileInputStream(propertiesFile)) {
3651
testProperties.load(input);
3752
} catch (IOException ioe) {
3853
}

0 commit comments

Comments
 (0)