Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.HttpException


        }

        //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


                return resourcesToXml(resources);
            } else {
                BufferedInputStream bi = null;
                bi = new BufferedInputStream(this.resource.getMethodData());
                if (!this.resource.exists()) {
                    throw new HttpException(this.systemId + "does not exist");
                }
                return bi;
            }
        } catch (HttpException he) {
            throw new SourceException("Could not get WebDAV resource " + getSecureURI(), he);
View Full Code Here

            notifier.notifyAbout("Saving server error response to: " + fname);
            FileOutputStream fos = new FileOutputStream(fname);
            FileChannel resultFile = fos.getChannel();
            resultFile.write(ByteBuffer.wrap(postRequest.getResponseBody()));
            resultFile.close();
            throw new HttpException("Request returned not " + expectedSC + " status code: " + result);
        }
        byte[] bytes = postRequest.getResponseBody();
        if (bytes == null) {
            bytes = new byte[0];
        }
View Full Code Here

                return resourcesToXml(resources);
            } else {
                BufferedInputStream bi = null;
                bi = new BufferedInputStream(this.resource.getMethodData());
                if (!this.resource.exists()) {
                    throw new HttpException(getSecureURI() + " does not exist");
                }
                return bi;
            }
        } catch (HttpException he) {
            throw new SourceException("Could not get WebDAV resource " + getSecureURI(), he);
View Full Code Here

        try {

            WebdavResource resource = WebDAVUtil.getWebdavResource(this.getAbsoluteURI(uri));
            if (!resource.exists()) {
                throw new HttpException(uri + " does not exist");
            }
            return new BufferedInputStream(resource.getMethodData());

        } catch (MalformedURLException mue) {
            throw new ProcessingException ("Bad URL for resource: " + this.repoBaseUrl + uri, mue);
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

    @Test(expected = BigSwitchVnsApiException.class)
    public void testExecuteDeleteObjectException() throws BigSwitchVnsApiException, IOException {
        _api.setControllerAddress("10.10.0.10");
        _method = mock(DeleteMethod.class);
        when(_method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
        when(_client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
        try {
            _api.executeDeleteObject("/");
        } finally {
            verify(_method, times(1)).releaseConnection();
        }
View Full Code Here

    }

    @Test(expected = CloudstackRESTException.class)
    public void testExecuteMethodWithLogin() throws CloudstackRESTException, HttpException, IOException {
        final GetMethod gm = mock(GetMethod.class);
        when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
        when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
        connector.executeMethod(gm);
        verify(gm, times(1)).getStatusCode();
    }
View Full Code Here

    }

    @Test(expected = CloudstackRESTException.class)
    public void testExecuteCreateObjectException() throws CloudstackRESTException, IOException {
        JsonEntity ls = new JsonEntity();
        when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
        method = mock(PostMethod.class);
        when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
        final 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.