package com.mantono.blink;

import static org.junit.Assert.*;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;

import org.junit.Test;

public class BookmarkTest
{
	@Test
	public void testGetDomainBasicUrl() throws MalformedURLException
	{
		final URL url = new URL("http://mantono.com");
		Bookmark bookmark = new Bookmark(url, 1L, new ArrayList<String>(0));
		assertEquals("mantono.com", bookmark.getDomain());
	}

	@Test
	public void testGetDomainUrlWithResource() throws MalformedURLException
	{
		final URL url = new URL("http://mantono.com/cant-touch-me");
		Bookmark bookmark = new Bookmark(url, 1L, new ArrayList<String>(0));
		assertEquals("mantono.com", bookmark.getDomain());
	}
	
	@Test
	public void testGetDomainUrlWithSubdomain() throws MalformedURLException
	{
		final URL url = new URL("http://sub.mantono.com");
		Bookmark bookmark = new Bookmark(url, 1L, new ArrayList<String>(0));
		assertEquals("sub.mantono.com", bookmark.getDomain());
	}
	
	@Test
	public void testGetDomainWithNumber() throws MalformedURLException
	{
		final URL url = new URL("http://nord59.se");
		Bookmark bookmark = new Bookmark(url, 1L, new ArrayList<String>(0));
		assertEquals("nord59.se", bookmark.getDomain());
	}

	@Test
	public void testGetDomainWithHyphen() throws MalformedURLException
	{
		final URL url = new URL("http://a-hyphen.com");
		Bookmark bookmark = new Bookmark(url, 1L, new ArrayList<String>(0));
		assertEquals("a-hyphen.com", bookmark.getDomain());
	}

	@Test
	public void testGetDomainWithPort() throws MalformedURLException
	{
		final URL url = new URL("http://mantono.com:80");
		Bookmark bookmark = new Bookmark(url, 1L, new ArrayList<String>(0));
		assertEquals("mantono.com", bookmark.getDomain());
	}

}

@@ -440,32 +440,294 @@
 getDomain());%0A%09%7D
+%0A%09%0A%09@Test%0A%09public void testGetDomainNoLeadingWww() throws MalformedURLException%0A%09%7B%0A%09%09final URL url = new URL(%22http://www.mantono.com%22);%0A%09%09Bookmark bookmark = new Bookmark(url, 1L, new ArrayList%3CString%3E(0));%0A%09%09assertEquals(%22mantono.com%22, bookmark.getDomain());%0A%09%7D
 %0A%0A%09@Test%0A%09public

Test case for testing removal of www from domain names.