Package org.apache.beehive.netui.tools.testrecorder.x2004.server

Examples of org.apache.beehive.netui.tools.testrecorder.x2004.server.ServerDefinitionDocument


            catType = catsType.addNewCategory();
            populateCategory( catType, category );
        }
        TestsType testsType = defs.addNewTests();
        TestDefinition testDef = null;
        TestType testType = null;
        for ( Iterator it = tests.iterator(); it.hasNext(); ) {
            testDef = (TestDefinition) it.next();
            testType = testsType.addNewTest();
            populateTest( testType, testDef );
        }
View Full Code Here


    private static TestDefinitions getTestDefinitionsInstance( TestType[] testTypes, Categories categories,
            Webapps webapps )
            throws ConfigException {
        List list = new ArrayList();
        TestDefinition testDef = null;
        TestType type = null;
        String[] testCategoryStrings = null;
        List testCategories = null;
        WebappConfig webapp = null;
        for ( int i = 0; i < testTypes.length; i++ ) {
            type = testTypes[i];
            if ( type.getCategories() != null ) {
                testCategoryStrings = type.getCategories().getCategoryArray();
                testCategories = getCategories( testCategoryStrings, categories );
            }
            else {
                testCategories = new ArrayList();
            }
            webapp = webapps.getWebapp( type.getWebapp() );
            if ( webapp == null ) {
                ConfigException ce = new ConfigException( "ERROR: unable to find test recorder webapp with name( " +
                        type.getWebapp() +
                        " ) referenced in test definition( " + type.getName() + " )" );
                log.fatal( ce );
                throw ce;
            }
            testDef =
                    new TestDefinition( type.getName().trim(), type.getDescription().trim(), webapp,
                            testCategories );
            categories.addTest( testDef );
            list.add( testDef );
        }
        TestDefinitions defs = new TestDefinitions( list, categories, webapps );
View Full Code Here

        for ( Iterator it = categories.iterator(); it.hasNext(); ) {
            category = (Category) it.next();
            catType = catsType.addNewCategory();
            populateCategory( catType, category );
        }
        TestsType testsType = defs.addNewTests();
        TestDefinition testDef = null;
        TestType testType = null;
        for ( Iterator it = tests.iterator(); it.hasNext(); ) {
            testDef = (TestDefinition) it.next();
            testType = testsType.addNewTest();
            populateTest( testType, testDef );
        }
        return doc;
    }
View Full Code Here

        return getDiffResults( is, file.getAbsolutePath() );
    }

    public static List getDiffResults( InputStream is, String resourceIdentifier )
            throws SessionXMLException, IOException {
        RecorderDiffDocument doc = null;
        try {
            XmlOptions loadOptions = new XmlOptions();
            loadOptions.setLoadLineNumbers();
            doc = RecorderDiffDocument.Factory.parse( is, loadOptions );
        }
View Full Code Here

    public static void createDiffFile( File diffFile, PlaybackSessionBean bean ) throws IOException {
        XmlOptions xmlOptions = new XmlOptions();
        xmlOptions.setSavePrettyPrint();
        xmlOptions.setSavePrettyPrintIndent( 3 );
        RecorderDiffDocument doc = createDiffSessionDocument( bean, xmlOptions );
        doc.save( diffFile, xmlOptions );
    }
View Full Code Here

        RecorderDiffDocument doc = createDiffSessionDocument( bean, xmlOptions );
        doc.save( diffFile, xmlOptions );
    }

    private static RecorderDiffDocument createDiffSessionDocument( PlaybackSessionBean bean, XmlOptions options ) {
        RecorderDiffDocument doc = RecorderDiffDocument.Factory.newInstance( options );
        RecorderDiffDocument.RecorderDiff diff = doc.addNewRecorderDiff();
        TestResults results = null;
        RequestData request = null;
        for ( int i = 0; i < bean.getTestCount(); i++ ) {
            results = bean.getTestResults( i );
            if ( results.isTestPassed() ) {
View Full Code Here

     * @throws SessionXMLException
     */
    private static List getDiffResults( RecorderDiffDocument document ) throws SessionXMLException {
        RecorderDiffDocument.RecorderDiff diff = document.getRecorderDiff();
        List list = new ArrayList( diff.sizeOfRequestArray() );
        TestDiffType diffType = null;
        TestResults results = null;
        for ( int i = 0; i < diff.sizeOfRequestArray(); i++ ) {
            diffType = diff.getRequestArray( i );
            results = new TestResults( diffType.getTestNumber(), diffType.getUri(), false, false );
            results.addDiffResult( diffType.getDiffResults() );
            list.add( results );
        }
        return list;
    }
View Full Code Here

        return getServerDefinition( is, file.getAbsolutePath() );
    }

    public static ServerDefinition getServerDefinition( InputStream is, String resourceIdentifier )
            throws ConfigException, IOException {
        ServerDefinitionDocument doc = null;

        StringBuffer inputStr = new StringBuffer();
        try {
            // First read the response into a buffer; that way, we can print it on error.
            int c;
            while ( ( c = is.read() ) != -1 )
            {
                inputStr.append( ( char ) c );
            }
           
            XmlOptions loadOptions = new XmlOptions();
            loadOptions.setLoadLineNumbers();
            doc = ServerDefinitionDocument.Factory.parse( inputStr.toString(), loadOptions );
        }
        catch ( XmlException e ) {
            log.fatal( "test recorder parse exception while parsing this document: " + inputStr.toString(), e );
            ConfigException ex = new ConfigException( "ERROR: failed parsing test recorder server definition XML, file( " +
                    resourceIdentifier + " )", e );
            log.fatal( ex );
            throw ex;
        }
        finally {
            if ( is != null ) {
                try {
                    is.close();
                }
                catch ( IOException e ) {
                    log.error( "ERROR: failed to close stream for file( " + resourceIdentifier + " )" );
                }
            }
        }

        assert doc != null;
        try {
            validate( doc, resourceIdentifier,
                    "ERROR: test recorder server definition XML document is not valid against the schema" );
        }
        catch ( ConfigException e ) {
            log.fatal( "test recorder failed validating server definition file( " + resourceIdentifier + " )", e );
            throw e;
        }
        ServerDefinition server = new ServerDefinition( doc.getServerDefinition().getName(),
                doc.getServerDefinition().getHostname(), doc.getServerDefinition().getPort() );
        populateServerDefinition( server, doc );
        return server;
    }
View Full Code Here

        return server;
    }

    public static void populateServerDefinition( final ServerDefinition server, final ServerDefinitionDocument doc ) {
        int cnt = doc.getServerDefinition().getWebapps().sizeOfWebappArray();
        WebappDefType webappType = null;
        WebappDefinition webapp = null;
        for ( int i = 0; i < cnt; i++ ) {
            webappType = doc.getServerDefinition().getWebapps().getWebappArray( i );
            webapp = new WebappDefinition( webappType.getName(), webappType.getDescription(),
                    webappType.getContextRoot(), webappType.getServletURI() );
            server.addWebapp( webapp );
        }
        return;
    }
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.tools.testrecorder.x2004.server.ServerDefinitionDocument

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.