Examples of JDOMFactory


Examples of org.jdom.input.JDOMFactory

    public void testSetProxiedElementsChanged() {
        PolicyProxyElementDetails details =
                new PolicyProxyElementDetails("imageComponent");
        ProxyElementDetails.ChangeReason reason =
                ProxyElementDetails.ELEMENTS;
        JDOMFactory factory = new DefaultJDOMFactory();
        ArrayList elements = new ArrayList();

        // Test that when the element changes then the element name changes.
        elements.add(factory.element("deviceImageAsset"));
        assertTrue("Element name has changed and reason is ELEMENTS.",
                details.setProxiedElements(elements.iterator(), reason));

        assertEquals("Element name should now be \"deviceImageAsset\"",
                "deviceImageAsset", details.getElementName());

        // Test that different element names produce UNDEFINED_ELEMENT_NAME
        Element element = factory.element("genericImageAsset");
        elements.add(element);
        assertTrue("Element name has changed and reason is ELEMENTS.",
                details.setProxiedElements(elements.iterator(), reason));
        assertEquals("Element name should now be \"" +
                ODOMElement.UNDEFINED_ELEMENT_NAME + "\"",
View Full Code Here

Examples of org.jdom.input.JDOMFactory

        extends TestCaseAbstract {
    /**
     * Test getElements with no skip or stop elements.
     */
    public void testGetChildrenSimple() {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element parent = factory.element("parent");
        Element child1 = factory.element("child1");
        Element child2 = factory.element("child2");
        parent.addContent(child1);
        parent.addContent(child2);

        ElementChildrenTreeContentProvider provider =
                new ElementChildrenTreeContentProvider();
View Full Code Here

Examples of org.jdom.input.JDOMFactory

    /**
     * Test getChildren with stop elements.
     */
    public void testGetChildrenStopElements() {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element parent1 = factory.element("parent1");
        Element child1a = factory.element("child1a");
        Element child2a = factory.element("child2a");
        parent1.addContent(child1a);
        parent1.addContent(child2a);

        Element parent2 = factory.element("parent2");
        Element child1b = factory.element("child1b");
        Element child2b = factory.element("child2b");
        parent2.addContent(child1b);
        parent2.addContent(child2b);

        String [] stopElements = { parent1.getName(), parent2.getName() };

        ElementChildrenTreeContentProvider provider =
                new ElementChildrenTreeContentProvider(null, stopElements,
                        false, false);

        Object [] elements = provider.getChildren(parent1);
        assertEquals("There should be no child elements for parent1", 0,
                elements.length);

        elements = provider.getChildren(parent2);
        assertEquals("There should be no child elements for parent2", 0,
                elements.length);

        // Make parent1 and parent2 child of some root element to ensure that
        // they do appear in the root's children.
        Element root = factory.element("root");
        root.addContent(parent1);
        root.addContent(parent2);

        elements = provider.getChildren(root);
        assertEquals("There should be two child elements for root.", 2,
View Full Code Here

Examples of org.jdom.input.JDOMFactory

    /**
     * Test getChildren with skip elements.
     */
    public void testGetChildrenSkipElements() {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element parent1 = factory.element("parent1");
        Element child1a = factory.element("child1a");
        Element child2a = factory.element("child2a");
        parent1.addContent(child1a);
        parent1.addContent(child2a);

        Element parent2 = factory.element("parent2");
        Element child1b = factory.element("child1b");
        Element child2b = factory.element("child2b");
        parent2.addContent(child1b);
        parent2.addContent(child2b);

        Element root = factory.element("root");
        root.addContent(parent1);
        root.addContent(parent2);

        // Test that parent1 is skipped but parent2 is not.
        String [] skipElements = { parent1.getName() };
View Full Code Here

Examples of org.jdom.input.JDOMFactory

    /**
     * Test getChildren() with both stop and skip elements at the same
     * time.
     */
    public void testGetChildrenSkipAndStopElements() {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element parent1 = factory.element("parent1");
        Element child1a = factory.element("child1a");
        Element child2a = factory.element("child2a");
        parent1.addContent(child1a);
        parent1.addContent(child2a);

        Element parent2 = factory.element("parent2");
        Element child1b = factory.element("child1b");
        Element child2b = factory.element("child2b");
        parent2.addContent(child1b);
        parent2.addContent(child2b);

        Element root = factory.element("root");
        root.addContent(parent1);
        root.addContent(parent2);

        Attribute rootAttr1 = factory.attribute("rootAttr1", "value");
        Attribute parentAttr1 = factory.attribute("parentAttr1", "value");

        root.setAttribute(rootAttr1);
        parent1.setAttribute(parentAttr1);

        // Skip both parents.
View Full Code Here

Examples of org.jdom.input.JDOMFactory

     * Test that getChildren() sorts returned elements and attributes
     * as required i.e. all attributes must come before all elements and
     * both elements and attributes must be ordered alphabetically.
     */
    public void testGetChildrenSorting() {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element parent1 = factory.element("parent1");
        Element child1a = factory.element("child1a");
        Element child2a = factory.element("child2a");
        parent1.addContent(child2a);
        parent1.addContent(child1a);

        Element parent2 = factory.element("parent2");
        Element child1b = factory.element("child1b");
        Element child2b = factory.element("child2b");
        parent2.addContent(child1b);
        parent2.addContent(child2b);

        Element root = factory.element("root");
        root.addContent(parent2);
        root.addContent(parent1);

        Attribute rootAttr1 = factory.attribute("rootAttr1", "value");
        Attribute rootAttr2 = factory.attribute("rootAttr2", "value");
        Attribute parentAttr1 = factory.attribute("parentAttr1", "value");

        root.setAttribute(rootAttr2);
        root.setAttribute(rootAttr1);
        parent1.setAttribute(parentAttr1);

View Full Code Here

Examples of org.jdom.input.JDOMFactory

    /**
     * Test getElements() when the root element should be displayed.
     */
    public void testGetElementsProvideRoot() {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element parent1 = factory.element("parent1");
        Element child1a = factory.element("child1a");
        Element child2a = factory.element("child2a");
        parent1.addContent(child2a);
        parent1.addContent(child1a);

        Element parent2 = factory.element("parent2");
        Element child1b = factory.element("child1b");
        Element child2b = factory.element("child2b");
        parent2.addContent(child1b);
        parent2.addContent(child2b);

        Element root = factory.element("root");
        root.addContent(parent2);
        root.addContent(parent1);


        ElementChildrenTreeContentProvider provider =
View Full Code Here

Examples of org.jdom.input.JDOMFactory

    /**
     * Test getElements() when the root element should not be displayed.
     */
    public void testGetElementsNoRoot() {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element parent1 = factory.element("parent1");
        Element child1a = factory.element("child1a");
        Element child2a = factory.element("child2a");
        parent1.addContent(child2a);
        parent1.addContent(child1a);

        Element parent2 = factory.element("parent2");
        Element child1b = factory.element("child1b");
        Element child2b = factory.element("child2b");
        parent2.addContent(child1b);
        parent2.addContent(child2b);

        Element root = factory.element("root");
        root.addContent(parent2);
        root.addContent(parent1);

        ElementChildrenTreeContentProvider provider =
                new ElementChildrenTreeContentProvider(null, null, true, false);
View Full Code Here

Examples of org.jdom.input.JDOMFactory

     * value for the specified policy type.
     * @param policyType the policy type
     * @return the policy element with an appropriate default value
     */
    private Element createPolicyElement(final PolicyType policyType) {
        final JDOMFactory factory = new ODOMFactory();

        final Element policiesElement = factory.element(
                DeviceRepositorySchemaConstants.POLICIES_ELEMENT_NAME,
                DEVICE_NS);
        policyType.addDefaultPolicyValue(policiesElement,
                "myPolicy", factory, null);

View Full Code Here

Examples of org.jdom.input.JDOMFactory

        TemporaryFileManager tempFileMgr = new TemporaryFileManager(
                new TestDeviceRepositoryCreator());
        tempFileMgr.executeWith(new TemporaryFileExecutor() {
            public void execute(File repository) throws Exception {

                JDOMFactory jdomFactory = new ODOMFactory();
                DeviceRepositoryAccessorManager manager =
                        new DeviceRepositoryAccessorManager(
                                repository.getPath(),
                                new TestTransformerMetaFactory(), jdomFactory, false);

                String sName = DeviceRepositorySchemaConstants.STANDARD_ELEMENT_NAME;

                ODOMElement e = (ODOMElement) manager.retrieveDeviceIdentification("PC");
                //create a standard element and add it to the device identification
                ODOMElement standard = (ODOMElement) jdomFactory.element(sName,
                        e.getNamespace());
                e.addContent(standard);

                List children = e.getChildren();
                Object[] childArray = children.toArray();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.