@Override protected <O extends ObjectType> void write(Writer writer, PrismObject<O> object) throws SchemaException, IOException { String xml = serializer.serialize(object); writer.write(xml); }
@Test @SuppressWarnings("Duplicates") public void testParseRoundTripAsPO() throws Exception{ displayTestTitle("testParseRoundTripAsPO"); processParsingsPO(v -> getPrismContext().serializerFor(language).serialize(v), "s0", true); processParsingsPO(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serialize(v), "s1", false); processParsingsPO(v -> getPrismContext().serializerFor(language).root(SchemaConstantsGenerated.C_USER).serialize(v), "s2", false); // misleading item name processParsingsPO(v -> getPrismContext().serializerFor(language).serializeRealValue(v.asObjectable()), "s3", false); processParsingsPO(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serializeAnyData(v.asObjectable()), "s4", false); }
@Test @SuppressWarnings("Duplicates") public void testParseRoundTripAsPO() throws Exception{ displayTestTitle("testParseRoundTripAsPO"); processParsingsPO(v -> getPrismContext().serializerFor(language).serialize(v), "s0", true); processParsingsPO(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serialize(v), "s1", false); processParsingsPO(v -> getPrismContext().serializerFor(language).root(SchemaConstantsGenerated.C_SYSTEM_CONFIGURATION).serialize(v), "s2", false); // misleading item name processParsingsPO(v -> getPrismContext().serializerFor(language).serializeRealValue(v.asObjectable()), "s3", false); processParsingsPO(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serializeAnyData(v.asObjectable()), "s4", false); }
public static void displaySearchFilterType(SearchFilterType filterType) throws SchemaException { MapXNode mapXNode = filterType.getFilterClauseXNode(); String dumpX = mapXNode.debugDump(); LOGGER.info(dumpX); System.out.println("filter clause xnode:\n" + dumpX + "\n"); String dumpXml = prismContext.xmlSerializer().serialize( prismContext.xnodeFactory().root(new QName("filterClauseXNode"), mapXNode)); System.out.println("filter clause xnode serialized:\n" + dumpXml + "\n"); }
@Test public void testParseRoundTrip() throws Exception { displayTestTitle("testParseRoundTrip"); processParsings(v -> getPrismContext().serializerFor(language).serialize(v), "s0"); processParsings(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serialize(v), "s1"); processParsings(v -> getPrismContext().serializerFor(language).root(SchemaConstantsGenerated.C_USER).serialize(v), "s2"); // misleading item name processParsings(v -> getPrismContext().serializerFor(language).serializeRealValue(v.getValue()), "s3"); processParsings(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serializeAnyData(v.getValue()), "s4"); }
@Test public void testParseToXNode() throws Exception { PrismContext prismContext = PrismTestUtil.getPrismContext(); RootXNode node = prismContext.parserFor(getFile()).parseToXNode(); System.out.println("Parsed to XNode:"); System.out.println(node.debugDump()); System.out.println("XML -> XNode -> XML:\n" + prismContext.xmlSerializer().serialize(node)); System.out.println("XML -> XNode -> JSON:\n" + prismContext.jsonSerializer().serialize(node)); System.out.println("XML -> XNode -> YAML:\n" + prismContext.yamlSerializer().serialize(node)); }
@Test @SuppressWarnings("Duplicates") public void testParseRoundTripAsPCV() throws Exception{ displayTestTitle("testParseRoundTripAsPCV"); processParsingsPCV(v -> getPrismContext().serializerFor(language).serialize(v), "s0"); processParsingsPCV(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serialize(v), "s1"); processParsingsPCV(v -> getPrismContext().serializerFor(language).root(SchemaConstantsGenerated.C_USER).serialize(v), "s2"); // misleading item name processParsingsPCV(v -> getPrismContext().serializerFor(language).serializeRealValue(v.asContainerable()), "s3"); processParsingsPCV(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serializeAnyData(v.asContainerable()), "s4"); }
@Test public void testParseToXNode() throws Exception { PrismContext prismContext = PrismTestUtil.getPrismContext(); RootXNode node = prismContext.parserFor(getFile()).parseToXNode(); System.out.println("Parsed to XNode:"); System.out.println(node.debugDump()); System.out.println("XML -> XNode -> XML:\n" + prismContext.xmlSerializer().serialize(node)); System.out.println("XML -> XNode -> JSON:\n" + prismContext.jsonSerializer().serialize(node)); System.out.println("XML -> XNode -> YAML:\n" + prismContext.yamlSerializer().serialize(node)); }
@Test public void testParseRoundTrip() throws Exception{ displayTestTitle("testParseRoundTrip"); //processParsings(v -> getPrismContext().serializerFor(language).serialize(v)); // no item name nor definition => cannot serialize processParsings(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serialize(v), "s1"); processParsings(v -> getPrismContext().serializerFor(language).root(SchemaConstantsGenerated.C_USER).serialize(v), "s2"); // misleading item name processParsings(v -> getPrismContext().serializerFor(language).serializeRealValue(v.asContainerable()), "s3"); processParsings(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serializeAnyData(v.asContainerable()), "s4"); }
@Test public void test350SerializeToXml() throws Exception { System.out.println("===[ test350SerializeToXml ]==="); PrismObject<UserType> jack = getJack(); measure("serialize to XML", () -> getPrismContext().xmlSerializer().serialize(jack)); }
@Test @SuppressWarnings("Duplicates") public void testParseRoundTripAsPCV() throws Exception{ displayTestTitle("testParseRoundTripAsPCV"); processParsingsPCV(v -> getPrismContext().serializerFor(language).serialize(v), "s0"); processParsingsPCV(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serialize(v), "s1"); processParsingsPCV(v -> getPrismContext().serializerFor(language).root(SchemaConstantsGenerated.C_SYSTEM_CONFIGURATION).serialize(v), "s2"); // misleading item name processParsingsPCV(v -> getPrismContext().serializerFor(language).serializeRealValue(v.asContainerable()), "s3"); processParsingsPCV(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serializeAnyData(v.asContainerable()), "s4"); }
@Test public void test360SerializeToJson() throws Exception { System.out.println("===[ test360SerializeToJson ]==="); PrismObject<UserType> jack = getJack(); measure("serialize to JSON", () -> getPrismContext().jsonSerializer().serialize(jack)); }
@Test public void testParseRoundTripAsPCV() throws Exception{ displayTestTitle("testParseRoundTripAsPCV"); processParsingsPCV(v -> getPrismContext().serializerFor(language).serialize(v), "s0"); processParsingsPCV(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serialize(v), "s1"); processParsingsPCV(v -> getPrismContext().serializerFor(language).root(SchemaConstantsGenerated.C_SYSTEM_CONFIGURATION).serialize(v), "s2"); // misleading item name processParsingsPCV(v -> getPrismContext().serializerFor(language).serializeRealValue(v.asContainerable()), "s3"); processParsingsPCV(v -> getPrismContext().serializerFor(language).root(new QName("dummy")).serializeAnyData(v.asContainerable()), "s4"); }
@Test public void test370SerializeToYaml() throws Exception { System.out.println("===[ test370SerializeToYaml ]==="); PrismObject<UserType> jack = getJack(); measure("serialize to YAML", () -> getPrismContext().yamlSerializer().serialize(jack)); }
@Test public void testParseRoundTripAsPCV() throws Exception{ displayTestTitle("testParseRoundTripAsPCV"); SerializationOptions o = SerializationOptions.createSerializeReferenceNames(); processParsingsPCV(v -> getPrismContext().serializerFor(language).options(o).serialize(v), "s0"); processParsingsPCV(v -> getPrismContext().serializerFor(language).options(o).root(new QName("dummy")).serialize(v), "s1"); processParsingsPCV(v -> getPrismContext().serializerFor(language).options(o).root(SchemaConstantsGenerated.C_SYSTEM_CONFIGURATION).serialize(v), "s2"); // misleading item name processParsingsPCV(v -> getPrismContext().serializerFor(language).options(o).serializeRealValue(v.asContainerable()), "s3"); processParsingsPCV(v -> getPrismContext().serializerFor(language).options(o).root(new QName("dummy")).serializeAnyData(v.asContainerable()), "s4"); }
@Test public void testYamlSerialization() throws Exception { displayTestTitle("testParseToXNode"); String file = MiscUtil.readFile(getFile()); System.out.println("Original text:\n" + file); RootXNode xnode = getPrismContext().parserFor(file).parseToXNode(); System.out.println("XNode:\n" + xnode.debugDump()); String yaml = getPrismContext().yamlSerializer().serialize(xnode); System.out.println("source -> XNode -> YAML:\n" + yaml); PrismValue value = getPrismContext().parserFor(yaml).parseItemValue(); assertPrismPropertyValueLocal((PrismPropertyValue<ExpressionPipelineType>) value); }
@Test public void testParseRoundTripAsPO() throws Exception{ displayTestTitle("testParseRoundTripAsPO"); SerializationOptions o = SerializationOptions.createSerializeReferenceNames(); processParsingsPO(v -> getPrismContext().serializerFor(language).options(o).serialize(v), "s0", true); processParsingsPO(v -> getPrismContext().serializerFor(language).options(o).root(new QName("dummy")).serialize(v), "s1", false); processParsingsPO(v -> getPrismContext().serializerFor(language).options(o).root(SchemaConstantsGenerated.C_SYSTEM_CONFIGURATION).serialize(v), "s2", false); // misleading item name processParsingsPO(v -> getPrismContext().serializerFor(language).options(o).serializeRealValue(v.asObjectable()), "s3", false); processParsingsPO(v -> getPrismContext().serializerFor(language).options(o).root(new QName("dummy")).serializeAnyData(v.asObjectable()), "s4", false); }
@Test public void test310ParseXml() throws Exception { System.out.println("===[ test310ParseXml ]==="); PrismObject<UserType> jack = getJack(); String string = getPrismContext().xmlSerializer().serialize(jack); measure("parse XML (" + string.length() + " chars)", () -> getPrismContext().parserFor(string).xml().parse()); measure("parse XML to XNode (" + string.length() + " chars)", () -> getPrismContext().parserFor(string).xml().parseToXNode()); }
@Test public void test320ParseJson() throws Exception { System.out.println("===[ test320ParseJson ]==="); PrismObject<UserType> jack = getJack(); String string = getPrismContext().jsonSerializer().serialize(jack); measure("parse JSON (" + string.length() + " chars)", () -> getPrismContext().parserFor(string).json().parse()); measure("parse JSON to XNode (" + string.length() + " chars)", () -> getPrismContext().parserFor(string).json().parseToXNode()); }
@Test public void test330ParseYaml() throws Exception { System.out.println("===[ test330ParseYaml ]==="); PrismObject<UserType> jack = getJack(); String string = getPrismContext().yamlSerializer().serialize(jack); measure("parse YAML (" + string.length() + " chars)", () -> getPrismContext().parserFor(string).yaml().parse()); measure("parse YAML to XNode (" + string.length() + " chars)", () -> getPrismContext().parserFor(string).yaml().parse()); }