S
- the "self" type of this assertion class.public abstract class AbstractUrlAssert<S extends AbstractUrlAssert<S>> extends AbstractAssert<S,URL>
URL
s.URL
Modifier and Type | Field and Description |
---|---|
protected Urls |
urls |
actual, info, myself
Modifier | Constructor and Description |
---|---|
protected |
AbstractUrlAssert(URL actual,
Class<?> selfType) |
Modifier and Type | Method and Description |
---|---|
S |
hasAnchor(String expected)
Verifies that the actual
URL has the expected anchor. |
S |
hasAuthority(String expected)
Verifies that the actual
URL has the expected authority. |
S |
hasHost(String expected)
Verifies that the actual
URL has the expected host. |
S |
hasNoAnchor()
Verifies that the actual
URL has no anchor. |
S |
hasNoPath()
Verifies that the actual
URL has no path. |
S |
hasNoPort()
Verifies that the actual
URL has no port. |
S |
hasNoQuery()
Verifies that the actual
URL has no query. |
S |
hasNoUserInfo()
Verifies that the actual
URL has no userinfo. |
S |
hasPath(String expected)
Verifies that the actual
URL has the expected path (which must not be null). |
S |
hasPort(int expected)
Verifies that the actual
URL has the expected port. |
S |
hasProtocol(String expected)
Verifies that the actual
URL has the expected protocol. |
S |
hasQuery(String expected)
Verifies that the actual
URL has the expected query. |
S |
hasUserInfo(String expected)
Verifies that the actual
URL has the expected userinfo. |
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasToString, inBinary, inHexadecimal, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, overridingErrorMessage, usingComparator, usingDefaultComparator, withFailMessage, withThreadDumpOnError
protected Urls urls
public S hasProtocol(String expected)
URL
has the expected protocol.
Examples:
// This assertion succeeds:
assertThat(new URL("ftp://helloworld.org")).hasProtocol("ftp");
// These assertion fails:
assertThat(new URL("http://helloworld.org")).hasProtocol("ftp");
expected
- the expected protocol of the actual URL
.this
assertion object.AssertionError
- if the actual protocol is not equal to the expected protocol.public S hasPath(String expected)
URL
has the expected path (which must not be null).
Examples:
// These assertions succeed:
assertThat(new URL("http://helloworld.org/pages")).hasPath("/pages");
assertThat(new URL("http://www.helloworld.org")).hasPath("");
// or preferably:
assertThat(new URL("http://www.helloworld.org")).hasNoPath();
// this assertion fails:
assertThat(new URL("http://helloworld.org/pickme")).hasPath("/pages/");
// this assertion throws an IllegalArgumentException:
assertThat(new URL("http://helloworld.org/pages")).hasPath(null);
expected
- the expected path of the actual URL
.this
assertion object.AssertionError
- if the actual URL path is not equal to the expected path.IllegalArgumentException
- if given path is null.public S hasNoPath()
URL
has no path.
Examples:
// This assertion succeeds:
assertThat(new URL("http://www.helloworld.org")).hasNoPath();
// this assertion fails:
assertThat(new URL("http://helloworld.org/france")).hasNoPath();
this
assertion object.AssertionError
- if the actual has a path.public S hasPort(int expected)
URL
has the expected port.
Examples:
// These assertions succeed:
assertThat(new URL("http://helloworld.org:8080")).hasPort(8080);
// These assertions fail:
assertThat(new URL("http://helloworld.org:8080")).hasPort(9876);
assertThat(new URL("http://helloworld.org")).hasPort(8080);
expected
- the expected port of the actual URL
.this
assertion object.AssertionError
- if the actual port is not equal to the expected port.public S hasNoPort()
URL
has no port.
Examples:
// This assertion succeeds:
assertThat(new URL("http://helloworld.org")).hasNoPort();
// This assertion fails:
assertThat(new URL("http://helloworld.org:8080")).hasNoPort();
this
assertion object.AssertionError
- if the actual has a port.public S hasHost(String expected)
URL
has the expected host.
Examples:
// These assertions succeed:
assertThat(new URL("http://helloworld.org/pages")).hasHost("helloworld.org");
assertThat(new URL("http://helloworld.org:8080")).hasHost("helloworld.org");
// These assertions fail:
assertThat(new URL("http://www.helloworld.org")).hasHost("helloworld.org");
assertThat(new URL("http://www.helloworld.org:8080")).hasHost("helloworld.org");
expected
- the expected host of the actual URL
.this
assertion object.AssertionError
- if the actual host is not equal to the expected host.public S hasAuthority(String expected)
URL
has the expected authority.
Examples:
// These assertions succeed:
assertThat(new URL("http://helloworld.org")).hasAuthority("helloworld.org");
assertThat(new URL("http://helloworld.org:8080")).hasAuthority("helloworld.org:8080");
assertThat(new URL("http://www.helloworld.org:8080/news")).hasAuthority("www.helloworld.org:8080");
// These assertions fail:
assertThat(new URL("http://www.helloworld.org:8080")).hasAuthority("www.helloworld.org");
assertThat(new URL("http://www.helloworld.org")).hasAuthority("www.helloworld.org:8080");
expected
- the expected authority of the actual URL
.this
assertion object.AssertionError
- if the actual authority is not equal to the expected authority.public S hasQuery(String expected)
URL
has the expected query.
Examples:
// This assertion succeeds:
assertThat(new URL("http://www.helloworld.org/index.html?type=test")).hasQuery("type=test");
// These assertions fail:
assertThat(new URL("http://www.helloworld.org/index.html?type=test")).hasQuery("type=hello");
assertThat(new URL("http://www.helloworld.org/index.html")).hasQuery("type=hello");
expected
- the expected query of the actual URL
.this
assertion object.AssertionError
- if the actual query is not equal to the expected query.public S hasNoQuery()
URL
has no query.
Examples:
// This assertion succeeds:
assertThat(new URL("http://www.helloworld.org/index.html")).hasNoQuery();
// These assertions fail:
assertThat(new URL("http://www.helloworld.org/index.html?type=test")).hasNoQuery();
this
assertion object.AssertionError
- if the actual has a query.public S hasAnchor(String expected)
URL
has the expected anchor.
Examples:
// This assertion succeeds:
assertThat(new URL("http://www.helloworld.org/news.html#sport")).hasAnchor("sport");
// These assertions fail:
assertThat(new URL("http://www.helloworld.org/news.html#sport")).hasAnchor("war");
assertThat(new URL("http://www.helloworld.org/news.html")).hasAnchor("sport");
expected
- the expected anchor of the actual URL
.this
assertion object.AssertionError
- if the actual anchor is not equal to the expected anchor.public S hasNoAnchor()
URL
has no anchor.
Examples:
// This assertion succeeds:
assertThat(new URL("http://www.helloworld.org/news.html")).hasNoAnchor();
// These assertions fail:
assertThat(new URL("http://www.helloworld.org/news.html#sport")).hasNoAnchor();
this
assertion object.AssertionError
- if the actual has a anchor.public S hasUserInfo(String expected)
URL
has the expected userinfo.
Examples:
// These assertions succeed:
assertThat(new URL("http://test:[email protected]/index.html")).hasUserInfo("test:pass");
assertThat(new URL("http://[email protected]/index.html")).hasUserInfo("test");
assertThat(new URL("http://:[email protected]/index.html")).hasUserInfo(":pass");
// These assertions fail:
assertThat(new URL("http://test:[email protected]/index.html")).hasUserInfo("test:fail");
assertThat(new URL("http://www.helloworld.org/index.html")).hasUserInfo("test:pass");
expected
- the expected userinfo of the actual URL
.this
assertion object.AssertionError
- if the actual userinfo is not equal to the expected userinfo.public S hasNoUserInfo()
URL
has no userinfo.
Examples:
// This assertion succeeds:
assertThat(new URL("http://www.helloworld.org/index.html")).hasNoUserInfo();
// This assertion fails:
assertThat(new URL("http://test:[email protected]/index.html")).hasNoUserInfo();
this
assertion object.AssertionError
- if the actual has some userinfo.Copyright © 2013–2016 AssertJ. All rights reserved.