Skip to content

Commit

Permalink
Change Test Config
Browse files Browse the repository at this point in the history
Adding test config via properties file, the file is in gitignored
  • Loading branch information
mrkoenigstein committed Jan 27, 2018
1 parent 956ccfd commit 9ee6ad4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target/
.idea/
jiraRestClient.iml
src/test/resource/config.properties
41 changes: 33 additions & 8 deletions src/test/java/de/micromata/jira/rest/junit/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import de.micromata.jira.rest.core.misc.RestPathConstants;
import org.junit.Before;

import java.io.FileInputStream;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
Expand All @@ -17,30 +19,53 @@
* Junit-Test for JiraRestClient.
* You need a running Jira-Instance with the TEST_SYSTEM_URL.
* Best use is the atlassian-plugin-sdk
*
* <p>
* User: Christian Schulze
* Email: [email protected]
* Date: 09.08.2014
*/
class BaseTest implements JqlConstants, RestPathConstants {

private static final String TEST_SYSTEM_URL = "http://localhost:2990/jira";
private static final String USERNAME = "admin";
private static final String PASSWORD = "admin";
static final String CONFIGFILENAME = "config.properties";

static final String URL_PARAM = "url";
static final String LOGIN_PARAM = "login";
static final String PASSWORD_PARAM = "password";

static final String USERNAME_TO_SEARCH = "admin";
static final String ISSUEKEY_TO_SEARCH = "DEMO-1";
static final String PROJECT_TO_SEARCH = "DEMO";

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String testSystemUrl = "http://localhost:2990/jira";
String login = "admin";
String password = "admin";

JiraRestClient jiraRestClient;

public BaseTest() {
try {
loadConfig();
} catch (IOException e) {
e.printStackTrace();
}
}

@Before
public void connect() throws URISyntaxException, IOException, ExecutionException, InterruptedException {
ExecutorService executorService = Executors.newFixedThreadPool(100);
ExecutorService executorService = Executors.newFixedThreadPool(100);
// ProxyHost proxy = new ProxyHost("proxy", 3128);
URI uri = new URI(TEST_SYSTEM_URL);
URI uri = new URI(testSystemUrl);
jiraRestClient = new JiraRestClient(executorService);
jiraRestClient.connect(uri, USERNAME, PASSWORD);
jiraRestClient.connect(uri, login, password);
}

private void loadConfig() throws IOException {
String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();
Properties config = new Properties();
config.load(new FileInputStream(path + CONFIGFILENAME));
testSystemUrl = config.getProperty(URL_PARAM);
login = config.getProperty(LOGIN_PARAM);
password = config.getProperty(PASSWORD_PARAM);

}
}

0 comments on commit 9ee6ad4

Please sign in to comment.