java/nekurak.net-ejb/test/cz/frantovo/nekurak/ext/GeoTest.java
author František Kučera <franta-hg@frantovo.cz>
Tue May 25 17:16:36 2010 +0200 (2010-05-25)
changeset 124 e720890878ac
parent 121 cd43c349f39b
child 125 1eecc767a610
permissions -rw-r--r--
Testování NullPointerException.
franta-hg@120
     1
package cz.frantovo.nekurak.ext;
franta-hg@120
     2
franta-hg@120
     3
import cz.frantovo.nekurak.ext.Geo.Souradnice;
franta-hg@120
     4
import org.junit.Test;
franta-hg@120
     5
import static org.junit.Assert.*;
franta-hg@120
     6
franta-hg@120
     7
/**
franta-hg@120
     8
 * Testuje hlavně dostupnost a funkčnost vzdálené služby (Google).
franta-hg@120
     9
 * @author fiki
franta-hg@120
    10
 */
franta-hg@120
    11
public class GeoTest {
franta-hg@120
    12
franta-hg@120
    13
    private Geo geo = new Geo();
franta-hg@120
    14
franta-hg@120
    15
    @Test
franta-hg@120
    16
    public void praha() {
franta-hg@121
    17
	testuj("Praha, Czech Republic", 50.0878114, 14.4204598);
franta-hg@121
    18
    }
franta-hg@121
    19
franta-hg@121
    20
    @Test
franta-hg@121
    21
    public void sanghaj() {
franta-hg@121
    22
	// https://frantovo.cz/blog/?q=cina-sanghaj-mesto-lide :-)
franta-hg@122
    23
	testuj("Shanghai, China", 31.230708, 121.472916);
franta-hg@121
    24
    }
franta-hg@121
    25
franta-hg@121
    26
    @Test
franta-hg@121
    27
    public void dallas() {
franta-hg@122
    28
	testuj("Dallas, TX", 32.802955, -96.769923);
franta-hg@121
    29
    }
franta-hg@121
    30
franta-hg@121
    31
    @Test
franta-hg@121
    32
    public void moskva() {
franta-hg@122
    33
	testuj("Moscow, Russia", 55.755786, 37.617633);
franta-hg@122
    34
    }
franta-hg@122
    35
franta-hg@122
    36
    @Test
franta-hg@122
    37
    public void loc() {
franta-hg@122
    38
	Souradnice s = geo.new Souradnice(55.755786, 37.617633);
franta-hg@122
    39
	assertEquals("Loc: 55.755786, 37.617633", s.getLoc());
franta-hg@120
    40
    }
franta-hg@120
    41
franta-hg@120
    42
    private void testuj(String vstup, double pozadovanaSirka, double pozadovanaDelka) {
franta-hg@120
    43
	Souradnice vystup = geo.getSouradnice(vstup);
franta-hg@120
    44
	assertEquals(geo.new Souradnice(pozadovanaSirka, pozadovanaDelka), vystup);
franta-hg@120
    45
    }
franta-hg@120
    46
}