Code example for URI

Methods: getFragment, getHost, getPath, getPort, getQuery, getScheme, getUserInfo

0
public class UrlBuilderTest { 
 
	protected UrlBuilder urlBuilder = new UrlBuilder();
	 
	@Test 
	public void testParsing() 
	{ 
		Map<String, String> params;
		 
		params = urlBuilder.parseQueryParameters("a=b&c=d");
		assertEquals("b", params.get("a"));
		assertEquals("d", params.get("c"));
		 
		params = urlBuilder.parseQueryParameters("a=b&c=");
		assertEquals("b", params.get("a"));
		assertEquals(null, params.get("c"));
	} 
	 
	@Test 
	public void testRender() throws UrlBuilderException, URISyntaxException 
	{ 
		URI baseUri = new URI("http://a@test1.bb.de/test/abc?abc=abc");
		Map<String, Object> parameters = new LinkedHashMap<>();
		parameters.put("cd","gh");
		parameters.put("numtest",1);
		URI result = urlBuilder.addQueryParameters(parameters, baseUri);
		assertEquals("http://a@test1.bb.de/test/abc?abc=abc&cd=gh&numtest=1", result.toString());