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

Commit e69e32a

Browse files
committed
Allow testing on CouchDB 3.0.0
1 parent ac3ab21 commit e69e32a

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/mazha/ChangesFeedTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void changes_docWithConflicts_conflictsShouldBeReturned() {
9898
@Test
9999
public void changes_dbChangesMustSuccessfullyReturnWithSeqInterval() throws IOException,
100100
URISyntaxException {
101-
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBV2(client.getRootUri()));
101+
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBVersion2or3(client.getRootUri()));
102102
Response res1 = ClientTestUtils.createHelloWorldDoc(client);
103103
Response res2 = ClientTestUtils.createHelloWorldDoc(client);
104104
ClientTestUtils.createHelloWorldDoc(client);

cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/mazha/ClientTestUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ public static List<String> getRemoteRevisionIDs(URI uri, CouchConfig config) thr
239239
return revisions;
240240
}
241241

242-
public static boolean isCouchDBV2(URI uri) throws URISyntaxException, IOException {
242+
public static boolean isCouchDBVersion2or3(URI uri) throws URISyntaxException, IOException {
243243
URI root = new URI(uri.getScheme() + "://" + uri.getAuthority());
244244
HttpConnection connection = Http.GET(root);
245245
String response = connection.execute().responseAsString();
246-
return response.contains("\"version\":\"2.");
246+
return response.contains("\"version\":\"2.") || response.contains("\"version\":\"3.");
247247
}
248248

249249

cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/mazha/CouchClientSelectorChangesTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.junit.Assert;
2020
import org.junit.Before;
2121
import org.junit.Test;
22-
import org.junit.experimental.categories.Category;
2322

2423
public class CouchClientSelectorChangesTest extends CouchClientTestBase {
2524

@@ -31,15 +30,15 @@ public void setUp() {
3130

3231
@Test
3332
public void changes_selector() throws Exception {
34-
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBV2(client.getRootUri()));
33+
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBVersion2or3(client.getRootUri()));
3534
String animalBirdSelector = "{\"selector\":{\"class\":\"bird\"}}";
3635
ChangesResult changes = client.changes(animalBirdSelector, null, 5);
3736
Assert.assertThat(changes.getResults(), hasSize(2));
3837
}
3938

4039
@Test
4140
public void changes_selectorAndMoreThanLimitNumberOfDocs() throws Exception {
42-
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBV2(client.getRootUri()));
41+
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBVersion2or3(client.getRootUri()));
4342
String animalMammalSelector = "{\"selector\":{\"class\":\"mammal\"}}";
4443
ChangesResult firstChangeSet = client.changes(animalMammalSelector, null, 5);
4544
Assert.assertThat(firstChangeSet.getResults(), hasSize(5));

cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/replication/PullStrategyDocIdTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private void pull(PullStrategy replicator, int expectedDocs) throws Exception {
3737

3838
@Test
3939
public void pull_filterDocIdsFromAnimalDb_twoDocShouldBePulled() throws Exception {
40-
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBV2(remoteDb.couchClient.getRootUri()));
40+
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBVersion2or3(remoteDb.couchClient.getRootUri()));
4141
List<String> docIds = Arrays.asList("snipe","kookaburra");
4242
PullStrategy replicator = super.getPullStrategy(docIds);
4343

@@ -57,7 +57,7 @@ public void pull_filterDocIdsFromAnimalDb_twoDocShouldBePulled() throws Exceptio
5757
public void
5858
pull_filterSelectorMammalFromAnimalDbUsingParameterizedFilter_eightDocShouldBePulled()
5959
throws Exception {
60-
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBV2(remoteDb.couchClient.getRootUri()));
60+
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBVersion2or3(remoteDb.couchClient.getRootUri()));
6161
List<String> docIds = Arrays.asList("aardvark", "badger", "elephant", "giraffe", "lemur", "llama",
6262
"panda", "zebra");
6363
PullStrategy replicator = super.getPullStrategy(docIds);

cloudant-sync-datastore-core/src/test/java/com/cloudant/sync/internal/replication/PullStrategySelectorTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
import org.junit.Assert;
2121
import org.junit.Test;
22-
import org.junit.experimental.categories.Category;
2322

2423
public class PullStrategySelectorTest extends ReplicationTestBase {
2524

@@ -35,7 +34,7 @@ private void pull(PullStrategy replicator, int expectedDocs) throws Exception {
3534

3635
@Test
3736
public void pull_filterSelectorBirdFromAnimalDb_twoDocShouldBePulled() throws Exception {
38-
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBV2(remoteDb.couchClient.getRootUri()));
37+
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBVersion2or3(remoteDb.couchClient.getRootUri()));
3938
String selector ="{\"selector\":{\"class\":\"bird\"}}";
4039
PullStrategy replicator = super.getPullStrategy(selector);
4140

@@ -55,7 +54,7 @@ public void pull_filterSelectorBirdFromAnimalDb_twoDocShouldBePulled() throws Ex
5554
public void
5655
pull_filterSelectorMammalFromAnimalDbUsingParameterizedFilter_eightDocShouldBePulled()
5756
throws Exception {
58-
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBV2(remoteDb.couchClient.getRootUri()));
57+
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBVersion2or3(remoteDb.couchClient.getRootUri()));
5958
String selector = "{\"selector\":{\"class\":\"mammal\"}}";
6059
PullStrategy replicator = super.getPullStrategy(selector);
6160

@@ -75,7 +74,7 @@ public void pull_filterSelectorBirdFromAnimalDb_twoDocShouldBePulled() throws Ex
7574
@Test
7675
public void pull_filterSelectorSmallFromAnimalDbUsingIntegerFilter_eightDocShouldBePulled()
7776
throws Exception {
78-
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBV2(remoteDb.couchClient.getRootUri()));
77+
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBVersion2or3(remoteDb.couchClient.getRootUri()));
7978
String selector = "{\"selector\":{\"max_length\":{\"$lte\":2}}}";
8079
PullStrategy replicator = super.getPullStrategy(selector);
8180

@@ -94,7 +93,7 @@ public void pull_filterSelectorSmallFromAnimalDbUsingIntegerFilter_eightDocShoul
9493
@Test
9594
public void pull_filterSelectorSmallFromAnimalDbUsingNullFilter_eightDocShouldBePulled()
9695
throws Exception {
97-
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBV2(remoteDb.couchClient.getRootUri()));
96+
org.junit.Assume.assumeTrue(ClientTestUtils.isCouchDBVersion2or3(remoteDb.couchClient.getRootUri()));
9897
String selector = "{\"selector\":{\"chinese_name\":\"\u718a\u732b\"}}";
9998
PullStrategy replicator = super.getPullStrategy(selector);
10099

0 commit comments

Comments
 (0)