Skip to content

Commit ac98396

Browse files
author
ssambasu
committed
Include ConnectionType for DeleteListenerTest
1 parent 4faffb3 commit ac98396

File tree

1 file changed

+15
-15
lines changed
  • marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/datamovement/functionaltests

1 file changed

+15
-15
lines changed

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/datamovement/functionaltests/DeleteListenerTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.util.HashSet;
1818
import java.util.Iterator;
1919
import java.util.Map;
20+
import java.util.Random;
2021
import java.util.Set;
2122
import java.util.concurrent.atomic.AtomicInteger;
2223

@@ -63,8 +64,6 @@ public class DeleteListenerTest extends BasicJavaClientREST {
6364
private static int port = 8000;
6465
private static String password = "admin";
6566
private static String server = "App-Services";
66-
private static JsonNode clusterInfo;
67-
6867
private static JacksonHandle jacksonHandle;
6968
private static StringHandle stringHandle;
7069
private static FileHandle fileHandle;
@@ -76,6 +75,7 @@ public class DeleteListenerTest extends BasicJavaClientREST {
7675
private static JsonNode jsonNode;
7776
private static final String query1 = "fn:count(fn:doc())";
7877
private static String[] hostNames;
78+
private static int forestCount = 1;
7979

8080
@BeforeClass
8181
public static void setUpBeforeClass() throws Exception {
@@ -87,12 +87,16 @@ public static void setUpBeforeClass() throws Exception {
8787
hostNames = getHosts();
8888
createDB(dbName);
8989
Thread.currentThread().sleep(500L);
90-
int count = 1;
91-
for (String forestHost : hostNames) {
92-
createForestonHost(dbName + "-" + count, dbName, forestHost);
93-
count++;
94-
Thread.currentThread().sleep(500L);
95-
}
90+
//Ensure db has atleast one forest
91+
createForestonHost(dbName + "-" + forestCount, dbName, hostNames[0]);
92+
forestCount++;
93+
for (String forestHost : hostNames) {
94+
for(int i = 0; i < new Random().nextInt(3); i++) {
95+
createForestonHost(dbName + "-" + forestCount, dbName, forestHost);
96+
forestCount++;
97+
}
98+
Thread.currentThread().sleep(500L);
99+
}
96100
// Create App Server if needed.
97101
createRESTServerWithDB(server, port);
98102

@@ -101,13 +105,10 @@ public static void setUpBeforeClass() throws Exception {
101105
enableSecurityOnRESTServer(server, dbName);
102106
}
103107

104-
dbClient = getDatabaseClient(user, password, Authentication.DIGEST);
108+
dbClient = getDatabaseClient(user, password, getConnType());
105109
DatabaseClient adminClient = DatabaseClientFactory.newClient(host, 8000, user, password, Authentication.DIGEST);
106110
dmManager = dbClient.newDataMovementManager();
107111

108-
clusterInfo = ((DatabaseClientImpl) adminClient).getServices()
109-
.getResource(null, "internal/forestinfo", null, null, new JacksonHandle()).get();
110-
111112
// JacksonHandle
112113
jsonNode = new ObjectMapper().readTree("{\"k1\":\"v1\"}");
113114
jacksonHandle = new JacksonHandle();
@@ -129,7 +130,7 @@ public static void setUpBeforeClass() throws Exception {
129130
@AfterClass
130131
public static void tearDownAfterClass() throws Exception {
131132
associateRESTServerWithDB(server, "Documents");
132-
for (int i = 0; i < hostNames.length; i++) {
133+
for (int i = 0; i < forestCount -1; i++) {
133134
System.out.println(dbName + "-" + (i + 1));
134135
detachForest(dbName, dbName + "-" + (i + 1));
135136
deleteForest(dbName + "-" + (i + 1));
@@ -176,8 +177,7 @@ public void massDeleteSingleThread() throws Exception {
176177
Assert.assertTrue(uriSet.isEmpty());
177178
Assert.assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 2000);
178179

179-
QueryBatcher queryBatcher = dmManager.newQueryBatcher(
180-
new StructuredQueryBuilder().collection("DeleteListener"))
180+
QueryBatcher queryBatcher = dmManager.newQueryBatcher(new StructuredQueryBuilder().collection("DeleteListener"))
181181
.withBatchSize(11)
182182
.withThreadCount(1)
183183
.onUrisReady(batch -> {

0 commit comments

Comments
 (0)