Skip to content
This repository was archived by the owner on Mar 11, 2022. It is now read-only.

Commit 8f015c3

Browse files
committed
Renamed test properties and fields
1 parent 35abe19 commit 8f015c3

7 files changed

Lines changed: 48 additions & 48 deletions

File tree

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ CouchDB. To run tests with a remote CouchDB or Cloudant, you need set the
112112
details of this CouchDB server, including access credentials:
113113

114114
```
115-
systemProp.test.couch.username=yourUsername
116-
systemProp.test.couch.password=yourPassword
117-
systemProp.test.couch.host=couchdbHost # default localhost
118-
systemProp.test.couch.port=couchdbPort # default 5984
119-
systemProp.test.couch.http=[http|https] # default http
115+
systemProp.test.server.user=yourUsername
116+
systemProp.test.server.password=yourPassword
117+
systemProp.test.server.host=couchdborcloudanthost # default localhost
118+
systemProp.test.server.port=5984 # default 5984
119+
systemProp.test.server.protocol=[http|https] # default http
120120
```
121121
Alternatively, provide a URL containing all the above information:
122122
```

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def runTests(testEnv, isServiceTests) {
2929
withEnv(testEnv) {
3030
withCredentials([(env.CREDS_ID.contains('iam')) ? string(credentialsId: env.CREDS_ID, variable: 'IAM_API_KEY') : usernamePassword(credentialsId: env.CREDS_ID, usernameVariable: 'DB_USER', passwordVariable: 'DB_PASSWORD')]) {
3131
try {
32-
sh "./gradlew ${(env.DB_USER?.trim()) ? '-Dtest.couch.username=$DB_USER -Dtest.couch.password=$DB_PASSWORD' : ''} -Dtest.couch.host=\$DB_HOST -Dtest.couch.port=\$DB_PORT -Dtest.couch.http=\$DB_HTTP \$GRADLE_TARGET"
32+
sh "./gradlew ${(env.DB_USER?.trim()) ? '-Dtest.server.user=$DB_USER -Dtest.server.password=$DB_PASSWORD' : ''} -Dtest.server.host=\$DB_HOST -Dtest.server.port=\$DB_PORT -Dtest.server.protocol=\$DB_HTTP \$GRADLE_TARGET"
3333
} finally {
3434
junit '**/build/test-results/**/*.xml'
3535
}

cloudant-client/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ task cloudantServiceTest(type: Test) {
110110

111111
task integrationTest(type: Test) {
112112
// Special environment variables for integration tests
113-
[SERVER_URL:'test.couch.url',
114-
SERVER_USER:'test.couch.username',
115-
SERVER_PASSWORD:'test.couch.password',
113+
[SERVER_URL:'test.server.url',
114+
SERVER_USER:'test.server.user',
115+
SERVER_PASSWORD:'test.server.password',
116116
TEST_REPLICATION_SOURCE_URL:'test.replication.source.url'].each { k,v ->
117117
def e = System.getenv(k)
118118
if (e) {

cloudant-client/src/test/java/com/cloudant/tests/CloudFoundryServiceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public void vcapSingleServiceEmptyCredentials() {
252252
public void execute() throws Throwable {
253253
VCAPGenerator vcap = new CloudFoundryServiceTest.VCAPGenerator();
254254
vcap.createNewLegacyServiceWithEmptyCredentials("test_bluemix_service_1",
255-
CloudantClientHelper.COUCH_HOST);
255+
CloudantClientHelper.SERVER_HOST);
256256
ClientBuilder.bluemix(vcap.toJson(), "test_bluemix_service_1");
257257
}
258258
});
@@ -277,7 +277,7 @@ public void vcapSingleServiceEmptyIAM() {
277277
public void execute() throws Throwable {
278278
VCAPGenerator vcap = new CloudFoundryServiceTest.VCAPGenerator();
279279
vcap.createNewServiceWithEmptyIAM("test_bluemix_service_1",
280-
CloudantClientHelper.COUCH_HOST);
280+
CloudantClientHelper.SERVER_HOST);
281281
ClientBuilder.bluemix(vcap.toJson(), "test_bluemix_service_1");
282282
}
283283
});
@@ -382,7 +382,7 @@ public void execute() throws Throwable {
382382
vcap.createNewLegacyService("test_bluemix_service_2", "foo2.bar", "admin2",
383383
"pass2");
384384
vcap.createNewLegacyServiceWithEmptyCredentials("test_bluemix_service_3",
385-
CloudantClientHelper.COUCH_HOST);
385+
CloudantClientHelper.SERVER_HOST);
386386
ClientBuilder.bluemix(vcap.toJson(), "test_bluemix_service_3");
387387
}
388388
});
@@ -397,7 +397,7 @@ public void execute() throws Throwable {
397397
vcap.createNewService("test_bluemix_service_1", "admin1", "apikey1");
398398
vcap.createNewService("test_bluemix_service_2", "admin2", "apikey2");
399399
vcap.createNewServiceWithEmptyIAM("test_bluemix_service_3",
400-
CloudantClientHelper.COUCH_HOST);
400+
CloudantClientHelper.SERVER_HOST);
401401
ClientBuilder.bluemix(vcap.toJson(), "test_bluemix_service_3");
402402
}
403403
});

cloudant-client/src/test/java/com/cloudant/tests/CloudantClientHelper.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,54 +33,54 @@ public abstract class CloudantClientHelper {
3333
//some tests need access to the URI with user info (e.g. replication)
3434
public static final String SERVER_URI_WITH_USER_INFO;
3535
//some tests need access to the credentials (e.g. auth interceptors, vcap)
36-
static final String COUCH_USERNAME;
37-
static final String COUCH_PASSWORD;
38-
static final String COUCH_HOST;
36+
static final String SERVER_USER;
37+
static final String SERVER_PASSWORD;
38+
static final String SERVER_HOST;
3939

4040
private static final CloudantClient CLIENT_INSTANCE;
4141

42-
private static final String COUCH_PORT;
43-
private static final String HTTP_PROTOCOL;
42+
private static final String SERVER_PORT;
43+
private static final String SERVER_PROTOCOL;
4444
private static final URL SERVER_URL;
4545

4646
static {
4747

4848
try {
4949
//a URL might be supplied, otherwise use the separate properties
50-
String URL = System.getProperty("test.couch.url");
50+
String URL = System.getProperty("test.server.url");
5151
if (URL != null) {
5252
URL couch = new URL(URL);
53-
HTTP_PROTOCOL = couch.getProtocol();
54-
COUCH_HOST = couch.getHost();
55-
COUCH_PORT = (couch.getPort() < 0) ? null : Integer.toString(couch.getPort());
53+
SERVER_PROTOCOL = couch.getProtocol();
54+
SERVER_HOST = couch.getHost();
55+
SERVER_PORT = (couch.getPort() < 0) ? null : Integer.toString(couch.getPort());
5656
String userInfo = couch.getUserInfo();
5757
if (userInfo != null) {
58-
COUCH_USERNAME = userInfo.substring(0, userInfo.indexOf(":"));
59-
COUCH_PASSWORD = userInfo.substring(userInfo.indexOf(":") + 1);
58+
SERVER_USER = userInfo.substring(0, userInfo.indexOf(":"));
59+
SERVER_PASSWORD = userInfo.substring(userInfo.indexOf(":") + 1);
6060
} else {
61-
COUCH_USERNAME = System.getProperty("test.couch.username");
62-
COUCH_PASSWORD = System.getProperty("test.couch.password");
61+
SERVER_USER = System.getProperty("test.server.user");
62+
SERVER_PASSWORD = System.getProperty("test.server.password");
6363
}
6464
} else {
65-
COUCH_USERNAME = System.getProperty("test.couch.username");
66-
COUCH_PASSWORD = System.getProperty("test.couch.password");
67-
COUCH_HOST = System.getProperty("test.couch.host", "localhost");
68-
COUCH_PORT = System.getProperty("test.couch.port", "5984");
69-
HTTP_PROTOCOL = System.getProperty("test.couch.http", "http"); //should either be
65+
SERVER_USER = System.getProperty("test.server.user");
66+
SERVER_PASSWORD = System.getProperty("test.server.password");
67+
SERVER_HOST = System.getProperty("test.server.host", "localhost");
68+
SERVER_PORT = System.getProperty("test.server.port", "5984");
69+
SERVER_PROTOCOL = System.getProperty("test.server.protocol", "http"); //should either be
7070
// http or https
7171
}
7272

7373
//now build the URLs
74-
SERVER_URL = new URL(HTTP_PROTOCOL + "://"
75-
+ COUCH_HOST
76-
+ ((COUCH_PORT != null) ? ":" + COUCH_PORT : "")); //port if supplied
74+
SERVER_URL = new URL(SERVER_PROTOCOL + "://"
75+
+ SERVER_HOST
76+
+ ((SERVER_PORT != null) ? ":" + SERVER_PORT : "")); //port if supplied
7777

7878
// Ensure username and password are correctly URL encoded when included in the URI
79-
SERVER_URI_WITH_USER_INFO = HTTP_PROTOCOL + "://"
80-
+ ((!IamAuthCondition.IS_IAM_ENABLED && COUCH_USERNAME != null) ?
81-
URLEncoder.encode(COUCH_USERNAME, "UTF-8") +
82-
":" + URLEncoder.encode(COUCH_PASSWORD, "UTF-8") + "@" : "") + COUCH_HOST + (
83-
(COUCH_PORT != null) ? ":" + COUCH_PORT : ""); //port if supplied
79+
SERVER_URI_WITH_USER_INFO = SERVER_PROTOCOL + "://"
80+
+ ((!IamAuthCondition.IS_IAM_ENABLED && SERVER_USER != null) ?
81+
URLEncoder.encode(SERVER_USER, "UTF-8") +
82+
":" + URLEncoder.encode(SERVER_PASSWORD, "UTF-8") + "@" : "") + SERVER_HOST + (
83+
(SERVER_PORT != null) ? ":" + SERVER_PORT : ""); //port if supplied
8484
} catch (Throwable t) {
8585
throw new RuntimeException(t);
8686
}
@@ -122,8 +122,8 @@ public static ClientBuilder getClientBuilder() {
122122
if (IamAuthCondition.IS_IAM_ENABLED) {
123123
builder.iamApiKey(IamAuthCondition.IAM_API_KEY);
124124
} else {
125-
builder.username(COUCH_USERNAME)
126-
.password(COUCH_PASSWORD);
125+
builder.username(SERVER_USER)
126+
.password(SERVER_PASSWORD);
127127
}
128128
return builder;
129129
}

cloudant-client/src/test/java/com/cloudant/tests/CloudantClientTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,10 @@ public void sessionDeleteOnShutdown() throws Exception {
497497
@RequiresCloudant
498498
public void testBasicAuth() throws IOException {
499499
BasicAuthInterceptor interceptor =
500-
new BasicAuthInterceptor(CloudantClientHelper.COUCH_USERNAME
501-
+ ":" + CloudantClientHelper.COUCH_PASSWORD);
500+
new BasicAuthInterceptor(CloudantClientHelper.SERVER_USER
501+
+ ":" + CloudantClientHelper.SERVER_PASSWORD);
502502

503-
CloudantClient client = ClientBuilder.account(CloudantClientHelper.COUCH_USERNAME)
503+
CloudantClient client = ClientBuilder.account(CloudantClientHelper.SERVER_USER)
504504
.interceptors(interceptor).build();
505505

506506
// Test passes if there are no exceptions

cloudant-client/src/test/java/com/cloudant/tests/HttpTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ public void testReadBeforeExecute() throws Exception {
226226
@DisabledWithIam
227227
@RequiresCloudant
228228
public void testCookieAuthWithoutRetry() throws IOException {
229-
CookieInterceptor interceptor = new CookieInterceptor(CloudantClientHelper.COUCH_USERNAME,
230-
CloudantClientHelper.COUCH_PASSWORD, clientResource.get().getBaseUri().toString());
229+
CookieInterceptor interceptor = new CookieInterceptor(CloudantClientHelper.SERVER_USER,
230+
CloudantClientHelper.SERVER_PASSWORD, clientResource.get().getBaseUri().toString());
231231

232232
HttpConnection conn = new HttpConnection("POST", dbResource.get().getDBUri().toURL(),
233233
"application/json");
@@ -285,8 +285,8 @@ public void testCookieAuthWithPath() throws Exception {
285285
@RequiresCloudant
286286
public void testBasicAuth() throws IOException {
287287
BasicAuthInterceptor interceptor =
288-
new BasicAuthInterceptor(CloudantClientHelper.COUCH_USERNAME
289-
+ ":" + CloudantClientHelper.COUCH_PASSWORD);
288+
new BasicAuthInterceptor(CloudantClientHelper.SERVER_USER
289+
+ ":" + CloudantClientHelper.SERVER_PASSWORD);
290290

291291
HttpConnection conn = new HttpConnection("POST", dbResource.get().getDBUri().toURL(),
292292
"application/json");

0 commit comments

Comments
 (0)