Package org.codehaus.plexus.util.xml

Examples of org.codehaus.plexus.util.xml.Xpp3Dom


     * @param test the test
     * @param runTime the elapsed time to execute the test.
     * @return the XML element describing the given test.
     */
    private Xpp3Dom createTestElement(Test test, long runTime) {
        Xpp3Dom testCase = new Xpp3Dom("testcase");
        testCase.setAttribute("name", getReportName(test));
        testCase.setAttribute("time", Long.toString(runTime) + " sec");
        return testCase;
    }
View Full Code Here


     * @param test the test
     * @param runTime the elapsed time to execute the test suite.
     * @return the XML element describing the given test suite.
     */
    private Xpp3Dom createTestSuiteElement(Test test, long runTime) {
        Xpp3Dom testCase = new Xpp3Dom("testsuite");
        testCase.setAttribute("name", getReportName(test));
        testCase.setAttribute("time", Long.toString(runTime) + " sec");
        return testCase;
    }
View Full Code Here

     * @param element the parent element
     * @param name the name of the element to create
     * @return the resulting XML tree.
     */
    private Xpp3Dom createElement(Xpp3Dom element, String name) {
        Xpp3Dom component = new Xpp3Dom(name);

        element.addChild(component);

        return component;
    }
View Full Code Here

     * @param testSuite the XML element.
     * @param bc the bundle context
     * @param configuration the configuration of the underlying OSGi platform
     */
    private void showProperties(Xpp3Dom testSuite, BundleContext bc, Map configuration) {
        Xpp3Dom properties = createElement(testSuite, "properties");
       
        Properties systemProperties = System.getProperties();

        if (systemProperties != null) {
            Enumeration propertyKeys = systemProperties.propertyNames();

            while (propertyKeys.hasMoreElements()) {
                String key = (String) propertyKeys.nextElement();

                String value = systemProperties.getProperty(key);

                if (value == null) {
                    value = "null";
                }

                Xpp3Dom property = createElement(properties, "property");

                property.setAttribute("name", key);

                property.setAttribute("value", value);

            }
        }
       
        if (configuration != null) {
            Iterator it = configuration.keySet().iterator();

            while (it.hasNext()) {
                String key = (String) it.next();

                Object obj = (Object) configuration.get(key);
                String value = null;
                if (obj == null) {
                    value = "null";
                } else if (obj instanceof String) {
                    value = (String) obj;
                } else {
                    value  = obj.toString();
                }

                Xpp3Dom property = createElement(properties, "property");

                property.setAttribute("name", key);

                property.setAttribute("value", value);

            }
        }

        Xpp3Dom buns = createElement(properties, "bundles");
        Bundle[] bundles = bc.getBundles();
        for (int i = 0; i < bundles.length; i++) {
            String sn = bundles[i].getSymbolicName();
            String state = "UNKNOWN";
            switch (bundles[i].getState()) {
                case Bundle.ACTIVE:
                    state = "ACTIVE";
                    break;
                case Bundle.INSTALLED:
                    state = "INSTALLED";
                    break;
                case Bundle.RESOLVED:
                    state = "RESOLVED";
                    break;
                case Bundle.UNINSTALLED:
                    state = "UNINSTALLED";
                    break;
                default:
                    break;
            }
            Xpp3Dom bundle = createElement(buns, "bundle");
            bundle.setAttribute("symbolic-name", sn);
            bundle.setAttribute("state", state);
        }

    }
View Full Code Here

        filter.addComponentsXml( reader );

        assertFalse( filter.components.isEmpty() );

        final Xpp3Dom componentDom = filter.components.get( "role" );

        assertEquals( "role", componentDom.getChild( "role" )
                                          .getValue() );
        assertNull( componentDom.getChild( "role-hint" ) );
        assertEquals( "org.apache.maven.Impl", componentDom.getChild( "implementation" )
                                                           .getValue() );
    }
View Full Code Here

        filter.addComponentsXml( reader );

        assertFalse( filter.components.isEmpty() );

        final Xpp3Dom componentDom = filter.components.get( "rolehint" );

        assertEquals( "role", componentDom.getChild( "role" )
                                          .getValue() );
        assertEquals( "hint", componentDom.getChild( "role-hint" )
                                          .getValue() );
        assertEquals( "org.apache.maven.Impl", componentDom.getChild( "implementation" )
                                                           .getValue() );
    }
View Full Code Here

        filter.addComponentsXml( reader );

        assertFalse( filter.components.isEmpty() );

        Xpp3Dom componentDom = filter.components.get( "rolehint" );

        assertEquals( "role", componentDom.getChild( "role" )
                                          .getValue() );
        assertEquals( "hint", componentDom.getChild( "role-hint" )
                                          .getValue() );
        assertEquals( "org.apache.maven.Impl", componentDom.getChild( "implementation" )
                                                           .getValue() );

        componentDom = filter.components.get( "rolehint2" );

        assertEquals( "role", componentDom.getChild( "role" )
                                          .getValue() );
        assertEquals( "hint2", componentDom.getChild( "role-hint" )
                                           .getValue() );
        assertEquals( "org.apache.maven.Impl2", componentDom.getChild( "implementation" )
                                                            .getValue() );
    }
View Full Code Here

    }

    public void testAddToArchive_ShouldWriteComponentWithoutHintToFile()
        throws IOException, ArchiverException, JDOMException
    {
        final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", null, "impl" ) );

        filter.components = new LinkedHashMap<String, Xpp3Dom>();
        filter.components.put( "role", dom );

        final FileCatchingArchiver fca = new FileCatchingArchiver();
View Full Code Here

    }

    public void testAddToArchive_ShouldWriteComponentWithHintToFile()
        throws IOException, ArchiverException, JDOMException
    {
        final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );

        filter.components = new LinkedHashMap<String, Xpp3Dom>();
        filter.components.put( "rolehint", dom );

        final FileCatchingArchiver fca = new FileCatchingArchiver();
View Full Code Here

    public void testAddToArchive_ShouldWriteTwoComponentToFile()
        throws IOException, ArchiverException, JDOMException
    {
        filter.components = new LinkedHashMap<String, Xpp3Dom>();

        final Xpp3Dom dom = createComponentDom( new ComponentDef( "role", "hint", "impl" ) );

        filter.components.put( "rolehint", dom );

        final Xpp3Dom dom2 = createComponentDom( new ComponentDef( "role", "hint2", "impl" ) );

        filter.components.put( "rolehint2", dom2 );

        final FileCatchingArchiver fca = new FileCatchingArchiver();
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.util.xml.Xpp3Dom

Copyright © 2018 www.massapicom. 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.