Example usage for org.apache.commons.httpclient URI URI

List of usage examples for org.apache.commons.httpclient URI URI

Introduction

In this page you can find the example usage for org.apache.commons.httpclient URI URI.

Prototype

public URI(URI base, URI relative) throws URIException 

Source Link

Document

Construct a general URI with the given relative URI.

Usage

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldKeepNonDefaultPortFromPrefix() throws Exception {
    // Given// w  w w .  j  ava2 s.  c om
    URI prefixUri = new URI("https://example.org:8443/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    // When
    String normalisedPrefix = fetchFilter.getNormalisedPrefix();
    // Then
    assertThat(normalisedPrefix, is(equalTo("https://example.org:8443/")));
}

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldKeepDefaultHttpPortInHttpsPrefix() throws Exception {
    // Given/*from  w  w  w.j  ava2  s . c  o  m*/
    URI prefixUri = new URI("https://example.org:80/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    // When
    String normalisedPrefix = fetchFilter.getNormalisedPrefix();
    // Then
    assertThat(normalisedPrefix, is(equalTo("https://example.org:80/")));
}

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldKeepDefaultHttpsPortInHttpPrefix() throws Exception {
    // Given/*from   w  ww . j  a  v  a2  s.  c  o m*/
    URI prefixUri = new URI("http://example.org:443/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    // When
    String normalisedPrefix = fetchFilter.getNormalisedPrefix();
    // Then
    assertThat(normalisedPrefix, is(equalTo("http://example.org:443/")));
}

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldFilterUndefinedUriAsOutOfScope() throws Exception {
    // Given// w  ww.j  a  v  a 2  s  .c  om
    URI prefixUri = new URI("http://example.org/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    // When
    FetchStatus filterStatus = fetchFilter.checkFilter(null);
    // Then
    assertThat(filterStatus, is(equalTo(FetchStatus.OUT_OF_SCOPE)));
}

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldFilterUriWithNoSchemeAsOutOfScope() throws Exception {
    // Given/*w w w .  j ava2  s . com*/
    URI prefixUri = new URI("http://example.org/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    URI uri = new URI("/path", true);
    // When
    FetchStatus filterStatus = fetchFilter.checkFilter(uri);
    // Then
    assertThat(filterStatus, is(equalTo(FetchStatus.OUT_OF_SCOPE)));
}

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldFilterUriWithNonHttpOrHttpsSchemeAsOutOfScope() throws Exception {
    // Given//w  w w  .  j a  v a 2 s  .c o  m
    URI prefixUri = new URI("http://example.org/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    URI uri = new URI("ftp://example.org/", true);
    // When
    FetchStatus filterStatus = fetchFilter.checkFilter(uri);
    // Then
    assertThat(filterStatus, is(equalTo(FetchStatus.OUT_OF_SCOPE)));
}

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldFilterUriWithNoHostAsOutOfScope() throws Exception {
    // Given/*from  w  w w.  ja  v a2s  . c om*/
    URI prefixUri = new URI("http://example.org/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    URI uri = new URI("http://", true);
    // When
    FetchStatus filterStatus = fetchFilter.checkFilter(uri);
    // Then
    assertThat(filterStatus, is(equalTo(FetchStatus.OUT_OF_SCOPE)));
}

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldFilterUriWithMalformedHostAsOutOfScope() throws Exception {
    // Given//from   w w w.j  a  v  a 2 s.c  o m
    URI prefixUri = new URI("http://example.org/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    URI uri = new URI("http://a%0/", true);
    // When
    FetchStatus filterStatus = fetchFilter.checkFilter(uri);
    // Then
    assertThat(filterStatus, is(equalTo(FetchStatus.OUT_OF_SCOPE)));
}

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldFilterUriWithDifferentSchemeAsOutOfScope() throws Exception {
    // Given//  w w w  . j  a v  a 2s . c  o m
    URI prefixUri = new URI("http://example.org/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    URI uri = new URI("https://example.org/", true);
    // When
    FetchStatus filterStatus = fetchFilter.checkFilter(uri);
    // Then
    assertThat(filterStatus, is(equalTo(FetchStatus.OUT_OF_SCOPE)));
}

From source file:org.zaproxy.zap.spider.filters.HttpPrefixFetchFilterUnitTest.java

@Test
public void shouldFilterUriWithDifferentSchemeButSamePortAsOutOfScope() throws Exception {
    // Given/*  ww w. j  a  v a 2 s.c o  m*/
    URI prefixUri = new URI("http://example.org/", true);
    HttpPrefixFetchFilter fetchFilter = new HttpPrefixFetchFilter(prefixUri);
    URI uri = new URI("https://example.org:80/", true);
    // When
    FetchStatus filterStatus = fetchFilter.checkFilter(uri);
    // Then
    assertThat(filterStatus, is(equalTo(FetchStatus.OUT_OF_SCOPE)));
}