Commit 15e3818f authored by Greg Messner's avatar Greg Messner
Browse files

Mods so tests can be run independent of the test suite.

parent 21689235
...@@ -10,19 +10,23 @@ import org.gitlab4j.api.models.Project; ...@@ -10,19 +10,23 @@ import org.gitlab4j.api.models.Project;
/** /**
* In order for the integration tests to run you must set the following properties in test-gitlab4j.properties * In order for the integration tests to run you must set the following properties in test-gitlab4j.properties
* and the resources pointed to must exist. * and the resources pointed to must exist.
* *
* TEST_NAMESPACE
* TEST_PROJECT_NAME
* TEST_HOST_URL * TEST_HOST_URL
* TEST_PRIVATE_TOKEN * TEST_PRIVATE_TOKEN
* TEST_NAMESPACE
* TEST_PROJECT_NAME
*/ */
public class AbstractIntegrationTest implements PropertyConstants { public class AbstractIntegrationTest implements PropertyConstants {
// Get the values of the minimum required test properties. // Get the values of the minimum required test properties.
protected static final String TEST_PROJECT_NAME = HelperUtils.getProperty(PROJECT_NAME_KEY);
protected static final String TEST_NAMESPACE = HelperUtils.getProperty(NAMESPACE_KEY);
protected static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY); protected static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY);
protected static String TEST_PRIVATE_TOKEN; protected static final String TEST_LOGIN_USERNAME = HelperUtils.getProperty(LOGIN_USERNAME_KEY);
protected static final String TEST_LOGIN_PASSWORD = HelperUtils.getProperty(LOGIN_PASSWORD_KEY);
protected static final String TEST_PROJECT_NAME = HelperUtils.getProperty(PROJECT_NAME_KEY);
protected static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY);
protected static final String TEST_GROUP_PROJECT_NAME = HelperUtils.getProperty(GROUP_PROJECT_KEY);
protected static final String TEST_NAMESPACE = HelperUtils.getProperty(NAMESPACE_KEY, TEST_LOGIN_USERNAME);
protected static final String TEST_PRIVATE_TOKEN = HelperUtils.getProperty(PRIVATE_TOKEN_KEY);
protected static class BaseTestResources { protected static class BaseTestResources {
protected GitLabApi gitLabApi; protected GitLabApi gitLabApi;
...@@ -58,26 +62,22 @@ public class AbstractIntegrationTest implements PropertyConstants { ...@@ -58,26 +62,22 @@ public class AbstractIntegrationTest implements PropertyConstants {
} }
String problems = ""; String problems = "";
if (TEST_NAMESPACE == null || TEST_NAMESPACE.trim().isEmpty()) {
problems += "TEST_NAMESPACE cannot be empty\n";
}
if (TEST_PROJECT_NAME == null || TEST_PROJECT_NAME.trim().isEmpty()) {
problems += "TEST_PROJECT_NAME cannot be empty\n";
}
if (TEST_HOST_URL == null || TEST_HOST_URL.trim().isEmpty()) { if (TEST_HOST_URL == null || TEST_HOST_URL.trim().isEmpty()) {
problems += "TEST_HOST_URL cannot be empty\n"; problems += "TEST_HOST_URL cannot be empty\n";
} }
if (TEST_PRIVATE_TOKEN == null) {
TEST_PRIVATE_TOKEN = HelperUtils.getProperty(PRIVATE_TOKEN_KEY);
}
if (TEST_PRIVATE_TOKEN == null || TEST_PRIVATE_TOKEN.trim().isEmpty()) { if (TEST_PRIVATE_TOKEN == null || TEST_PRIVATE_TOKEN.trim().isEmpty()) {
problems += "TEST_PRIVATE_TOKEN cannot be empty\n"; problems += "TEST_PRIVATE_TOKEN cannot be empty\n";
} }
if (TEST_NAMESPACE == null || TEST_NAMESPACE.trim().isEmpty()) {
problems += "TEST_NAMESPACE cannot be empty\n";
}
if (TEST_PROJECT_NAME == null || TEST_PROJECT_NAME.trim().isEmpty()) {
problems += "TEST_PROJECT_NAME cannot be empty\n";
}
if (problems.isEmpty()) { if (problems.isEmpty()) {
try { try {
GitLabApi gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TEST_PRIVATE_TOKEN); GitLabApi gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TEST_PRIVATE_TOKEN);
......
...@@ -34,15 +34,13 @@ import com.googlecode.junittoolbox.WildcardPatternSuite; ...@@ -34,15 +34,13 @@ import com.googlecode.junittoolbox.WildcardPatternSuite;
@IncludeCategory(IntegrationTest.class) @IncludeCategory(IntegrationTest.class)
public class IntegrationTestSuite implements PropertyConstants { public class IntegrationTestSuite implements PropertyConstants {
private static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY, "http://localhost:8090"); private static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY);
private static final String TEST_LOGIN_USERNAME = HelperUtils.getProperty(LOGIN_USERNAME_KEY, "gitlab4j"); private static final String TEST_LOGIN_USERNAME = HelperUtils.getProperty(LOGIN_USERNAME_KEY);
private static final String TEST_LOGIN_PASSWORD = HelperUtils.getProperty(LOGIN_PASSWORD_KEY, "ChangeMeNow"); private static final String TEST_LOGIN_PASSWORD = HelperUtils.getProperty(LOGIN_PASSWORD_KEY);
private static final String TEST_NAMESPACE = HelperUtils.getProperty(NAMESPACE_KEY, TEST_LOGIN_USERNAME);
private static final String TEST_PROJECT_NAME = HelperUtils.getProperty(PROJECT_NAME_KEY, "test-project"); private static final String TEST_PROJECT_NAME = HelperUtils.getProperty(PROJECT_NAME_KEY);
private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY, "test-group"); private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY);
private static final String TEST_GROUP_PROJECT_NAME = HelperUtils.getProperty(GROUP_PROJECT_KEY, "test-group-project"); private static final String TEST_GROUP_PROJECT_NAME = HelperUtils.getProperty(GROUP_PROJECT_KEY);
protected static final String TEST_NAMESPACE = HelperUtils.getProperty(NAMESPACE_KEY, TEST_LOGIN_USERNAME);
protected static final String TEST_PRIVATE_TOKEN_NAME = "GitLab4J Test Private Token - " + HelperUtils.getRandomInt(1000); protected static final String TEST_PRIVATE_TOKEN_NAME = "GitLab4J Test Private Token - " + HelperUtils.getRandomInt(1000);
protected static String TEST_PRIVATE_TOKEN = HelperUtils.getProperty(PRIVATE_TOKEN_KEY); protected static String TEST_PRIVATE_TOKEN = HelperUtils.getProperty(PRIVATE_TOKEN_KEY);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment