Package org.apache.avalon.framework.configuration

Examples of org.apache.avalon.framework.configuration.DefaultConfiguration


     *         would not contain any information.
     */
    Configuration saveState()
    {
        boolean empty = true;
        DefaultConfiguration state = new DefaultConfiguration( "instrumentable", "-" );
        state.setAttribute( "name", m_name );

        // Save the child Instrumentables
        InstrumentableProxy[] childProxies = getChildInstrumentableProxies();
        for( int i = 0; i < childProxies.length; i++ )
        {
            Configuration childState = childProxies[ i ].saveState();
            if ( childState != null )
            {
                empty = false;
                state.addChild( childState );
            }
        }

        // Save the direct Instruments
        InstrumentProxy[] proxies = getInstrumentProxies();
        for( int i = 0; i < proxies.length; i++ )
        {
            Configuration childState = proxies[ i ].saveState();
            if ( childState != null )
            {
                empty = false;
                state.addChild( childState );
            }
        }

        // Only return a state if it contains information.
        if ( empty )
View Full Code Here


                Iterator iter = subTree.list().iterator();
                List configs = new LinkedList();
                while (iter.hasNext())
                {
                        TestElement item = (TestElement)iter.next();
                        DefaultConfiguration config = new DefaultConfiguration("node","node");
                        config.addChild(getConfigForTestElement(null,item));
                        List configList = getConfigsFromTree(subTree.getTree(item));
                        Iterator iter2 = configList.iterator();
                        while(iter2.hasNext())
                        {
                                config.addChild((Configuration)iter2.next());
                        }
                        configs.add(config);
                }
                return configs;
        }
View Full Code Here

                return configs;
        }
       
        public static Configuration getConfiguration(byte[] bin)
        {
                DefaultConfiguration config = new DefaultConfiguration(BINARY,"JMeter Save Service");
                try {
                        config.setValue(new String(bin,"utf-8"));
                } catch(UnsupportedEncodingException e) {
                        log.error("",e);
                }
                return config;
        }
View Full Code Here

                return result;         
        }
       
        public static Configuration getConfiguration(AssertionResult assResult)
        {
                DefaultConfiguration config = new DefaultConfiguration(ASSERTION_RESULT_TAG_NAME,
                                "JMeter Save Service");
                config.setAttribute(FAILURE_MESSAGE,assResult.getFailureMessage());
                config.setAttribute(ERROR,""+assResult.isError());
                config.setAttribute(FAILURE,""+assResult.isFailure());
                return config;         
        }
View Full Code Here

               data recorded.
        **/

        public static Configuration getConfiguration(SampleResult result,boolean funcTest)
        {
                DefaultConfiguration config = new DefaultConfiguration(SAMPLE_RESULT_TAG_NAME,"JMeter Save Service");

                if (saveTime)
                {
                        config.setAttribute(TIME,""+result.getTime());
                }
                if (saveLabel)
                {
                        config.setAttribute(LABEL,result.getSampleLabel());
                }
                if (saveResponseCode)
                {
                        config.setAttribute(RESPONSE_CODE,result.getResponseCode());
                }
                if (saveResponseMessage)
                {
                        config.setAttribute(RESPONSE_MESSAGE,result.getResponseMessage());
                }
                if (saveThreadName)
                {
                        config.setAttribute(THREAD_NAME,result.getThreadName());
                }
                if (saveDataType)
                {
                        config.setAttribute(DATA_TYPE,result.getDataType());
                }

                if (printMilliseconds)
                {
                        config.setAttribute(TIME_STAMP,""+result.getTimeStamp());
                }
                else if (formatter != null)
                {
                        String stamp = formatter.format(new Date(result.getTimeStamp()));
                        config.setAttribute(TIME_STAMP, stamp);
                }

                if (saveSuccessful)
                {
                        config.setAttribute(SUCCESSFUL,new Boolean(result.isSuccessful()).toString());
                }

                SampleResult[] subResults = result.getSubResults();
                for(int i = 0;i < subResults.length;i++)
                {
                        config.addChild(getConfiguration(subResults[i],funcTest));
                }

                AssertionResult[] assResults = result.getAssertionResults();

                if(funcTest)
                {
                        config.addChild(getConfigForTestElement(null,result.getSamplerData()));
                        for(int i = 0;i < assResults.length;i++)
                        {
                                config.addChild(getConfiguration(assResults[i]));
                        }
                        config.addChild(getConfiguration(result.getResponseData()));
                }
                // Determine which of the assertion results to save and
                // whether to save the response data
                else
                {
                        if (assertionsResultsToSave == SAVE_ALL_ASSERTIONS)
                        {
                                config.addChild(getConfigForTestElement(null,result.getSamplerData()));
                                for(int i = 0;i < assResults.length;i++)
                                {
                                        config.addChild(getConfiguration(assResults[i]));
                                }
                        }
                        else if ((assertionsResultsToSave == SAVE_FIRST_ASSERTION)
                                 && assResults.length > 0)
                        {
                                config.addChild(getConfiguration(assResults[0]));
                        }

                        if (saveResponseData)
                        {
                                config.addChild(getConfiguration(result.getResponseData()));
                        }
                }
                return config;         
        }
View Full Code Here

                return config;         
        }

        public static Configuration getConfigForTestElement(String named,TestElement item)
        {
                DefaultConfiguration config = new DefaultConfiguration("testelement","testelement");
                if(named != null)
                {
                        config.setAttribute("name",named);
                }
                if(item.getProperty(TestElement.TEST_CLASS) != null)
                {
                        config.setAttribute("class",(String)item.getProperty(TestElement.TEST_CLASS));
                }
                else
                {
                        config.setAttribute("class",item.getClass().getName());
                }
                Iterator iter = item.getPropertyNames().iterator();
                while (iter.hasNext())
                {
                        String name = (String)iter.next();
                        Object value = item.getProperty(name);
                        if(value instanceof TestElement)
                        {
                                config.addChild(getConfigForTestElement(name,(TestElement)value));
                        }
                        else if(value instanceof Collection)
                        {
                                config.addChild(createConfigForCollection(name,(Collection)value));
                        }
                        else if(value != null)
                        {
                                config.addChild(createConfigForString(name,value.toString()));
                        }
                }
                return config;
        }
View Full Code Here

                return config;
        }

        private static Configuration createConfigForCollection(String propertyName,Collection list)
        {
                DefaultConfiguration config = new DefaultConfiguration("collection","collection");
                if(propertyName != null)
                {
                        config.setAttribute("name",propertyName);
                }
                config.setAttribute("class",list.getClass().getName());
                Iterator iter = list.iterator();
                while (iter.hasNext())
                {
                        Object item = iter.next();
                        if(item instanceof TestElement)
                        {
                                config.addChild(getConfigForTestElement(null,(TestElement)item));
                        }
                        else if(item instanceof Collection)
                        {
                                config.addChild(createConfigForCollection(null,(Collection)item));
                        }
                        else
                        {
                                config.addChild(createConfigForString(item.toString()));
                        }
                }
                return config;
        }
View Full Code Here

                return config;
        }

        private static Configuration createConfigForString(String value)
        {
                DefaultConfiguration config = new DefaultConfiguration("string","string");
                config.setValue(value);
                config.setAttribute(XML_SPACE,PRESERVE);
                return config;
        }
View Full Code Here

        {
                if(value == null)
                {
                        value = "";
                }
                DefaultConfiguration config = new DefaultConfiguration("property","property");
                config.setAttribute("name",name);
                config.setValue(value);
                config.setAttribute(XML_SPACE,PRESERVE);
                return config;
        }
View Full Code Here

            throw new RuntimeException("Error in getUserInbox.");
        } else {
            // need mailbox object
            getLogger().info("Need inbox for " + userName );
            String destination = inboxRootURL + userName + "/";
            DefaultConfiguration mboxConf
                = new DefaultConfiguration("repository", "generated:AvalonFileRepository.compose()");
            mboxConf.setAttribute("destinationURL", destination);
            mboxConf.setAttribute("type", "MAIL");
            try {
                userInbox = (MailRepository) mailstore.select(mboxConf);
                mailboxes.put(userName, userInbox);
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.configuration.DefaultConfiguration

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.