Skip to content

Commit 43d0dfa

Browse files
committed
Fixing a test in StringQueryHostBatcherTest
1 parent 8ebddc5 commit 43d0dfa

File tree

2 files changed

+21
-39
lines changed

2 files changed

+21
-39
lines changed

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

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ public void testServerXQueryTransform() throws IOException, ParserConfigurationE
13471347
* @throws InterruptedException
13481348
*/
13491349
@Test
1350-
public void testQueryBatcherWithForestRemoveAndAdd() throws IOException, InterruptedException
1350+
public void testQueryBatcherWithForestRemoveAndAdd() throws InterruptedException
13511351
{
13521352
System.out.println("Running testQueryBatcherWithForestRemoveAndAdd");
13531353
String testMultipleDB = "QBMultipleForestDB";
@@ -1476,28 +1476,10 @@ public void testQueryBatcherWithForestRemoveAndAdd() throws IOException, Interru
14761476
assertTrue( batchFailResultsRem.toString().contains("Test has Exceptions"));
14771477
}
14781478
}
1479-
} catch (Exception e) {
1480-
System.out.print(e.getMessage());
1481-
fail("testQueryBatcherWithForestRemoveAndAdd method failed");
1482-
}
1483-
1484-
finally {
1485-
// Associate back the original DB.
1486-
try {
1487-
associateRESTServerWithDB(restServerName, dbName);
1488-
} catch (Exception e) {
1489-
e.printStackTrace();
1490-
}
1491-
detachForest(testMultipleDB, testMultipleForest[0]);
1492-
detachForest(testMultipleDB, testMultipleForest[1]);
1493-
// In case something asserts
1494-
detachForest(testMultipleDB, testMultipleForest[2]);
1495-
deleteDB(testMultipleDB);
1496-
1497-
deleteForest(testMultipleForest[0]);
1498-
deleteForest(testMultipleForest[1]);
1499-
deleteForest(testMultipleForest[2]);
1500-
}
1479+
} finally {
1480+
associateRESTServerWithDB(restServerName, dbName);
1481+
deleteDB(testMultipleDB);
1482+
}
15011483
}
15021484

15031485
/*
@@ -1510,9 +1492,7 @@ public void testQueryBatcherWithForestRemoveAndAdd() throws IOException, Interru
15101492
* @throws InterruptedException
15111493
*/
15121494
@Test
1513-
public void testBatchClientLookupTimeout() throws IOException, InterruptedException
1514-
{
1515-
System.out.println("Running testBatchClientLookupTimeout");
1495+
public void testBatchClientLookupTimeout() throws InterruptedException{
15161496
String testMultipleDB = "QBMultipleForestDB";
15171497
String[] testMultipleForest = { "QBMultipleForestDB-1" };
15181498

@@ -1602,9 +1582,6 @@ public void testBatchClientLookupTimeout() throws IOException, InterruptedExcept
16021582
}
16031583
}
16041584
assertTrue( batchResults.toString().isEmpty());
1605-
} catch (Exception e) {
1606-
System.out.print(e.getMessage());
1607-
fail("testBatchClientLookupTimeout method failed");
16081585
} finally {
16091586
associateRESTServerWithDB(restServerName, dbName);
16101587
deleteDB(testMultipleDB);

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/functionaltest/ConnectedRESTQA.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import java.security.cert.X509Certificate;
3939
import java.util.*;
4040

41+
import static org.junit.jupiter.api.Assertions.fail;
42+
4143
public abstract class ConnectedRESTQA {
4244

4345
private static Properties testProperties = null;
@@ -348,10 +350,15 @@ public static void setDatabaseProperties(String dbName, String prop, boolean pro
348350
* root property name else if it has an existing sub property name then it
349351
* adds elements to that array
350352
*/
351-
private static void setDatabaseProperties(String dbName, String propName, ObjectNode objNode) throws IOException {
353+
private static void setDatabaseProperties(String dbName, String propName, ObjectNode objNode) {
352354
ManageClient client = newManageClient();
353355
String databaseProperties = new DatabaseManager(client).getPropertiesAsJson(dbName);
354-
JsonNode jnode = new ObjectMapper().readTree(databaseProperties);
356+
JsonNode jnode = null;
357+
try {
358+
jnode = new ObjectMapper().readTree(databaseProperties);
359+
} catch (JsonProcessingException e) {
360+
fail("Could not parse database-properties: " + databaseProperties + "; cause: " + e.getMessage());
361+
}
355362

356363
if (!jnode.has(propName)) {
357364
((ObjectNode) jnode).putArray(propName).addAll(objNode.withArray(propName));
@@ -374,7 +381,7 @@ public static void enableCollectionLexicon(String dbName) {
374381
setDatabaseProperties(dbName, "collection-lexicon", true);
375382
}
376383

377-
public static void enableWordLexicon(String dbName) throws Exception {
384+
public static void enableWordLexicon(String dbName) {
378385
ObjectMapper mapper = new ObjectMapper();
379386
ObjectNode childNode = mapper.createObjectNode();
380387
ArrayNode childArray = mapper.createArrayNode();
@@ -395,13 +402,11 @@ public static void setMaintainLastModified(String dbName, boolean opt) {
395402
* This function constructs a range element index with default
396403
* collation,range-value-positions and invalid values
397404
*/
398-
public static void addRangeElementIndex(String dbName, String type, String namespace, String localname)
399-
throws Exception {
405+
public static void addRangeElementIndex(String dbName, String type, String namespace, String localname) {
400406
addRangeElementIndex(dbName, type, namespace, localname, false);
401407
}
402408

403-
public static void addRangeElementIndex(String dbName, String type, String namespace, String localname,
404-
boolean positions) throws Exception {
409+
public static void addRangeElementIndex(String dbName, String type, String namespace, String localname, boolean positions) {
405410
ObjectMapper mapper = new ObjectMapper();
406411
ObjectNode mainNode = mapper.createObjectNode();
407412

@@ -419,7 +424,7 @@ public static void addRangeElementIndex(String dbName, String type, String names
419424
setDatabaseProperties(dbName, "range-element-index", mainNode);
420425
}
421426

422-
public static void addRangeElementIndex(String dbName, String[][] rangeElements) throws Exception {
427+
public static void addRangeElementIndex(String dbName, String[][] rangeElements) {
423428
ObjectMapper mapper = new ObjectMapper();
424429
ObjectNode mainNode = mapper.createObjectNode();
425430

@@ -530,7 +535,7 @@ public static void addRangePathIndex(String dbName, String type, String pathexpr
530535
setDatabaseProperties(dbName, "range-path-index", childNode);
531536
}
532537

533-
public static void addRangePathIndex(String dbName, String[][] rangePaths) throws Exception {
538+
public static void addRangePathIndex(String dbName, String[][] rangePaths) {
534539
ObjectMapper mapper = new ObjectMapper();
535540
ObjectNode childNode = mapper.createObjectNode();
536541
ArrayNode childArray = mapper.createArrayNode();
@@ -585,7 +590,7 @@ public static void addPathNamespace(String dbName, String[][] pathNamespace) thr
585590
setDatabaseProperties(dbName, "path-namespace", childNode);
586591
}
587592

588-
public static void setupAppServicesConstraint(String dbName) throws Exception {
593+
public static void setupAppServicesConstraint(String dbName) {
589594
// Add new range elements into this array
590595
String[][] rangeElements = {
591596
// { scalar-type, namespace-uri, localname, collation,

0 commit comments

Comments
 (0)