java/nekurak.net-lib/test/cz/frantovo/nekurak/dto/PodnikTest.java
author František Kučera <franta-hg@frantovo.cz>
Sun Jan 09 01:05:59 2011 +0100 (2011-01-09)
changeset 156 5f14ce03f518
permissions -rw-r--r--
U podniků se místo „www stránka“ bude zobrazovat doména daného webu.
franta-hg@156
     1
package cz.frantovo.nekurak.dto;
franta-hg@156
     2
franta-hg@156
     3
import org.junit.Test;
franta-hg@156
     4
import static org.junit.Assert.*;
franta-hg@156
     5
franta-hg@156
     6
public class PodnikTest {
franta-hg@156
     7
franta-hg@156
     8
	@Test
franta-hg@156
     9
	public void testGetDomena() {
franta-hg@156
    10
		zkontrolujDoménu("http://www.example.com/index.html", "www.example.com");
franta-hg@156
    11
		zkontrolujDoménu("http://www.eXample.COM/index.html", "www.example.com");
franta-hg@156
    12
		zkontrolujDoménu("https://paranoid.cz/index.html", "paranoid.cz");
franta-hg@156
    13
		zkontrolujDoménu("http://frantovo.cz", "frantovo.cz");
franta-hg@156
    14
		zkontrolujDoménu("ftp://ftp.frantovo.cz", "ftp.frantovo.cz");
franta-hg@156
    15
		zkontrolujDoménu("http://čeština.frantovo.cz/xxx/ZZZ", "čeština.frantovo.cz");
franta-hg@156
    16
		zkontrolujDoménu("example.com", null);
franta-hg@156
    17
		zkontrolujDoménu("./soubor.txt", null);
franta-hg@156
    18
		zkontrolujDoménu("file:///etc/passwd", null);
franta-hg@156
    19
		zkontrolujDoménu("", null);
franta-hg@156
    20
		zkontrolujDoménu(null, null);
franta-hg@156
    21
	}
franta-hg@156
    22
franta-hg@156
    23
	private void zkontrolujDoménu(String url, String očekávanáDoména) {
franta-hg@156
    24
		Podnik p = new Podnik();
franta-hg@156
    25
		p.setUrl(url);
franta-hg@156
    26
		assertEquals(očekávanáDoména, p.getUrlDomena());
franta-hg@156
    27
franta-hg@156
    28
	}
franta-hg@156
    29
}