Example usage for org.apache.http.client ClientProtocolException ClientProtocolException

List of usage examples for org.apache.http.client ClientProtocolException ClientProtocolException

Introduction

In this page you can find the example usage for org.apache.http.client ClientProtocolException ClientProtocolException.

Prototype

public ClientProtocolException() 

Source Link

Usage

From source file:com.splunk.shuttl.testutil.ClassWithExternalDependencies.java

public static void main(String[] args) {
    new ClientProtocolException();
    System.exit(ShellClassRunnerTest.EXIT_CODE);
}

From source file:org.pentaho.di.ui.spoon.SpoonSlaveTest.java

@Test
public void setErrorTextWithCauseExceptionWithoutCauseMessage() {
    //cause without message
    ClientProtocolException cpe = new ClientProtocolException();
    Exception e = new KettleException("kettleMessage", cpe);

    SpoonSlave spoonSlave = mock(SpoonSlave.class);
    doCallRealMethod().when(spoonSlave).setExceptionMessage(any(Exception.class));

    String message = spoonSlave.setExceptionMessage(e);

    assertEquals(message, e.getMessage().toString());

}

From source file:eu.esdihumboldt.hale.io.codelist.InspireCodeListAdvisor.java

@Override
public void copyResource(LocatableInputSupplier<? extends InputStream> resource, final Path target,
        IContentType resourceType, boolean includeRemote, IOReporter reporter) throws IOException {

    URI uri = resource.getLocation();
    String uriScheme = uri.getScheme();
    if (uriScheme.equals("http")) {
        // Get the response for the given uri
        Response response = INSPIRECodeListReader.getResponse(uri);

        // Handle the fluent response
        response.handleResponse(new ResponseHandler<Boolean>() {

            @Override/*from w  w w  .j  a  v  a  2 s  .c  om*/
            public Boolean handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
                StatusLine status = response.getStatusLine();
                HttpEntity entity = response.getEntity();

                if (status.getStatusCode() >= 300) {
                    throw new HttpResponseException(status.getStatusCode(), status.getReasonPhrase());
                }
                if (entity == null) {
                    throw new ClientProtocolException();
                }
                // Copy the resource file to the target path
                Files.copy(entity.getContent(), target);
                return true;
            }
        });
    } else {
        super.copyResource(resource, target, resourceType, includeRemote, reporter);
    }
}

From source file:org.pentaho.di.ui.core.dialog.ErrorDialogTest.java

@Test
public void setErrorTextWithCauseExceptionWithoutCauseMessage() {
    //cause without message
    ClientProtocolException cpe = new ClientProtocolException();
    Exception e = new KettleException("kettleMessage", cpe);

    StringBuilder text = new StringBuilder();
    StringBuilder details = new StringBuilder();

    ErrorDialog dialog = mock(ErrorDialog.class);
    doCallRealMethod().when(dialog).handleException(anyString(), any(Exception.class), any(StringBuilder.class),
            any(StringBuilder.class));

    dialog.handleException("argMessage", e, text, details);

    assertEquals(text.toString(), e.getMessage().toString());

}

From source file:com.google.android.apps.authenticator.timesync.NetworkTimeProviderTest.java

public void testRequestThrowsExceptions() throws Exception {
    withHttpRequestThrowing(new IOException(""));
    try {//from  w  ww. j  ava 2 s.c o  m
        mProvider.getNetworkTime();
        fail();
    } catch (IOException expected) {
    }

    withHttpRequestThrowing(new ClientProtocolException());
    try {
        mProvider.getNetworkTime();
        fail();
    } catch (IOException expected) {
    }
}

From source file:org.chaplib.TestHttpResource.java

@Test(expected = RuntimeException.class)
public void transformsClientProtocolExceptionOnGet() throws Exception {
    when(mockHttpClient.execute(any(HttpUriRequest.class))).thenThrow(new ClientProtocolException());
    impl.value(mockParser);// ww  w.  j  a v a 2 s. com
}

From source file:com.akop.bach.parser.PsnParser.java

@Override
protected String preparseResponse(String response) throws IOException {
    // Sony's stupid method of requesting re-authentication
    // This needs to be improved; too un-dependable

    if (response.startsWith("<script") && response.endsWith("</script>"))
        throw new ClientProtocolException();

    return super.preparseResponse(response);
}

From source file:org.robertburrelldonkin.template4couchdb.rest.HttpClientRestClientTest.java

@Test(expected = HttpClientRestClientException.class)
public void testGetClientProcotolExceptionRethrow() throws Exception {
    when(client.execute((HttpGet) anyObject(), eq(handler))).thenThrow(new ClientProtocolException());
    subject.get(URL, mapper);/*from  w  w  w  .j  a va 2 s .c om*/
}

From source file:com.launchkey.sdk.transport.v1.ApacheHttpClientTransportPingTest.java

@Test
public void testPingWrapsClientExceptionInLaunchKeyException() throws Exception {
    ClientProtocolException expectedCause = new ClientProtocolException();
    expectedException.expect(LaunchKeyException.class);
    expectedException.expectMessage("Exception caught processing ping request");
    expectedException.expectCause(is(expectedCause));

    when(httpClient.execute(any(HttpUriRequest.class))).thenThrow(expectedCause);
    transport.ping(new PingRequest());
}