Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpException


            setStatusCode(method.getStatusLine().getStatusCode());
        }
        // Also accept OK sent by buggy servers.
        if (status != HttpStatus.SC_MULTI_STATUS
            && status != HttpStatus.SC_OK) {
            HttpException ex = new HttpException();
            ex.setReasonCode(status);
            throw ex;
        }
        thisResource = false;

        return method.getResponses();
View Full Code Here


        int status = client.executeMethod(method);

        // Also accept OK sent by buggy servers.
        if (status != HttpStatus.SC_MULTI_STATUS
            && status != HttpStatus.SC_OK) {
            HttpException ex = new HttpException();
            ex.setReasonCode(status);
            throw ex;
        }

        // It contains the results.
        Vector results = new Vector();
View Full Code Here

        }

        //slide/tamino delivers status code OK.
        //can be removed when the server sends MULTI_STATUS
        if (status != HttpStatus.SC_MULTI_STATUS && status != HttpStatus.SC_OK) {
            HttpException ex = new HttpException();
            ex.setReasonCode(status);
            throw ex;
        }
        thisResource = false;

        return method.getResponses();
View Full Code Here

        try {
            int result = httpClient.executeMethod(httpGetMethod);

            if(result != HttpStatus.SC_OK) {
                if(result < 200 || result > 299) {
                    throw new HttpException("Received status code '" + result + "' on WSDL HTTP (GET) request: '" + url + "'.");
                } else {
                    logger.warn("Received status code '" + result + "' on WSDL HTTP (GET) request: '" + url + "'.");
                }
            }
View Full Code Here

            try {
              int result = httpClient.executeMethod(httpMethod);

                if(result != HttpStatus.SC_OK) {
                    if(result < 200 || result > 299) {
                        throw new HttpException("Received status code '" + result + "' on WSDL HTTP (GET) request: '" + url + "'.");
                    } else {
                        logger.warn("Received status code '" + result + "' on WSDL HTTP (GET) request: '" + url + "'.");
                    }
                }
               
View Full Code Here

              +response.getResponseHeaders()+"\n"+response.getResponseBody());
        }
           
            if(response.getResponseError() != null) {
                if(getResponseCodeCheckDisabled() == false) {
                    throw new HttpException(response.getResponseError());
                } else {
                    logger.logMessage("Ignoring HTTP error response: " +
                        response.getResponseError(), this, MessageLogger.DEBUG);
                }
            }
View Full Code Here

                            + response.getResponseBody());
            }
           
            if(response.getResponseError() != null) {
                if(getResponseCodeCheckDisabled() == false) {
                    throw new HttpException(response.getResponseError());
                } else {
                    logger.logMessage("Ignoring HTTP error response: " +
                        response.getResponseError(), this, MessageLogger.DEBUG);
                }
            }
View Full Code Here

                                    this.getData().getAttribute(USER_ATTR),
                                        this.getData().getAttribute(PASSWORD_ATTR),
                                        DEFAULT_CHARSET, responseCharsetName, null);

            if(data.getResponseError()!=null)
          throw new HttpException(data.getResponseError());
      } catch(Exception e){
        logger.logMessage(e.toString(), this, MessageLogger.ERROR);
        PipeComponentUtils.failTransfer();
      }
      logger.logMessage("Request complete", this, MessageLogger.DEBUG);
View Full Code Here

     * It not possible to properly mock login()
     */
    @Test (expected=BigSwitchVnsApiException.class)
    public void executeMethodTestWithLogin() throws BigSwitchVnsApiException, HttpException, IOException {
        GetMethod gm = mock(GetMethod.class);
        when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
        when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
        _api.executeMethod(gm);
        verify(gm, times(1)).getStatusCode();
    }
View Full Code Here

    @Test (expected=BigSwitchVnsApiException.class)
    public void testExecuteCreateObjectException() throws BigSwitchVnsApiException, IOException {
        _api.setControllerAddress("10.10.0.10");
        NetworkData network = new NetworkData();
        when(_client.executeMethod((HttpMethod) any())).thenThrow(new HttpException());
        _method = mock(PostMethod.class);
        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        Header header = mock(Header.class);
        when(header.getValue()).thenReturn("text/html");
        when(_method.getResponseHeader("Content-Type")).thenReturn(header);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.HttpException

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.