Examples of JDOMFactory


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
                ODOMElement standard = (ODOMElement) jdomFactory.element(sName,
                        e.getNamespace());
                //add to the element
                e.addContent(standard);

                List children = e.getChildren();
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();
                TransformerMetaFactory transformerMetaFactory =
                        new TestTransformerMetaFactory();

                // Don't need a test instance for the static test but to test that
                // the static test hasn't altered any state an instance is required
View Full Code Here

Examples of org.jdom.input.JDOMFactory

    /**
     *
     * @throws Exception
     */
    public void testMoveListeners() throws Exception {
        final JDOMFactory factory = new ODOMFactory();

        ODOMElement fromRoot = (ODOMElement) factory.element("root");
        ODOMElement fromChild1 = (ODOMElement) factory.element("child");
        ODOMElement fromChild2 = (ODOMElement) factory.element("child");
        fromRoot.addContent(fromChild1);
        fromRoot.addContent(fromChild2);
        factory.document(fromRoot);

        ODOMChangeListener rootListener = createODOMChangeListener();
        fromRoot.addChangeListener(rootListener);
        fromRoot.addChangeListener(rootListener, ChangeQualifier.NAME);

        ODOMChangeListener child1Listener = createODOMChangeListener();
        fromChild1.addChangeListener(child1Listener);
        fromChild1.addChangeListener(child1Listener, ChangeQualifier.NAME);

        ODOMChangeListener child2Listener = createODOMChangeListener();
        fromChild2.addChangeListener(child2Listener);
        fromChild2.addChangeListener(child2Listener, ChangeQualifier.NAME);

        ODOMElement toRoot = (ODOMElement) factory.element("root");
        ODOMElement toChild1 = (ODOMElement) factory.element("child");
        toRoot.addContent(toChild1);
        factory.document(toRoot);

        fromRoot.moveListeners(toRoot);

        assertEquals("There should be no listeners in fromRoot.", 0,
                getNumListeners(fromRoot));
View Full Code Here

Examples of org.jdom.input.JDOMFactory

     * point of view of the command pattern it uses, this test case exists to
     * exercise the recursive nature of the implementation of the method in
     * the <code>ODOMElement</code> class.
     */
    public void testRecursiveDetach() throws Exception {
        final JDOMFactory factory = new ODOMFactory();

        // Build some test data
        ODOMElement fromRoot = (ODOMElement) factory.element("root");
        fromRoot.setName("Root");
        ODOMElement fromChild1 = (ODOMElement) factory.element("child");
        fromChild1.setName("Child1");
        ODOMElement fromChild2 = (ODOMElement) factory.element("child");
        fromChild2.setName("Child2");
        fromRoot.addContent(fromChild1);
        fromRoot.addContent(fromChild2);

        ODOMChangeListener rootListener = createODOMChangeListener();
View Full Code Here

Examples of org.jdom.input.JDOMFactory

    private void addMultiTypeElementTest(PolicyTypeComposition composition,
                                         PolicyType policyType,
                                         String expectedElementName,
                                         String expectedSubElementName) {

        JDOMFactory factory = new DefaultJDOMFactory();
        Element policy = factory.element("policy");
        composition.addTypeElement(policy, policyType, factory);
        assertEquals("There should be a single child element of policy.",
                1, policy.getChildren().size());
        Element type = (Element) policy.getChildren().get(0);
        assertEquals("Expected a " +
View Full Code Here

Examples of org.jdom.input.JDOMFactory

     * single valued PolicyType to be added.
     */
    private void addSingleTypeElementTest(PolicyType policyType,
                                          String expectedElementName) {

        JDOMFactory factory = new DefaultJDOMFactory();
        Element policy = factory.element("policy");
        PolicyTypeComposition.SINGLE.addTypeElement(policy, policyType,
                factory);
        assertEquals("There should be a single child element of policy.",
                1, policy.getChildren().size());
        Element type = (Element) policy.getChildren().get(0);
View Full Code Here

Examples of org.jdom.input.JDOMFactory

    /**
     * The that addTypeElement works with a STRUCTURE PolicyTypeComposition.
     */
    public void testAddTypeElementStructure() {

        JDOMFactory factory = new DefaultJDOMFactory();
        Element policy = factory.element("policy");
        PolicyTypeComposition.STRUCTURE.addTypeElement(policy,
                PolicyType.EMULATE_EMPHASIS_TAG, factory);
        assertEquals("There should be a single child element of policy.",
                1, policy.getChildren().size());
        Element type = (Element) policy.getChildren().get(0);
View Full Code Here

Examples of org.jdom.input.JDOMFactory

    /**
     * TestPolicyTypeComposition.ORDERED_SET#canHandleType(Element).
     */
    public void testOrderedSetCanHandleTypeElement() throws Exception {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element type = factory.element(DeviceRepositorySchemaConstants.
                POLICY_DEFINITION_TYPE_ELEMENT_NAME);
        Element orderedSet = factory.element(
                DeviceRepositorySchemaConstants.
                POLICY_DEFINITION_ORDEREDSET_ELEMENT_NAME);
        type.addContent(orderedSet);

        assertTrue("Should be able to handle an " +
View Full Code Here

Examples of org.jdom.input.JDOMFactory

    /**
     * TestPolicyTypeComposition.UNORDERED_SET#canHandleType(Element).
     */
    public void testUnorderedSetCanHandleTypeElement() throws Exception {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element type = factory.element(DeviceRepositorySchemaConstants.
                POLICY_DEFINITION_TYPE_ELEMENT_NAME);
        Element orderedSet = factory.element(
                DeviceRepositorySchemaConstants.
                POLICY_DEFINITION_UNORDEREDSET_ELEMENT_NAME);
        type.addContent(orderedSet);

        assertTrue("Should be able to handle an " +
View Full Code Here

Examples of org.jdom.input.JDOMFactory

     * Helper method that creates the type element for the given policy type.
     * @param policyType the policy type
     * @return the type element
     */
    private Element createTypeElement(PolicyType policyType) {
        JDOMFactory factory = new DefaultJDOMFactory();
        Element type = factory.element(DeviceRepositorySchemaConstants.
                POLICY_DEFINITION_TYPE_ELEMENT_NAME);
        // this is a bit clumsy
        if (policyType == PolicyType.EMULATE_EMPHASIS_TAG) {
            type.setAttribute(DeviceRepositorySchemaConstants.
                                POLICY_DEFINITION_TYPE_NAME_ATTRIBUTE_NAME,
                              PolicyType.EMULATE_EMPHASIS_TAG.getName());
        }
        Element element = factory.element(
                policyType.getName());
        type.addContent(element);
        return type;
    }
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.