NullPointerException: Cannot invoke "uri.Uri.getHost()" because the return value of "uri.UriParser.parse()" is null

Hi,

I’ve already checked the similar question https://forum.prog2.sic.saarland/t/uriparsertest-testscheme-nullpointerexception/1298, but I still do not understand my error: NullPointerException: Cannot invoke “uri.Uri.getHost()” because the return value of “uri.UriParser.parse()” is null

I thought we would only need to add tests in SimpleTests.java. All other files have to be edited first for the second part. What am I doing wrong?

Thanks in advance!

Are you usre your URI is valid? If it is not, then parse() will return null.

You can check using a correct implementation, like URI parser

Also, for now, you can not “test your tests”, since they are tested by running them against mutants and the reference implementation, which only happens during daily tests.

1 Like

I was using the URI

foo://example.com:8042/over/there?name=ferret#nose

from the link in the project description: https://www.ietf.org/rfc/rfc3986.txt.

Probably the fragment broke the URI and it returned null. Thank you very much for the fast response.
The link for the URI parser is perfect. Thank you very much!

This is not a valid URI within the scope of the project because the path example.com:8042 is not allowed, since it contains a colon, which (again) is not allowed.

Further, we do not support the hash (i.e. the #nose).

1 Like