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

Examples of org.apache.beehive.netui.tools.testrecorder.shared.ResponseData


        return respData;
    }

    public void setRespData( boolean replaceSessionId ) throws SessionFailedException {
        respData = ResponseWrapper.populate( (HttpServletResponse) newResponse,
                new ResponseData( request.getServerName(), request.getServerPort() ) );      
        if ( replaceSessionId &&  respData.getBody() != null ) {
            respData.setBody( serverAdapter.replaceSessionIDrespData.getBody() ) );
        }
    }
View Full Code Here


    protected void startPlayback() throws PlaybackException {
        HttpMethod method = new GetMethod( RequestData.genUri( "http",
                getTest().getWebapp().getServer().getHostname(), getTest().getWebapp().getServer().getPort(),
                getTest().getWebapp().getServletURI() ) );
        method.setQueryString( getStartParams() );
        ResponseData response = null;
        try {
            response = execute( getControlClient(), method );
        }
        catch ( Exception e ) {
            String msg = "Failed to execute start playback request, exception( " + e.getMessage() + " )";
            log.error( msg, e );
            if ( e instanceof PlaybackException ) {
                throw (PlaybackException) e;
            }
            throw new PlaybackException( msg, e );
        }
        String outcome = response.getHeader( Constants.OUTCOME_HEADER );
        String testId = response.getHeader( Constants.TEST_ID_HEADER );
        String testFileName = response.getHeader( Constants.RECORD_FILE_HEADER );
        String startMsg = response.getHeader( Constants.MSG_ATTRIBUTE );
        // config the playback stop params
        setStopParam( 3, new NameValuePair( Constants.TEST_ID_HEADER, testId ) );
        setTestId( testId );
        if ( log.isInfoEnabled() ) {
            log.info( "outcome( " + outcome + " )" );
View Full Code Here

        boolean rtnVal = false;
        HttpMethod method = new GetMethod( RequestData.genUri( "http",
                getTest().getWebapp().getServer().getHostname(), getTest().getWebapp().getServer().getPort(),
                getTest().getWebapp().getServletURI() ) );
        method.setQueryString( getStopParams() );
        ResponseData response = null;
        try {
            response = execute( getControlClient(), method );
        }
        catch ( Exception e ) {
            String msg = "Failed to execute stop playback request, exception( " + e.getMessage() + " )";
            log.error( msg, e );
            if ( e instanceof PlaybackException ) {
                throw (PlaybackException) e;
            }
            throw new PlaybackException( msg, e );
        }
        String outcome = response.getHeader( Constants.OUTCOME_HEADER );
        String resultsFileName = response.getHeader( Constants.RESULTS_FILE_HEADER );
        String diffFileName = response.getHeader( Constants.RESULTS_DIFF_HEADER );
        String stopMsg = response.getHeader( Constants.MSG_ATTRIBUTE );
        if ( log.isDebugEnabled() ) {
            log.debug( "stop outcome( " + outcome + " )" );
            log.debug( "stopMsg( " + stopMsg + " )" );
        }
        if ( outcome != null && !outcome.equals( Constants.ERROR ) ) {
View Full Code Here

                }
                HttpMethod method = createPlaybackMethod( request, getTest() );
                if ( log.isDebugEnabled() ) {
                    log.debug( "playback URI( " + method.getURI() + " )" );
                }
                ResponseData response = execute( getTestClient(), method );
                if ( log.isDebugEnabled() ) {
                    log.debug( "playback response, status code( " + response.getStatusCode() + " )" );
                    log.debug( "playback response, body(\n" + response.getBody() + " )" );
                }
                String outcome = response.getHeader( Constants.OUTCOME_HEADER );
                if ( log.isDebugEnabled() ) {
                    log.debug( "outcome( " + outcome + " )" );
                }
                if ( response.getStatusCode() >= 400 ) {
                    String msg = "WARNING: unable to access URI( " + method.getURI() +
                            " ), status code( " + response.getStatusCode() + " ) returned";
                    System.out.println( msg );
                    if ( log.isWarnEnabled() ) {
                        log.warn( msg );
                    }
                }
View Full Code Here

            throw new PlaybackException( msg, e );
        }
    }

    protected ResponseData execute( HttpClient client, HttpMethod method ) throws PlaybackException, IOException {
        ResponseData response = new ResponseData( method.getHostConfiguration().getHost(),
                method.getHostConfiguration().getPort() );
        int statusCode = -1;
        // retry up to 3 times.
        for ( int attempt = 0; statusCode == -1 && attempt < 3; attempt++ ) {
            try {
                statusCode = client.executeMethod( method );
            }
            catch ( HttpRecoverableException e ) {
                if ( log.isWarnEnabled() ) {
                    String msg = "A recoverable exception occurred calling URI( " + method.getURI() +
                            " ), retrying. exception( " + e.getMessage() + " )";
                    log.error( msg, e );
                }
            }
            catch ( IOException e ) {
                String msg = "Failed executing request( " + method.getURI() + " ), exception( " + e.getMessage() +
                        " )";
                log.error( msg, e );
                throw e;
            }
        }
        // Retries failed
        if ( statusCode == -1 ) {
            String msg = "Failed to execute request( " + method.getURI() + " )";
            log.error( msg );
            throw new PlaybackException( msg );
        }
        response.setStatusCode( statusCode );
        byte[] responseBody = method.getResponseBody();
        response.setBody( new String( responseBody ) );
        if ( log.isDebugEnabled() ) {
            log.debug( "statusCode( " + statusCode + " )" );
//            log.debug( "response body:\n" + response.getBody() + "\n" );
        }
        response.setHeaders( convertHeaders( method.getResponseHeaders() ) );
        method.releaseConnection();
        return response;
    }
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.tools.testrecorder.shared.ResponseData

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.