Search in sources :

Example 91 with Attribute

use of com.android.org.bouncycastle.asn1.x509.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 92 with Attribute

use of com.android.org.bouncycastle.asn1.x509.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 93 with Attribute

use of com.android.org.bouncycastle.asn1.x509.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 94 with Attribute

use of com.android.org.bouncycastle.asn1.x509.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 95 with Attribute

use of com.android.org.bouncycastle.asn1.x509.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)149 Element (org.jdom2.Element)104 IOException (java.io.IOException)31 ArrayList (java.util.ArrayList)27 Document (org.jdom2.Document)18 DataConversionException (org.jdom2.DataConversionException)16 X509Certificate (java.security.cert.X509Certificate)15 Editor (jmri.jmrit.display.Editor)15 GeneralName (org.bouncycastle.asn1.x509.GeneralName)15 Test (org.junit.Test)14 List (java.util.List)13 NamedIcon (jmri.jmrit.catalog.NamedIcon)13 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)12 Attribute (org.bouncycastle.asn1.pkcs.Attribute)12 Extensions (org.bouncycastle.asn1.x509.Extensions)12 GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)12 CertificateEncodingException (java.security.cert.CertificateEncodingException)11 Attribute (org.bouncycastle.asn1.x509.Attribute)11 HashMap (java.util.HashMap)10 HashSet (java.util.HashSet)9