Search in sources :

Example 71 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project mycore by MyCoRe-Org.

the class MCRNodeBuilderTest method testBuildingTrees.

@Test
public void testBuildingTrees() throws JaxenException, JDOMException {
    Element root = new Element("root");
    Attribute built = new MCRNodeBuilder().buildAttribute("parent/child/@attribute", null, root);
    assertNotNull(built);
    assertEquals("attribute", built.getName());
    assertNotNull(built.getParent());
    assertEquals("child", built.getParent().getName());
    assertNotNull(built.getParent().getParentElement());
    assertEquals("parent", built.getParent().getParentElement().getName());
    assertNotNull(built.getParent().getParentElement().getParentElement());
    assertEquals("root", built.getParent().getParentElement().getParentElement().getName());
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) Test(org.junit.Test)

Example 72 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project mycore by MyCoRe-Org.

the class MCRNodeBuilderTest method testBuildingAttributes.

@Test
public void testBuildingAttributes() throws JaxenException, JDOMException {
    Attribute built = new MCRNodeBuilder().buildAttribute("@attribute", null, null);
    assertNotNull(built);
    assertEquals("attribute", built.getName());
    assertTrue(built.getValue().isEmpty());
    built = new MCRNodeBuilder().buildAttribute("@attribute", "value", null);
    assertNotNull(built);
    assertEquals("attribute", built.getName());
    assertEquals("value", built.getValue());
    Element parent = new Element("parent");
    built = new MCRNodeBuilder().buildAttribute("@attribute", null, parent);
    assertNotNull(built);
    assertEquals("attribute", built.getName());
    assertNotNull(built.getParent());
    assertEquals("parent", built.getParent().getName());
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) Test(org.junit.Test)

Example 73 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project mycore by MyCoRe-Org.

the class MCRXPathBuilderTest method testXPath.

@Test
public void testXPath() {
    Element root = new Element("root");
    Element title1 = new Element("title");
    Element title2 = new Element("title");
    Element author = new Element("contributor");
    Attribute role = new Attribute("role", "author");
    Attribute lang = new Attribute("lang", "de", Namespace.XML_NAMESPACE);
    author.setAttribute(role);
    author.setAttribute(lang);
    root.addContent(title1);
    root.addContent(author);
    root.addContent(title2);
    new Document(root);
    assertEquals("/root", MCRXPathBuilder.buildXPath(root));
    assertEquals("/root/contributor", MCRXPathBuilder.buildXPath(author));
    assertEquals("/root/title", MCRXPathBuilder.buildXPath(title1));
    assertEquals("/root/title[2]", MCRXPathBuilder.buildXPath(title2));
    assertEquals("/root/contributor/@role", MCRXPathBuilder.buildXPath(role));
    assertEquals("/root/contributor/@xml:lang", MCRXPathBuilder.buildXPath(lang));
    root.detach();
    assertEquals("root", MCRXPathBuilder.buildXPath(root));
    assertEquals("root/contributor", MCRXPathBuilder.buildXPath(author));
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) Document(org.jdom2.Document) Test(org.junit.Test)

Example 74 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project mycore by MyCoRe-Org.

the class MCRChangeTrackerTest method testBreakpoint.

@Test
public void testBreakpoint() {
    Element root = new Element("root");
    Document doc = new Document(root);
    MCRChangeTracker tracker = new MCRChangeTracker();
    Element title = new Element("title");
    root.addContent(title);
    tracker.track(MCRAddedElement.added(title));
    tracker.track(MCRBreakpoint.setBreakpoint(root, "Test"));
    Attribute href = new Attribute("href", "foo", MCRConstants.XLINK_NAMESPACE);
    root.setAttribute(href);
    tracker.track(MCRAddedAttribute.added(href));
    tracker.track(MCRSetAttributeValue.setValue(href, "bar"));
    String label = tracker.undoLastBreakpoint(doc);
    assertEquals("Test", label);
    assertNull(root.getAttribute("href"));
    assertEquals(1, tracker.getChangeCounter());
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) Document(org.jdom2.Document) Test(org.junit.Test)

Example 75 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project mycore by MyCoRe-Org.

the class MCRChangeTrackerTest method testAddAttribute.

@Test
public void testAddAttribute() throws JaxenException {
    Document doc = new Document(new MCRNodeBuilder().buildElement("document[title]", null, null));
    MCRChangeTracker tracker = new MCRChangeTracker();
    Attribute id = new Attribute("id", "foo");
    doc.getRootElement().setAttribute(id);
    tracker.track(MCRAddedAttribute.added(id));
    tracker.undoChanges(doc);
    assertNull(doc.getRootElement().getAttribute("id"));
}
Also used : MCRNodeBuilder(org.mycore.common.xml.MCRNodeBuilder) Attribute(org.jdom2.Attribute) Document(org.jdom2.Document) Test(org.junit.Test)

Aggregations

Attribute (org.jdom2.Attribute)148 Element (org.jdom2.Element)104 Document (org.jdom2.Document)18 ArrayList (java.util.ArrayList)17 DataConversionException (org.jdom2.DataConversionException)16 Editor (jmri.jmrit.display.Editor)15 Test (org.junit.Test)15 IOException (java.io.IOException)14 NamedIcon (jmri.jmrit.catalog.NamedIcon)13 Attribute (org.bouncycastle.asn1.x509.Attribute)11 HashMap (java.util.HashMap)10 List (java.util.List)9 HashSet (java.util.HashSet)7 Map (java.util.Map)7 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)7 Attribute (ucar.nc2.Attribute)7 Asn1Integer (com.android.hotspot2.asn1.Asn1Integer)5 Asn1Object (com.android.hotspot2.asn1.Asn1Object)5 Asn1Oid (com.android.hotspot2.asn1.Asn1Oid)5 OidMappings (com.android.hotspot2.asn1.OidMappings)5