|
1 | 1 | package com.projectkaiser.scm.jenkins.api; |
2 | 2 |
|
| 3 | +import static org.junit.Assert.assertTrue; |
| 4 | + |
3 | 5 | import java.io.IOException; |
4 | 6 | import java.io.StringReader; |
5 | 7 | import java.io.StringWriter; |
|
9 | 11 | import javax.xml.parsers.DocumentBuilderFactory; |
10 | 12 | import javax.xml.parsers.ParserConfigurationException; |
11 | 13 |
|
| 14 | +import org.junit.Before; |
| 15 | +import org.junit.BeforeClass; |
12 | 16 | import org.w3c.dom.Document; |
13 | 17 | import org.w3c.dom.NodeList; |
14 | 18 | import org.xml.sax.InputSource; |
15 | 19 | import org.xml.sax.SAXException; |
16 | 20 |
|
17 | | -import com.projectkaiser.scm.jenkins.api.IJenkinsApi; |
18 | | -import com.projectkaiser.scm.jenkins.api.JenkinsApi; |
19 | 21 | import com.sun.org.apache.xml.internal.serialize.OutputFormat; |
20 | 22 | import com.sun.org.apache.xml.internal.serialize.XMLSerializer; |
21 | 23 |
|
22 | 24 | public class JenkinsApiTest { |
23 | 25 |
|
24 | | - IJenkinsApi api = new JenkinsApi("http://localhost:8080", "", ""); |
| 26 | + IJenkinsApi api; |
| 27 | + |
| 28 | + private static final String TEST_JENKINS_URL = System.getProperty("PK_TEST_JENKINS_URL") == null ? |
| 29 | + System.getenv("PK_TEST_JENKINS_URL") : System.getProperty("PK_TEST_JENKINS_URL"); |
| 30 | + private static final String TEST_JENKINS_USER = System.getProperty("PK_TEST_JENKINS_USER") == null ? |
| 31 | + System.getenv("PK_TEST_JENKINS_USER") : System.getProperty("PK_TEST_JENKINS_USER"); |
| 32 | + private static final String TEST_JENKINS_PASS = System.getProperty("PK_TEST_JENKINS_PASS") == null ? |
| 33 | + System.getenv("PK_TEST_JENKINS_PASS") : System.getProperty("PK_TEST_JENKINS_PASS"); |
25 | 34 |
|
| 35 | + @BeforeClass |
| 36 | + public static void setUpClass() { |
| 37 | + assertTrue("Set PK_TEST_JENKINS_URL enviroment variable as url to test Jenkins server to execute tests", |
| 38 | + TEST_JENKINS_URL != null); |
| 39 | + assertTrue("Set TEST_JENKINS_USER enviroment variable as test Jenkins server user name", |
| 40 | + TEST_JENKINS_USER != null); |
| 41 | + assertTrue("Set TEST_JENKINS_PASS enviroment variable as test Jenkins server user password", |
| 42 | + TEST_JENKINS_PASS != null); |
| 43 | + } |
| 44 | + |
| 45 | + @Before |
| 46 | + public void setUp() { |
| 47 | + api = new JenkinsApi(TEST_JENKINS_URL, TEST_JENKINS_USER, TEST_JENKINS_PASS); |
| 48 | + } |
26 | 49 |
|
27 | 50 | public void JenkinsAPITest() throws ParserConfigurationException, SAXException, IOException { |
28 | 51 | String config = api.getJobConfigXml("test job"); |
|
0 commit comments