@Test
    public void testTokenization() {
        URI uri = new URI("http://this.i_s:5000/wo_ho;ba-lo?gobo#banana", true);
        List<URI.Token> tokens = uri.tokenize();
        URI.Token token;

        token = tokens.get(0);
        assertEquals("http", token.getToken());
        assertEquals(URI.URLContext.URL_SCHEME, token.getContext());

        token = tokens.get(1);
        assertEquals("this", token.getToken());
        assertEquals(URI.URLContext.URL_HOST, token.getContext());

        token = tokens.get(2);
        assertEquals("i_s", token.getToken());
        assertEquals(URI.URLContext.URL_HOST, token.getContext());

        token = tokens.get(3);
        assertEquals("5000", token.getToken());
        assertEquals(URI.URLContext.URL_PORT, token.getContext());

        token = tokens.get(4);
        assertEquals("wo_ho", token.getToken());
        assertEquals(URI.URLContext.URL_PATH, token.getContext());

        token = tokens.get(5);
        assertEquals("ba-lo", token.getToken());
        assertEquals(URI.URLContext.URL_PATH, token.getContext());

        token = tokens.get(6);
        assertEquals("gobo", token.getToken());
        assertEquals(URI.URLContext.URL_QUERY, token.getContext());

        token = tokens.get(7);
        assertEquals("banana", token.getToken());
        assertEquals(URI.URLContext.URL_FRAGMENT, token.getContext());

        try {
            tokens.get(8);
            fail();
        } catch (IndexOutOfBoundsException ioobe) {
        }
    }
Tests the URI class

@author bratseth
vespajlib/src/test/java/com/yahoo/net/URITestCase.java