33import static org .junit .Assert .assertNotNull ;
44import static org .junit .Assume .assumeTrue ;
55
6- import org .gitlab4j .api .GitLabApi .ApiVersion ;
6+ import java .util .Map ;
7+
78import org .gitlab4j .api .models .Version ;
89import org .junit .Before ;
910import org .junit .BeforeClass ;
@@ -23,9 +24,15 @@ public class TestGitLabApi {
2324 // The following needs to be set to your test repository
2425 private static final String TEST_HOST_URL ;
2526 private static final String TEST_PRIVATE_TOKEN ;
27+ private static final String TEST_PROXY_URI ;
28+ private static final String TEST_PROXY_USERNAME ;
29+ private static final String TEST_PROXY_PASSWORD ;
2630 static {
2731 TEST_HOST_URL = TestUtils .getProperty ("TEST_HOST_URL" );
2832 TEST_PRIVATE_TOKEN = TestUtils .getProperty ("TEST_PRIVATE_TOKEN" );
33+ TEST_PROXY_URI = TestUtils .getProperty ("TEST_PROXY_URI" );
34+ TEST_PROXY_USERNAME = TestUtils .getProperty ("TEST_PROXY_USERNAME" );
35+ TEST_PROXY_PASSWORD = TestUtils .getProperty ("TEST_PROXY_PASSWORD" );
2936 }
3037
3138 private static GitLabApi gitLabApi ;
@@ -47,7 +54,7 @@ public static void setup() {
4754 }
4855
4956 if (problems .isEmpty ()) {
50- gitLabApi = new GitLabApi (ApiVersion . V4 , TEST_HOST_URL , TEST_PRIVATE_TOKEN );
57+ gitLabApi = new GitLabApi (TEST_HOST_URL , TEST_PRIVATE_TOKEN );
5158 } else {
5259 System .err .print (problems );
5360 }
@@ -66,4 +73,19 @@ public void testGetVersion() throws GitLabApiException {
6673 assertNotNull (version .getVersion ());
6774 assertNotNull (version .getRevision ());
6875 }
76+
77+ @ Test
78+ public void testProxyConnection () throws GitLabApiException {
79+ assumeTrue (TEST_PROXY_URI != null && TEST_PROXY_USERNAME != null && TEST_PROXY_PASSWORD != null );
80+
81+ // Setup a GitLabApi instance to use a proxy
82+ Map <String , Object > clientConfig = ProxyClientConfig .createProxyClientConfig (TEST_PROXY_URI , TEST_PROXY_USERNAME , TEST_PROXY_PASSWORD );
83+ GitLabApi gitLabApi = new GitLabApi (TEST_HOST_URL , TEST_PRIVATE_TOKEN , null , clientConfig );
84+
85+ Version version = gitLabApi .getVersion ();
86+ assertNotNull (version );
87+ System .out .format ("version=%s, revision=%s%n" , version .getVersion (), version .getRevision ());
88+ assertNotNull (version .getVersion ());
89+ assertNotNull (version .getRevision ());
90+ }
6991}
0 commit comments