Commit 0b2f6aa8 authored by Ate Douma's avatar Ate Douma

CMS7-7781: revert to literal comparison of the json output as that is actually...

CMS7-7781: revert to literal comparison of the json output as that is actually intended to be checked here as well
parent 6498d908
......@@ -21,7 +21,6 @@ import javax.jcr.Node;
import javax.jcr.nodetype.NodeTypeManager;
import javax.jcr.nodetype.NodeTypeTemplate;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.hippoecm.frontend.PluginTest;
import org.junit.After;
......@@ -151,9 +150,11 @@ public class HippoContentTypeServiceTest extends PluginTest {
assertNotNull(t);
String json = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(t);
final JsonNode jsonNode = new ObjectMapper().readTree(json);
final JsonNode jsonNodeFromFile = new ObjectMapper().readTree(getClass().getResourceAsStream("nt-file.json"));
if (!jsonNode.equals(jsonNodeFromFile)) {
// Note: when updating the nt-file.json file, make sure not to (re)format it and that it doesn't have any trailing (empty) lines.
// The purpose of the literal comparison here, instead of a logical one by just comparing their json
// structure is to ensure the output is actually also in a readable order, and remains so.
String jsonFromFile = new java.util.Scanner(getClass().getResourceAsStream("nt-file.json")).useDelimiter("\\A").next();
if (!json.equals(jsonFromFile)) {
boolean showJson = true;
if (showJson) {
fail("JSON serialization for nt:file doesn't match content for nt-file.json. JSON output: \n"+json+"\n");
......@@ -197,7 +198,7 @@ public class HippoContentTypeServiceTest extends PluginTest {
fail("UnsupportedOperationException expected for ContentTypes.getType(test:test).getItem(test:title).getValidators().clear()");
} catch (UnsupportedOperationException uoe) {}
// repeat sealed check for EffectiveNodeType underlying the ContentType
// repeat sealed check for EffectiveNodeType underlying the ContentType
try {
ctCache.getType("test:test").getEffectiveNodeType().getSuperTypes().clear();
fail("UnsupportedOperationException expected for EffectiveNodeTypes.getType(test:test).getSuperTypes().clear()");
......@@ -298,10 +299,12 @@ public class HippoContentTypeServiceTest extends PluginTest {
assertTrue(ct.getSuperTypes().contains("hippostd:container"));
String json = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(ct);
final JsonNode jsonNode = new ObjectMapper().readTree(json);
final JsonNode jsonNodeFromFile = new ObjectMapper().readTree(getClass().getResourceAsStream("testNode.json"));
if (!jsonNode.equals(jsonNodeFromFile)) {
// Note: when updating the testNode.json file, make sure not to (re)format it and that it doesn't have any trailing (empty) lines.
// The purpose of the literal comparison, instead of a logical one by just comparing their json
// structure is to ensure the output is actually also in a readable order, and remains so.
String jsonFromFile = new java.util.Scanner(getClass().getResourceAsStream("testNode.json")).useDelimiter("\\A").next();
if (!json.equals(jsonFromFile)) {
boolean showJson = true;
if (showJson) {
fail("JSON serialization for testNode doesn't match content for testNode.json. JSON output: \n"+json+"\n");
......
......@@ -25,8 +25,7 @@
"multiTyped" : false,
"multiTypes" : [ ],
"validators" : [ ],
"itemProperties" : {
},
"itemProperties" : { },
"effectiveNodeTypeItem" : {
"name" : "test:title",
"definingType" : "test:test",
......@@ -58,8 +57,7 @@
"multiTyped" : false,
"multiTypes" : [ ],
"validators" : [ ],
"itemProperties" : {
},
"itemProperties" : { },
"effectiveNodeTypeItem" : {
"name" : "*",
"definingType" : "hippostd:relaxed",
......@@ -91,8 +89,7 @@
"multiTyped" : false,
"multiTypes" : [ ],
"validators" : [ ],
"itemProperties" : {
},
"itemProperties" : { },
"effectiveNodeTypeItem" : {
"name" : "jcr:mixinTypes",
"definingType" : "nt:base",
......@@ -124,8 +121,7 @@
"multiTyped" : false,
"multiTypes" : [ ],
"validators" : [ ],
"itemProperties" : {
},
"itemProperties" : { },
"effectiveNodeTypeItem" : {
"name" : "jcr:primaryType",
"definingType" : "nt:base",
......@@ -159,8 +155,7 @@
"multiTyped" : false,
"multiTypes" : [ ],
"validators" : [ ],
"itemProperties" : {
},
"itemProperties" : { },
"effectiveNodeTypeItem" : {
"name" : "test:child",
"definingType" : "test:test",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment