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());
}
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());
}
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));
}
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());
}
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"));
}
Aggregations