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 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));
        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 bundle = createElement(properties, "property");
        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;
            }
            bundle.setAttribute("name", "bundle-" + sn);
            bundle.setAttribute("value", state);
        }

    }
View Full Code Here

      MavenPluginAdapter merged = new MavenPluginAdapter(dominant);
      if (DependencyBuilder.areEquivalent(dominant.getDependency(), recessive.getDependency()))
      {
         MavenPluginAdapter recessiveAdaptater = new MavenPluginAdapter(recessive);
         // Merge the configurations
         Xpp3Dom mergedDomConfig = Xpp3Dom.mergeXpp3Dom((Xpp3Dom) merged.getConfiguration(),
                  (Xpp3Dom) recessiveAdaptater.getConfiguration());
         merged.setConfiguration(mergedDomConfig);
         // Merge the executions
         List<PluginExecution> mergedExecutions = mergePluginsExecutions(merged.getExecutionsAsMap(),
                  recessiveAdaptater.getExecutionsAsMap());
View Full Code Here

         {
            if (recessive.containsKey(entry.getKey())
                     && recessive.get(entry.getKey()).getConfiguration() != null)
            {
               // Merge configurations
               Xpp3Dom mergedDomConfig = Xpp3Dom.mergeXpp3Dom((Xpp3Dom) pluginExecution.getConfiguration(),
                        (Xpp3Dom) recessive.get(entry.getKey()).getConfiguration());
               mergedPluginExecution.setConfiguration(mergedDomConfig);
            }
            else
            {
View Full Code Here

            Plugin plugin = (Plugin) project.getModel().getBuild().getPluginsAsMap().get("org.apache.geronimo.buildsupport:car-maven-plugin");
            if (plugin == null) {
                throw new Error("Unable to resolve car plugin");
            }

            Xpp3Dom dom;
            if (plugin.getExecutions().isEmpty()) {
                dom = (Xpp3Dom) plugin.getConfiguration();
            } else {
                if (plugin.getExecutions().size() > 1) {
                    throw new IllegalStateException("Cannot determine correct configuration for PluginMetadataGeneratorMojo: " + plugin.getExecutionsAsMap().keySet());
                }
                dom = (Xpp3Dom) ((PluginExecution) plugin.getExecutions().get(0)).getConfiguration();
            }
            Xpp3Dom instanceDom = dom.getChild("instance");

            if (instanceDom == null || instanceDom.getChild("plugin-artifact") == null) {
                instance = new PluginArtifactType();
            } else {
                String instanceString = instanceDom.getChild("plugin-artifact").toString();
                instance = PluginXmlUtil.loadPluginArtifactMetadata(new StringReader(instanceString.replace("#{", "${")));
            }
            if (this.commonInstance != null && this.commonInstance.getChild("plugin-artifact") != null) {
                PluginArtifactType commonInstance = PluginXmlUtil.loadPluginArtifactMetadata(new StringReader(this.commonInstance.getChild("plugin-artifact").toString().replace("#{", "${")));
                //merge
View Full Code Here

        repository.setId( "id=" + protocol );

        repository.setProtocol( protocol );

        Xpp3Dom conf = new Xpp3Dom( "configuration" );

        Xpp3Dom configurableField = new Xpp3Dom( "configurableField" );

        configurableField.setValue( s );

        conf.addChild( configurableField );

        wagonManager.addConfiguration( repository.getId(), conf );
View Full Code Here

        PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
        String goalId = mojoDescriptor.getGoal();
        String groupId = pluginDescriptor.getGroupId();
        String artifactId = pluginDescriptor.getArtifactId();
        String executionId = mojoExecution.getExecutionId();
        Xpp3Dom dom = project.getGoalConfiguration( groupId, artifactId, executionId, goalId );
        Xpp3Dom reportDom = project.getReportConfiguration( groupId, artifactId, executionId );
        dom = Xpp3Dom.mergeXpp3Dom( dom, reportDom );
        if ( mojoExecution.getConfiguration() != null )
        {
            dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
        }
View Full Code Here

        throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException,
        ArtifactResolutionException
    {
        MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
        PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor();
        Xpp3Dom dom = project.getReportConfiguration( descriptor.getGroupId(), descriptor.getArtifactId(),
                                                      mojoExecution.getExecutionId() );
        if ( mojoExecution.getConfiguration() != null )
        {
            dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
        }
View Full Code Here

        Plugin result3 = (Plugin) results.get( 2 );

        assertEquals( "group2", result3.getGroupId() );
        assertEquals( "artifact2", result3.getArtifactId() );

        Xpp3Dom result3Config = (Xpp3Dom) result3.getConfiguration();

        assertNotNull( result3Config );

        assertEquals( "value", result3Config.getChild( "key" ).getValue() );
        assertEquals( "value2", result3Config.getChild( "key2" ).getValue() );
    }
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.