Search in sources :

Example 86 with Node

use of org.dom4j.Node in project core by craftercms.

the class TemplateProcessorTest method testProcess.

@Test
public void testProcess() throws Exception {
    item = processor.process(null, null, item);
    assertNotNull(item.getDescriptorDom());
    Node body = item.getDescriptorDom().selectSingleNode("/root/body");
    assertNotNull(body);
    assertEquals(BODY_MODEL_VALUE, body.getText());
}
Also used : Node(org.dom4j.Node) Test(org.junit.Test)

Example 87 with Node

use of org.dom4j.Node in project core by craftercms.

the class TextMetaDataExtractingProcessorTest method setUpTestItem.

private void setUpTestItem() {
    Node cssNode = mock(Node.class);
    when(cssNode.getText()).thenReturn(CSS);
    Node jsNode = mock(Node.class);
    when(jsNode.getText()).thenReturn(JS);
    Document descriptorDom = mock(Document.class);
    when(descriptorDom.selectSingleNode(testMetaDataNodesXPathQueries[0])).thenReturn(cssNode);
    when(descriptorDom.selectSingleNode(testMetaDataNodesXPathQueries[1])).thenReturn(jsNode);
    item = new Item();
    item.setDescriptorDom(descriptorDom);
}
Also used : Item(org.craftercms.core.service.Item) Node(org.dom4j.Node) Document(org.dom4j.Document)

Example 88 with Node

use of org.dom4j.Node in project core by craftercms.

the class ContentStoreServiceImplTest method assertContentFrEsDescriptorItem.

private void assertContentFrEsDescriptorItem(Item item, boolean processorSpecified) {
    assertNotNull(item);
    assertEquals(CONTENT_FR_ES_DESCRIPTOR_NAME, item.getName());
    assertEquals(CONTENT_FR_ES_DESCRIPTOR_PATH, item.getUrl());
    assertFalse(item.isFolder());
    assertEquals(CONTENT_FR_ES_DESCRIPTOR_PATH, item.getDescriptorUrl());
    assertNotNull(item.getDescriptorDom());
    assertSystemInfoProperties(item);
    if (processorSpecified) {
        assertEquals(FIRST_QUOTE_EN, item.getProperty("//first-quote"));
        assertEquals(SECOND_QUOTE_FR, item.getProperty("//second-quote"));
        assertEquals(THIRD_QUOTE_ES, item.getProperty("//third-quote"));
    } else {
        Node firstQuote = item.getDescriptorDom().selectSingleNode("//first-quote");
        assertNotNull(firstQuote);
        assertEquals(FIRST_QUOTE_EN, firstQuote.getText());
        Node secondQuote = item.getDescriptorDom().selectSingleNode("//second-quote");
        assertNotNull(secondQuote);
        assertEquals(SECOND_QUOTE_FR, secondQuote.getText());
        Node thirdQuote = item.getDescriptorDom().selectSingleNode("//third-quote");
        assertNotNull(thirdQuote);
        assertEquals(THIRD_QUOTE_ES, thirdQuote.getText());
    }
}
Also used : Node(org.dom4j.Node)

Example 89 with Node

use of org.dom4j.Node in project core by craftercms.

the class ContentStoreServiceImplTest method assertCrafterCMSLogoItem.

private void assertCrafterCMSLogoItem(Item item, boolean processorSpecified) {
    assertNotNull(item);
    assertEquals(CRAFTER_CMS_LOGO_NAME, item.getName());
    assertEquals(CRAFTER_CMS_LOGO_PATH, item.getUrl());
    assertFalse(item.isFolder());
    assertEquals(CRAFTER_CMS_LOGO_META_FILE_PATH, item.getDescriptorUrl());
    assertNotNull(item.getDescriptorDom());
    assertSystemInfoProperties(item);
    assertEquals(CRAFTER_CMS_LOGO_RESOLUTION_WIDTH, Integer.parseInt((String) item.getProperty("//resolution/width")));
    assertEquals(CRAFTER_CMS_LOGO_RESOLUTION_HEIGHT, Integer.parseInt((String) item.getProperty("//resolution/height")));
    if (processorSpecified) {
        String size = (String) item.getProperty("//size");
        assertEquals(CRAFTER_CMS_LOGO_SIZE, size);
    } else {
        Node size = item.getDescriptorDom().selectSingleNode("//size");
        assertNotNull(size);
        assertEquals(CRAFTER_CMS_LOGO_SIZE, size.getText());
    }
}
Also used : Node(org.dom4j.Node)

Example 90 with Node

use of org.dom4j.Node in project core by craftercms.

the class ContentStoreServiceImplTest method assertContentDescriptorItem.

private void assertContentDescriptorItem(Item item, boolean processorSpecified) {
    assertNotNull(item);
    assertEquals(CONTENT_DESCRIPTOR_NAME, item.getName());
    assertEquals(CONTENT_DESCRIPTOR_PATH, item.getUrl());
    assertFalse(item.isFolder());
    assertEquals(CONTENT_DESCRIPTOR_PATH, item.getDescriptorUrl());
    assertNotNull(item.getDescriptorDom());
    assertSystemInfoProperties(item);
    if (processorSpecified) {
        assertEquals(FIRST_QUOTE_EN, item.getProperty("//first-quote"));
        assertEquals(SECOND_QUOTE_EN, item.getProperty("//second-quote"));
        assertEquals(THIRD_QUOTE_EN, item.getProperty("//third-quote"));
    } else {
        Node firstQuote = item.getDescriptorDom().selectSingleNode("//first-quote");
        assertNotNull(firstQuote);
        assertEquals(FIRST_QUOTE_EN, firstQuote.getText());
        Node secondQuote = item.getDescriptorDom().selectSingleNode("//second-quote");
        assertNotNull(secondQuote);
        assertEquals(SECOND_QUOTE_EN, secondQuote.getText());
        Node thirdQuote = item.getDescriptorDom().selectSingleNode("//third-quote");
        assertNotNull(thirdQuote);
        assertEquals(THIRD_QUOTE_EN, thirdQuote.getText());
    }
}
Also used : Node(org.dom4j.Node)

Aggregations

Node (org.dom4j.Node)253 Document (org.dom4j.Document)83 Element (org.dom4j.Element)61 ArrayList (java.util.ArrayList)56 List (java.util.List)54 Test (org.junit.Test)40 SAXReader (org.dom4j.io.SAXReader)28 File (java.io.File)25 Iterator (java.util.Iterator)18 ReturnedDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedDocument)18 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)18 HashMap (java.util.HashMap)16 URL (java.net.URL)15 ReturnedMultipartDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedMultipartDocument)15 InputStream (java.io.InputStream)14 Attribute (org.dom4j.Attribute)14 Image (java.awt.Image)12 ConnectionException (org.collectionspace.chain.csp.persistence.services.connection.ConnectionException)11 VFSItem (org.olat.core.util.vfs.VFSItem)10 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10