Search in sources :

Example 91 with Document

use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.

the class MCRXSLTransformationTest method transform.

@Test
public void transform() {
    Element root = new Element("root");
    Document in = new Document(root);
    root.addContent(new Element("child").setAttribute("hasChildren", "no"));
    Document out = MCRXSLTransformation.transform(in, stylesheet.getAbsolutePath());
    assertTrue("Input not the same as Output", MCRXMLHelper.deepEqual(in, out));
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) Test(org.junit.Test)

Example 92 with Document

use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.

the class MCRCategLinkServiceImplTest method loadWorldClassification.

private void loadWorldClassification() throws URISyntaxException, MCRException, SAXParseException, IOException {
    URL worlClassUrl = this.getClass().getResource(WORLD_CLASS_RESOURCE_NAME);
    Document xml = MCRXMLParserFactory.getParser().parseXML(new MCRVFSContent(worlClassUrl));
    category = MCRXMLTransformer.getCategory(xml);
}
Also used : Document(org.jdom2.Document) URL(java.net.URL) MCRVFSContent(org.mycore.common.content.MCRVFSContent)

Example 93 with Document

use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.

the class MCRMetadataStoreTest method getNextFreeID.

@Test
public void getNextFreeID() throws Exception {
    int id1 = getMetaDataStore().getNextFreeID();
    assertTrue(id1 >= 0);
    assertFalse(getMetaDataStore().exists(id1));
    Document xml1 = new Document(new Element("root"));
    int id2 = getMetaDataStore().create(new MCRJDOMContent(xml1)).getID();
    assertTrue(id2 > id1);
    assertTrue(getMetaDataStore().getNextFreeID() > id2);
}
Also used : Element(org.jdom2.Element) MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) Document(org.jdom2.Document) Test(org.junit.Test)

Example 94 with Document

use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.

the class MCRMetadataStoreTest method retrieve.

@Test
public void retrieve() throws Exception {
    Document xml1 = new Document(new Element("root"));
    int id = getMetaDataStore().create(new MCRJDOMContent(xml1)).getID();
    MCRStoredMetadata sm1 = getMetaDataStore().retrieve(id);
    MCRContent xml2 = sm1.getMetadata();
    assertEquals(new MCRJDOMContent(xml1).asString(), xml2.asString());
}
Also used : Element(org.jdom2.Element) MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) Document(org.jdom2.Document) MCRContent(org.mycore.common.content.MCRContent) Test(org.junit.Test)

Example 95 with Document

use of io.atlasmap.v2.Document in project mycore by MyCoRe-Org.

the class MCRMetadataStoreTest method createDocumentInt.

@Test
public void createDocumentInt() throws Exception {
    Document xml1 = new Document(new Element("root"));
    try {
        getMetaDataStore().create(new MCRJDOMContent(xml1), 0);
        fail("metadata store allows to save with id \"0\".");
    } catch (Exception e) {
    // test passed
    }
    int id = getMetaDataStore().getNextFreeID();
    assertTrue(id > 0);
    MCRStoredMetadata sm1 = getMetaDataStore().create(new MCRJDOMContent(xml1), id);
    assertNotNull(sm1);
    MCRContent xml2 = getMetaDataStore().retrieve(id).getMetadata();
    assertEquals(new MCRJDOMContent(xml1).asString(), xml2.asString());
    getMetaDataStore().create(new MCRJDOMContent(xml1), id + 1);
    MCRContent xml3 = getMetaDataStore().retrieve(id + 1).getMetadata();
    assertEquals(new MCRJDOMContent(xml1).asString(), xml3.asString());
}
Also used : Element(org.jdom2.Element) MCRJDOMContent(org.mycore.common.content.MCRJDOMContent) Document(org.jdom2.Document) MCRContent(org.mycore.common.content.MCRContent) Test(org.junit.Test)

Aggregations

Document (org.jdom2.Document)403 Element (org.jdom2.Element)248 Test (org.junit.Test)111 SAXBuilder (org.jdom2.input.SAXBuilder)95 IOException (java.io.IOException)74 File (java.io.File)58 XMLOutputter (org.jdom2.output.XMLOutputter)55 JDOMException (org.jdom2.JDOMException)44 Field (io.atlasmap.v2.Field)40 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)34 ArrayList (java.util.ArrayList)30 Test (org.junit.jupiter.api.Test)27 MCRNodeBuilder (org.mycore.common.xml.MCRNodeBuilder)25 DocType (org.jdom2.DocType)24 InputStream (java.io.InputStream)23 JsonField (io.atlasmap.json.v2.JsonField)22 MCRContent (org.mycore.common.content.MCRContent)22 Document (com.google.cloud.language.v1.Document)21 HashMap (java.util.HashMap)21 MCRException (org.mycore.common.MCRException)21