Package org.apache.beehive.netui.tools.testrecorder.shared.config

Examples of org.apache.beehive.netui.tools.testrecorder.shared.config.ConfigException


    private void doPlaybackStart( HttpServletRequest request, HttpServletResponse response )
            throws IOException, ConfigException {
        String testName = getTestName( request );
        TestDefinition test = getTest( testName );
        if ( test == null ) {
            throw new ConfigException(
                    "ERROR: playback start failed, unable to find a test for test name( " + testName + " )" );
        }
        if ( log.isInfoEnabled() ) {
            log.info( "playback start test( " + test.getName() + " )" );
        }
View Full Code Here


            serverDef = XMLHelper.getServerDefinition( is, Constants.SERVER_FILE );
        }
        catch ( Throwable e ) {
            String msg = "Failed to obtain test recorder server definition from XML";
            log.error( msg, e );
            throw new ConfigException( msg, e );
        }
        finally {
            if ( is != null ) {
                try {
                    is.close();
                }
                catch ( IOException e ) {
                    log.error( "Failed closing stream of server definition XML", e );
                    throw e;
                }
            }
        }
        if ( serverDef == null ) {
            String msg = "Failed to obtain test recorder server definition from XML";
            log.error( msg );
            throw new ConfigException( msg );
        }
        // the schema insures that at least one webapp is defined
        assert serverDef.getWebappCount() != 0 : "no webapps defined in server definition XML file" ;
        String webappList = getWebappsProperty();
        if ( webappList == null ) {
            String msg = "ERROR: the '" + WEBAPPS_PROPERTY + "' property must be set.";
            log.error( msg );
            throw new ConfigException( msg );
        }
        webappList = webappList.trim();
        WebappDefinition webapp = null;
        TestDefinitions tests = null;
        if ( webappList.equalsIgnoreCase( "all" ) ) {
            WebappDefinition[] webappDefList = serverDef.getWebapps();
            for ( int i = 0; i < webappDefList.length; i++ ) {
                webapp = webappDefList[i];
                tests = getTestDefinitions( webapp );
                if ( tests == null ) {
                    continue;
                }
                serverDef.addTestDefinitions( webapp, tests );
            }
        }
        else {
            String webappName = null;
            for ( StringTokenizer stringTokenizer = new StringTokenizer( webappList, "," );
                    stringTokenizer.hasMoreTokens(); ) {
                webappName = stringTokenizer.nextToken().trim();
                if ( webappName.length() == 0 ) {
                    continue;
                }
                webapp = serverDef.getWebapp( webappName );
                if ( webapp == null ) {
                    String msg = "WARNING: no webapp found with name( " + webappName + " )";
                    if ( log.isErrorEnabled() ) {
                        log.error( msg );
                    }
                    System.err.println( msg );
                    continue;
                }
                if ( log.isDebugEnabled() ) {
                    log.debug( "retrieving test definition for webapp at( " + webapp.getContextRoot() + " )" );
                }
                tests = getTestDefinitions( webapp );
                if ( tests == null ) {
                    continue;
                }
                serverDef.addTestDefinitions( webapp, tests );
            }
        }
        if ( serverDef.getTestDefinitionsCount() == 0 ) {
            String msg = "ERROR: no test definitions found";
            log.error( msg );
            throw new ConfigException( msg );
        }
    }
View Full Code Here

            String msg = "ERROR: encountered exception processing resource( " + Constants.CONFIG_FILE + " )";
            log.fatal( msg, e );
            if ( e instanceof ConfigException ) {
                throw (ConfigException) e;
            }
            throw new ConfigException( msg, e );
        }
        finally {
            try {
                if ( is != null ) {
                    is.close();
                }
            }
            catch ( IOException e ) {
                if ( log.isWarnEnabled() ) {
                    log.warn( "WARNING: received exception closing HTTP stream for( " + Constants.CONFIG_FILE +
                            " )", e );
                }
                //ignore
            }
            method.releaseConnection();
        }
        if ( log.isInfoEnabled() ) {
            log.info( "config( " + config + " )" );
        }

        method = new GetMethod( uri );
        queryParams[2] = webappParam;
        method.setQueryString( queryParams );
        is = executeXMLRequest( method, uri, Constants.WEBAPPS_FILE );
        Webapps webapps = null;
        try {
            webapps = XMLHelper.getWebapps( is, Constants.WEBAPPS_FILE, config );
        }
        catch ( Exception e ) {
            String msg = "ERROR: encountered exception processing resource( " + Constants.WEBAPPS_FILE + " )";
            log.fatal( msg, e );
            if ( e instanceof ConfigException ) {
                throw (ConfigException) e;
            }
            throw new ConfigException( msg, e );
        }
        finally {
            try {
                if ( is != null ) {
                    is.close();
                }
            }
            catch ( IOException e ) {
                if ( log.isWarnEnabled() ) {
                    log.warn( "WARNING: received exception closing HTTP stream for( " + Constants.WEBAPPS_FILE +
                            " )", e );
                }
                // ignore
            }
            method.releaseConnection();
        }
        if ( log.isInfoEnabled() ) {
            log.info( "webapps( " + webapps + " )" );
        }

        method = new GetMethod( uri );
        queryParams[2] = testsParam;
        method.setQueryString( queryParams );
        is = executeXMLRequest( method, uri, Constants.TESTS_FILE );
        TestDefinitions testDefinitions = null;
        try {
            testDefinitions = XMLHelper.getTestDefinitionsInstance( is, Constants.TESTS_FILE, webapps,
                    config.getBaseDirectory().getAbsolutePath() );
        }
        catch ( Exception e ) {
            String msg = "ERROR: encountered exception processing resource( " + Constants.TESTS_FILE + " )";
            log.fatal( msg, e );
            if ( e instanceof ConfigException ) {
                throw (ConfigException) e;
            }
            throw new ConfigException( msg, e );
        }
        finally {
            try {
                if ( is != null ) {
                    is.close();
View Full Code Here

                catch ( IOException e1 ) {
                    // ignore
                }
            }
            method.releaseConnection();
            throw new ConfigException( msg, e );
        }
        return is;
    }
View Full Code Here

        }
        // Retries failed
        if ( statusCode == -1 ) {
            String msg = "Failed to execute request( " + method.getURI() + " )";
            log.error( msg );
            throw new ConfigException( msg );
        }
        InputStream is = method.getResponseBodyAsStream();
        return is;
    }
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.tools.testrecorder.shared.config.ConfigException

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.