From 15e3818f23ee724c1656adef19ededa5744eacc2 Mon Sep 17 00:00:00 2001 From: Greg Messner Date: Sat, 4 May 2019 12:58:31 -0700 Subject: [PATCH] Mods so tests can be run independent of the test suite. --- .../gitlab4j/api/AbstractIntegrationTest.java | 36 +++++++++---------- .../gitlab4j/api/IntegrationTestSuite.java | 16 ++++----- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/test/java/org/gitlab4j/api/AbstractIntegrationTest.java b/src/test/java/org/gitlab4j/api/AbstractIntegrationTest.java index c219e78a..25723f02 100644 --- a/src/test/java/org/gitlab4j/api/AbstractIntegrationTest.java +++ b/src/test/java/org/gitlab4j/api/AbstractIntegrationTest.java @@ -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 * and the resources pointed to must exist. - * - * TEST_NAMESPACE - * TEST_PROJECT_NAME + * * TEST_HOST_URL * TEST_PRIVATE_TOKEN + * TEST_NAMESPACE + * TEST_PROJECT_NAME */ public class AbstractIntegrationTest implements PropertyConstants { // 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 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 GitLabApi gitLabApi; @@ -58,26 +62,22 @@ public class AbstractIntegrationTest implements PropertyConstants { } 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()) { 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()) { 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()) { try { GitLabApi gitLabApi = new GitLabApi(ApiVersion.V4, TEST_HOST_URL, TEST_PRIVATE_TOKEN); diff --git a/src/test/java/org/gitlab4j/api/IntegrationTestSuite.java b/src/test/java/org/gitlab4j/api/IntegrationTestSuite.java index f199139f..787b1f0a 100644 --- a/src/test/java/org/gitlab4j/api/IntegrationTestSuite.java +++ b/src/test/java/org/gitlab4j/api/IntegrationTestSuite.java @@ -34,15 +34,13 @@ import com.googlecode.junittoolbox.WildcardPatternSuite; @IncludeCategory(IntegrationTest.class) 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_LOGIN_USERNAME = HelperUtils.getProperty(LOGIN_USERNAME_KEY, "gitlab4j"); - private static final String TEST_LOGIN_PASSWORD = HelperUtils.getProperty(LOGIN_PASSWORD_KEY, "ChangeMeNow"); - - private static final String TEST_PROJECT_NAME = HelperUtils.getProperty(PROJECT_NAME_KEY, "test-project"); - private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY, "test-group"); - private static final String TEST_GROUP_PROJECT_NAME = HelperUtils.getProperty(GROUP_PROJECT_KEY, "test-group-project"); - - protected static final String TEST_NAMESPACE = HelperUtils.getProperty(NAMESPACE_KEY, TEST_LOGIN_USERNAME); + private static final String TEST_HOST_URL = HelperUtils.getProperty(HOST_URL_KEY); + private static final String TEST_LOGIN_USERNAME = HelperUtils.getProperty(LOGIN_USERNAME_KEY); + 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); + private static final String TEST_GROUP = HelperUtils.getProperty(GROUP_KEY); + private static final String TEST_GROUP_PROJECT_NAME = HelperUtils.getProperty(GROUP_PROJECT_KEY); 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); -- GitLab