Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit f41af07

Browse files
committed
Fixing test so it runs on both ML8 and ML9
1 parent 8f77938 commit f41af07

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/main/java/com/marklogic/mgmt/clusters/ClusterManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.marklogic.mgmt.ManageClient;
55
import com.marklogic.mgmt.admin.ActionRequiringRestart;
66
import com.marklogic.mgmt.admin.AdminManager;
7+
import com.marklogic.rest.util.Fragment;
78

89
public class ClusterManager extends AbstractManager {
910

@@ -29,4 +30,9 @@ public boolean execute() {
2930
}
3031
});
3132
}
33+
34+
public String getVersion() {
35+
Fragment f = manageClient.getXml("/manage/v2");
36+
return f.getElementValue("/c:local-cluster-default/c:version");
37+
}
3238
}

src/main/java/com/marklogic/rest/util/Fragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public Fragment(String xml, Namespace... namespaces) {
2929
try {
3030
internalDoc = new SAXBuilder().build(new StringReader(xml));
3131
List<Namespace> list = new ArrayList<Namespace>();
32+
list.add(Namespace.getNamespace("c", "http://marklogic.com/manage/clusters"));
3233
list.add(Namespace.getNamespace("db", "http://marklogic.com/manage/databases"));
3334
list.add(Namespace.getNamespace("f", "http://marklogic.com/manage/forests"));
3435
list.add(Namespace.getNamespace("h", "http://marklogic.com/manage/hosts"));

src/test/java/com/marklogic/appdeployer/command/viewschemas/ManageViewSchemasTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.marklogic.appdeployer.command.viewschemas;
22

3+
import com.marklogic.mgmt.clusters.ClusterManager;
34
import org.jdom2.Namespace;
45
import org.springframework.http.ResponseEntity;
56
import org.springframework.web.client.RestTemplate;
@@ -67,9 +68,13 @@ protected void afterResourcesCreated() {
6768
String body = response.getBody();
6869
body = body.substring(body.indexOf("<json:array"));
6970

71+
String version = new ClusterManager(manageClient).getVersion();
72+
// This changed between ML8 and ML9
73+
String expectedAmount = version != null && version.startsWith("8") ? "amount": "main.ordertable.amount";
74+
7075
Fragment xml = new Fragment("<results>" + body + "</results>",
7176
Namespace.getNamespace("json", "http://marklogic.com/xdmp/json"));
72-
xml.assertElementValue("/results/json:array[1]/json:value", "amount");
77+
xml.assertElementValue("/results/json:array[1]/json:value", expectedAmount);
7378
xml.assertElementValue("/results/json:array[2]/json:value", "111");
7479
xml.assertElementValue("/results/json:array[3]/json:value", "222");
7580
}

0 commit comments

Comments
 (0)