forked from gitlab4j/gitlab4j-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestGitLabApi.java
77 lines (63 loc) · 2.79 KB
/
TestGitLabApi.java
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
75
76
77
package org.gitlab4j.api;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.util.Map;
import org.gitlab4j.api.models.Version;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* In order for these tests to run you must set the following properties in test-gitlab4j.properties
*
* TEST_HOST_URL
* TEST_PRIVATE_TOKEN
*
* If any of the above are NULL, all tests in this class will be skipped.
*
*/
@Tag("integration")
@ExtendWith(SetupIntegrationTestExtension.class)
@org.junit.jupiter.api.Disabled("Integration tests are disabled, see https://github.com/gitlab4j/gitlab4j-api/issues/1165")
public class TestGitLabApi extends AbstractIntegrationTest {
// The following needs to be set to your test repository
private static final String TEST_PROXY_URI = HelperUtils.getProperty(PROXY_URI_KEY);
private static final String TEST_PROXY_USERNAME = HelperUtils.getProperty(PROXY_USERNAME_KEY);
private static final String TEST_PROXY_PASSWORD = HelperUtils.getProperty(PROXY_PASSWORD_KEY);
private static GitLabApi gitLabApi;
public TestGitLabApi() {
super();
}
@BeforeAll
public static void setup() {
// Must setup the connection to the GitLab test server
gitLabApi = baseTestSetup();
}
@BeforeEach
public void beforeMethod() {
assumeTrue(gitLabApi != null);
}
@Test
public void testGetVersion() throws GitLabApiException {
Version version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("version=%s, revision=%s%n", version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
}
@Test
public void testProxyConnection() throws GitLabApiException {
assumeTrue(TEST_PROXY_URI != null && TEST_PROXY_USERNAME != null && TEST_PROXY_PASSWORD != null);
assumeTrue(TEST_PROXY_URI.length() > 0 && TEST_PROXY_USERNAME.length() > 0 && TEST_PROXY_PASSWORD.length() > 0);
// Setup a GitLabApi instance to use a proxy
Map<String, Object> clientConfig = ProxyClientConfig.createProxyClientConfig(TEST_PROXY_URI, TEST_PROXY_USERNAME, TEST_PROXY_PASSWORD);
GitLabApi gitLabApi = new GitLabApi(TEST_HOST_URL, TEST_PRIVATE_TOKEN, null, clientConfig);
Version version = gitLabApi.getVersion();
assertNotNull(version);
System.out.format("version=%s, revision=%s%n", version.getVersion(), version.getRevision());
assertNotNull(version.getVersion());
assertNotNull(version.getRevision());
gitLabApi.close();
}
}