Java Code Examples for org.apache.commons.httpclient.URIException#getMessage()

The following examples show how to use org.apache.commons.httpclient.URIException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScanTarget.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
public ScanTarget(URI uri) {
    this.uri = copyURI(uri);

    this.scheme = uri.getScheme();

    try {
        this.host = uri.getHost();
    } catch (URIException e) {
        throw new IllegalArgumentException("Failed to get host from URI: " + e.getMessage(), e);
    }

    this.port = getPort(scheme, uri.getPort());

    try {
        this.uri.setPath(null);
        this.uri.setQuery(null);
        this.uri.setFragment(null);
    } catch (URIException ignore) {
        // It's safe to set the URI query, path and fragment components to null.
    }

    this.stringRepresentation = createHostPortString(host, port);
    buildHtmlStringRepresentation();
}
 
Example 2
Source File: UsableURIFactoryTest.java    From webarchive-commons with Apache License 2.0 6 votes vote down vote up
public final void testTooLongAfterEscaping() {
    StringBuffer buffer = new StringBuffer("http://www.archive.org/a/");
    // Append bunch of spaces.  When escaped, they'll triple in size.
    for (int i = 0; i < 1024; i++) {
    	buffer.append(" ");
    }
    buffer.append("/index.html");
    String message = null;
    try {
    	UsableURIFactory.getInstance(buffer.toString());
    } catch (URIException e) {
        message = e.getMessage();
    }
    assertTrue("Wrong or no exception: " + message, (message != null) &&
        message.startsWith("Created (escaped) uuri >"));
}