Skip to content

Commit da1a57e

Browse files
committed
Test fixes for 12 nightly
1 parent f5c4132 commit da1a57e

File tree

5 files changed

+342
-11
lines changed

5 files changed

+342
-11
lines changed

marklogic-client-api/src/test/java/com/marklogic/client/test/PlanGeneratedTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818

1919
import com.marklogic.client.io.Format;
2020
import com.marklogic.client.test.junit5.RequiresML11;
21+
import com.marklogic.client.test.junit5.RequiresML11OrLower;
2122
import com.marklogic.client.type.ServerExpression;
2223
import org.junit.jupiter.api.Test;
2324
import org.junit.jupiter.api.extension.ExtendWith;
2425

2526
// IMPORTANT: Do not edit. This file is generated.
2627
// Exception - some of these tests cannot pass on ML <= 10. Those have been modified to not run unless ML is >= 11.
28+
// Other tests have been disabled to not run on ML >= 12. Getting those tests to pass would require running the Optic
29+
// code generator workspace on src/main/java, which would then prevent many of the tests from passing on ML <= 11.
2730
public class PlanGeneratedTest extends PlanGeneratedBase {
2831

2932
@Test
@@ -326,6 +329,7 @@ public void testFnFormatTime2Exec() {
326329
executeTester("testFnFormatTime2", p.fn.formatTime(p.col("1"), p.col("2")), false, null, null, null, "10:09:08:00", new ServerExpression[]{ p.xs.time("10:09:08Z"), p.xs.string("[H01]:[m01]:[s01]:[f01]") });
327330
}
328331

332+
@ExtendWith(RequiresML11OrLower.class)
329333
@Test
330334
public void testFnHead1Exec() {
331335
executeTester("testFnHead1", p.fn.head(p.col("1")), false, null, null, null, "a", new ServerExpression[]{ p.xs.stringSeq(p.xs.string("a"), p.xs.string("b"), p.xs.string("c")) });
@@ -471,6 +475,7 @@ public void testFnNumber1Exec() {
471475
executeTester("testFnNumber1", p.fn.number(p.col("1")), false, null, null, null, "1.1", new ServerExpression[]{ p.xs.string("1.1") });
472476
}
473477

478+
@ExtendWith(RequiresML11OrLower.class)
474479
@Test
475480
public void testFnPrefixFromQName1Exec() {
476481
executeTester("testFnPrefixFromQName1", p.fn.prefixFromQName(p.col("1")), false, null, null, Format.JSON, null, new ServerExpression[]{ p.xs.QName("abc") });
@@ -1825,6 +1830,7 @@ public void testXsNCName1Exec() {
18251830
executeTester("testXsNCName1", p.xs.NCName(p.col("1")), false, null, null, null, "a-b-c", new ServerExpression[]{ p.xs.string("a-b-c") });
18261831
}
18271832

1833+
@ExtendWith(RequiresML11OrLower.class)
18281834
@Test
18291835
public void testXsNegativeInteger1Exec() {
18301836
executeTester("testXsNegativeInteger1", p.xs.negativeInteger(p.col("1")), false, null, null, null, "-1", new ServerExpression[]{ p.xs.doubleVal(-1) });
@@ -1835,11 +1841,13 @@ public void testXsNMTOKEN1Exec() {
18351841
executeTester("testXsNMTOKEN1", p.xs.NMTOKEN(p.col("1")), false, null, null, null, "a:b:c", new ServerExpression[]{ p.xs.string("a:b:c") });
18361842
}
18371843

1844+
@ExtendWith(RequiresML11OrLower.class)
18381845
@Test
18391846
public void testXsNonNegativeInteger1Exec() {
18401847
executeTester("testXsNonNegativeInteger1", p.xs.nonNegativeInteger(p.col("1")), false, null, null, null, "0", new ServerExpression[]{ p.xs.string("0") });
18411848
}
18421849

1850+
@ExtendWith(RequiresML11OrLower.class)
18431851
@Test
18441852
public void testXsNonPositiveInteger1Exec() {
18451853
executeTester("testXsNonPositiveInteger1", p.xs.nonPositiveInteger(p.col("1")), false, null, null, null, "0", new ServerExpression[]{ p.xs.string("0") });
@@ -1855,6 +1863,7 @@ public void testXsNumeric1Exec() {
18551863
executeTester("testXsNumeric1", p.xs.numeric(p.col("1")), false, null, null, null, "1.2", new ServerExpression[]{ p.xs.doubleVal(1.2) });
18561864
}
18571865

1866+
@ExtendWith(RequiresML11OrLower.class)
18581867
@Test
18591868
public void testXsPositiveInteger1Exec() {
18601869
executeTester("testXsPositiveInteger1", p.xs.positiveInteger(p.col("1")), false, null, null, null, "1", new ServerExpression[]{ p.xs.doubleVal(1) });
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.marklogic.client.test.junit5;
2+
3+
import com.marklogic.client.test.Common;
4+
import com.marklogic.client.test.MarkLogicVersion;
5+
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
6+
import org.junit.jupiter.api.extension.ExecutionCondition;
7+
import org.junit.jupiter.api.extension.ExtensionContext;
8+
9+
public class RequiresML11OrLower implements ExecutionCondition {
10+
11+
private static MarkLogicVersion markLogicVersion;
12+
13+
@Override
14+
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
15+
if (markLogicVersion == null) {
16+
markLogicVersion = Common.getMarkLogicVersion();
17+
}
18+
return markLogicVersion.getMajor() <= 11 ?
19+
ConditionEvaluationResult.enabled("MarkLogic major version is 11 or lower") :
20+
ConditionEvaluationResult.disabled("MarkLogic major version is 12 or higher");
21+
}
22+
}

marklogic-client-api/src/test/java/com/marklogic/client/test/rows/ColumnInfoTest.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,39 @@
88
import com.marklogic.client.row.RawQueryDSLPlan;
99
import com.marklogic.client.row.RowManager;
1010
import com.marklogic.client.test.Common;
11+
import com.marklogic.client.test.MarkLogicVersion;
1112
import com.marklogic.client.test.junit5.RequiresML11;
1213
import org.junit.jupiter.api.BeforeEach;
1314
import org.junit.jupiter.api.Test;
1415
import org.junit.jupiter.api.extension.ExtendWith;
1516
import org.skyscreamer.jsonassert.JSONAssert;
1617
import org.springframework.core.io.ClassPathResource;
1718

19+
import java.io.IOException;
20+
1821
import static org.junit.jupiter.api.Assertions.assertEquals;
1922
import static org.junit.jupiter.api.Assertions.assertTrue;
2023

2124
@ExtendWith(RequiresML11.class)
2225
public class ColumnInfoTest {
2326

2427
private RowManager rowManager;
28+
private static final ObjectMapper objectMapper = new ObjectMapper();
2529

2630
@BeforeEach
2731
void beforeEach() {
2832
rowManager = Common.connect().newRowManager();
2933
}
3034

3135
@Test
32-
void allTypesWithDSLPlan() {
36+
void allTypesWithDSLPlan() throws Exception {
3337
String query = "op.fromView('javaClient', 'allTypes')";
3438
RawQueryDSLPlan plan = rowManager.newRawQueryDSLPlan(new StringHandle(query));
3539
verifyColumnInfo(plan);
3640
}
3741

3842
@Test
39-
void allTypesWithSerializedPlan() {
43+
void allTypesWithSerializedPlan() throws Exception {
4044
String serializedQuery = "{\n" +
4145
" \"$optic\": {\n" +
4246
" \"ns\": \"op\",\n" +
@@ -64,7 +68,7 @@ void allTypesWithSerializedPlan() {
6468
*
6569
* @param plan
6670
*/
67-
private void verifyColumnInfo(PlanBuilder.Plan plan) {
71+
private void verifyColumnInfo(PlanBuilder.Plan plan) throws Exception {
6872
StringHandle output = Common.client.newRowManager().columnInfo(plan, new StringHandle());
6973

7074
assertTrue(output.getServerTimestamp() > 0, "The server timestamp should be present so that a client, such as " +
@@ -74,13 +78,17 @@ private void verifyColumnInfo(PlanBuilder.Plan plan) {
7478
assertEquals(36, columnInfos.length, "There are 35 column definitions in the allTypes TDE, and then a 36th " +
7579
"column info is added for the rowid column.");
7680

77-
ObjectMapper mapper = new ObjectMapper();
78-
try {
79-
JsonNode actualColumnInfo = mapper.readTree("[" + String.join(",", columnInfos) + "]");
80-
JsonNode expectedColumnInfo = mapper.readTree(new ClassPathResource("allTypes-columnInfo.json").getInputStream());
81-
JSONAssert.assertEquals(expectedColumnInfo.toString(), actualColumnInfo.toString(), true);
82-
} catch (Exception ex) {
83-
throw new RuntimeException(ex);
84-
}
81+
JsonNode actualColumnInfo = objectMapper.readTree("[" + String.join(",", columnInfos) + "]");
82+
JsonNode expectedColumnInfo = getExpectedColumnInfo();
83+
JSONAssert.assertEquals(expectedColumnInfo.toString(), actualColumnInfo.toString(), true);
84+
}
85+
86+
private JsonNode getExpectedColumnInfo() throws IOException {
87+
MarkLogicVersion version = Common.getMarkLogicVersion();
88+
String file = version.getMajor() <= 11 ?
89+
"columnInfo/allTypes-marklogic-11.json" :
90+
"columnInfo/allTypes-marklogic-12.json";
91+
92+
return objectMapper.readTree(new ClassPathResource(file).getInputStream());
8593
}
8694
}

0 commit comments

Comments
 (0)