Skip to content

Commit cd1d847

Browse files
committed
Fixing compiler warnings
Prepping for 6.4.0 release.
1 parent 4eeca8b commit cd1d847

File tree

3 files changed

+49
-61
lines changed

3 files changed

+49
-61
lines changed

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -742,25 +742,18 @@ public void testMinHosts() throws Exception {
742742
}
743743

744744
@Test
745-
public void testWhiteBlackListNPE() throws Exception {
745+
public void testWhiteBlackListNPE() {
746746
Assumptions.assumeTrue(hostNames.length > 1);
747747

748-
System.out.println(Thread.currentThread().getStackTrace()[1].getMethodName());
749-
try {
750-
FilteredForestConfiguration forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig())
751-
.withBlackList(null);
752-
assertTrue(1 > 2);
753-
} catch (Exception e) {
754-
assertTrue(e instanceof java.lang.IllegalArgumentException);
755-
}
748+
assertThrows(IllegalArgumentException.class, () -> {
749+
String[] hostNames = null;
750+
new FilteredForestConfiguration(dmManager.readForestConfig()).withBlackList(hostNames);
751+
});
756752

757-
try {
758-
FilteredForestConfiguration forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig())
759-
.withWhiteList(null);
760-
assertTrue(1 > 2);
761-
} catch (Exception e) {
762-
assertTrue(e instanceof java.lang.IllegalArgumentException);
763-
}
753+
assertThrows(IllegalArgumentException.class, () -> {
754+
String[] hostNames = null;
755+
new FilteredForestConfiguration(dmManager.readForestConfig()).withWhiteList(hostNames);
756+
});
764757
}
765758

766759
private void serverStartStop(String server, String command) throws Exception {

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

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,13 +2401,12 @@ public void testQBWhiteList() throws Exception {
24012401
});
24022402
qb.onQueryFailure(throwable -> throwable.printStackTrace());
24032403

2404-
try {
2405-
forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig()).withWhiteList(null);
2406-
fail("hostnames shouldn't be null");
2404+
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> {
2405+
String[] hostNames = null;
2406+
new FilteredForestConfiguration(dmManager.readForestConfig()).withWhiteList(hostNames);
2407+
});
2408+
assertEquals("hostNames must not be null", ex.getMessage());
24072409

2408-
} catch (IllegalArgumentException e) {
2409-
assertEquals("hostNames must not be null", e.getMessage());
2410-
}
24112410
try {
24122411
forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig()).withWhiteList("asdf");
24132412
qb.withBatchSize(50).withForestConfig(forestConfig);
@@ -2440,13 +2439,12 @@ public void testWBWhiteList() throws Exception {
24402439
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 0);
24412440

24422441
WriteBatcher ihb2 = dmManager.newWriteBatcher();
2443-
try {
2444-
forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig()).withWhiteList(null);
2445-
fail("hostnames shouldn't be null");
24462442

2447-
} catch (IllegalArgumentException e) {
2448-
assertEquals("hostNames must not be null", e.getMessage());
2449-
}
2443+
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> {
2444+
String[] hostNames = null;
2445+
new FilteredForestConfiguration(dmManager.readForestConfig()).withWhiteList(hostNames);
2446+
});
2447+
assertEquals("hostNames must not be null", ex.getMessage());
24502448

24512449
try {
24522450
forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig()).withWhiteList("asdf");
@@ -2479,7 +2477,7 @@ public void testWBWhiteList() throws Exception {
24792477
}
24802478

24812479
@Test
2482-
public void testQBBlackList() throws Exception {
2480+
public void testQBBlackList() {
24832481
Assumptions.assumeTrue(!isLBHost());
24842482
Assumptions.assumeTrue(hostNames.length > 1);
24852483
System.out.println("In testQBBlackList method");
@@ -2517,13 +2515,11 @@ public void testQBBlackList() throws Exception {
25172515
});
25182516
qb.onQueryFailure(throwable -> throwable.printStackTrace());
25192517

2520-
try {
2521-
forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig()).withBlackList(null);
2522-
fail("hostnames shouldn't be null");
2523-
2524-
} catch (IllegalArgumentException e) {
2525-
assertEquals("hostNames must not be null", e.getMessage());
2526-
}
2518+
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> {
2519+
String[] hostNames = null;
2520+
new FilteredForestConfiguration(dmManager.readForestConfig()).withBlackList(hostNames);
2521+
});
2522+
assertEquals("hostNames must not be null", ex.getMessage());
25272523

25282524
try {
25292525
forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig()).withBlackList(hostNames)
@@ -2545,7 +2541,7 @@ public void testQBBlackList() throws Exception {
25452541
}
25462542

25472543
@Test
2548-
public void testWBBlackList() throws Exception {
2544+
public void testWBBlackList() {
25492545
Assumptions.assumeTrue(!isLBHost());
25502546
Assumptions.assumeTrue(hostNames.length > 1);
25512547
System.out.println("In testWBBlackList method");
@@ -2558,13 +2554,12 @@ public void testWBBlackList() throws Exception {
25582554
assertTrue(dbClient.newServerEval().xquery(query1).eval().next().getNumber().intValue() == 0);
25592555

25602556
WriteBatcher ihb2 = dmManager.newWriteBatcher();
2561-
try {
2562-
forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig()).withWhiteList(null);
2563-
fail("hostnames shouldn't be null");
25642557

2565-
} catch (IllegalArgumentException e) {
2566-
assertEquals("hostNames must not be null", e.getMessage());
2567-
}
2558+
IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, () -> {
2559+
String[] hostNames = null;
2560+
new FilteredForestConfiguration(dmManager.readForestConfig()).withWhiteList(hostNames);
2561+
});
2562+
assertEquals("hostNames must not be null", ex.getMessage());
25682563

25692564
forestConfig = new FilteredForestConfiguration(dmManager.readForestConfig()).withBlackList("asdf");
25702565
ihb2.withBatchSize(50).withForestConfig(forestConfig);

ml-development-tools/src/test/kotlin/com/marklogic/client/test/dbfunction/fntestgen.kt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -646,12 +646,12 @@ if (true) {
646646
val responseBodyTypes = listOf("none", "text", "document", "multipart")
647647
for (responseBodyNum in responseBodyTypes.indices) {
648648
val responseBodyType = responseBodyTypes[responseBodyNum]
649-
val responseBody = responseBodyType.capitalize()
649+
val responseBody = responseBodyType.replaceFirstChar {it.uppercase()}
650650

651651
val requestBodyTypes = listOf("none", "urlencoded", "multipart")
652652
for (requestBodyNum in requestBodyTypes.indices) {
653653
val requestBodyType = requestBodyTypes[requestBodyNum]
654-
val requestBody = requestBodyType.capitalize()
654+
val requestBody = requestBodyType.replaceFirstChar {it.uppercase()}
655655
val modExtension = modExtensions[(responseBodyNum + requestBodyNum) % modExtensions.size]
656656

657657
val requestParams =
@@ -697,7 +697,7 @@ if (true) {
697697
val testBaseEnd = "For$responseBody"
698698

699699
val testBundle = testBaseStart+testBaseEnd
700-
val bundleTested = testBundle.capitalize()+"Bundle"
700+
val bundleTested = testBundle.replaceFirstChar {it.uppercase()}+"Bundle"
701701
val bundleTester = bundleTested+"Test"
702702
val bundleJSONPath = "$jsonPath$testBundle/"
703703
val bundleFilename = bundleJSONPath+"service.json"
@@ -775,7 +775,7 @@ if (true) {
775775
"name" to "param1", "datatype" to atomicCurr,
776776
"multiple" to testMultiple, "nullable" to testNullable
777777
))
778-
val testName = testBaseStart+atomicCurr.capitalize()+testBaseEnd+testNum
778+
val testName = testBaseStart+atomicCurr.replaceFirstChar {it.uppercase()}+testBaseEnd+testNum
779779
val testdef =
780780
if (responseReturnValue === null) mapOf(
781781
"functionName" to testName, "params" to funcParams
@@ -939,7 +939,7 @@ if (true) {
939939
"multiple" to testMultiple, "nullable" to testNullable
940940
))
941941
val testMax = 2
942-
val docTestName = testBaseStart+docCurr.capitalize()+testBaseEnd+(testNum * testMax)
942+
val docTestName = testBaseStart+docCurr.replaceFirstChar {it.uppercase()}+testBaseEnd+(testNum * testMax)
943943
val docTestdef =
944944
if (responseReturnValue === null) mapOf(
945945
"functionName" to docTestName, "params" to docFuncParams
@@ -955,7 +955,7 @@ if (true) {
955955
mapOf("name" to "param3", "datatype" to atomic2)
956956
)
957957

958-
val testName = testBaseStart+docCurr.capitalize()+testBaseEnd+((testNum * testMax) + j - 1)
958+
val testName = testBaseStart+docCurr.replaceFirstChar {it.uppercase()}+testBaseEnd+((testNum * testMax) + j - 1)
959959
val testdef1 = replaceFuncName(docTestdef, testName)
960960
val testdef2 =
961961
if (j < testMax) testdef1
@@ -1089,7 +1089,7 @@ if (true) {
10891089
val funcReturn = mapOf(
10901090
"datatype" to atomicCurr, "nullable" to testNullable
10911091
)
1092-
val testName = testBaseStart+testBaseEnd+atomicCurr.capitalize()+testNum
1092+
val testName = testBaseStart+testBaseEnd+atomicCurr.replaceFirstChar {it.uppercase()}+testNum
10931093
val testdef =
10941094
if (requestParams === null) mapOf(
10951095
"functionName" to testName, "return" to funcReturn
@@ -1211,7 +1211,7 @@ if (true) {
12111211
"datatype" to docCurr,
12121212
"multiple" to testMultiple, "nullable" to testNullable
12131213
)
1214-
val testName = testBaseStart+testBaseEnd+docCurr.capitalize()+testNum
1214+
val testName = testBaseStart+testBaseEnd+docCurr.replaceFirstChar {it.uppercase()}+testNum
12151215
val testdef =
12161216
if (requestParams === null) mapOf(
12171217
"functionName" to testName, "return" to funcReturn
@@ -1305,7 +1305,7 @@ if (true) {
13051305
"datatype" to docCurr,
13061306
"multiple" to testMultiple, "nullable" to testNullable
13071307
)
1308-
val testName = testBaseStart + testBaseEnd + docCurr.capitalize() + testNum
1308+
val testName = testBaseStart + testBaseEnd + docCurr.replaceFirstChar {it.uppercase()} + testNum
13091309
val testdef =
13101310
if (requestParams === null) mapOf(
13111311
"functionName" to testName, "return" to funcReturn
@@ -1421,7 +1421,7 @@ if (true) {
14211421
if (true) {
14221422
val atomicMappingConstructors = getAtomicMappingConstructors()
14231423
val atomicMappingBundle = "mapAtomics"
1424-
val atomicMappingBundleTested = atomicMappingBundle.capitalize()+"Bundle"
1424+
val atomicMappingBundleTested = atomicMappingBundle.replaceFirstChar {it.uppercase()}+"Bundle"
14251425
val atomicMappingBundleTester = atomicMappingBundleTested+"Test"
14261426
val atomicMappingBundleJSONPath = "$jsonPath$atomicMappingBundle/"
14271427
val atomicMappingBundleFilename = atomicMappingBundleJSONPath+"service.json"
@@ -1438,12 +1438,12 @@ if (true) {
14381438
val atomicMappingDatatypes = atomicMappingConstructors.keys.toTypedArray()
14391439
for (datatypeNum in atomicMappingDatatypes.indices) {
14401440
val datatype = atomicMappingDatatypes[datatypeNum]
1441-
val testBaseStart = atomicMappingBundle+datatype.capitalize()
1441+
val testBaseStart = atomicMappingBundle+datatype.replaceFirstChar {it.uppercase()}
14421442
val datatypeConstructors = atomicMappingConstructors[datatype] as Map<String,String>
14431443
val modExtension = modExtensions[datatypeNum % modExtensions.size]
14441444
for (mappedType in datatypeConstructors.keys) {
1445-
// mappedType.capitalize().replace('.', '_')
1446-
val testMapped = mappedType.split('.').joinToString("") { word -> word.capitalize() }
1445+
// mappedType.replaceFirstChar {it.uppercase()}.replace('.', '_')
1446+
val testMapped = mappedType.split('.').joinToString("") { word -> word.replaceFirstChar {it.uppercase()} }
14471447
val mappedConstructor = datatypeConstructors[mappedType] as String
14481448
val typeConstructors = mapOf(datatype to mappedConstructor)
14491449
for (testNum in allTestTypes.indices) {
@@ -1511,7 +1511,7 @@ if (true) {
15111511
if (true) {
15121512
val documentMappingConstructors = getDocumentMappingConstructors()
15131513
val documentMappingBundle = "mapDocuments"
1514-
val documentMappingBundleTested = documentMappingBundle.capitalize()+"Bundle"
1514+
val documentMappingBundleTested = documentMappingBundle.replaceFirstChar {it.uppercase()}+"Bundle"
15151515
val documentMappingBundleTester = documentMappingBundleTested+"Test"
15161516
val documentMappingBundleJSONPath = "$jsonPath$documentMappingBundle/"
15171517
val documentMappingBundleFilename = documentMappingBundleJSONPath+"service.json"
@@ -1528,11 +1528,11 @@ if (true) {
15281528
val documentMappedDatatypes = documentMappingConstructors.keys.toTypedArray()
15291529
for (datatypeNum in documentMappedDatatypes.indices) {
15301530
val datatype = documentMappedDatatypes[datatypeNum]
1531-
val testBaseStart = documentMappingBundle+datatype.capitalize()
1531+
val testBaseStart = documentMappingBundle+datatype.replaceFirstChar {it.uppercase()}
15321532
val datatypeConstructors = documentMappingConstructors[datatype] as Map<String,String>
15331533
val modExtension = modExtensions[datatypeNum % modExtensions.size]
15341534
for (mappedType in datatypeConstructors.keys) {
1535-
val testMapped = mappedType.split('.').joinToString("") { word -> word.capitalize() }
1535+
val testMapped = mappedType.split('.').joinToString("") { word -> word.replaceFirstChar {it.uppercase()} }
15361536
val mappedConstructor = datatypeConstructors[mappedType] as String
15371537
val typeConstructors = mapOf(datatype to mappedConstructor)
15381538
for (testNum in allTestTypes.indices) {
@@ -1662,8 +1662,8 @@ if (true) {
16621662
)
16631663
val moduleInitTestString = serializer.writeValueAsString(moduleInitTestdef)
16641664
for (modExtension in modExtensions) {
1665-
val moduleInitBundle = "moduleInit"+modExtension.capitalize()
1666-
val moduleInitBundleTested = moduleInitBundle.capitalize()+"Bundle"
1665+
val moduleInitBundle = "moduleInit"+modExtension.replaceFirstChar {it.uppercase()}
1666+
val moduleInitBundleTested = moduleInitBundle.replaceFirstChar {it.uppercase()}+"Bundle"
16671667
val moduleInitBundleTester = moduleInitBundleTested+"Test"
16681668
val moduleInitBundleJSONPath = "$jsonPath$moduleInitBundle/"
16691669
val moduleInitBundleFilename = moduleInitBundleJSONPath+"service.json"

0 commit comments

Comments
 (0)