Skip to content

Commit f57fbe3

Browse files
author
Ben Pedrick
committed
Read API key and secret from command line for unit tests.
1 parent 06fb192 commit f57fbe3

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
See documentation at: http://www.tokbox.com/opentok/api/tools/documentation/api/server_side_libraries.html?proglang=java
2+
3+
To run the Unit tests, you must specify an API key and secret on the command
4+
line:
5+
> mvn test -DapiKey=<your_api_key> -DapiSecret=<your_api_secret>

src/main/java/com/opentok/api/API_Config.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
package com.opentok.api;
99

1010
public class API_Config {
11-
/*public static final int API_KEY = ;*/ // Fill this in with generated API Key (http://tokbox.com/opentok/api/tools/js/apikey)
11+
public static final int API_KEY = 0; // Fill this in with generated API Key (http://tokbox.com/opentok/api/tools/js/apikey)
1212

13-
/*public static final String API_SECRET = "";*/ // Fill this in with generated API Secret in email
13+
public static final String API_SECRET = ""; // Fill this in with generated API Secret in email
1414

1515
public static final String API_URL = "https://api.opentok.com";
1616
}

src/main/java/com/opentok/util/TokBoxXML.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public String getElementValue(String elementName, String parentElement) {
4343
Node parentNode = TokBoxUtils.parseXML(parentElement, this.xml.getElementsByTagName(parentElement));
4444
Node searchNode = TokBoxUtils.parseXML(elementName, parentNode.getChildNodes());
4545

46-
return searchNode.getTextContent();
46+
return null == searchNode ? null : searchNode.getTextContent();
4747
}
4848

4949

src/test/java/com/opentok/test/UnitTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@ public class UnitTest {
2424

2525
private OpenTokSDK sdk;
2626

27+
private int apiKey;
28+
private String apiSecret;
29+
2730
public UnitTest() {
28-
sdk = new OpenTokSDK(API_Config.API_KEY,API_Config.API_SECRET);
31+
apiKey = Integer.valueOf(System.getProperty("apiKey"));
32+
apiSecret = System.getProperty("apiSecret");
33+
sdk = new OpenTokSDK(apiKey, apiSecret);
2934
}
3035

3136
private TokBoxXML get_session_info(String session_id) throws OpenTokException {

0 commit comments

Comments
 (0)