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

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


        }
    }

    private void doRecordStart( String testName, HttpServletRequest request, HttpServletResponse response,
            boolean overwrite, String testUser, String description ) throws IOException, ServletException {
        TestDefinition test = getTest( testName );
        if ( test == null ) {
            test = new TestDefinition( testName, description, TestRecorderFilter.instance().getWebapp(), null );
        }
        if ( test.getWebapp() != TestRecorderFilter.instance().getWebapp() ) {
            String msg = "ERROR: unable to start recording, the webapp of the test( " +
                    test.getWebapp().getName() + " ) is not the same as this webapp( " +
                    TestRecorderFilter.instance().getWebapp() + " )";
            forward( request, response, msg, Constants.RECORD_PAGE, true );
            return;
        }
        // may throw IOException or SecurityException
        RecordSession session = null;
        try {
            session = getRecordSession( test, overwrite, testUser, description );
            if ( description != null ) {
                test.setDescription( description );
            }
            TestRecorderFilter.instance().getTestDefinitions().add( test );
        }
        catch ( Exception ex ) {
            String msg = "ERROR: unable to start recording, unable to obtain session, exception( " +
View Full Code Here


    }

    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() + " )" );
        }
        PlaybackSession session = null;
        try {
            session = getPlaybackSession( test );
        }
View Full Code Here

    public void doDiff( HttpServletRequest request, HttpServletResponse response )
            throws IOException, ServletException, ConfigException {
        // TODO use test name constant here, similar to the rest of the commands
        String sessionName = request.getParameter( Constants.FILE );
        TestDefinition test = getTest( sessionName );
        if ( test == null ) {
            String msg = "ERROR: unable to display diff output, no test was found for name( " + sessionName +
                    " )";
            forward( request, response, msg, Constants.ERROR_PAGE, true );
            return;
        }
        try {
            Writer wrtr = response.getWriter();
            File diffFile = getDiffFile( test );
            if ( !diffFile.exists() ) {
                String msg = "ERROR: unable to display diff output, no file was found for test( " +
                        test.getName() + " ), file( " + diffFile.getAbsolutePath() + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            // output an html page
            wrtr.write( "<html><head><title>Test Diffs of " );
            wrtr.write( test.getName() );
            wrtr.write( "</title></head>\n" );
            wrtr.write( "<body>\n" );
            wrtr.write( "<h4>Test Diffs: " );
            wrtr.write( test.getName() );
            wrtr.write( "</h4>\n" );
            wrtr.write( "<pre>" );
            wrtr.write( Reporter.genDiffDetails( diffFile ) );
            wrtr.write( "</pre>" );
            wrtr.write( "</body></html>" );
        }
        catch ( Exception e ) {
            String msg = "ERROR: failed to display diff file, exception( " + e.getMessage() +
                    " ), test( " + test.getName() + " )";
            forward( request, response, msg, Constants.ERROR_PAGE, true );
            return;
        }
    }
View Full Code Here

    }

    public void doLink( HttpServletRequest request, HttpServletResponse response )
            throws IOException, ServletException, ConfigException {
        String sessionName = request.getParameter( Constants.FILE );
        TestDefinition test = getTest( sessionName );
        WebappConfig config = TestRecorderFilter.instance().getWebapp();
        try {
            if ( test == null ) {
                String msg = "No test was found for name( " + sessionName + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }

            File recFile = getRecordSessionFile( test );
            if ( !recFile.exists() ) {
                String msg = "No file was found for test( " + test.getName() + " ), file( " +
                        recFile.getAbsolutePath() + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }

            RecordSessionBean bean = null;
            try {
                bean = XMLHelper.getRecordSessionBean( recFile );
            }
            catch ( SessionXMLException e ) {
                String msg = "Failed processing file for record session( " + test.getName() + " ), file( " +
                        recFile.getAbsolutePath() + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            RequestData rd = bean.getRequestData( 0 );
            if ( rd == null ) {
                String msg = "Unable to find the first request in the test ( " + test.getName() + " ), file( " +
                        recFile.getAbsolutePath() + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            String host = config.getServer().getHostname();
            if ( host.equals( "localhost" ) )
            {
                host = request.getServerName();
            }
            response.sendRedirect( rd.getUri( host, config.getServer().getPort() ) );
            return;
        }
        catch ( Exception e ) {
            String msg = "ERROR: failed to display test details, exception( " + e.getMessage() +
                    " ), test( " + test.getName() + " )";
            forward( request, response, msg, Constants.ERROR_PAGE, true, e );
        }
    }
View Full Code Here

    public void doDetails( HttpServletRequest request, HttpServletResponse response )
            throws IOException, ServletException, ConfigException {
        // TODO use test name constant here, similar to the rest of the commands
        String sessionName = request.getParameter( Constants.FILE );
        TestDefinition test = getTest( sessionName );
        try {
            if ( test == null ) {
                String msg = "No test was found for name( " + sessionName + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            Writer wrtr = response.getWriter();
            File recFile = getRecordSessionFile( test );
            if ( !recFile.exists() ) {
                String msg = "No file was found for test( " + test.getName() + " ), file( " +
                        recFile.getAbsolutePath() + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            RecordSessionBean bean = null;
            try {
                bean = XMLHelper.getRecordSessionBean( recFile );
            }
            catch ( SessionXMLException e ) {
                String msg = "Failed processing file for record session( " + test.getName() + " ), file( " +
                        recFile.getAbsolutePath() + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            // output an html page
            wrtr.write( "<html><head><title>Test Details of " );
            wrtr.write( test.getName() );
            wrtr.write( "</title></head>\n" );
            wrtr.write( "<body>\n" );
            wrtr.write( "<h3>Test Details: " );
            wrtr.write( test.getName() );
            wrtr.write( "</h3>\n" );
            wrtr.write( Reporter.genDetails( bean ) );
            wrtr.write( "</body></html>" );
        }
        catch ( Exception e ) {
            String msg = "ERROR: failed to display test details, exception( " + e.getMessage() +
                    " ), test( " + test.getName() + " )";
            forward( request, response, msg, Constants.ERROR_PAGE, true, e );
        }
    }
View Full Code Here

    private void doDisplayRecord( HttpServletRequest request, HttpServletResponse response )
            throws ServletException, IOException {
        String testString = request.getParameter( "test" );
        TestRecorderFilter filter = TestRecorderFilter.instance();
        TestDefinition test = filter.getTestDefinitions().getTest( testString );
        File file = null;
        try {
            if ( test == null ) {
                String msg = "No test was found for name( " + testString + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            file = new File( test.getTestFilePath() );
            if ( !file.exists() ) {
                String msg = "No record file was found for test( " + test.getName() + " ), file( " +
                        file.getAbsolutePath() + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            doFileReport( request, response, test, file, "Record File for '" + test.getName() + "' Test" );
        }
        catch ( Exception e ) {
            String msg = "ERROR: failed to display record file, exception( " + e.getMessage() +
                    " ), test( " + test.getName() + " ), file( " + file + " )";
            forward( request, response, msg, Constants.ERROR_PAGE, true, e );
        }
    }
View Full Code Here

    private void doDisplayPlayback( HttpServletRequest request, HttpServletResponse response )
            throws ServletException, IOException {
        String testString = request.getParameter( "test" );
        TestRecorderFilter filter = TestRecorderFilter.instance();
        TestDefinition test = filter.getTestDefinitions().getTest( testString );
        File file = null;
        try {
            if ( test == null ) {
                String msg = "No test was found for name( " + testString + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            file = new File( test.getResultFilePath() );
            if ( !file.exists() ) {
                String msg = "No playback file was found for test( " + test.getName() + " ), file( " +
                        file.getAbsolutePath() + " )";
                forward( request, response, msg, Constants.ERROR_PAGE, true );
                return;
            }
            doFileReport( request, response, test, file, "Playback File for '" + test.getName() + "' Test" );
        }
        catch ( Exception e ) {
            String msg = "ERROR: failed to display playback file, exception( " + e.getMessage() +
                    " ), test( " + test.getName() + " ), file( " + file + " )";
            forward( request, response, msg, Constants.ERROR_PAGE, true, e );
        }
    }
View Full Code Here

            log.debug( "test name( " + name + " )" );
        }
        if ( name == null ) {
            return null;
        }
        TestDefinition test = TestRecorderFilter.instance().getTestDefinitions().getTest( name );
        return test;
    }
View Full Code Here

            }
        }
    }

    private static void addList( List list, TestSuite suite, HashMap webappMap, boolean includeWebappInName ) {
        TestDefinition def = null;
        for ( int i = 0; i < list.size(); i++ ) {
            def = (TestDefinition) list.get( i );
            log.debug( "Adding test( " + def.getName() + " )to JUnit suite" );
            if ( includeWebappInName ) {
                suite.addTest( new TestRecorderJUnitTest( def, def.getWebapp().getName() + "-" + def.getName() ) );
            }
            else {
                suite.addTest( new TestRecorderJUnitTest( def ) );
            }
            addWebapp( webappMap, def.getWebapp() );
        }
    }
View Full Code Here

        List list = new ArrayList();
        if ( testList == null ) {
            return list;
        }
        String name = null;
        TestDefinition test = null;
        for ( StringTokenizer stringTokenizer = new StringTokenizer( testList, "," );
                stringTokenizer.hasMoreTokens(); ) {
            name = stringTokenizer.nextToken().trim();
            if ( name.length() == 0 ) {
                continue;
View Full Code Here

TOP

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

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.