moved net.sf.marineapi examples to net.sf.marineapi.test bundle

Change-Id: I8000408bed7576e5410c0e750566755756de8ff1
This commit is contained in:
Axel Uhl committed 2017-04-21 14:25:09 +02:00
1 parent bacebe129f
commit df3ef78f77
64 files changed
+8294 -6836

No files matched your search

File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -1 +0,0 @@
$GPGSA,A,3,03,05,07,08,10,15,18,19,21,28,,,1.4,0.9,1.1*3A␍$GPGSV,3,1,12,03,02,011,37,05,20,210,38,07,14,084,41,08,50,084,48*74␍$GPGSV,3,2,12,10,01,189,38,15,55,282,37,18,18,325,40,19,19,032,00*79␍$GPGSV,3,3,12,21,07,305,00,28,63,127,47,33,16,220,00,37,28,178,36*72␍$GPGLL,6003.9421,N,01940.2829,E,131548,A,A*4B␍$GPBOD,,T,,M,,*47␍$PGRME,3.7,M,5.6,M,6.7,M*28␍$PGRMZ,-6,f,3*30␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131550,A,6003.9425,N,01940.2853,E,2.3,76.6,280510,4.8,E,A*23␍$GPRMB,A,,,,,,,,,,,,A,A*0B␍$GPGGA,131550,6003.9425,N,01940.2853,E,1,10,0.9,-1.6,M,21.7,M,,*68␍$GPGSA,A,3,03,05,07,08,10,15,18,19,21,28,,,1.4,0.9,1.1*3A␍$GPGSV,3,1,12,03,02,011,36,05,20,210,39,07,14,084,41,08,50,084,48*74␍$GPGSV,3,2,12,10,01,189,37,15,55,282,38,18,18,325,41,19,19,032,31*7A␍$GPGSV,3,3,12,21,07,305,00,28,63,127,47,33,16,220,00,37,28,178,36*72␍$GPGLL,6003.9425,N,01940.2853,E,131550,A,A*4B␍$GPBOD,,T,,M,,*47␍$PGRME,3.3,M,4.9,M,5.9,M*2F␍$PGRMZ,-5,f,3*33␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131552,A,6003.9428,N,01940.2876,E,2.1,75.8,280510,4.8,E,A*24␍$GPRMB,A,,,,,,,,,,,,A,A*0B␍$GPGGA,131552,6003.9428,N,01940.2876,E,1,10,0.8,-1.4,M,21.7,M,,*63␍$GPGSA,A,3,03,05,07,08,10,15,18,19,21,28,,,1.4,0.8,1.1*3B␍$GPGSV,3,1,12,03,02,011,36,05,20,210,40,07,14,084,40,08,50,084,48*7B␍$GPGSV,3,2,12,10,01,189,38,15,55,282,37,18,18,325,42,19,19,032,33*7B␍$GPGSV,3,3,12,21,07,305,00,28,63,127,46,33,16,220,00,37,28,178,00*76␍$GPGLL,6003.9428,N,01940.2876,E,131552,A,A*43␍$GPBOD,,T,,M,,*47␍$PGRME,3.4,M,5.0,M,6.0,M*2A␍$PGRMZ,-4,f,3*32␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131554,A,6003.9431,N,01940.2901,E,2.2,76.2,280510,4.8,E,A*21␍$GPRMB,A,,,,,,,,,,,,A,A*0B␍$GPGGA,131554,6003.9431,N,01940.2901,E,1,10,0.8,-1.2,M,21.7,M,,*6A␍$GPGSA,A,3,03,05,07,08,10,15,18,19,21,28,,,1.3,0.8,1.0*3D␍$GPGSV,3,1,12,03,02,011,38,05,20,210,41,07,14,084,39,08,50,084,48*7A␍$GPGSV,3,2,12,10,01,189,38,15,55,282,37,18,18,325,42,19,19,032,32*7A␍$GPGSV,3,3,12,21,07,305,35,28,63,127,46,33,16,220,00,37,28,178,00*70␍$GPGLL,6003.9431,N,01940.2901,E,131554,A,A*4C␍$GPBOD,,T,,M,,*47␍$PGRME,3.4,M,5.0,M,6.0,M*2A␍$PGRMZ,-4,f,3*32␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131556,A,6003.9433,N,01940.2926,E,2.2,81.9,280510,4.8,E,A*27␍$GPRMB,A,,,,,,,,,,,,A,A*0B␍$GPGGA,131556,6003.9433,N,01940.2926,E,1,10,0.9,-1.3,M,21.7,M,,*6F␍$GPGSA,A,3,03,05,07,08,10,15,18,19,21,28,,,1.4,0.9,1.1*3A␍$GPGSV,3,1,12,03,02,011,37,05,20,210,42,07,14,084,39,08,50,084,48*76␍$GPGSV,3,2,12,10,01,189,38,15,55,282,38,18,18,325,40,19,19,032,00*76␍$GPGSV,3,3,12,21,07,305,38,28,63,127,46,33,16,220,00,37,28,178,00*7D␍$GPGLL,6003.9433,N,01940.2926,E,131556,A,A*49␍$GPBOD,,T,,M,,*47␍$PGRME,3.4,M,5.0,M,6.0,M*2A␍$PGRMZ,-4,f,3*32␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131558,A,6003.9436,N,01940.2949,E,2.2,78.0,280510,4.8,E,A*2A␍$GPRMB,A,,,,,,,,,,,,A,A*0B␍$GPGGA,131558,6003.9436,N,01940.2949,E,1,10,0.8,-1.5,M,21.7,M,,*6A␍$GPGSA,A,3,03,05,07,08,10,15,18,19,21,28,,,1.3,0.8,1.0*3D␍$GPGSV,3,1,12,03,02,011,35,05,20,210,43,07,14,084,38,08,50,084,48*74␍$GPGSV,3,2,12,10,01,189,39,15,55,282,37,18,18,325,39,19,19,032,00*76␍$GPGSV,3,3,12,21,07,305,38,28,63,127,46,33,16,220,00,37,28,178,00*7D␍$GPGLL,6003.9436,N,01940.2949,E,131558,A,A*4B␍$GPBOD,,T,,M,,*47␍$PGRME,3.3,M,4.7,M,5.8,M*20␍$PGRMZ,-5,f,3*33␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131600,A,6003.9438,N,01940.2973,E,2.1,79.9,280510,4.8,E,A*28␍$GPRMB,A,,,,,,,,,,,,A,A*0B␍$GPGGA,131600,6003.9438,N,01940.2973,E,1,10,0.8,-1.3,M,21.7,M,,*65␍$GPGSA,A,3,03,05,07,08,10,15,18,19,21,28,,,1.4,0.8,1.1*3B␍$GPGSV,3,1,12,03,02,011,35,05,20,210,43,07,14,084,37,08,50,084,48*7B␍$GPGSV,3,2,12,10,01,189,39,15,55,282,38,18,18,325,38,19,19,032,39*72␍$GPGSV,3,3,12,21,07,305,39,28,63,127,46,33,16,220,00,37,28,178,00*7C␍$GPGLL,6003.9438,N,01940.2973,E,131600,A,A*42␍$GPBOD,,T,,M,,*47␍$PGRME,3.4,M,4.8,M,5.8,M*28␍$PGRMZ,-4,f,3*32␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131602,A,6003.9439,N,01940.2996,E,2.1,83.9,280510,4.8,E,A*25␍$GPRMB,A,,,,,,,,,,,,A,A*0B␍$GPGGA,131602,6003.9439,N,01940.2996,E,1,10,0.9,-1.4,M,21.7,M,,*6B␍$GPGSA,A,3,03,05,07,08,10,15,18,19,21,28,,,1.4,0.9,1.1*3A␍$GPGSV,3,1,12,03,02,011,34,05,20,210,43,07,14,084,36,08,50,084,47*74␍$GPGSV,3,2,12,10,01,189,39,15,55,282,38,18,18,325,37,19,19,032,37*73␍$GPGSV,3,3,12,21,07,305,39,28,63,127,47,33,16,220,00,37,28,178,00*7D␍$GPGLL,6003.9439,N,01940.2996,E,131602,A,A*4A␍$GPBOD,,T,,M,,*47␍$PGRME,3.3,M,4.7,M,5.7,M*2F␍$PGRMZ,-4,f,3*32␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍
@@ -1 +0,0 @@
$GPGSA,A,3,,05,,08,,,18,19,21,,,,1.7,1.3,1.0*38␍$GPGSV,3,1,12,03,01,010,34,05,19,210,43,07,13,084,38,08,49,085,49*72␍$GPGSV,3,2,12,10,00,189,00,15,56,281,39,18,19,323,41,19,18,030,00*78␍$GPGSV,3,3,12,21,06,304,30,28,63,125,47,33,16,220,00,37,28,178,38*7D␍$GPGLL,6003.9499,N,01940.4863,E,131838,A,D*4F␍$GPBOD,,T,,M,,*47␍$PGRME,6.0,M,11.3,M,12.8,M*20␍$PGRMZ,-4,f,3*32␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131840,A,6003.9502,N,01940.4884,E,2.2,72.4,280510,4.8,E,D*25␍$GPRMB,A,,,,,,,,,,,,A,D*0E␍$GPGGA,131840,6003.9502,N,01940.4884,E,2,05,1.3,-0.8,M,21.7,M,,*6F␍$GPGSA,A,3,,05,,08,,,18,19,21,,,,1.7,1.3,1.0*38␍$GPGSV,3,1,12,03,01,010,00,05,19,210,41,07,13,084,39,08,49,085,49*76␍$GPGSV,3,2,12,10,00,189,00,15,56,281,39,18,19,323,40,19,18,030,37*7D␍$GPGSV,3,3,12,21,06,304,30,28,63,125,47,33,16,220,00,37,28,178,37*72␍$GPGLL,6003.9502,N,01940.4884,E,131840,A,D*4A␍$GPBOD,,T,,M,,*47␍$PGRME,6.0,M,11.4,M,13.0,M*2E␍$PGRMZ,-3,f,3*35␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131842,A,6003.9505,N,01940.4904,E,1.9,76.3,280510,4.8,E,D*22␍$GPRMB,A,,,,,,,,,,,,A,D*0E␍$GPGGA,131842,6003.9505,N,01940.4904,E,2,05,1.2,-0.6,M,21.7,M,,*6C␍$GPGSA,A,3,,05,,08,,,18,19,21,,,,1.6,1.2,1.0*38␍$GPGSV,3,1,12,03,01,010,00,05,19,210,40,07,13,084,38,08,49,085,48*77␍$GPGSV,3,2,12,10,00,189,00,15,56,281,40,18,19,323,39,19,18,030,36*7C␍$GPGSV,3,3,12,21,06,304,34,28,63,125,47,33,16,220,00,37,28,178,00*72␍$GPGLL,6003.9505,N,01940.4904,E,131842,A,D*46␍$GPBOD,,T,,M,,*47␍$PGRME,5.9,M,11.7,M,13.2,M*25␍$PGRMZ,-2,f,3*34␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131844,A,6003.9510,N,01940.4927,E,2.1,75.0,280510,4.8,E,D*2A␍$GPRMB,A,,,,,,,,,,,,A,D*0E␍$GPGGA,131844,6003.9510,N,01940.4927,E,2,05,1.6,-0.6,M,21.7,M,,*6B␍$GPGSA,A,3,,05,,08,,,18,19,21,,,,1.9,1.6,1.0*33␍$GPGSV,3,1,12,03,01,010,00,05,19,210,39,07,13,084,37,08,49,085,48*76␍$GPGSV,3,2,12,10,00,189,00,15,56,281,40,18,19,323,38,19,18,030,00*78␍$GPGSV,3,3,12,21,06,304,35,28,63,124,47,33,16,220,00,37,28,178,00*72␍$GPGLL,6003.9510,N,01940.4927,E,131844,A,D*45␍$GPBOD,,T,,M,,*47␍$PGRME,6.0,M,11.2,M,12.8,M*21␍$PGRMZ,-2,f,3*34␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131846,A,6003.9513,N,01940.4948,E,2.1,77.6,280510,4.8,E,D*26␍$GPRMB,A,,,,,,,,,,,,A,D*0E␍$GPGGA,131846,6003.9513,N,01940.4948,E,2,08,1.4,-0.8,M,21.7,M,,*62␍$GPGSA,A,3,,05,07,08,,15,18,19,21,28,,,1.8,1.4,1.1*38␍$GPGSV,3,1,12,03,01,010,00,05,19,210,38,07,13,084,36,08,49,085,47*79␍$GPGSV,3,2,12,10,00,189,00,15,56,281,41,18,19,323,38,19,18,030,41*7C␍$GPGSV,3,3,12,21,06,304,35,28,63,124,48,33,16,220,00,37,28,178,00*7D␍$GPGLL,6003.9513,N,01940.4948,E,131846,A,D*4D␍$GPBOD,,T,,M,,*47␍$PGRME,3.7,M,5.2,M,6.4,M*2F␍$PGRMZ,-3,f,3*35␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131848,A,6003.9517,N,01940.4969,E,2.2,67.8,280510,4.8,E,D*23␍$GPRMB,A,,,,,,,,,,,,A,D*0E␍$GPGGA,131848,6003.9517,N,01940.4969,E,2,08,2.0,-0.3,M,21.7,M,,*67␍$GPGSA,A,3,,05,07,08,,15,18,19,21,28,,,2.5,2.0,1.0*30␍$GPGSV,3,1,12,03,01,010,00,05,19,210,37,07,13,084,35,08,49,085,47*75␍$GPGSV,3,2,12,10,00,189,00,15,56,281,42,18,19,323,37,19,18,030,41*70␍$GPGSV,3,3,12,21,06,304,35,28,63,124,47,33,16,220,00,37,28,178,00*72␍$GPGLL,6003.9517,N,01940.4969,E,131848,A,D*44␍$GPBOD,,T,,M,,*47␍$PGRME,4.1,M,5.6,M,6.9,M*27␍$PGRMZ,-1,f,3*37␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131850,A,6003.9521,N,01940.4991,E,2.2,69.9,280510,4.8,E,D*27␍$GPRMB,A,,,,,,,,,,,,A,D*0E␍$GPGGA,131850,6003.9521,N,01940.4991,E,2,08,1.0,-0.1,M,21.7,M,,*6D␍$GPGSA,A,3,,05,07,08,,15,18,19,21,28,,,1.7,1.0,1.2*30␍$GPGSV,3,1,12,03,01,010,00,05,19,210,37,07,13,084,39,08,49,085,47*79␍$GPGSV,3,2,12,10,00,189,00,15,56,281,41,18,19,323,36,19,18,030,40*73␍$GPGSV,3,3,12,21,06,304,36,28,63,124,48,33,16,220,00,37,28,178,00*7E␍$GPGLL,6003.9521,N,01940.4991,E,131850,A,D*4F␍$GPBOD,,T,,M,,*47␍$PGRME,3.3,M,4.7,M,5.7,M*2F␍$PGRMZ,0,f,3*1B␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,131852,A,6003.9525,N,01940.5014,E,2.2,73.4,280510,4.8,E,A*27␍$GPRMB,A,,,,,,,,,,,,A,A*0B␍$GPGGA,131852,6003.9525,N,01940.5014,E,1,08,0.9,-0.2,M,21.7,M,,*66␍$GPGSA,A,3,,05,07,08,,15,18,19,21,28,,,1.6,0.9,1.2*39␍$GPGSV,3,1,12,03,01,010,00,05,19,210,38,07,13,084,39,08,49,085,46*77␍$GPGSV,3,2,12,10,00,189,00,15,56,281,42,18,19,323,38,19,18,030,40*7E␍$GPGSV,3,3,12,21,06,304,37,28,63,124,47,33,16,220,00,37,28,178,38*7B␍$GPGLL,6003.9525,N,01940.5014,E,131852,A,A*49␍$GPBOD,,T,,M,,*47␍$PGRME,3.3,M,4.7,M,5.7,M*2F␍$PGRMZ,-1,f,3*37␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍
@@ -1 +0,0 @@
$GPGSA,A,3,02,04,05,07,08,10,13,16,23,,,,2.3,1.4,1.6*38␍$GPGSV,3,1,12,02,25,252,45,04,06,214,33,05,39,299,36,07,68,165,45*7E␍$GPGSV,3,2,12,08,37,205,43,10,63,258,39,13,47,095,45,16,19,031,37*73␍$GPGSV,3,3,12,23,21,097,44,29,06,325,34,37,21,178,44,39,24,173,39*72␍$GPGLL,6004.3035,N,01940.9139,E,095200,A,D*45␍$GPBOD,54.6,T,49.7,M,Fl.W.3s,*77␍$PGRME,3.3,M,4.5,M,5.8,M*22␍$PGRMZ,-6,f,3*30␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,095202,A,6004.3030,N,01940.9154,E,1.7,124.6,030610,4.9,E,D*1B␍$GPRMB,A,0.03,L,,Fl.W.3s,6004.899,N,01942.501,E,0.993,53.0,0.4,V,D*51␍$GPGGA,095202,6004.3030,N,01940.9154,E,2,09,1.3,-2.0,M,21.7,M,,*6A␍$GPGSA,A,3,02,04,05,07,08,10,13,16,23,,,,2.2,1.3,1.6*3E␍$GPGSV,3,1,12,02,25,252,45,04,06,214,34,05,39,299,36,07,68,165,46*7A␍$GPGSV,3,2,12,08,37,205,43,10,63,258,39,13,47,095,45,16,19,031,38*7C␍$GPGSV,3,3,12,23,21,097,44,29,06,325,35,37,21,178,44,39,24,173,39*73␍$GPGLL,6004.3030,N,01940.9154,E,095202,A,D*49␍$GPBOD,54.6,T,49.7,M,Fl.W.3s,*77␍$PGRME,3.1,M,4.3,M,5.6,M*28␍$PGRMZ,-6,f,3*30␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,095204,A,6004.3024,N,01940.9169,E,1.7,127.0,030610,4.9,E,D*13␍$GPRMB,A,0.03,L,,Fl.W.3s,6004.899,N,01942.501,E,0.992,52.9,0.3,V,D*5F␍$GPGGA,095204,6004.3024,N,01940.9169,E,2,09,1.3,-1.9,M,21.7,M,,*6D␍$GPGSA,A,3,02,04,05,07,08,10,13,16,23,,,,2.2,1.3,1.6*3E␍$GPGSV,3,1,12,02,25,252,44,04,06,214,34,05,39,299,00,07,68,165,46*7E␍$GPGSV,3,2,12,08,37,205,43,10,63,258,39,13,47,095,45,16,19,031,39*7D␍$GPGSV,3,3,12,23,21,097,44,29,06,325,34,37,21,178,44,39,24,173,39*72␍$GPGLL,6004.3024,N,01940.9169,E,095204,A,D*44␍$GPBOD,54.6,T,49.7,M,Fl.W.3s,*77␍$PGRME,3.2,M,4.4,M,5.7,M*2D␍$PGRMZ,-6,f,3*30␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,095206,A,6004.3021,N,01940.9176,E,1.7,124.9,030610,4.9,E,D*10␍$GPRMB,A,0.03,L,,Fl.W.3s,6004.899,N,01942.501,E,0.992,52.9,0.5,V,D*59␍$GPGGA,095206,6004.3021,N,01940.9176,E,2,09,1.6,-2.3,M,21.7,M,,*68␍$GPGSA,A,3,02,04,05,07,08,10,13,16,23,,,,2.5,1.6,1.7*3D␍$GPGSV,3,1,12,02,25,252,44,04,06,214,33,05,39,299,00,07,68,165,45*7A␍$GPGSV,3,2,12,08,37,205,41,10,63,258,39,13,47,095,46,16,19,031,00*76␍$GPGSV,3,3,12,23,21,097,43,29,06,325,00,37,21,178,42,39,24,173,39*74␍$GPGLL,6004.3021,N,01940.9176,E,095206,A,D*4D␍$GPBOD,54.6,T,49.7,M,Fl.W.3s,*77␍$PGRME,4.0,M,4.5,M,6.4,M*29␍$PGRMZ,-7,f,3*31␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,095208,A,6004.3011,N,01940.9197,E,1.7,131.4,030610,4.9,E,D*1B␍$GPRMB,A,0.03,L,,Fl.W.3s,6004.899,N,01942.501,E,0.992,52.8,0.3,V,D*5E␍$GPGGA,095208,6004.3011,N,01940.9197,E,2,09,1.7,-2.0,M,21.7,M,,*68␍$GPGSA,A,3,02,04,05,07,08,10,13,16,23,,,,2.5,1.7,1.7*3C␍$GPGSV,3,1,12,02,25,252,44,04,06,214,00,05,39,299,34,07,68,165,45*7D␍$GPGSV,3,2,12,08,37,205,41,10,63,258,39,13,47,095,46,16,19,031,40*72␍$GPGSV,3,3,12,23,21,097,42,29,06,325,00,37,21,178,43,39,24,173,40*7A␍$GPGLL,6004.3011,N,01940.9197,E,095208,A,D*4F␍$GPBOD,54.6,T,49.7,M,Fl.W.3s,*77␍$PGRME,3.0,M,4.4,M,5.3,M*2B␍$PGRMZ,-6,f,3*30␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,095210,A,6004.3005,N,01940.9210,E,1.6,126.2,030610,4.9,E,D*1A␍$GPRMB,A,0.03,L,,Fl.W.3s,6004.899,N,01942.501,E,0.992,52.8,0.2,V,D*5F␍$GPGGA,095210,6004.3005,N,01940.9210,E,2,09,1.3,-1.8,M,21.7,M,,*67␍$GPGSA,A,3,02,04,05,07,08,10,13,16,23,,,,2.2,1.3,1.7*3F␍$GPGSV,3,1,12,02,25,252,44,04,06,214,00,05,39,299,33,07,68,165,45*7A␍$GPGSV,3,2,12,08,37,205,42,10,63,258,40,13,47,095,46,16,19,031,42*7D␍$GPGSV,3,3,12,23,21,097,42,29,06,325,00,37,21,178,43,39,24,173,40*7A␍$GPGLL,6004.3005,N,01940.9210,E,095210,A,D*4F␍$GPBOD,54.6,T,49.7,M,Fl.W.3s,*77␍$PGRME,3.0,M,4.4,M,5.3,M*2B␍$PGRMZ,-6,f,3*30␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,095212,A,6004.2999,N,01940.9223,E,1.7,130.3,030610,4.9,E,D*12␍$GPRMB,A,0.03,L,,Fl.W.3s,6004.899,N,01942.501,E,0.992,52.7,0.2,V,D*50␍$GPGGA,095212,6004.2999,N,01940.9223,E,2,09,1.3,-1.7,M,21.7,M,,*67␍$GPGSA,A,3,02,04,05,07,08,10,13,16,23,,,,2.2,1.3,1.7*3F␍$GPGSV,3,1,12,02,25,252,44,04,06,214,00,05,39,299,00,07,68,165,45*7A␍$GPGSV,3,2,12,08,37,205,43,10,63,258,40,13,47,095,47,16,19,031,41*7E␍$GPGSV,3,3,12,23,21,097,42,29,06,325,31,37,21,178,43,39,24,173,40*78␍$GPGLL,6004.2999,N,01940.9223,E,095212,A,D*40␍$GPBOD,54.6,T,49.7,M,Fl.W.3s,*77␍$PGRME,3.1,M,4.4,M,5.4,M*2D␍$PGRMZ,-6,f,3*30␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍$GPRMC,095214,A,6004.2993,N,01940.9236,E,1.8,136.0,030610,4.9,E,D*10␍$GPRMB,A,0.03,L,,Fl.W.3s,6004.899,N,01942.501,E,0.991,52.7,0.3,V,D*52␍$GPGGA,095214,6004.2993,N,01940.9236,E,2,09,1.4,-1.7,M,21.7,M,,*68␍$GPGSA,A,3,02,04,05,07,08,10,13,16,23,,,,2.3,1.4,1.7*39␍$GPGSV,3,1,12,02,25,252,44,04,06,214,00,05,39,299,00,07,68,165,45*7A␍$GPGSV,3,2,12,08,37,205,43,10,63,258,39,13,47,095,47,16,19,031,40*71␍$GPGSV,3,3,12,23,21,097,42,29,06,325,33,37,21,178,44,39,24,173,41*7C␍$GPGLL,6004.2993,N,01940.9236,E,095214,A,D*48␍$GPBOD,54.6,T,49.7,M,Fl.W.3s,*77␍$PGRME,3.2,M,4.5,M,5.5,M*2E␍$PGRMZ,-6,f,3*30␍$PGRMM,WGS 84*06␍$GPRTE,1,1,c,*37␍
@@ -1 +0,0 @@
$GPRMB,A,0.20,R,A003,A002,6004.099,N,01940.515,E,0.310,180.1,-0.3,V,D*68 $GPGGA,094140,6004.4083,N,01940.5157,E,2,10,1.0,0.1,M,21.7,M,,*4B $GPGSA,A,3,02,04,05,07,08,10,13,16,23,29,,,1.7,1.0,1.3*35 $GPGSV,3,1,12,02,28,256,34,04,10,216,39,05,35,301,00,07,65,172,43*7A $GPGSV,3,2,12,08,33,205,43,10,61,267,42,13,52,094,49,16,22,035,43*73 $GPGSV,3,3,12,23,27,095,39,29,08,329,37,37,21,178,38,39,24,173,00*7C $GPGLL,6004.4083,N,01940.5157,E,094140,A,D*4D $GPBOD,139.7,T,134.9,M,A002,A003*45 $PGRME,2.9,M,4.3,M,5.2,M*25 $PGRMZ,0,f,3*1B $PGRMM,WGS 84*06 $GPRTE,1,1,c,A003-A001 1,A003,A002,A001*54 $GPRMC,094142,A,6004.4085,N,01940.5176,E,1.8,80.0,030610,4.8,E,D*2F $GPRMB,A,0.20,R,A003,A002,6004.099,N,01940.515,E,0.310,180.3,-0.5,V,D*6C $GPGGA,094142,6004.4085,N,01940.5176,E,2,10,1.0,0.1,M,21.7,M,,*4C $GPGSA,A,3,02,04,05,07,08,10,13,16,23,29,,,1.7,1.0,1.4*32 $GPGSV,3,1,12,02,28,256,34,04,10,216,39,05,35,301,00,07,65,172,42*7B $GPGSV,3,2,12,08,33,205,44,10,61,267,41,13,52,094,48,16,22,035,43*76 $GPGSV,3,3,12,23,27,095,38,29,08,329,36,37,21,178,38,39,24,173,40*78 $GPGLL,6004.4085,N,01940.5176,E,094142,A,D*4A $GPBOD,139.7,T,134.9,M,A002,A003*45 $PGRME,3.0,M,4.2,M,5.3,M*2D $PGRMZ,0,f,3*1B $PGRMM,WGS 84*06 $GPWPL,6004.407,N,01939.993,E,A003*39 $GPRMC,094144,A,6004.4087,N,01940.5195,E,1.7,74.9,030610,4.8,E,D*2B $GPRMB,A,0.20,R,A003,A002,6004.099,N,01940.515,E,0.310,180.4,-0.5,V,D*6B $GPGGA,094144,6004.4087,N,01940.5195,E,2,10,1.2,0.2,M,21.7,M,,*44 $GPGSA,A,3,02,04,05,07,08,10,13,16,23,29,,,1.9,1.2,1.5*3F $GPGSV,3,1,12,02,28,256,00,04,10,216,38,05,35,301,31,07,65,172,43*7E $GPGSV,3,2,12,08,33,205,44,10,61,267,41,13,52,094,48,16,22,035,42*77 $GPGSV,3,3,12,23,27,095,38,29,08,329,35,37,21,178,38,39,24,173,39*75 $GPGLL,6004.4087,N,01940.5195,E,094144,A,D*43 $GPBOD,139.7,T,134.9,M,A002,A003*45 $PGRME,3.4,M,4.7,M,5.9,M*26 $PGRMZ,1,f,3*1A $PGRMM,WGS 84*06 $GPWPL,6004.099,N,01940.515,E,A002*37 $GPRMC,094146,A,6004.4089,N,01940.5214,E,1.7,75.7,030610,4.8,E,D*22 $GPRMB,A,0.20,R,A003,A002,6004.099,N,01940.515,E,0.310,180.6,-0.3,V,D*6F $GPGGA,094146,6004.4089,N,01940.5214,E,2,10,1.2,0.3,M,21.7,M,,*43 $GPGSA,A,3,02,04,05,07,08,10,13,16,23,29,,,2.0,1.2,1.6*36 $GPGSV,3,1,12,02,28,256,00,04,10,216,37,05,35,301,34,07,65,172,42*75 $GPGSV,3,2,12,08,33,205,44,10,61,267,42,13,52,094,48,16,22,035,40*76 $GPGSV,3,3,12,23,27,095,40,29,08,329,34,37,21,178,38,39,24,173,38*7A $GPGLL,6004.4089,N,01940.5214,E,094146,A,D*45 $GPBOD,139.7,T,134.9,M,A002,A003*45 $PGRME,3.5,M,4.9,M,6.1,M*22 $PGRMZ,1,f,3*1A $PGRMM,WGS 84*06 $GPWPL,6003.958,N,01940.872,E,A001*3B $GPRMC,094148,A,6004.4090,N,01940.5232,E,1.7,79.4,030610,4.8,E,D*2F $GPRMB,A,0.20,R,A003,A002,6004.099,N,01940.515,E,0.310,180.8,-0.4,V,D*66 $GPGGA,094148,6004.4090,N,01940.5232,E,2,10,1.4,0.5,M,21.7,M,,*41 $GPGSA,A,3,02,04,05,07,08,10,13,16,23,29,,,2.2,1.4,1.7*33 $GPGSV,3,1,12,02,28,256,00,04,10,216,36,05,35,301,35,07,65,172,43*74 $GPGSV,3,2,12,08,33,205,44,10,61,267,42,13,52,094,48,16,22,035,40*76 $GPGSV,3,3,12,23,27,095,39,29,08,329,35,37,21,178,38,39,24,173,37*7A $GPGLL,6004.4090,N,01940.5232,E,094148,A,D*47 $GPBOD,139.7,T,134.9,M,A002,A003*45 $PGRME,3.6,M,5.1,M,6.3,M*2A $PGRMZ,2,f,3*19 $PGRMM,WGS 84*06 $GPRTE,1,1,c,A003-A001 1,A003,A002,A001*54 $GPRMC,094150,A,6004.4092,N,01940.5251,E,1.7,76.3,030610,4.8,E,D*29 $GPRMB,A,0.20,R,A003,A002,6004.099,N,01940.515,E,0.310,180.9,-0.3,V,D*60 $GPGGA,094150,6004.4092,N,01940.5251,E,2,10,1.5,0.6,M,21.7,M,,*4D $GPGSA,A,3,02,04,05,07,08,10,13,16,23,29,,,2.6,1.5,2.1*33 $GPGSV,3,1,12,02,28,256,00,04,10,216,35,05,35,301,35,07,65,172,43*77 $GPGSV,3,2,12,08,33,205,43,10,61,267,41,13,52,094,48,16,22,035,39*7C $GPGSV,3,3,12,23,27,095,39,29,08,329,35,37,21,178,38,39,24,173,38*75 $GPGLL,6004.4092,N,01940.5251,E,094150,A,D*49 $GPBOD,139.7,T,134.9,M,A002,A003*45 $PGRME,3.6,M,5.4,M,6.5,M*29 $PGRMZ,2,f,3*19 $PGRMM,WGS 84*06 $GPWPL,6004.407,N,01939.993,E,A003*39 $GPRMC,094152,A,6004.4093,N,01940.5271,E,1.8,80.8,030610,4.8,E,D*25 $GPRMB,A,0.21,R,A003,A002,6004.099,N,01940.515,E,0.310,181.1,-0.2,V,D*69 $GPGGA,094152,6004.4093,N,01940.5271,E,2,07,1.5,0.7,M,21.7,M,,*4B $GPGSA,A,3,,04,05,07,08,10,13,,,29,,,2.6,1.5,2.1*37 $GPGSV,3,1,12,02,28,256,00,04,10,216,34,05,35,301,34,07,65,172,43*77 $GPGSV,3,2,12,08,33,205,43,10,61,267,41,13,52,094,48,16,22,035,40*72 $GPGSV,3,3,12,23,27,095,38,29,08,329,37,37,21,178,38,39,24,173,38*76 $GPGLL,6004.4093,N,01940.5271,E,094152,A,D*48 $GPBOD,139.7,T,134.9,M,A002,A003*45 $PGRME,3.9,M,6.1,M,7.3,M*27 $PGRMZ,2,f,3*19 $PGRMM,WGS 84*06 $GPWPL,6004.099,N,01940.515,E,A002*37 $GPRMC,094154,A,6004.4095,N,01940.5289,E,1.8,82.1,030610,4.8,E,D*29 $GPRMB,A,0.21,R,A003,A002,6004.099,N,01940.515,E,0.311,181.3,-0.3,V,D*6B $GPGGA,094154,6004.4095,N,01940.5289,E,2,08,1.6,0.7,M,21.7,M,,*40 $GPGSA,A,3,,04,05,07,08,10,13,16,,29,,,2.7,1.6,2.2*31 $GPGSV,3,1,12,02,28,256,00,04,10,216,33,05,35,301,34,07,65,172,43*70 $GPGSV,3,2,12,08,33,205,42,10,61,267,41,13,52,094,48,16,22,035,41*72 $GPGSV,3,3,12,23,26,095,37,29,08,329,36,37,21,178,38,39,24,173,37*76 $GPGLL,6004.4095,N,01940Line truncated
@@ -1,217 +0,0 @@
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2010.02.13 13:08:23 =~=~=~=~=~=~=~=~=~=~=~=
2,14,52,083,45,07,,,00,05,,,27*71
$GPGSV,3,3,12,02,,,26,24,,,00,26,30,047,48,06,,,25*43
$GPRMC,110728,A,6013.0600,N,02453.5376,E,000.0,000.0,130210,,,A*79
$GPGGA,110729,6013.0599,N,02453.5376,E,1,04,03.4,-00016.6,M,045.5,M,,*63
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,08,03,,,00,19,25,189,51,22,22,075,51,14,52,083,45*44
$GPGSV,2,2,08,07,,,00,24,,,00,26,30,047,48,06,,,26*4A
$GPRMC,110729,A,6013.0599,N,02453.5376,E,000.0,000.0,130210,,,A*7B
$GPGGA,110730,6013.0599,N,02453.5377,E,1,04,03.4,-00016.6,M,045.5,M,,*6A
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,07,03,,,00,19,25,189,51,22,22,075,50,14,52,083,45*4A
$GPGSV,2,2,07,07,,,00,24,,,00,26,30,047,48,,,,*47
$GPRMC,110730,A,6013.0599,N,02453.5377,E,000.0,000.0,130210,,,A*72
$GPGGA,110731,6013.0599,N,02453.5376,E,1,04,03.4,-00016.6,M,045.5,M,,*6A
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,07,03,,,26,19,25,189,51,22,22,075,51,14,52,083,46*4C
$GPGSV,2,2,07,07,,,26,24,,,26,26,30,047,49,,,,*46
$GPRMC,110731,A,6013.0599,N,02453.5376,E,000.0,000.0,130210,,,A*72
$GPGGA,110732,6013.0599,N,02453.5376,E,1,04,03.4,-00016.7,M,045.5,M,,*68
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,3,1,12,03,,,00,11,,,00,19,25,189,51,17,,,00*46
$GPGSV,3,2,12,22,22,075,51,14,52,083,45,07,,,00,04,,,00*76
$GPGSV,3,3,12,15,,,00,24,,,00,26,30,047,48,20,,,00*42
$GPRMC,110732,A,6013.0599,N,02453.5376,E,000.0,000.0,130210,,,A*71
$GPGGA,110733,6013.0599,N,02453.5375,E,1,04,03.4,-00016.8,M,045.5,M,,*65
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,08,11,,,00,19,25,189,50,17,,,00,22,22,075,51*78
$GPGSV,2,2,08,14,52,083,44,04,,,00,26,30,047,47,20,,,00*79
$GPRMC,110733,A,6013.0599,N,02453.5375,E,000.0,000.0,130210,,,A*73
$GPGGA,110734,6013.0600,N,02453.5374,E,1,04,03.4,-00016.9,M,045.5,M,,*61
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,08,11,60,262,23,19,25,189,50,17,12,327,31,22,22,075,51*7E
$GPGSV,2,2,08,14,52,083,44,04,,,00,26,30,047,47,20,,,00*79
$GPRMC,110734,A,6013.0600,N,02453.5374,E,000.0,000.0,130210,,,A*76
$GPGGA,110735,6013.0600,N,02453.5373,E,1,04,03.4,-00016.9,M,045.5,M,,*67
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,3,1,12,10,,,00,11,60,262,26,19,25,189,50,17,12,327,28*4E
$GPGSV,3,2,12,22,22,075,51,14,52,083,45,18,,,00,04,,,26*7C
$GPGSV,3,3,12,23,,,00,13,,,00,26,30,047,48,20,19,247,27*7F
$GPRMC,110735,A,6013.0600,N,02453.5373,E,000.0,000.0,130210,,,A*70
$GPGGA,110736,6013.0600,N,02453.5373,E,1,04,03.4,-00016.9,M,045.5,M,,*64
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,05,19,25,189,51,22,22,075,51,14,52,083,45,23,,,27*4E
$GPGSV,2,2,05,26,30,047,48,,,,,,,,,,,,*44
$GPRMC,110736,A,6013.0600,N,02453.5373,E,000.0,000.0,130210,,,A*73
$GPGGA,110737,6013.0600,N,02453.5373,E,1,04,03.4,-00016.8,M,045.5,M,,*64
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,3,1,10,01,,,00,29,,,00,19,25,189,50,12,,,00*49
$GPGSV,3,2,10,22,22,075,51,14,52,083,44,21,,,00,32,,,00*74
$GPGSV,3,3,10,23,,,00,26,30,047,48,,,,,,,,*41
$GPRMC,110737,A,6013.0600,N,02453.5373,E,000.0,000.0,130210,,,A*72
$GPGGA,110738,6013.0599,N,02453.5373,E,1,04,03.4,-00016.8,M,045.5,M,,*68
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,07,01,,,00,29,,,00,19,25,189,50,22,22,075,51*7B
$GPGSV,2,2,07,14,52,083,43,32,,,00,26,30,047,48,,,,*79
$GPRMC,110738,A,6013.0599,N,02453.5373,E,000.0,000.0,130210,,,A*7E
$GPGGA,110739,6013.0599,N,02453.5374,E,1,04,03.4,-00016.7,M,045.5,M,,*61
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,07,01,,,25,29,,,25,19,25,189,50,22,22,075,51*7B
$GPGSV,2,2,07,14,52,083,45,32,49,234,27,26,30,047,48,,,,*42
$GPRMC,110739,A,6013.0599,N,02453.5374,E,000.0,000.0,130210,,,A*78
$GPGGA,110740,6013.0599,N,02453.5374,E,1,04,03.4,-00016.6,M,045.5,M,,*6E
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,3,1,12,01,,,00,29,,,00,19,25,189,50,09,,,00*41
$GPGSV,3,2,12,22,22,075,51,14,52,083,44,25,,,00,32,,,00*72
$GPGSV,3,3,12,08,,,00,27,,,00,26,30,047,49,16,,,00*49
$GPRMC,110740,A,6013.0599,N,02453.5374,E,000.0,000.0,130210,,,A*76
$GPGGA,110741,6013.0599,N,02453.5374,E,1,04,03.4,-00016.6,M,045.5,M,,*6F
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,07,19,25,189,50,09,,,00,22,22,075,51,14,52,083,45*40
$GPGSV,2,2,07,25,,,00,27,,,00,26,30,047,49,,,,*45
$GPRMC,110741,A,6013.0599,N,02453.5374,E,000.0,000.0,130210,,,A*77
$GPGGA,110742,6013.0599,N,02453.5374,E,1,04,03.4,-00016.5,M,045.5,M,,*6F
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,2,1,07,19,25,189,51,09,,,00,22$GPGGA,110826,6013.0600,N,02453.5359,E,1,04,03.4,-00015.9,M,045.5,M,,*61
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,3,1,09,28,,,00,19,24,189,49,22,21,075,51,14,52,082,47*45
$GPGSV,3,2,09,05,,,00,02,,,00,06,,,00,26,30,047,48*48
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110826,A,6013.0600,N,02453.5359,E,000.0,000.0,130210,,,A*75
$GPGGA,110827,6013.0600,N,02453.5358,E,1,04,03.4,-00015.9,M,045.5,M,,*61
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,3,1,09,28,,,00,19,24,189,48,22,21,075,50,14,52,082,46*44
$GPGSV,3,2,09,05,,,00,02,,,00,06,,,00,26,30,047,47*47
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110827,A,6013.0600,N,02453.5358,E,000.0,000.0,130210,,,A*75
$GPGGA,110828,6013.0600,N,02453.5358,E,1,04,03.4,-00015.9,M,045.5,M,,*6E
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.1*0C
$GPGSV,3,1,09,28,,,00,19,24,189,47,22,21,075,50,14,52,082,45*48
$GPGSV,3,2,09,05,,,00,02,,,00,06,,,00,26,30,047,47*47
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110828,A,6013.0600,N,02453.5358,E,000.0,000.0,130210,,,A*7A
$GPGGA,110829,6013.0600,N,02453.5357,E,1,04,03.4,-00015.9,M,045.5,M,,*60
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,28,,,00,19,24,189,47,22,21,075,49,14,52,082,45*40
$GPGSV,3,2,09,05,,,00,02,,,00,06,,,00,26,30,047,47*47
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110829,A,6013.0600,N,02453.5357,E,000.0,000.0,130210,,,A*74
$GPGGA,110830,6013.0600,N,02453.5356,E,1,04,03.4,-00015.9,M,045.5,M,,*69
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,28,,,00,19,24,189,47,22,21,075,50,14,52,082,46*4B
$GPGSV,3,2,09,05,,,00,02,,,00,06,,,00,26,30,047,47*47
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110830,A,6013.0600,N,02453.5356,E,000.0,000.0,130210,,,A*7D
$GPGGA,110831,6013.0600,N,02453.5356,E,1,04,03.4,-00016.0,M,045.5,M,,*62
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,28,,,00,19,24,189,47,22,21,075,50,14,52,082,45*48
$GPGSV,3,2,09,05,,,00,02,,,00,06,,,00,26,30,047,47*47
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110831,A,6013.0600,N,02453.5356,E,000.0,000.0,130210,,,A*7C
$GPGGA,110832,6013.0600,N,02453.5355,E,1,04,03.4,-00016.0,M,045.5,M,,*62
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,28,,,00,19,24,189,47,22,21,075,50,14,52,082,45*48
$GPGSV,3,2,09,05,,,00,02,,,00,06,,,00,26,30,047,47*47
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110832,A,6013.0600,N,02453.5355,E,000.0,000.0,130210,,,A*7C
$GPGGA,110833,6013.0600,N,02453.5354,E,1,04,03.4,-00016.0,M,045.5,M,,*62
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,28,,,00,19,24,189,47,22,21,075,49,14,52,082,45*40
$GPGSV,3,2,09,05,,,00,02,,,00,06,,,00,26,30,047,47*47
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110833,A,6013.0600,N,02453.5354,E,000.0,000.0,130210,,,A*7C
$GPGGA,110834,6013.0600,N,02453.5353,E,1,04,03.4,-00016.1,M,045.5,M,,*63
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,28,,,00,19,24,189,47,22,21,075,50,14,52,082,45*48
$GPGSV,3,2,09,05,,,00,02,,,00,06,,,00,26,30,047,47*47
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110834,A,6013.0600,N,02453.5353,E,000.0,000.0,130210,,,A*7C
$GPGGA,110835,6013.0601,N,02453.5352,E,1,04,03.4,-00016.1,M,045.5,M,,*62
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,28,,,27,19,24,189,47,22,21,075,50,14,52,082,45*4D
$GPGSV,3,2,09,05,,,27,02,,,30,06,,,00,26,30,047,47*41
$GPGSV,3,3,09,03,,,00,,,,,,,,,,,,*73
$GPRMC,110835,A,6013.0601,N,02453.5352,E,000.0,000.0,130210,,,A*7D
$GPGGA,110836,6013.0601,N,02453.5351,E,1,04,03.4,-00016.1,M,045.5,M,,*62
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,12,28,,,00,31,,,00,19,24,189,48,07,,,00*45
$GPGSV,3,2,12,22,21,075,51,14,52,082,45,05,,,27,02,,,27*70
$GPGSV,3,3,12,24,,,00,06,,,26,26,30,047,47,03,,,27*4F
$GPRMC,110836,A,6013.0601,N,02453.5351,E,000.0,000.0,130210,,,A*7D
$GPGGA,110837,6013.0602,N,02453.5350,E,1,04,03.4,-00016.1,M,045.5,M,,*61
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,2,1,08,31,,,00,19,24,189,47,07,,,00,22,21,075,51*7F
$GPGSV,2,2,08,14,52,082,45,24,,,00,26,30,047,47,03,,,00*7A
$GPRMC,110837,A,6013.0602,N,02453.5350,E,000.0,000.0,130210,,,A*7E
$GPGGA,110838,6013.0602,N,02453.5349,E,1,04,03.4,-00016.1,M,045.5,M,,*66
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,2,1,07,31,,,00,19,24,189,48,07,,,00,22,21,075,51*7F
$GPGSV,2,2,07,14,52,082,45,24,,,00,26,30,047,47,,,,*76
$GPRMC,110838,A,6013.0602,N,02453.5349,E,000.0,000.0,130210,,,A*79
$GPGGA,110839,6013.0602,N,02453.5348,E,1,04,03.4,-00016.1,M,045.5,M,,*66
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,2,1,07,31,,,00,19,24,189,48,07,,,00,22,21,075,50*7E
$GPGSV,2,2,07,14,52,082,44,24,,,00,26,30,047,47,,,,*77
$GPRMC,110839,A,6013.0602,N,02453.5348,E,000.0,000.0,130210,,,A*79
$GPGGA,110840,6013.0602,N,02453.5348,E,1,04,03.4,-00016.1,M,045.5,M,,*68
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,2,1,07,31,,,00,19,24,189,48,07,,,00,22,21,075,49*76
$GPGSV,2,2,07,14,52,082,44,24,,,00,26,30,047,47,,,,*77
$GPRMC,110840,A,6013.0602,N,02453.5348,E,000.0,000.0,130210,,,A*77
$GPGGA,110841,6013.0602,N,02453.5348,E,1,04,03.4,-00016.0,M,045.5,M,,*68
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,2,1,07,31,,,00,19,24,189,47,07,,,00,22,21,075,50*71
$GPGSV,2,2,07,14,52,082,44,24,,,00,26,30,047,47,,,,*77
$GPRMC,110841,A,6013.0602,N,02453.5348,E,000.0,000.0,130210,,,A*76
$GPGGA,110842,6013.0602,N,02453.5347,E,1,04,03.4,-00016.0,M,045.5,M,,*64
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,2,1,07,31,,,00,19,24,189,47,07,,,00,22,21,075,50*71
$GPGSV,2,2,07,14,52,082,44,24,,,00,26,30,047,47,,,,*77
$GPRMC,110842,A,6013.0602,N,02453.5347,E,000.0,000.0,130210,,,A*7A
$GPGGA,110843,6013.0602,N,02453.5347,E,1,04,03.4,-00015.9,M,045.5,M,,*6F
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,2,1,07,31,,,00,19,24,189,48,07,,,00,22,21,075,50*7E
$GPGSV,2,2,07,14,52,082,45,24,,,00,26,30,047,46,,,,*77
$GPRMC,110843,A,6013.0602,N,02453.5347,E,000.0,000.0,130210,,,A*7B
$GPGGA,110844,6013.0602,N,02453.5347,E,1,04,03.4,-00015.9,M,045.5,M,,*68
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,2,1,07,31,00,128,26,19,24,189,48,07,,,29,22,21,075,50*4A
$GPGSV,2,2,07,14,52,082,45,24,,,00,26,30,047,47,,,,*76
$GPRMC,110844,A,6013.0602,N,02453.5347,E,000.0,000.0,130210,,,A*7C
$GPGGA,110845,6013.0603,N,02453.5346,E,1,04,03.4,-00015.8,M,045.5,M,,*68
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,12,11,,,00,31,00,128,28,19,24,189,48,07,,,27*7B
$GPGSV,3,2,12,22,21,075,51,14,52,082,45,17,,,00,04,,,00*75
$GPGSV,3,3,12,24,,,25,15,,,00,26,30,047,47,20,,,00*4A
$GPRMC,110845,A,6013.0603,N,02453.5346,E,000.0,000.0,130210,,,A*7D
$GPGGA,110846,6013.0603,N,02453.5345,E,1,04,03.4,-00015.8,M,045.5,M,,*68
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,11,,,00,19,24,189,48,22,21,075,51,14,52,082,45*4C
$GPGSV,3,2,09,17,,,00,04,,,00,24,,,00,26,30,047,47*42
$GPGSV,3,3,09,20,,,00,,,,,,,,,,,,*72
$GPRMC,110846,A,6013.0603,N,02453.5345,E,000.0,000.0,130210,,,A*7D
$GPGGA,110847,6013.0603,N,02453.5345,E,1,04,03.4,-00015.7,M,045.5,M,,*66
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,11,,,00,19,24,189,48,22,21,075,50,14,52,082,45*4D
$GPGSV,3,2,09,17,,,00,04,,,00,24,,,00,26,30,047,46*43
$GPGSV,3,3,09,20,,,00,,,,,,,,,,,,*72
$GPRMC,110847,A,6013.0603,N,02453.5345,E,000.0,000.0,130210,,,A*7C
$GPGGA,110848,6013.0603,N,02453.5344,E,1,04,03.4,-00015.7,M,045.5,M,,*68
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,11,,,00,19,24,189,48,22,21,075,50,14,52,082,45*4D
$GPGSV,3,2,09,17,,,00,04,,,00,24,,,00,26,30,047,47*42
$GPGSV,3,3,09,20,,,00,,,,,,,,,,,,*72
$GPRMC,110848,A,6013.0603,N,02453.5344,E,000.0,000.0,130210,,,A*72
$GPGGA,110849,6013.0603,N,02453.5343,E,1,04,03.4,-00015.7,M,045.5,M,,*6E
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,11,,,00,19,24,189,48,22,21,075,50,14,52,082,45*4D
$GPGSV,3,2,09,17,,,00,04,,,00,24,,,00,26,30,047,47*42
$GPGSV,3,3,09,20,,,00,,,,,,,,,,,,*72
$GPRMC,110849,A,6013.0603,N,02453.5343,E,000.0,000.0,130210,,,A*74
$GPGGA,110850,6013.0603,N,02453.5343,E,1,04,03.4,-00015.7,M,045.5,M,,*66
$GPGSA,A,3,14,19,22,26,,,,,,,,,04.6,03.4,03.0*0D
$GPGSV,3,1,09,11,,,00,19,24,189,48,22,21,075,50,14,52,082,46*4E
$GPGSV,3,2,09,17,,,00,04,,,00,24,,,00,26,30,047,47*42
$GPGSV,3,3,09,20,,,00,,,,,,,,,,,,*72
$GPRMC,110850,A,6013.0603,N,02453.5343,E,000.0,000.0,130210,,,A*7C
@@ -1,46 +0,0 @@
Messprotokoll 19.12.2012
Windvane nicht kalibriert. Plan: Messfahrt mit jeweils 90°-Schritten. Festhalten von Fahrtgeschwindigkeit des Autos,
ausserdem GPS-Track von einem Android HTC Desire.
Vergleich der Windgeschwindigkeit mit Hansmesser
11:42 7.5-9.2kt
Messfahrten entlang Soling
1. Messfahrt, Beginn 11:45:00, Kopfstellung 0°, Handwindmessung: 4.3-6kt, Tacho 28km/h. Ende ca. 11:46:20
2. Messfahrt, Beginn 11:47:00, Kopfstellung 0°, Handwindmessung: 5-6kt, Tacho 28km/h. Ende ca. 11:47:40
3. Messfahrt, Beginn 11:48:00, Kopfstellung 0°, Handwindmessung: 5-6kt, Tacho 40km/h. Ende ca. 11:48:35
4. Messfahrt, Beginn 11:50:00, Kopfstellung 0°, Handwindmessung: 5-7kt, Tacho 40km/h. Ende ca. 11:50:11
5. Messfahrt, Beginn 11:51:00, Kopfstellung 0°, Handwindmessung: 2.5-3,5kt, Tacho 20km/h. Ende ca. 11:51:50
6. Messfahrt, Beginn 11:52:30, Kopfstellung 0°, Handwindmessung: 4-5kt, Tacho 20km/h. Ende ca. 11:53:20
7. Messfahrt, Beginn 11:55:20, Kopfstellung 90°, Handwindmessung: 4-6kt, Tacho 40km/h. Ende ca. 11:55:45
8. Messfahrt, Beginn 11:57:00, Kopfstellung 90°, Handwindmessung: 4-5kt, Tacho 40km/h. Ende ca. 11:57:20
9. Messfahrt, Beginn 11:58:30, Kopfstellung 180°, Handwindmessung: 4-5kt, Tacho 40km/h. Ende ca. 11:58:53
10. Messfahrt, Beginn 12:00:00, Kopfstellung 180°, Handwindmessung: 5.5-6.5kt, Tacho 40km/h. Ende ca. 12:00:25
11. Messfahrt, Beginn 12:01:30, Kopfstellung 270°, Handwindmessung: 2.7-3.5kt, Tacho 40km/h. Ende ca. 12:01:50
12. Messfahrt, Beginn 12:03:00, Kopfstellung 270°, Handwindmessung: 5.5-6.5kt, Tacho 40km/h. Ende ca. 12:03:20
13. Messfahrt, Beginn 12:04:45, Kopfstellung 0°, Handwindmessung: 3.8-4.8kt, Tacho 40km/h. Ende ca. 12:05:05
14. Messfahrt, Beginn 12:06:00, Kopfstellung 0°, Handwindmessung: 3.7-4.5kt, Tacho 40km/h. Ende ca. 12:06:21
15. Messfahrt, Beginn 12:09:00, Kreisfahrt links Volleinschlag im Schritttempo, Kopfstellung 0°, Handwindmessung: 3.7-5.1kt, Tacho 4km/h, Ende ca. 12:10:42
16. Messfahrt, Beginn 12:12:10, Kreisfahrt recht Volleinschlag im Schritttempo, Kopfstellung 0°, Handwindmessung: 2.7-5.0kt, Tacho 4km/h, Ende ca. 12:13:15
@@ -1,20 +0,0 @@
$IIMWV,273,R,24.3,N,A*10
$IIVHW,,,347,M,0.00,N,,*64
$IIVLW,1958.64,N,1958.64,N*4D
$IIVPW,00.00,N,,*31␍$IIVTG,,T,312,M,0.0,N,,*0C
$IIVWR,088,L,24.5,N,12.6,M,,*2A
$IIVWT,088,L,24.7,N,12.6,M,,*2E
$IIXTE,A,A,5.36,R,N*67
$IIDBT,013.4,f,04.1,M,02.2,F*12
$IIGLL,3748.4051,N,12226.618,W,,A*1D
$IIHDM,348,M*33
$IIMTA,39.4,C*0B
$IIMTW,016,C*3A
$IIMWD,,T,258,M,24.6,N,12.6,M*7E
$IIMWV,272,R,24.6,N,A*14
$IIVHW,,,348,M,0.00,N,,*6B
$IIVLW,1958.64,N,1958.64,N*4D
$IIVPW,00.00,N,,*31
$IIVTG,,T,315,M,0.0,N,,*0B
$IIVWR,091,L,24.9,N,12.8,M,,*20
$IIVWT,090,L,24.6,N,12.6,M,,*26␍$IIXTE,A,A,5.36,R,N*67␍$IIDBT,013.2,f,04.0,M,02.2,F*15␍$IIGLL,3748.4052,N,12226.618,W,,A*1E␍$IIHDM,348,M*33␍$IIMTA,17.9,C*0A␍$IIMTW,016,C*3A␍$IIMWD,,T,254,M,26.4,N,13.5,M*70␍$IIMWV,267,R,26.0,N,A*14␍$IIVHW,,,348,M,0.00,N,,*6B␍$IIVLW,1958.64,N,1958.64,N*4D␍$IIVPW,00.00,N,,*31␍$IIVTG,,T,295,M,0.0,N,,*02␍$IIVWR,093,L,26.5,N,13.6,M,,*23␍$IIVWT,094,L,26.7,N,13.7,M,,*21␍$IIXTE,A,A,5.36,R,N*67␍$IIDBT,013.3,f,04.0,M,02.2,F*14␍$IIGLL,3748.4051,N,12226.618,W,,A*1D␍$IIHDM,348,M*33␍$IIMTA,3.6,C*30␍$IIMTW,016,C*3A␍$IIMWD,,T,250,M,27.0,N,13.8,M*7C␍$IIMWV,265,R,26.4,N,A*12
@@ -1,230 +0,0 @@
package com.sap.sailing.nmeaconnector.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import org.junit.Test;
import com.sap.sailing.domain.base.impl.KilometersPerHourSpeedWithBearingImpl;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.SpeedWithBearing;
import com.sap.sailing.domain.common.Wind;
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
import com.sap.sailing.domain.common.impl.DegreePosition;
import com.sap.sailing.domain.common.tracking.GPSFixMoving;
import com.sap.sailing.domain.common.tracking.impl.GPSFixMovingImpl;
import com.sap.sailing.domain.tracking.WindTrack;
import com.sap.sailing.domain.tracking.impl.DynamicGPSFixMovingTrackImpl;
import com.sap.sailing.domain.tracking.impl.WindComparator;
import com.sap.sailing.domain.tracking.impl.WindTrackImpl;
import com.sap.sailing.nmeaconnector.NmeaFactory;
import com.sap.sailing.nmeaconnector.NmeaUtil;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
import com.sap.sse.common.impl.MillisecondsTimePoint;
import net.sf.marineapi.nmea.event.SentenceEvent;
import net.sf.marineapi.nmea.event.SentenceListener;
import net.sf.marineapi.nmea.io.SentenceReader;
import net.sf.marineapi.nmea.sentence.BATSentence;
import net.sf.marineapi.nmea.sentence.BATSentence.WindVaneBatteryStatus;
import net.sf.marineapi.nmea.sentence.MWVSentence;
import net.sf.marineapi.nmea.sentence.Sentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import slash.navigation.base.BaseRoute;
import slash.navigation.base.NavigationFormat;
import slash.navigation.base.NavigationFormatParser;
import slash.navigation.base.ParserResult;
import slash.navigation.gpx.Gpx10Format;
import slash.navigation.gpx.GpxPosition;
import slash.navigation.gpx.GpxRoute;
public class ReadWindVaneDataTest {
@Test
public void testWindVaneFilePresence() throws IOException {
InputStream is = getClass().getResourceAsStream("/windvane.nmea");
assertNotNull(is);
is.close();
}
@Test
public void readWindVaneOutputWithInterlacedTimeStamps() throws IOException, InterruptedException {
final List<Sentence> sentences = new ArrayList<>();
final List<TimePoint> timePointsForSentences = new ArrayList<>();
readWindVaneNmeaFile(sentences, timePointsForSentences);
assertEquals(674, sentences.size()); // we have 684 sentences altogether; 74 of those are WIBAT which are now understood;
// 10 messages (one of them a WIBAT) have no timestamp yet
}
@Test
public void findProprietaryBatteryMessages() throws IOException, InterruptedException {
final List<Sentence> sentences = new ArrayList<>();
final List<TimePoint> timePointsForSentences = new ArrayList<>();
readWindVaneNmeaFile(sentences, timePointsForSentences);
boolean found = false;
for (Sentence sentence : sentences) {
if (sentence.getTalkerId() == TalkerId.WI) {
if (sentence.getSentenceId().equals("BAT")) {
found = true;
assertTrue(sentence instanceof BATSentence);
assertEquals(WindVaneBatteryStatus.GOOD, ((BATSentence) sentence).getWindVaneBatteryStatus());
assertEquals(5, ((BATSentence) sentence).getBaseUnitBatteryLevel());
}
}
}
assertTrue("Expected to find BAT message", found);
}
private void readWindVaneNmeaFile(final List<Sentence> sentences, final List<TimePoint> timePointsForSentences)
throws IOException, InterruptedException {
NmeaUtil nmeaUtil = NmeaFactory.INSTANCE.getUtil();
DateFormat df = new SimpleDateFormat("EE, dd. MMM yyyy HH:mm:ss", Locale.GERMANY);
TimePoint lastTimestampFromFile = null;
InputStream is = getClass().getResourceAsStream("/windvane.nmea");
PipedInputStream pis = new PipedInputStream();
PipedOutputStream pos = new PipedOutputStream(pis);
SentenceReader nmeaReader = new SentenceReader(pis);
nmeaReader.addSentenceListener(new SentenceListener() {
@Override
public void sentenceRead(SentenceEvent event) {
TimePoint timePoint = new MillisecondsTimePoint(event.getTimeStamp());
Sentence sentence = event.getSentence();
sentences.add(sentence);
System.out.println("Time from file: "+timePointsForSentences.get(sentences.size()-1)+", Timestamp in sentence: "+timePoint+
", Talker ID: "+sentence.getTalkerId()+", Sentence ID: "+sentence.getSentenceId());
}
@Override public void readingStopped() {}
@Override public void readingStarted() {}
@Override public void readingPaused() {}
});
nmeaReader.start();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
while ((line=br.readLine()) != null) {
if (line.startsWith("$") || line.startsWith("!")) {
// NMEA0183 sentence
// Special hack for a bug with the WindVane's speed unit output which erroneously uses "K" for "knots":
line = nmeaUtil.replace(line, ",K,", ",N,");
if (lastTimestampFromFile != null) {
lastTimestampFromFile = lastTimestampFromFile.plus(1000);
timePointsForSentences.add(lastTimestampFromFile);
// write the sentence only if we have a time stamp for it
pos.write(line.getBytes());
pos.write(new byte[] { 13, 10 });
pos.flush();
}
} else {
try {
// Maybe it's an interwoven timestamp. Try out...
Date date = df.parse(line);
final MillisecondsTimePoint newTimePointFromFile = new MillisecondsTimePoint(date);
if (lastTimestampFromFile != null && newTimePointFromFile.before(lastTimestampFromFile)) {
System.err.println("Surprise! Received more than five NMEA messages in five seconds at "+newTimePointFromFile);
}
lastTimestampFromFile = newTimePointFromFile;
} catch (ParseException pe) {
pe.printStackTrace();
}
}
}
pos.close();
br.close();
Thread.sleep(3000);
nmeaReader.stop();
}
@Test
public void readGpxFile() throws IOException {
DynamicGPSFixMovingTrackImpl<Object> track = new DynamicGPSFixMovingTrackImpl<Object>("Wind Vane", /* millisecondsOverWhichToAverage */ 5000);
loadGpxFileIntoTrack(track);
track.lockForRead();
try {
assertEquals(489, track.getRawFixes().size());
} finally {
track.unlockAfterRead();
}
}
@Test
public void readWindVaneNmeaIntoWindTrack() throws IOException, InterruptedException {
NmeaUtil nmeaUtil = NmeaFactory.INSTANCE.getUtil();
final List<Sentence> sentences = new ArrayList<>();
DynamicGPSFixMovingTrackImpl<Object> gpsTrack = new DynamicGPSFixMovingTrackImpl<Object>("Wind Vane", /* millisecondsOverWhichToAverage */ 5000);
loadGpxFileIntoTrack(gpsTrack);
final List<TimePoint> timePointsForSentences = new ArrayList<>();
WindTrack windTrack = new WindTrackImpl(/* millisecondsOverWhichToAverage */ 5000, /* useSpeed */ true,
/* nameForReadWriteLock */ "readWindVaneNmeaIntoWindTrack");
readWindVaneNmeaFile(sentences, timePointsForSentences);
Iterator<TimePoint> timePointIter = timePointsForSentences.iterator();
for (Sentence sentence : sentences) {
TimePoint timePoint = timePointIter.next();
Position position = gpsTrack.getEstimatedPosition(timePoint, /* extrapolate */ true);
if (SentenceId.MWV == SentenceId.valueOf(sentence.getSentenceId())) {
MWVSentence mwvSentence = (MWVSentence) sentence;
final Wind wind = nmeaUtil.getWind(timePoint, position, mwvSentence);
Wind oldWindAtOrAfter = windTrack.getFirstFixAtOrAfter(timePoint);
if (oldWindAtOrAfter != null && WindComparator.INSTANCE.compare(oldWindAtOrAfter, wind) == 0) {
System.err.println("Surprise: two wind fixes for the same time point and the same position. Old: "
+ oldWindAtOrAfter + ". New: " + wind);
}
windTrack.add(wind);
}
}
windTrack.lockForRead();
try {
assertEquals(601, Util.size(windTrack.getRawFixes()));
System.out.println("\n\nTimePoint"+"\t"
+"AWS/kts"+"\t"
+"AWA"+"\t"
+"SOG/kts"+"\t"
+"COG");
for (Wind rawWind : windTrack.getRawFixes()) {
final SpeedWithBearing estimatedSpeed = gpsTrack.getEstimatedSpeed(rawWind.getTimePoint());
System.out.println(rawWind.getTimePoint()+"\t"
+rawWind.getKnots()+"\t"
+rawWind.getBearing().getDegrees()+"\t"
+estimatedSpeed.getKnots()+"\t"
+estimatedSpeed.getBearing().getDegrees());
}
} finally {
windTrack.unlockAfterRead();
}
}
private void loadGpxFileIntoTrack(DynamicGPSFixMovingTrackImpl<Object> track) throws IOException {
ParserResult read = new NavigationFormatParser().read(getClass().getResource("/20121219114023.gpx"),
Arrays.asList(new NavigationFormat[] { new Gpx10Format() }));
@SuppressWarnings("rawtypes")
List<BaseRoute> routes = read.getAllRoutes();
assertNotNull(routes);
assertEquals(1, routes.size());
assertEquals(489, routes.get(0).getPositionCount());
GpxRoute route = (GpxRoute) routes.get(0);
List<GpxPosition> gpsPositions = route.getPositions();
assertNotNull(gpsPositions);
for (GpxPosition gpxPosition : gpsPositions) {
GPSFixMoving gpsFixMoving = new GPSFixMovingImpl(new DegreePosition(gpxPosition.getLatitude(), gpxPosition.getLongitude()),
new MillisecondsTimePoint(gpxPosition.getTime().getTimeInMillis()), new KilometersPerHourSpeedWithBearingImpl(
gpxPosition.getSpeed(), new DegreeBearingImpl(gpxPosition.getHeading())));
track.addGPSFix(gpsFixMoving);
}
}
}
@@ -0,0 +1,130 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.APBSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.DataStatus;
import net.sf.marineapi.nmea.util.Direction;
import org.junit.Before;
import org.junit.Test;
public class APBTest {
public static final String EXAMPLE = "$GPAPB,A,A,0.10,R,N,V,V,011,M,DEST,011,M,011,M";
private APBSentence apb;
private APBSentence empty;
@Before
public void setUp() throws Exception {
apb = new APBParser(EXAMPLE);
empty = new APBParser(TalkerId.AG);
}
@Test
public void testAPBParserString() {
assertEquals(TalkerId.GP, apb.getTalkerId());
assertEquals("APB", apb.getSentenceId());
assertEquals(14, apb.getFieldCount());
}
@Test
public void testAPBParserTalkerId() {
assertEquals(TalkerId.AG, empty.getTalkerId());
assertEquals("APB", empty.getSentenceId());
assertEquals(14, empty.getFieldCount());
}
@Test
public void testGetBearingPositionToDestination() {
empty.setBearingPositionToDestination(123.45);
assertEquals(123.5, empty.getBearingPositionToDestination(), 0.1);
}
@Test
public void testGetBearingOriginToDestination() {
empty.setBearingOriginToDestination(234.56);
assertEquals(234.6, empty.getBearingOriginToDestination(), 0.1);
}
@Test
public void testGetCrossTrackError() {
empty.setCrossTrackError(12.345);
assertEquals(12.3, empty.getCrossTrackError(), 0.1);
}
@Test
public void testGetCrossTrackUnits() {
empty.setCrossTrackUnits(APBSentence.NM);
assertEquals(APBSentence.NM, empty.getCrossTrackUnits());
}
@Test
public void testGetCycleLockStatus() {
empty.setCycleLockStatus(DataStatus.ACTIVE);
assertEquals(DataStatus.ACTIVE, empty.getCycleLockStatus());
}
@Test
public void testGetDestionationWaypointId() {
empty.setDestinationWaypointId("WP001");
assertEquals("WP001", empty.getDestionationWaypointId());
}
@Test
public void testGetHeadingToDestionation() {
empty.setHeadingToDestination(98.765);
assertEquals(98.8, empty.getHeadingToDestionation(), 0.1);
}
@Test
public void testGetStatus() {
empty.setStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, empty.getStatus());
}
@Test
public void testGetSteerTo() {
empty.setSteerTo(Direction.LEFT);
assertEquals(Direction.LEFT, empty.getSteerTo());
}
@Test
public void testIsArrivalCircleEntered() {
empty.setArrivalCircleEntered(true);
assertTrue(empty.isArrivalCircleEntered());
}
@Test
public void testIsBearingOriginToDestionationTrue() {
empty.setBearingOriginToDestionationTrue(true);
assertTrue(empty.isBearingOriginToDestionationTrue());
}
@Test
public void testIsBearingPositionToDestinationTrue() {
empty.setBearingPositionToDestinationTrue(false);
assertFalse(empty.isBearingPositionToDestinationTrue());
}
@Test
public void testIsHeadingToDestinationTrue() {
empty.setHeadingToDestinationTrue(true);
assertTrue(empty.isHeadingToDestinationTrue());
}
@Test
public void testIsPerpendicularPassed() {
empty.setPerpendicularPassed(false);
assertFalse(empty.isPerpendicularPassed());
}
@Test
public void testSetArrivalCircleEntered() {
empty.setArrivalCircleEntered(true);
assertTrue(empty.isArrivalCircleEntered());
}
}
@@ -0,0 +1,353 @@
package net.sf.marineapi.nmea.parser;
import junit.framework.TestCase;
import net.sf.marineapi.nmea.sentence.BODSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* Tests the BOD sentence parser.
*
* @author Kimmo Tuukkanen
*/
public class BODTest extends TestCase {
public static final String EXAMPLE = "$GPBOD,234.9,T,228.8,M,RUSKI,*1D";
private BODSentence empty;
private BODSentence bod;
/**
* setUp
*/
@Override
@Before
public void setUp() throws Exception {
try {
empty = new BODParser(TalkerId.GP);
bod = new BODParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* tearDown
*/
@Override
@After
public void tearDown() throws Exception {
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#BODParser()} .
*/
@Test
public void testConstructor() {
assertEquals(6, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#BODParser(java.lang.String)}
* .
*/
@Test
public void testConstructorWithInvalidSentence() {
try {
new BODParser("$HUBBA,habba,doo,dah,doo");
} catch (IllegalArgumentException e) {
// OK
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#BODParser(java.lang.String)}
* .
*/
@Test
public void testConstructorWithNullString() {
try {
new BODParser((String) null);
} catch (IllegalArgumentException e) {
// OK
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#BODParser(java.lang.String)}
* .
*/
@Test
public void testConstructorWithNullTalkerId() {
try {
new BODParser((TalkerId) null);
} catch (IllegalArgumentException e) {
// OK
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#BODParser(java.lang.String)}
* .
*/
@Test
public void testConstructorWithRandomString() {
try {
new BODParser("foobar and haystack");
} catch (IllegalArgumentException e) {
// OK
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getDestinationWaypointId()}
* .
*/
@Test
public void testGetDestinationWaypointId() {
try {
String id = bod.getDestinationWaypointId();
assertEquals("RUSKI", id);
} catch (ParseException e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getMagneticBearing()}.
*/
@Test
public void testGetMagneticBearing() {
try {
double b = bod.getMagneticBearing();
assertEquals(228.8, b, 0.001);
} catch (ParseException e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getOriginWaypointId()}.
*/
@Test
public void testGetOriginWaypointId() {
try {
bod.getOriginWaypointId();
} catch (DataNotAvailableException e) {
// ok, field is empty
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getTrueBearing()}.
*/
@Test
public void testGetTrueBearing() {
try {
double b = bod.getTrueBearing();
assertEquals(234.9, b, 0.001);
} catch (ParseException e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getDestinationWaypointId()}
* .
*/
@Test
public void testSetDestinationWaypointId() {
try {
bod.setDestinationWaypointId("TIISKERI");
assertEquals("TIISKERI", bod.getDestinationWaypointId());
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getDestinationWaypointId()}
* .
*/
@Test
public void testSetDestinationWaypointIdWithEmptyStr() {
try {
bod.setDestinationWaypointId("");
bod.getDestinationWaypointId();
} catch (Exception e) {
assertTrue(e instanceof DataNotAvailableException);
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getDestinationWaypointId()}
* .
*/
@Test
public void testSetDestinationWaypointIdWithNull() {
try {
bod.setDestinationWaypointId(null);
bod.getDestinationWaypointId();
} catch (Exception e) {
assertTrue(e instanceof DataNotAvailableException);
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getMagneticBearing()}.
*/
@Test
public void testSetMagneticBearing() {
final double bearing = 180.0;
try {
bod.setMagneticBearing(bearing);
assertEquals(bearing, bod.getMagneticBearing());
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getMagneticBearing()}.
*/
@Test
public void testSetMagneticBearingWithRounding() {
final double bearing = 65.654321;
try {
bod.setMagneticBearing(bearing);
assertTrue(bod.toString().contains(",065.7,"));
assertEquals(bearing, bod.getMagneticBearing(), 0.1);
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getMagneticBearing()}.
*/
@Test
public void testSetMagneticBearingWithGreaterThanAllowed() {
try {
bod.setMagneticBearing(360.01);
fail("Did not throw exception");
} catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException);
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getMagneticBearing()}.
*/
@Test
public void testSetMagneticBearingWithNegativeValue() {
try {
bod.setMagneticBearing(-0.01);
fail("Did not throw exception");
} catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException);
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getOriginWaypointId()}.
*/
@Test
public void testSetOriginWaypointId() {
try {
bod.setOriginWaypointId("TAINIO");
assertEquals("TAINIO", bod.getOriginWaypointId());
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getTrueBearing()}.
*/
@Test
public void testSetTrueBearing() {
final double bearing = 180.0;
try {
bod.setTrueBearing(bearing);
assertEquals(bearing, bod.getTrueBearing());
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getTrueBearing()}.
*/
@Test
public void testSetTrueBearingWithRounding() {
final double bearing = 90.654321;
try {
bod.setTrueBearing(bearing);
assertTrue(bod.toString().contains(",090.7,"));
assertEquals(bearing, bod.getTrueBearing(), 0.1);
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getTrueBearing()}.
*/
@Test
public void testSetTrueBearingGreaterThanAllowed() {
try {
bod.setTrueBearing(360.01);
fail("Did not throw exception");
} catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException);
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.BODParser#getTrueBearing()}.
*/
@Test
public void testSetTrueBearingWithNegativeValue() {
try {
bod.setTrueBearing(-0.01);
fail("Did not throw exception");
} catch (Exception e) {
assertTrue(e instanceof IllegalArgumentException);
}
}
}
@@ -0,0 +1,72 @@
/*
* ChecksumTest.java
* Copyright (C) 2010 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import net.sf.marineapi.nmea.sentence.Checksum;
import org.junit.Test;
/**
* Tests the Checksum class.
*
* @author Kimmo Tuukkanen
*/
public class ChecksumTest {
/**
* Test method for
* {@link net.sf.marineapi.nmea.sentence.Checksum#add(java.lang.String)}.
*/
@Test
public void testAdd() {
String a = "$GPGLL,6011.552,N,02501.941,E,120045,A";
String b = "$GPGLL,6011.552,N,02501.941,E,120045,A*";
String c = "$GPGLL,6011.552,N,02501.941,E,120045,A*00";
final String expected = a.concat("*26");
assertEquals(expected, Checksum.add(a));
assertEquals(expected, Checksum.add(b));
assertEquals(expected, Checksum.add(c));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.sentence.Checksum#calculate(java.lang.String)}
* .
*/
@Test
public void testCalculate() {
assertEquals("1D", Checksum.calculate(BODTest.EXAMPLE));
assertEquals("63", Checksum.calculate(GGATest.EXAMPLE));
assertEquals("26", Checksum.calculate(GLLTest.EXAMPLE));
assertEquals("0B", Checksum.calculate(RMCTest.EXAMPLE));
assertEquals("3D", Checksum.calculate(GSATest.EXAMPLE));
assertEquals("73", Checksum.calculate(GSVTest.EXAMPLE));
assertEquals("58", Checksum.calculate(RMBTest.EXAMPLE));
assertEquals("25", Checksum.calculate(RTETest.EXAMPLE));
}
@Test
public void testDelimiterIndex() {
assertEquals(13, Checksum.index("$GPGGA,,,,,,,"));
assertEquals(13, Checksum.index("$GPGGA,,,,,,,*00"));
}
}
@@ -0,0 +1,62 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import net.sf.marineapi.nmea.sentence.DBTSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
public class DBTTest {
public static final String EXAMPLE = "$IIDBT,013.4,f,04.1,M,02.2,F*12";
private DBTSentence dbt;
private DBTSentence empty;
@Before
public void setUp() throws Exception {
empty = new DBTParser(TalkerId.II);
dbt = new DBTParser(EXAMPLE);
}
@Test
public void testConstructor() {
assertEquals("DBT", empty.getSentenceId());
assertEquals(TalkerId.II, empty.getTalkerId());
assertEquals(6, empty.getFieldCount());
}
@Test
public void testGetFathoms() {
assertEquals(2.2, dbt.getFathoms(), 0.01);
}
@Test
public void testGetFeet() {
assertEquals(13.4, dbt.getFeet(), 0.01);
}
@Test
public void testGetMeters() {
assertEquals(4.1, dbt.getDepth(), 0.01);
}
@Test
public void testSetFathoms() {
empty.setFathoms(7.33333);
assertEquals(7.3, empty.getFathoms(), 0.1);
}
@Test
public void testSetFeet() {
empty.setFeet(12.33333);
assertEquals(12.3, empty.getFeet(), 0.1);
}
@Test
public void testSetMeters() {
empty.setDepth(23.654321);
assertEquals(23.7, empty.getDepth(), 0.1);
}
}
@@ -0,0 +1,73 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import net.sf.marineapi.nmea.sentence.DPTSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
public class DPTTest {
public static final String EXAMPLE = "$IIDPT,012.6,-1.0,100";
DPTSentence empty;
DPTSentence dpt;
@Before
public void setUp() throws Exception {
empty = new DPTParser(TalkerId.II);
dpt = new DPTParser(EXAMPLE);
}
@Test
public void testDPTParser() {
assertEquals(TalkerId.II, empty.getTalkerId());
assertEquals("DPT", empty.getSentenceId());
assertEquals(3, empty.getFieldCount());
}
@Test
public void testDPTParserString() {
assertEquals(TalkerId.II, dpt.getTalkerId());
assertEquals("DPT", dpt.getSentenceId());
assertEquals(3, dpt.getFieldCount());
}
@Test
public void testGetDepth() {
assertEquals(12.6, dpt.getDepth(), 0.01);
}
@Test
public void testGetOffset() {
assertEquals(-1.0, dpt.getOffset(), 0.01);
}
@Test
public void testSetDepth() {
final double depth = 1.2333333;
empty.setDepth(depth);
assertEquals(depth, empty.getDepth(), 0.1);
}
@Test
public void testSetOffset() {
final double offset = 1.555555;
empty.setOffset(offset);
assertEquals(offset, empty.getOffset(), 0.1);
}
@Test
public void testGetMaximum() {
assertEquals(100, dpt.getMaximum(), 1);
}
@Test
public void testSetMaximum() {
final int max = 123;
dpt.setMaximum(max);
assertEquals(max, dpt.getMaximum(), 1);
}
}
@@ -0,0 +1,103 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.DTMSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
public class DTMTest {
public static final String EXAMPLE = "$GPDTM,W84,,0.000000,N,0.000000,E,0.0,W84*6F";
private DTMSentence dtm;
private DTMSentence empty;
@Before
public void setUp() throws Exception {
dtm = new DTMParser(EXAMPLE);
empty = new DTMParser(TalkerId.GP);
}
@Test
public void testDTMParserString() {
assertEquals("DTM", dtm.getSentenceId());
assertEquals(TalkerId.GP, dtm.getTalkerId());
assertEquals(8, dtm.getFieldCount());
}
@Test
public void testDTMParserTalkerId() {
assertEquals("DTM", empty.getSentenceId());
assertEquals(TalkerId.GP, empty.getTalkerId());
assertEquals(8, empty.getFieldCount());
}
@Test
public void testGetAltitudeOffset() {
assertEquals(0.0, dtm.getAltitudeOffset(), 0.1);
}
@Test
public void testGetDatumCode() {
assertEquals("W84", dtm.getDatumCode());
}
@Test
public void testGetDatumSubCode() {
try {
dtm.getDatumSubCode();
fail("didn't throw exception");
} catch (Exception e) {
// pass
}
}
@Test
public void testGetLatitudeOffset() {
assertEquals(0.0, dtm.getLatitudeOffset(), 0.1);
}
@Test
public void testGetLongitudeOffset() {
assertEquals(0.0, dtm.getLongitudeOffset(), 0.1);
}
@Test
public void testGetName() {
assertEquals("W84", dtm.getName());
}
@Test
public void testSetDatumCode() {
dtm.setDatumCode("W72");
assertEquals("W72", dtm.getDatumCode());
}
@Test
public void testSetDatumSubCode() {
dtm.setDatumSubCode("123");
assertEquals("123", dtm.getDatumSubCode());
}
@Test
public void testSetLatitudeOffset() {
dtm.setLatitudeOffset(0.12345678);
assertEquals(0.1235, dtm.getLatitudeOffset(), 0.0001);
}
@Test
public void testSetLongitudeOffset() {
dtm.setLongitudeOffset(1.23456789);
assertEquals(1.2346, dtm.getLongitudeOffset(), 0.0001);
}
@Test
public void testSetName() {
dtm.setName("S83");
assertEquals("S83", dtm.getName());
}
}
@@ -0,0 +1,245 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.CompassPoint;
import net.sf.marineapi.nmea.util.Datum;
import net.sf.marineapi.nmea.util.GpsFixQuality;
import net.sf.marineapi.nmea.util.Position;
import net.sf.marineapi.nmea.util.Time;
import net.sf.marineapi.nmea.util.Units;
import org.junit.Before;
import org.junit.Test;
/**
* Test the GGA sentence parser.
*
* @author Kimmo Tuukkanen
*/
public class GGATest {
public static final String EXAMPLE = "$GPGGA,120044.567,6011.552,N,02501.941,E,1,00,2.0,28.0,M,19.6,M,,*63";
private GGAParser gga;
private GGAParser empty;
@Before
public void setUp() {
try {
empty = new GGAParser(TalkerId.GP);
gga = new GGAParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(14, empty.getFieldCount());
}
@Test
public void testGetAltitude() {
assertEquals(28.0, gga.getAltitude(), 0.001);
}
@Test
public void testGetAltitudeUnits() {
assertEquals(Units.METER, gga.getAltitudeUnits());
}
@Test
public void testGetDgpsAge() {
try {
gga.getDgpsAge();
fail("Did not throw ParseException");
} catch (DataNotAvailableException e) {
// ok
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testGetDgpsStationId() {
try {
gga.getDgpsStationId();
fail("Did not throw ParseException");
} catch (DataNotAvailableException e) {
// ok
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testGetFixQuality() {
assertEquals(GpsFixQuality.NORMAL, gga.getFixQuality());
}
@Test
public void testGetGeoidalHeight() {
assertEquals(19.6, gga.getGeoidalHeight(), 0.001);
}
@Test
public void testGetGeoidalHeightUnits() {
assertEquals(Units.METER, gga.getGeoidalHeightUnits());
}
@Test
public void testGetHorizontalDOP() {
assertEquals(2.0, gga.getHorizontalDOP(), 0.001);
}
@Test
public void testGetNumberOfSatellites() {
assertEquals(0, gga.getSatelliteCount());
}
@Test
public void testGetPosition() {
// expected lat/lon values
final double lat = 60 + (11.552 / 60);
final double lon = 25 + (1.941 / 60);
final double alt = 28.0;
Position p = gga.getPosition();
assertNotNull(p);
assertEquals(lat, p.getLatitude(), 0.0000001);
assertEquals(CompassPoint.NORTH, p.getLatitudeHemisphere());
assertEquals(lon, p.getLongitude(), 0.0000001);
assertEquals(CompassPoint.EAST, p.getLongitudeHemisphere());
assertEquals(Datum.WGS84, p.getDatum());
assertEquals(alt, p.getAltitude(), 0.01);
}
@Test
public void testGetTime() {
Time t = gga.getTime();
assertNotNull(t);
assertEquals(12, t.getHour());
assertEquals(0, t.getMinutes());
assertEquals(44.567, t.getSeconds(), 0.001);
}
/**
*
*/
@Test
public void testGGAParser() {
GGAParser instance = new GGAParser(EXAMPLE);
SentenceId sid = SentenceId.valueOf(instance.getSentenceId());
assertEquals(SentenceId.GGA, sid);
}
@Test
public void testSetAltitude() {
final double alt = 11.11111;
gga.setAltitude(alt);
assertEquals(alt, gga.getAltitude(), 0.1);
}
@Test
public void testSetAltitudeUnits() {
assertEquals(Units.METER, gga.getAltitudeUnits());
gga.setAltitudeUnits(Units.FEET);
assertEquals(Units.FEET, gga.getAltitudeUnits());
}
@Test
public void testSetDgpsAge() {
final double age = 33.333333;
gga.setDgpsAge(age);
assertEquals(age, gga.getDgpsAge(), 0.1);
}
@Test
public void testSetDgpsStationId() {
gga.setDgpsStationId("0001");
assertEquals("0001", gga.getDgpsStationId());
}
@Test
public void testSetFixQuality() {
assertEquals(GpsFixQuality.NORMAL, gga.getFixQuality());
gga.setFixQuality(GpsFixQuality.INVALID);
assertEquals(GpsFixQuality.INVALID, gga.getFixQuality());
}
@Test
public void testSetGeoidalHeight() {
final double height = 3.987654;
gga.setGeoidalHeight(height);
assertEquals(height, gga.getGeoidalHeight(), 0.1);
}
@Test
public void testSetGeoidalHeightUnits() {
assertEquals(Units.METER, gga.getGeoidalHeightUnits());
gga.setGeoidalHeightUnits(Units.FEET);
assertEquals(Units.FEET, gga.getGeoidalHeightUnits());
}
@Test
public void testSetHorizontalDOP() {
final double hdop = 0.123456;
gga.setHorizontalDOP(hdop);
assertEquals(hdop, gga.getHorizontalDOP(), 0.1);
}
@Test
public void testSetPosition() {
final double lat = 61 + (1.111 / 60);
final double lon = 27 + (7.777 / 60);
final double alt = 11.1;
Position p = new Position(lat, lon);
p.setAltitude(alt);
gga.setPosition(p);
final String str = gga.toString();
assertTrue(str.contains(",6101.111,N,"));
assertTrue(str.contains(",02707.777,E,"));
Position wp = gga.getPosition();
assertNotNull(wp);
assertEquals(lat, wp.getLatitude(), 0.0000001);
assertEquals(lon, wp.getLongitude(), 0.0000001);
assertEquals(CompassPoint.NORTH, wp.getLatitudeHemisphere());
assertEquals(CompassPoint.EAST, wp.getLongitudeHemisphere());
assertEquals(alt, wp.getAltitude(), 0.01);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.GGAParser#getTime()}.
*/
@Test
public void testSetTime() {
Time t = new Time(1, 2, 3.456);
gga.setTime(t);
assertTrue(gga.toString().contains("GPGGA,010203.456,6011"));
}
@Test
public void testSetNumberOfSatellites() {
gga.setSatelliteCount(5);
assertEquals(5, gga.getSatelliteCount());
assertTrue(gga.toString().contains(",E,1,05,2.0,28.0,"));
}
@Test
public void testSetNumberOfSatellitesThrows() {
try {
gga.setSatelliteCount(-1);
fail("setSatelliteCount() did not throw exception");
} catch(IllegalArgumentException e) {
assertEquals(0, gga.getSatelliteCount());
assertEquals("Satelite count cannot be negative", e.getMessage());
}
}
}
@@ -0,0 +1,151 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.CompassPoint;
import net.sf.marineapi.nmea.util.DataStatus;
import net.sf.marineapi.nmea.util.Position;
import net.sf.marineapi.nmea.util.Time;
import org.junit.Before;
import org.junit.Test;
/**
* Tests the GLL sentence parser.
*
* @author Kimmo Tuukkanen
*/
public class GLLTest {
/**
* Example sentence
*/
public static final String EXAMPLE = "$GPGLL,6011.552,N,02501.941,E,120045,A*26";
private GLLParser empty;
private GLLParser instance;
/**
* setUp
*/
@Before
public void setUp() {
try {
empty = new GLLParser(TalkerId.GP);
instance = new GLLParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(6, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GLLParser#getDataStatus()}.
*/
@Test
public void testGetDataStatus() {
assertEquals(DataStatus.ACTIVE, instance.getStatus());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GLLParser#getPosition()}.
*/
@Test
public void testGetPosition() {
final double lat = 60 + (11.552 / 60);
final double lon = 25 + (1.941 / 60);
Position p = instance.getPosition();
assertNotNull(p);
assertEquals(lat, p.getLatitude(), 0.0000001);
assertEquals(lon, p.getLongitude(), 0.0000001);
assertEquals(CompassPoint.NORTH, p.getLatitudeHemisphere());
assertEquals(CompassPoint.EAST, p.getLongitudeHemisphere());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.GLLParser#getTime()}.
*/
@Test
public void testGetTime() {
Time t = instance.getTime();
assertNotNull(t);
assertEquals(12, t.getHour());
assertEquals(0, t.getMinutes());
assertEquals(45.0, t.getSeconds(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GLLParser#setDataStatus(DataStatus)}.
*/
@Test
public void testSetDataStatus() {
assertEquals(DataStatus.ACTIVE, instance.getStatus());
instance.setStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, instance.getStatus());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GLLParser#setPosition(Position)}.
*/
@Test
public void testSetPositionWithNonZeroValues() {
final double lat = 60 + (11.552 / 60);
final double lon = 25 + (1.941 / 60);
Position p2 = new Position(lat, lon);
instance.setPosition(p2);
final String s2 = instance.toString();
final Position p = instance.getPosition();
assertTrue(s2.contains(",6011.552,N,"));
assertTrue(s2.contains(",02501.941,E,"));
assertNotNull(p);
assertEquals(lat, p.getLatitude(), 0.0000001);
assertEquals(lon, p.getLongitude(), 0.0000001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GLLParser#setPosition(Position)}.
*/
@Test
public void testSetPositionWithZeroValues() {
Position p1 = new Position(0.0, 0.0);
instance.setPosition(p1);
String s1 = instance.toString();
Position p = instance.getPosition();
assertTrue(s1.contains(",0000.000,N,"));
assertTrue(s1.contains(",00000.000,E,"));
assertNotNull(p);
assertEquals(0.0, p.getLatitude(), 0.0000001);
assertEquals(0.0, p.getLongitude(), 0.0000001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GLLParser#setTime(Time)}.
*/
@Test
public void testSetTime() {
Time t = new Time(1, 2, 3.4);
instance.setTime(t);
assertTrue(instance.toString().contains(",E,010203.400,A*"));
}
}
@@ -0,0 +1,211 @@
/*
* GNSTest.java
* Copyright (C) 2016 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import net.sf.marineapi.nmea.sentence.GNSSentence;
import net.sf.marineapi.nmea.sentence.GNSSentence.Mode;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.CompassPoint;
import net.sf.marineapi.nmea.util.Position;
import net.sf.marineapi.nmea.util.Time;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* GNS parser tests
*
* @author Kimmo Tuukkanen
*/
public class GNSTest {
public static final String EXAMPLE = "$GNGNS,014035.00,4332.69262,S,17235.48549,E,RR,13,0.9,25.63,11.24,,*70";
GNSSentence gns;
GNSSentence empty;
@Before
public void setUp() throws Exception {
gns = new GNSParser(EXAMPLE);
assertEquals(TalkerId.GN, gns.getTalkerId());
assertEquals(SentenceId.GNS.name(), gns.getSentenceId());
assertEquals(12, gns.getFieldCount());
empty = new GNSParser(TalkerId.GP);
assertEquals(TalkerId.GP, empty.getTalkerId());
assertEquals(SentenceId.GNS.name(), empty.getSentenceId());
assertEquals(12, empty.getFieldCount());
}
@Test
public void getTime() throws Exception {
Time t = gns.getTime();
assertEquals(1, t.getHour());
assertEquals(40, t.getMinutes());
assertEquals(35.00, t.getSeconds(), 0.001);
}
@Test
public void setTime() throws Exception {
gns.setTime(new Time(10, 20, 30));
assertEquals(10, gns.getTime().getHour());
assertEquals(20, gns.getTime().getMinutes());
assertEquals(30.0, gns.getTime().getSeconds(), 0.1);
}
@Test
public void getPosition() throws Exception {
// 4332.69262,S,17235.48549,E
final double LAT = -(43 + 32.69262 / 60);
final double LON = 172 + 35.48549 / 60;
Position p = gns.getPosition();
assertEquals(LAT, p.getLatitude(), 0.00001);
assertEquals(CompassPoint.SOUTH, p.getLatitudeHemisphere());
assertEquals(LON, p.getLongitude(), 0.00001);
assertEquals(CompassPoint.EAST, p.getLongitudeHemisphere());
}
@Test
public void setPosition() throws Exception {
final double LAT = 61.23456;
final double LON = 21.23456;
empty.setPosition(new Position(LAT, LON));
Position p = empty.getPosition();
assertEquals(LAT, p.getLatitude(), 0.00001);
assertEquals(CompassPoint.NORTH, p.getLatitudeHemisphere());
assertEquals(LON, p.getLongitude(), 0.00001);
assertEquals(CompassPoint.EAST, p.getLongitudeHemisphere());
}
@Test
public void getGpsMode() throws Exception {
assertEquals(Mode.RTK, gns.getGpsMode());
assertEquals(Mode.NONE, empty.getGpsMode());
}
@Test
public void setGpsMode() throws Exception {
gns.setGpsMode(Mode.DGPS);
assertTrue(gns.toString().contains(",DR,"));
assertEquals(Mode.DGPS, gns.getGpsMode());
assertEquals(Mode.RTK, gns.getGlonassMode());
assertEquals(0, gns.getAdditionalModes().length);
}
@Test
public void getGlonassMode() throws Exception {
assertEquals(Mode.RTK, gns.getGlonassMode());
assertEquals(Mode.NONE, empty.getGlonassMode());
}
@Test
public void setGlonassMode() throws Exception {
gns.setGlonassMode(Mode.FRTK);
assertTrue(gns.toString().contains(",RF,"));
assertEquals(Mode.FRTK, gns.getGlonassMode());
assertEquals(Mode.RTK, gns.getGpsMode());
assertEquals(0, gns.getAdditionalModes().length);
}
@Test
public void setAdditionalModes() throws Exception {
gns.setAdditionalModes(Mode.AUTOMATIC, Mode.ESTIMATED);
assertTrue(gns.toString().contains(",RRAE,"));
assertEquals(Mode.RTK, gns.getGpsMode());
assertEquals(Mode.RTK, gns.getGlonassMode());
}
@Test
public void getAdditionalModes() throws Exception {
gns.setAdditionalModes(Mode.AUTOMATIC, Mode.ESTIMATED);
Mode[] additional = gns.getAdditionalModes();
assertEquals(2, additional.length);
assertEquals(Mode.AUTOMATIC, additional[0]);
assertEquals(Mode.ESTIMATED, additional[1]);
}
@Test
public void getSatelliteCount() throws Exception {
assertEquals(13, gns.getSatelliteCount());
}
@Test
public void setSatelliteCount() throws Exception {
gns.setSatelliteCount(8);
assertTrue(gns.toString().contains(",08,"));
assertEquals(8, gns.getSatelliteCount());
}
@Test
public void getHorizontalDOP() throws Exception {
assertEquals(0.9, gns.getHorizontalDOP(), 0.001);
}
@Test
public void setHorizontalDOP() throws Exception {
gns.setHorizontalDOP(0.123);
assertEquals(0.12, gns.getHorizontalDOP(), 0.001);
}
@Test
public void getOrthometricHeight() throws Exception {
assertEquals(25.63, gns.getOrthometricHeight(), 0.001);
}
@Test
public void setOrthometricHeight() throws Exception {
gns.setOrthometricHeight(12.342);
assertEquals(12.34, gns.getOrthometricHeight(), 0.0001);
}
@Test
public void getGeoidalSeparation() throws Exception {
assertEquals(11.24, gns.getGeoidalSeparation(), 0.001);
}
@Test
public void setGeoidalSeparation() throws Exception {
gns.setGeoidalSeparation(1.234);
assertEquals(1.23, gns.getGeoidalSeparation(), 0.001);
}
@Test
public void testDgpsAge() throws Exception {
empty.setDgpsAge(10);
assertTrue(empty.toString().contains(",10.0,*"));
assertEquals(10, empty.getDgpsAge(), 0.1);
}
@Test
public void testDgpsStationId() throws Exception {
gns.setDgpsStationId("1234");
assertTrue(gns.toString().contains(",1234*"));
assertEquals("1234", gns.getDgpsStationId());
}
}
@@ -0,0 +1,191 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.GSASentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.FaaMode;
import net.sf.marineapi.nmea.util.GpsFixStatus;
import org.junit.Before;
import org.junit.Test;
/**
* Tests the GSA sentence parser.
*
* @author Kimmo Tuukkanen
*/
public class GSATest {
/** Example sentence */
public static final String EXAMPLE = "$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D";
private GSASentence empty;
private GSASentence instance;
@Before
public void setUp() {
try {
empty = new GSAParser(TalkerId.GP);
instance = new GSAParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(17, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#getFixStatus()} .
*/
@Test
public void testGetFixStatus() {
assertEquals(GpsFixStatus.GPS_3D, instance.getFixStatus());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.GSAParser#getMode()}.
*/
@Test
public void testGetFaaMode() {
assertEquals(FaaMode.AUTOMATIC, instance.getMode());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#getHorizontalDOP()}.
*/
@Test
public void testGetHorizontalDOP() {
double hdop = instance.getHorizontalDOP();
assertEquals(1.6, hdop, 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#getPositionDOP()}.
*/
@Test
public void testGetPositionDOP() {
double pdop = instance.getPositionDOP();
assertEquals(1.6, pdop, 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#getSatelliteIds()}.
*/
@Test
public void testGetSatelliteIds() {
String[] satellites = instance.getSatelliteIds();
assertEquals(5, satellites.length);
assertEquals("02", satellites[0]);
assertEquals("07", satellites[1]);
assertEquals("09", satellites[2]);
assertEquals("24", satellites[3]);
assertEquals("26", satellites[4]);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#getVerticalDOP()}.
*/
@Test
public void testGetVerticalDOP() {
double vdop = instance.getVerticalDOP();
assertEquals(1.0, vdop, 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#setFixStatus(GpsFixStatus)}
* .
*/
@Test
public void testSetFixStatus() {
instance.setFixStatus(GpsFixStatus.GPS_NA);
assertTrue(instance.toString().contains(",A,1,"));
assertEquals(GpsFixStatus.GPS_NA, instance.getFixStatus());
instance.setFixStatus(GpsFixStatus.GPS_2D);
assertTrue(instance.toString().contains(",A,2,"));
assertEquals(GpsFixStatus.GPS_2D, instance.getFixStatus());
instance.setFixStatus(GpsFixStatus.GPS_3D);
assertTrue(instance.toString().contains(",A,3,"));
assertEquals(GpsFixStatus.GPS_3D, instance.getFixStatus());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#setMode(FaaMode)}.
*/
@Test
public void testSetFaaMode() {
instance.setMode(FaaMode.DGPS);
assertTrue(instance.toString().contains(",D,"));
assertEquals(FaaMode.DGPS, instance.getMode());
instance.setMode(FaaMode.SIMULATED);
assertTrue(instance.toString().contains(",S,"));
assertEquals(FaaMode.SIMULATED, instance.getMode());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#setHorizontalDOP(double)}.
*/
@Test
public void testSetHorizontalDOP() {
final double hdop = 1.98765;
instance.setHorizontalDOP(hdop);
assertEquals(hdop, instance.getHorizontalDOP(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#setPositionDOP(double)}.
*/
@Test
public void testSetPositionDOP() {
final double pdop = 1.56788;
instance.setPositionDOP(pdop);
assertEquals(pdop, instance.getPositionDOP(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#setSatellitesIds(String[])}
* .
*/
@Test
public void testSetSatelliteIds() {
String[] ids = { "02", "04", "06", "08", "10", "12" };
instance.setSatelliteIds(ids);
String[] satellites = instance.getSatelliteIds();
assertEquals(ids.length, satellites.length);
int i = 0;
for (String id : ids) {
assertEquals(id, satellites[i++]);
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSAParser#setVerticalDOP(double)}.
*/
@Test
public void testSetVerticalDOP() {
final double vdop = 1.56789;
instance.setVerticalDOP(vdop);
assertEquals(vdop, instance.getVerticalDOP(), 0.1);
}
}
@@ -0,0 +1,194 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import net.sf.marineapi.nmea.sentence.GSVSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.SatelliteInfo;
import org.junit.Before;
import org.junit.Test;
/**
* Test the GSV sentence parser.
*
* @author Kimmo Tuukkanen
*/
public class GSVTest {
/** Example sentence */
public static final String EXAMPLE = "$GPGSV,3,2,12,15,56,182,51,17,38,163,47,18,63,058,50,21,53,329,47*73";
private GSVSentence empty;
private GSVSentence gsv;
@Before
public void setUp() {
try {
empty = new GSVParser(TalkerId.GP);
gsv = new GSVParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(19, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#getSatelliteCount()}.
*/
@Test
public void testGetSatelliteCount() {
assertEquals(12, gsv.getSatelliteCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#getSatelliteInfo()}.
*/
@Test
public void testGetSatelliteInfo() {
List<SatelliteInfo> sat = gsv.getSatelliteInfo();
assertEquals(4, sat.size());
testSatelliteInfo(sat.get(0), "15", 56, 182, 51);
testSatelliteInfo(sat.get(1), "17", 38, 163, 47);
testSatelliteInfo(sat.get(2), "18", 63, 58, 50);
testSatelliteInfo(sat.get(3), "21", 53, 329, 47);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#getSatelliteInfo()}.
*/
@Test
public void testGetSatelliteInfoWithEmptyFields() {
GSVSentence g = new GSVParser("$GPGSV,3,2,12,15,56,182,51,17,38,163,47,18,,,,21,53,329,47");
List<SatelliteInfo> sat = g.getSatelliteInfo();
assertEquals(3, sat.size());
testSatelliteInfo(sat.get(0), "15", 56, 182, 51);
testSatelliteInfo(sat.get(1), "17", 38, 163, 47);
testSatelliteInfo(sat.get(2), "21", 53, 329, 47);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#getSatelliteInfo()}.
*/
@Test
public void testGetSatelliteInfoWithShortSentence() {
GSVSentence g = new GSVParser("$GPGSV,3,2,12,15,56,182,51,17,38,163,47");
List<SatelliteInfo> sat = g.getSatelliteInfo();
assertEquals(2, sat.size());
testSatelliteInfo(sat.get(0), "15", 56, 182, 51);
testSatelliteInfo(sat.get(1), "17", 38, 163, 47);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#getSentenceCount()}.
*/
@Test
public void testGetSentenceCount() {
assertEquals(3, gsv.getSentenceCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#getSentenceIndex()}.
*/
@Test
public void testGetSentenceIndex() {
assertEquals(2, gsv.getSentenceIndex());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.GSVParser#isFirst()}.
*/
@Test
public void testIsFirst() {
assertFalse(gsv.isFirst());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.GSVParser#isLast()} .
*/
@Test
public void testIsLast() {
assertFalse(gsv.isLast());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#setSatelliteCount(int)}.
*/
@Test
public void testSetSatelliteCount() {
gsv.setSatelliteCount(5);
assertEquals(5, gsv.getSatelliteCount());
gsv.setSatelliteCount(10);
assertEquals(10, gsv.getSatelliteCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#getSatelliteInfo()}.
*/
@Test
public void testSetSatelliteInfo() {
List<SatelliteInfo> si = new ArrayList<SatelliteInfo>();
si.add(new SatelliteInfo("01", 11, 12, 13));
si.add(new SatelliteInfo("02", 21, 22, 23));
si.add(new SatelliteInfo("03", 31, 32, 33));
gsv.setSatelliteInfo(si);
assertTrue(gsv.toString().contains(",03,31,032,33,,,,*"));
List<SatelliteInfo> sat = gsv.getSatelliteInfo();
assertEquals(3, sat.size());
testSatelliteInfo(sat.get(0), "01", 11, 12, 13);
testSatelliteInfo(sat.get(1), "02", 21, 22, 23);
testSatelliteInfo(sat.get(2), "03", 31, 32, 33);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.GSVParser#setSentenceCount(int)}.
*/
@Test
public void testSetSentenceCount() {
gsv.setSentenceCount(1);
assertEquals(1, gsv.getSentenceCount());
gsv.setSentenceCount(2);
assertEquals(2, gsv.getSentenceCount());
}
@Test
public void testParserGlonassGSV() {
GSVParser gl = new GSVParser("$GLGSV,2,1,07,70,28,145,44,71,67,081,46,72,34,359,40,77,16,245,35,1*76");
assertEquals(TalkerId.GL, gl.getTalkerId());
}
/**
* Tests the given SatelliteInfo against specified values.
*/
private void testSatelliteInfo(SatelliteInfo si, String id, int elevation,
int azimuth, int noise) {
assertEquals(id, si.getId());
assertEquals(elevation, si.getElevation(), 0.1);
assertEquals(azimuth, si.getAzimuth(), 0.1);
assertEquals(noise, si.getNoise(), 0.1);
}
}
@@ -0,0 +1,289 @@
/*
* HDGTest.java
* Copyright (C) 2011 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.HDGSentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
/**
* @author Kimmo Tuukkanen
*/
public class HDGTest {
public static final String EXAMPLE = "$HCHDG,123.4,1.2,E,1.2,W";
HDGSentence hdg;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
hdg = new HDGParser(EXAMPLE);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.HDGParser(TalkerId)}.
*/
@Test
public void testConstructor() {
HDGSentence empty = new HDGParser(TalkerId.HC);
assertEquals(TalkerId.HC, empty.getTalkerId());
assertEquals(SentenceId.HDG.toString(), empty.getSentenceId());
try {
empty.getHeading();
} catch (DataNotAvailableException e) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.HDTParser#isTrue()}.
*/
@Test
public void testIsTrue() {
assertFalse(hdg.isTrue());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#HDGParser(java.lang.String)}
* .
*/
@Test
public void testHDGParserString() {
assertTrue(hdg.isValid());
assertEquals(TalkerId.HC, hdg.getTalkerId());
assertEquals("HDG", hdg.getSentenceId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#HDGParser(net.sf.marineapi.nmea.sentence.TalkerId)}
* .
*/
@Test
public void testHDGParserTalkerId() {
HDGParser hdgp = new HDGParser(TalkerId.HC);
assertTrue(hdgp.isValid());
assertEquals(TalkerId.HC, hdgp.getTalkerId());
assertEquals("HDG", hdgp.getSentenceId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#getDeviation()}.
*/
@Test
public void testGetDeviation() {
assertEquals(1.2, hdg.getDeviation(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#getHeading()}.
*/
@Test
public void testGetHeading() {
assertEquals(123.4, hdg.getHeading(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#getVariation()}.
*/
@Test
public void testGetVariation() {
// 1.2 degrees west -> -1.2
assertEquals(-1.2, hdg.getVariation(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setDeviation(double)}.
*/
@Test
public void testSetDeviationWest() {
final double dev = -5.5;
hdg.setDeviation(dev);
assertEquals(dev, hdg.getDeviation(), 0.1);
assertTrue(hdg.toString().contains(",005.5,W,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setDeviation(double)}.
*/
@Test
public void testSetDeviationEast() {
final double dev = 5.5;
hdg.setDeviation(dev);
assertEquals(dev, hdg.getDeviation(), 0.1);
assertTrue(hdg.toString().contains(",005.5,E,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setDeviation(double)}.
*/
@Test
public void testSetDeviationTooHigh() {
final double value = 180.000001;
try {
hdg.setDeviation(value);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setDeviation(double)}.
*/
@Test
public void testSetDeviationTooLow() {
final double value = -180.000001;
try {
hdg.setHeading(value);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setHeading(double)}.
*/
@Test
public void testSetHeading() {
final double value = 359.9;
hdg.setHeading(value);
assertEquals(value, hdg.getHeading(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setHeading(double)}.
*/
@Test
public void testSetHeadingTooHigh() {
final double value = 360.000001;
try {
hdg.setHeading(value);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setHeading(double)}.
*/
@Test
public void testSetHeadingTooLow() {
final double value = -0.000001;
try {
hdg.setHeading(value);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setVariation(double)}.
*/
@Test
public void testSetVariationEast() {
final double var = 179.9;
hdg.setVariation(var);
assertEquals(var, hdg.getVariation(), 0.1);
assertTrue(hdg.toString().contains(",179.9,E*"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setVariation(double)}.
*/
@Test
public void testSetVariationWest() {
final double var = -0.1;
hdg.setVariation(var);
assertEquals(var, hdg.getVariation(), 0.1);
assertTrue(hdg.toString().contains(",000.1,W*"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setVariation(double)}.
*/
@Test
public void testSetVariationTooHigh() {
final double var = 180.00001;
try {
hdg.setVariation(var);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDGParser#setVariation(double)}.
*/
@Test
public void testSetVariationTooLow() {
final double var = -180.00001;
try {
hdg.setVariation(var);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
}
@@ -0,0 +1,128 @@
/*
* HDMTest.java
* Copyright (C) 2011 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.HDMSentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
/**
* HDM parser tests.
*
* @author Kimmo Tuukkanen
*/
public class HDMTest {
public static final String EXAMPLE = "$GPHDM,90.0,M";
HDMSentence hdm;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
hdm = new HDMParser(EXAMPLE);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.HDMParser(TalkerId)}.
*/
@Test
public void testConstructor() {
HDMSentence empty = new HDMParser(TalkerId.HC);
assertEquals(TalkerId.HC, empty.getTalkerId());
assertEquals(SentenceId.HDM.toString(), empty.getSentenceId());
try {
empty.getHeading();
} catch (DataNotAvailableException e) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.HDTParser#isTrue()}.
*/
@Test
public void testIsTrue() {
assertFalse(hdm.isTrue());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDMParser#getHeading()}.
*/
@Test
public void testGetHeading() {
double value = hdm.getHeading();
assertEquals(90.0, value, 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDMParser#setHeading(double)}.
*/
@Test
public void testSetHeading() {
hdm.setHeading(123.45);
assertEquals(123.5, hdm.getHeading(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDMParser#setHeading(double)}.
*/
@Test
public void testSetNegativeHeading() {
try {
hdm.setHeading(-0.005);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDMParser#setHeading(double)}.
*/
@Test
public void testSetHeadingTooHigh() {
try {
hdm.setHeading(360.0001);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
}
@@ -0,0 +1,126 @@
/*
* HDTTest.java
* Copyright (C) 2011 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.HDTSentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
/**
* @author Kimmo Tuukkanen
*/
public class HDTTest {
public static final String EXAMPLE = "$HCHDT,90.1,T";
HDTSentence hdt;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
hdt = new HDTParser(EXAMPLE);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.HDTParser(TalkerId)}.
*/
@Test
public void testConstructor() {
HDTSentence empty = new HDTParser(TalkerId.HE);
assertEquals(TalkerId.HE, empty.getTalkerId());
assertEquals(SentenceId.HDT.toString(), empty.getSentenceId());
try {
empty.getHeading();
} catch (DataNotAvailableException e) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.HDTParser#isTrue()}.
*/
@Test
public void testIsTrue() {
assertTrue(hdt.isTrue());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDTParser#getHeading()}.
*/
@Test
public void testGetHeading() {
double value = hdt.getHeading();
assertEquals(90.0, value, 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDTParser#setHeading(double)}.
*/
@Test
public void testSetHeading() {
hdt.setHeading(123.45);
assertEquals(123.5, hdt.getHeading(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDTParser#setHeading(double)}.
*/
@Test
public void testSetNegativeHeading() {
try {
hdt.setHeading(-0.005);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.HDTParser#setHeading(double)}.
*/
@Test
public void testSetHeadingTooHigh() {
try {
hdt.setHeading(360.0001);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
}
@@ -0,0 +1,180 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.MDASentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
/**
* @author Richard van Nieuwenhoven
*/
public class MDATest {
public static final String EXAMPLE = "$IIMDA,99700.0,P,1.00,B,3.2,C,,C,,,,C,295.19,T,,M,5.70,N,2.93,M*08";
public static final String EXAMPLE2 = "$IIMDA,30.0,I,1.0149,B,26.8,C,,C,64.2,16.4,19.5,C,,T,38.7,M,10.88,N,5.60,M*36";
private MDASentence mda;
private MDASentence mda2;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
mda = new MDAParser(EXAMPLE);
mda2 = new MDAParser(EXAMPLE2);
}
@Test
public void testMDAParserTalkerId() {
MDAParser mwdp = new MDAParser(TalkerId.II);
assertEquals(TalkerId.II, mwdp.getTalkerId());
assertEquals(SentenceId.MDA.toString(), mwdp.getSentenceId());
}
@Test
public void testGetMagneticWindDirection() {
assertTrue(Double.isNaN(mda.getMagneticWindDirection()));
assertEquals(38.7, mda2.getMagneticWindDirection(), 0.1);
}
@Test
public void testGetTrueWindDirection() {
assertEquals(295.19, mda.getTrueWindDirection(), 0.1);
assertTrue(Double.isNaN(mda2.getTrueWindDirection()));
}
@Test
public void testGetWindSpeed() {
assertEquals(2.93, mda.getWindSpeed(), 0.1);
assertEquals(5.6, mda2.getWindSpeed(), 0.1);
}
@Test
public void testGetWindSpeedKnots() {
assertEquals(5.7, mda.getWindSpeedKnots(), 0.1);
assertEquals(10.88, mda2.getWindSpeedKnots(), 0.1);
}
@Test
public void testGetAbsoluteHumidity() {
assertTrue(Double.isNaN(mda.getAbsoluteHumidity()));
assertEquals(16.4, mda2.getAbsoluteHumidity(), 0.1);
}
@Test
public void testGetAirTemperature() {
assertEquals(3.2, mda.getAirTemperature(), 0.1);
assertEquals(26.8, mda2.getAirTemperature(), 0.1);
}
@Test
public void testGetSecondaryBarometricPressure() {
assertEquals(1.0, mda.getSecondaryBarometricPressure(), 0.1);
assertEquals('B', mda.getSecondaryBarometricPressureUnit());
assertEquals(1.0, mda2.getSecondaryBarometricPressure(), 0.1);
assertEquals('B', mda2.getSecondaryBarometricPressureUnit());
}
@Test
public void testGetPrimaryBarometricPressure() {
assertEquals(99700.0, mda.getPrimaryBarometricPressure(), 0.1);
assertEquals('P', mda.getPrimaryBarometricPressureUnit());
assertEquals(30.0, mda2.getPrimaryBarometricPressure(), 0.1);
assertEquals('I', mda2.getPrimaryBarometricPressureUnit());
}
@Test
public void testGetRelativeHumidity() {
assertTrue(Double.isNaN(mda.getRelativeHumidity()));
assertEquals(64.2, mda2.getRelativeHumidity(), 0.1);
}
@Test
public void testGetDewPoint() {
assertTrue(Double.isNaN(mda.getDewPoint()));
assertEquals(19.5, mda2.getDewPoint(), 0.1);
}
@Test
public void testGetWaterTemperature() {
assertTrue(Double.isNaN(mda.getWaterTemperature()));
assertTrue(Double.isNaN(mda2.getWaterTemperature()));
}
@Test
public void testSetMagneticWindDirection() {
mda.setMagneticWindDirection(123.4);
assertEquals(123.4, mda.getMagneticWindDirection(), 0.1);
}
@Test
public void testSetTrueWindDirection() {
mda.setTrueWindDirection(234.5);
assertEquals(234.5, mda.getTrueWindDirection(), 0.1);
}
@Test
public void testSetWindSpeed() {
mda.setWindSpeed(12.3);
assertEquals(12.3, mda.getWindSpeed(), 0.1);
}
@Test
public void testSetWindSpeedKnots() {
mda.setWindSpeedKnots(6.78);
assertEquals(6.78, mda.getWindSpeedKnots(), 0.01);
}
@Test
public void testSetAbsoluteHumidity() {
mda.setAbsoluteHumidity(34.5);
assertEquals(34.5, mda.getAbsoluteHumidity(), 0.1);
}
@Test
public void testSetAirTemperature() {
mda.setAirTemperature(18.9);
assertEquals(18.9, mda.getAirTemperature(), 0.1);
}
@Test
public void testSetSecondaryBarometricPressure() {
mda.setSecondaryBarometricPressure(0.99);
mda.setSecondaryBarometricPressureUnit('B');
assertEquals(0.99, mda.getSecondaryBarometricPressure(), 0.01);
assertEquals('B', mda.getSecondaryBarometricPressureUnit());
}
@Test
public void testSetPrimaryBarometricPressure() {
mda.setPrimaryBarometricPressure(29.53);
mda.setPrimaryBarometricPressureUnit('I');
assertEquals(29.53, mda.getPrimaryBarometricPressure(), 0.01);
assertEquals('I', mda.getPrimaryBarometricPressureUnit());
}
@Test
public void testSetRelativeHumidity() {
mda.setRelativeHumidity(55.5);
assertEquals(55.5, mda.getRelativeHumidity(), 0.1);
}
@Test
public void testSetDewPoint() {
mda.setDewPoint(6.7);
assertEquals(6.7, mda.getDewPoint(), 0.1);
}
@Test
public void testSetWaterTemperature() {
mda.setWaterTemperature(8.9);
assertEquals(8.9, mda.getWaterTemperature(), 0.1);
}
}
@@ -0,0 +1,101 @@
/*
* MHUTest.java
* Copyright (C) 2016 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import net.sf.marineapi.nmea.sentence.MHUSentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
/**
* MHU parser tests.
*
* @author Kimmo Tuukkanen
*/
public class MHUTest {
public static final String EXAMPLE = "$IIMHU,66.0,5.0,3.0,C";
private MHUSentence mhu;
private MHUSentence empty;
@Before
public void setUp() {
mhu = new MHUParser(EXAMPLE);
empty = new MHUParser(TalkerId.II);
assertEquals(4, mhu.getFieldCount());
}
@Test
public void testEmptySentenceConstructor() {
assertEquals(TalkerId.II, empty.getTalkerId());
assertEquals(SentenceId.MHU.toString(), empty.getSentenceId());
assertEquals(4, empty.getFieldCount());
assertEquals('C', empty.getDewPointUnit());
}
@Test
public void testGetRelativeHumidity() throws Exception {
assertEquals(66.0, mhu.getRelativeHumidity(), 0.1);
}
@Test
public void testGetAbsoluteHumidity() throws Exception {
assertEquals(5.0, mhu.getAbsoluteHumidity(), 0.1);
}
@Test
public void testGetDewPoint() throws Exception {
assertEquals(3.0, mhu.getDewPoint(), 0.1);
}
@Test
public void testGetDewPointUnit() throws Exception {
assertEquals('C', mhu.getDewPointUnit());
}
@Test
public void testSetRelativeHumidity() throws Exception {
mhu.setRelativeHumidity(55.55555);
assertEquals(55.6, mhu.getRelativeHumidity(), 0.1);
}
@Test
public void testSetAbsoluteHumidity() throws Exception {
mhu.setAbsoluteHumidity(6.1234);
assertEquals(6.1, mhu.getAbsoluteHumidity(), 0.1);
}
@Test
public void testSetDewPoint() throws Exception {
mhu.setDewPoint(1.2356);
assertEquals(1.2, mhu.getDewPoint(), 0.1);
}
@Test
public void testSetDewPointUnit() throws Exception {
mhu.setDewPointUnit('F');
assertEquals('F', mhu.getDewPointUnit());
}
}
@@ -0,0 +1,59 @@
package net.sf.marineapi.nmea.parser;
import net.sf.marineapi.nmea.sentence.MMBSentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* MMBTest
*
* @author Kimmo Tuukkanen
*/
public class MMBTest {
public static final String EXAMPLE = "$IIMMB,29.9870,I,1.0154,B*75";
MMBSentence mmb;
MMBSentence empty;
@Before
public void setUp() throws Exception {
mmb = new MMBParser(EXAMPLE);
empty = new MMBParser(TalkerId.WI);
}
@Test
public void testConstructors() {
assertEquals(4, mmb.getFieldCount());
assertEquals(4, empty.getFieldCount());
assertEquals(TalkerId.II, mmb.getTalkerId());
assertEquals(TalkerId.WI, empty.getTalkerId());
assertEquals(SentenceId.MMB.name(), empty.getSentenceId());
}
@Test
public void testGetInchesOfMercury() throws Exception {
assertEquals(29.9870, mmb.getInchesOfMercury(), 0.0001);
}
@Test
public void testGetBars() throws Exception {
assertEquals(1.0154, mmb.getBars(), 0.0001);
}
@Test
public void testSetInchesOfMercury() throws Exception {
mmb.setInchesOfMercury(29.9999);
assertEquals(29.9999, mmb.getInchesOfMercury(), 0.0001);
}
@Test
public void testSetBars() throws Exception {
mmb.setBars(1.1234);
assertEquals(1.1234, mmb.getBars(), 0.0001);
}
}
@@ -0,0 +1,48 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.MTASentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
public class MTATest {
public static final String EXAMPLE = "$IIMTA,21.5,C";
private MTASentence mta;
@Before
public void setUp() throws Exception {
mta = new MTAParser(EXAMPLE);
}
@Test
public void testMTAParserString() {
assertEquals(TalkerId.II, mta.getTalkerId());
assertEquals(SentenceId.MTA.name(), mta.getSentenceId());
}
@Test
public void testMTAParserTalkerId() {
MTAParser empty = new MTAParser(TalkerId.WI);
assertEquals(TalkerId.WI, empty.getTalkerId());
assertEquals(SentenceId.MTA.name(), empty.getSentenceId());
assertTrue(empty.getCharValue(1) == 'C');
}
@Test
public void testGetTemperature() {
assertEquals(21.5, mta.getTemperature(), 0.01);
}
@Test
public void testSetTemperature() {
mta.setTemperature(15.3335);
assertEquals(15.33, mta.getTemperature(), 0.01);
}
}
@@ -0,0 +1,73 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import net.sf.marineapi.nmea.sentence.MTWSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
/**
* MTW parser tests.
*
* @author Kimmo Tuukkanen
*/
public class MTWTest {
public static final String EXAMPLE = "$IIMTW,17.75,C";
private MTWSentence mtw;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
mtw = new MTWParser(EXAMPLE);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MTWParser#MTWParser(java.lang.String)}
* .
*/
@Test
public void testMTWParserString() {
assertEquals("MTW", mtw.getSentenceId());
assertEquals(TalkerId.II, mtw.getTalkerId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MTWParser#MTWParser(net.sf.marineapi.nmea.sentence.TalkerId)}
* .
*/
@Test
public void testMTWParserTalkerId() {
MTWParser empty = new MTWParser(TalkerId.II);
assertEquals("MTW", empty.getSentenceId());
assertEquals(TalkerId.II, empty.getTalkerId());
assertEquals(2, empty.getFieldCount());
assertEquals('C', empty.getCharValue(1));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MTWParser#getTemperature()}.
*/
@Test
public void testGetTemperature() {
assertEquals(17.75, mtw.getTemperature(), 0.01);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MTWParser#setTemperature(double)}.
*/
@Test
public void testSetTemperature() {
mtw.setTemperature(12.345);
assertEquals(12.345, mtw.getTemperature(), 0.01);
}
}
@@ -0,0 +1,79 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.MWDSentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
/**
* @author Richard van Nieuwenhoven
*/
public class MWDTest {
public static final String EXAMPLE = "$IIMWD,295.19,T,,M,5.09,N,2.62,M*56";
private MWDSentence mwd;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
mwd = new MWDParser(EXAMPLE);
}
@Test
public void testMWDParserTalkerId() {
MWDParser mwdp = new MWDParser(TalkerId.II);
assertEquals(TalkerId.II, mwdp.getTalkerId());
assertEquals(SentenceId.MWD.toString(), mwdp.getSentenceId());
}
@Test
public void testGetMagneticWindDirection() {
assertTrue(Double.isNaN(mwd.getMagneticWindDirection()));
}
@Test
public void testGetTrueWindDirection() {
assertEquals(295.19, mwd.getTrueWindDirection(), 0.1);
}
@Test
public void testGetWindSpeed() {
assertEquals(2.62, mwd.getWindSpeed(), 0.1);
}
@Test
public void testGetWindSpeedKnots() {
assertEquals(5.09, mwd.getWindSpeedKnots(), 0.1);
}
@Test
public void testSetMagneticWindDirection() {
mwd.setMagneticWindDirection(123.4);
assertEquals(123.4, mwd.getMagneticWindDirection(), 0.1);
}
@Test
public void testSetTrueWindDirection() {
mwd.setTrueWindDirection(234.5);
assertEquals(234.5, mwd.getTrueWindDirection(), 0.1);
}
@Test
public void testSetWindSpeed() {
mwd.setWindSpeed(12.3);
assertEquals(12.3, mwd.getWindSpeed(), 0.1);
}
@Test
public void testSetWindSpeedKnots() {
mwd.setWindSpeedKnots(6.2);
assertEquals(6.2, mwd.getWindSpeedKnots(), 0.1);
}
}
@@ -0,0 +1,233 @@
/*
* MWVTest.java
* Copyright (C) 2011 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.MWVSentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.DataStatus;
import net.sf.marineapi.nmea.util.Units;
import org.junit.Before;
import org.junit.Test;
/**
* @author Kimmo Tuukkanen
*/
public class MWVTest {
public static final String EXAMPLE = "$IIMWV,125.1,T,5.5,M,A";
private MWVSentence mwv;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
mwv = new MWVParser(EXAMPLE);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#MWVParser(net.sf.marineapi.nmea.sentence.TalkerId)}
* .
*/
@Test
public void testMWVParserTalkerId() {
MWVParser mwvp = new MWVParser(TalkerId.II);
assertEquals(TalkerId.II, mwvp.getTalkerId());
assertEquals(SentenceId.MWV.toString(), mwvp.getSentenceId());
assertEquals(DataStatus.VOID, mwvp.getStatus());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.MWVParser#getAngle()}
* .
*/
@Test
public void testGetAngle() {
assertEquals(125.1, mwv.getAngle(), 0.1); // "$IIMWV,125.1,T,5.5,A"
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.MWVParser#getSpeed()}
* .
*/
@Test
public void testGetSpeed() {
assertEquals(5.5, mwv.getSpeed(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#getSpeedUnit()}.
*/
@Test
public void testGetSpeedUnit() {
assertEquals(Units.METER, mwv.getSpeedUnit());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#getStatus()}.
*/
@Test
public void testGetStatus() {
assertEquals(DataStatus.ACTIVE, mwv.getStatus());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.MWVParser#isTrue()}.
*/
@Test
public void testIsTrue() {
assertTrue(mwv.isTrue());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#setAngle(double)}.
*/
@Test
public void testSetAngle() {
final double angle = 88.123;
mwv.setAngle(angle);
assertEquals(angle, mwv.getAngle(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#setAngle(double)}.
*/
@Test
public void testSetNegativeAngle() {
final double angle = -0.1;
try {
mwv.setAngle(angle);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#setAngle(double)}.
*/
@Test
public void testSetAngleOutOfRange() {
final double angle = 360.1;
try {
mwv.setAngle(angle);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#setSpeed(double)}.
*/
@Test
public void testSetSpeed() {
final double speed = 7.75;
mwv.setSpeed(speed);
assertEquals(speed, mwv.getSpeed(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#setSpeed(double)}.
*/
@Test
public void testSetNegativeSpeed() {
final double speed = -0.01;
try {
mwv.setSpeed(speed);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#setSpeedUnit(net.sf.marineapi.nmea.util.Units)}
* .
*/
@Test
public void testSetSpeedUnit() {
mwv.setSpeedUnit(Units.KMH);
assertEquals(Units.KMH, mwv.getSpeedUnit());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#setSpeedUnit(net.sf.marineapi.nmea.util.Units)}
* .
*/
@Test
public void testSetInvalidSpeedUnit() {
try {
mwv.setSpeedUnit(Units.FATHOMS);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#setStatus(net.sf.marineapi.nmea.util.DataStatus)}
* .
*/
@Test
public void testSetStatus() {
mwv.setStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, mwv.getStatus());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.MWVParser#setTrue(boolean)}.
*/
@Test
public void testSetTrue() {
assertTrue(mwv.isTrue());
mwv.setTrue(false);
assertFalse(mwv.isTrue());
}
}
@@ -0,0 +1,188 @@
/*
* PositionParserTest.java
* Copyright (C) 2010 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.util.CompassPoint;
import net.sf.marineapi.nmea.util.Position;
import org.junit.Before;
import org.junit.Test;
/**
* Unit tests for PositionParser class.
*
* @author Kimmo Tuukkanen
*/
public class PositionParserTest {
private PositionParser instance;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
instance = new PositionParser(GLLTest.EXAMPLE, SentenceId.GLL) {
};
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#parseHemisphereLat(int)}
* .
*/
@Test
public void testParseHemisphereLat() {
assertEquals(CompassPoint.NORTH, instance.parseHemisphereLat(1));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#parseHemisphereLon(int)}
* .
*/
@Test
public void testParseHemisphereLon() {
assertEquals(CompassPoint.EAST, instance.parseHemisphereLon(3));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#parseLatitude(int)}.
*/
@Test
public void testParseLatitude() {
// 6011.552
final double lat = 60 + (11.552 / 60);
assertEquals(lat, instance.parseLatitude(0), 0.000001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#parseLongitude(int)}.
*/
@Test
public void testParseLongitude() {
// 02501.941
final double lat = 25 + (01.941 / 60);
assertEquals(lat, instance.parseLongitude(2), 0.000001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#setLatHemisphere(int, net.sf.marineapi.nmea.util.CompassPoint)}
* .
*/
@Test
public void testSetLatHemisphere() {
instance.setLatHemisphere(1, CompassPoint.SOUTH);
assertTrue(instance.toString().contains(",S,"));
assertEquals(CompassPoint.SOUTH, instance.parseHemisphereLat(1));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#setLatitude(int, double)}
* .
*/
@Test
public void testSetLatitude() {
// 2501.941
final double lat = 25 + (01.941 / 60);
instance.setLatitude(0, lat);
assertTrue(instance.toString().contains(",02501.941"));
assertEquals(lat, instance.parseLatitude(0), 0.000001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#setLongitude(int, double)}
* .
*/
@Test
public void testSetLongitude() {
// 02801.941
final double lon = 28 + (01.941 / 60);
instance.setLongitude(2, lon);
assertTrue(instance.toString().contains(",02801.941"));
assertEquals(lon, instance.parseLongitude(2), 0.000001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#setLonHemisphere(int, net.sf.marineapi.nmea.util.CompassPoint)}
* .
*/
@Test
public void testSetLonHemisphere() {
instance.setLonHemisphere(3, CompassPoint.WEST);
assertTrue(instance.toString().contains(",W,"));
assertEquals(CompassPoint.WEST, instance.parseHemisphereLon(3));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#setPositionValues(Position, int, int, int, int)
*/
@Test
public void testSetPositionValuesNE() {
final double lat = 60 + (11.552 / 60);
final double lon = 25 + (1.941 / 60);
Position p2 = new Position(lat, lon);
instance.setPositionValues(p2, 0, 1, 2, 3);
final String s2 = instance.toString();
final Position p = instance.parsePosition(0, 1, 2, 3);
assertTrue(s2.contains(",6011.552,N,"));
assertTrue(s2.contains(",02501.941,E,"));
assertNotNull(p);
assertEquals(lat, p.getLatitude(), 0.0000001);
assertEquals(lon, p.getLongitude(), 0.0000001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.PositionParser#setPositionValues(Position, int, int, int, int)
*/
@Test
public void testSetPositionValuesSW() {
final double lat = -60 - (11.552 / 60);
final double lon = -25 - (1.941 / 60);
Position p2 = new Position(lat, lon);
instance.setPositionValues(p2, 0, 1, 2, 3);
final String s2 = instance.toString();
final Position p = instance.parsePosition(0, 1, 2, 3);
assertTrue(s2.contains(",6011.552,S,"));
assertTrue(s2.contains(",02501.941,W,"));
assertNotNull(p);
assertEquals(lat, p.getLatitude(), 0.0000001);
assertEquals(lon, p.getLongitude(), 0.0000001);
}
}
@@ -0,0 +1,326 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.RMBSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.CompassPoint;
import net.sf.marineapi.nmea.util.DataStatus;
import net.sf.marineapi.nmea.util.Direction;
import net.sf.marineapi.nmea.util.Waypoint;
import org.junit.Before;
import org.junit.Test;
/**
* Tests the RMB sentence parser.
*
* @author Kimmo Tuukkanen
*/
public class RMBTest {
/** Example sentence */
public static final String EXAMPLE = "$GPRMB,A,0.00,R,,RUSKI,5536.200,N,01436.500,E,432.3,234.9,,V*58";
private RMBSentence empty;
private RMBSentence rmb;
/**
* setUp
*/
@Before
public void setUp() {
try {
empty = new RMBParser(TalkerId.GP);
rmb = new RMBParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(13, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#getArrivalStatus()}.
*/
@Test
public void testArrivalStatus() {
assertEquals(DataStatus.VOID, rmb.getArrivalStatus());
assertFalse(rmb.hasArrived());
rmb.setArrivalStatus(DataStatus.ACTIVE);
assertEquals(DataStatus.ACTIVE, rmb.getArrivalStatus());
assertTrue(rmb.hasArrived());
rmb.setArrivalStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, rmb.getArrivalStatus());
assertFalse(rmb.hasArrived());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#getBearing()} .
*/
@Test
public void testGetBearing() {
assertEquals(234.9, rmb.getBearing(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#getCrossTrackError()}.
*/
@Test
public void testGetCrossTrackError() {
assertEquals(0.0, rmb.getCrossTrackError(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#getDestination()} .
*/
@Test
public void testGetDestination() {
final String id = "RUSKI";
final double lat = 55 + (36.200 / 60);
final double lon = 14 + (36.500 / 60);
Waypoint wp = rmb.getDestination();
assertNotNull(wp);
assertEquals(id, wp.getId());
assertEquals(lat, wp.getLatitude(), 0.0000001);
assertEquals(lon, wp.getLongitude(), 0.0000001);
assertEquals(CompassPoint.NORTH, wp.getLatitudeHemisphere());
assertEquals(CompassPoint.EAST, wp.getLongitudeHemisphere());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#getOriginId()}.
*/
@Test
public void testGetOriginId() {
// FIXME test data should contain ID
try {
assertEquals("", rmb.getOriginId());
fail("Did not throw ParseException");
} catch (Exception e) {
assertTrue(e instanceof DataNotAvailableException);
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RMBParser#getRange()}
* .
*/
@Test
public void testGetRange() {
assertEquals(432.3, rmb.getRange(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#getStatus()}.
*/
@Test
public void testGetStatus() {
assertEquals(DataStatus.ACTIVE, rmb.getStatus());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#getSteerTo()}.
*/
@Test
public void testGetSteerTo() {
assertEquals(Direction.RIGHT, rmb.getSteerTo());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#getVelocity()}.
*/
@Test
public void testGetVelocity() {
// FIXME test data should contain velocity
try {
assertEquals(0.0, rmb.getVelocity(), 0.001);
fail("Did not throw ParseException");
} catch (Exception e) {
assertTrue(e instanceof DataNotAvailableException);
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setBearing(double)} .
*/
@Test
public void testSetBearing() {
final double brg = 90.56789;
rmb.setBearing(brg);
assertTrue(rmb.toString().contains(",090.6,"));
assertEquals(brg, rmb.getBearing(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setBearing(double)} .
*/
@Test
public void testSetBearingWithNegativeValue() {
try {
rmb.setBearing(-0.001);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("0..360"));
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setBearing(double)} .
*/
@Test
public void testSetBearingWithValueGreaterThanAllowed() {
try {
rmb.setBearing(360.001);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("0..360"));
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setCrossTrackError(double)}
* .
*/
@Test
public void testSetCrossTrackError() {
final double xte = 2.56789;
rmb.setCrossTrackError(xte);
assertTrue(rmb.toString().contains(",2.57,"));
assertEquals(xte, rmb.getCrossTrackError(), 0.2);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setDestination(Waypoint)} .
*/
@Test
public void testSetDestination() {
final String id = "MYDEST";
final double lat = 61 + (1.111 / 60);
final double lon = 27 + (7.777 / 60);
Waypoint d = new Waypoint(id, lat, lon);
rmb.setDestination(d);
String str = rmb.toString();
Waypoint wp = rmb.getDestination();
assertTrue(str.contains(",MYDEST,6101.111,N,02707.777,E,"));
assertNotNull(wp);
assertEquals(id, wp.getId());
assertEquals(lat, wp.getLatitude(), 0.0000001);
assertEquals(lon, wp.getLongitude(), 0.0000001);
assertEquals(CompassPoint.NORTH, wp.getLatitudeHemisphere());
assertEquals(CompassPoint.EAST, wp.getLongitudeHemisphere());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setOriginId(String)}.
*/
@Test
public void testSetOriginId() {
rmb.setOriginId("ORIGIN");
assertTrue(rmb.toString().contains(",ORIGIN,RUSKI,"));
assertEquals("ORIGIN", rmb.getOriginId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setRange(double)} .
*/
@Test
public void testSetRange() {
final double range = 12.3456;
rmb.setRange(range);
assertTrue(rmb.toString().contains(",12.3,"));
assertEquals(range, rmb.getRange(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setStatus(DataStatus)}.
*/
@Test
public void testSetStatus() {
rmb.setStatus(DataStatus.ACTIVE);
assertEquals(DataStatus.ACTIVE, rmb.getStatus());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setSteerTo(CompassPoint)}.
*/
@Test
public void testSetSteerTo() {
rmb.setSteerTo(Direction.LEFT);
assertTrue(rmb.toString().contains(",L,"));
assertEquals(Direction.LEFT, rmb.getSteerTo());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setSteerTo(CompassPoint)}.
*/
@Test
public void testSetSteerToWithNull() {
try {
rmb.setSteerTo(null);
fail("Did not throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("LEFT or RIGHT"));
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setVelocity()}.
*/
@Test
public void testSetVelocity() {
final double v = 40.66666;
rmb.setVelocity(v);
assertTrue(rmb.toString().contains(",40.7,"));
assertEquals(v, rmb.getVelocity(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMBParser#setVelocity()}.
*/
@Test
public void testSetVelocityWithNegativeValue() {
final double v = -0.123;
rmb.setVelocity(v);
assertTrue(rmb.toString().contains(",-0.1,"));
assertEquals(v, rmb.getVelocity(), 0.1);
}
}
@@ -0,0 +1,322 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.CompassPoint;
import net.sf.marineapi.nmea.util.DataStatus;
import net.sf.marineapi.nmea.util.Date;
import net.sf.marineapi.nmea.util.FaaMode;
import net.sf.marineapi.nmea.util.Position;
import net.sf.marineapi.nmea.util.Time;
import org.junit.Before;
import org.junit.Test;
/**
* Tests the RMC sentence parser.
*
* @author Kimmo Tuukkanen
*/
public class RMCTest {
/** Example sentence */
public static final String EXAMPLE = "$GPRMC,120044.567,A,6011.552,N,02501.941,E,000.0,360.0,160705,006.1,E,A*0B";
/** Example of legacy format (short by one field) */
public static final String EXAMPLE_LEGACY = "$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F";
RMCParser empty;
RMCParser rmc;
RMCParser legacy;
@Before
public void setUp() {
try {
empty = new RMCParser(TalkerId.GP);
rmc = new RMCParser(EXAMPLE);
legacy = new RMCParser(EXAMPLE_LEGACY);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(12, empty.getFieldCount());
assertEquals(11, legacy.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#getCourse()} .
*/
@Test
public void testGetCorrectedCourse() {
double expected = rmc.getCourse() + rmc.getVariation();
assertEquals(expected, rmc.getCorrectedCourse(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#getCourse()} .
*/
@Test
public void testGetCourse() {
assertEquals(360.0, rmc.getCourse(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#getDataStatus()}.
*/
@Test
public void testGetDataStatus() {
assertEquals(DataStatus.ACTIVE, rmc.getStatus());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RMCParser#getDate()}.
*/
@Test
public void testGetDate() {
Date expected = new Date(2005, 7, 16);
Date parsed = rmc.getDate();
assertEquals(expected, parsed);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RMCParser#getDay()}.
*/
@Test
public void testGetDay() {
assertEquals(16, rmc.getDate().getDay());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#getDirectionOfVariation()}
* .
*/
@Test
public void testGetDirectionOfVariation() {
assertTrue(rmc.getVariation() < 0);
assertEquals(CompassPoint.EAST, rmc.getDirectionOfVariation());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RMCParser#getMode()}.
*/
@Test
public void testGetFaaMode() {
assertEquals(FaaMode.AUTOMATIC, rmc.getMode());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#getVariation()} .
*/
@Test
public void testGetMagneticVariation() {
assertEquals(-6.1, rmc.getVariation(), 0.001);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RMCParser#getMonth()}
* .
*/
@Test
public void testGetMonth() {
assertEquals(7, rmc.getDate().getMonth());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#getPosition()}.
*/
@Test
public void testGetPosition() {
final double lat = 60 + (11.552 / 60);
final double lon = 25 + (1.941 / 60);
Position p = rmc.getPosition();
assertNotNull(p);
assertEquals(lat, p.getLatitude(), 0.0000001);
assertEquals(lon, p.getLongitude(), 0.0000001);
assertEquals(CompassPoint.NORTH, p.getLatitudeHemisphere());
assertEquals(CompassPoint.EAST, p.getLongitudeHemisphere());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RMCParser#getSpeed()}
* .
*/
@Test
public void testGetSpeed() {
assertEquals(0.0, rmc.getSpeed(), 0.001);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RMCParser#getTime()}.
*/
@Test
public void testGetTime() {
Time t = rmc.getTime();
assertNotNull(t);
assertEquals(12, t.getHour());
assertEquals(0, t.getMinutes());
assertEquals(44.567, t.getSeconds(), 0.001);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RMCParser#getYear()}.
*/
@Test
public void testGetYear() {
assertEquals(2005, rmc.getDate().getYear());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#setCourse(double)} .
*/
@Test
public void testSetCourse() {
final double cog = 90.55555;
rmc.setCourse(cog);
assertTrue(rmc.toString().contains(",090.6,"));
assertEquals(cog, rmc.getCourse(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#setDataStatus(DataStatus)}.
*/
@Test
public void testSetDataStatus() {
rmc.setStatus(DataStatus.ACTIVE);
assertEquals(DataStatus.ACTIVE, rmc.getStatus());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#getTime()}.
*/
@Test
public void testSetDate() {
rmc.setDate(new Date(2010, 6, 9));
assertTrue(rmc.toString().contains(",360.0,090610,006.1,"));
rmc.setDate(new Date(2010, 11, 12));
assertTrue(rmc.toString().contains(",360.0,121110,006.1,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#getDirectionOfVariation()}
* .
*/
@Test
public void testSetDirectionOfVariation() {
rmc.setDirectionOfVariation(CompassPoint.WEST);
assertEquals(CompassPoint.WEST, rmc.getDirectionOfVariation());
rmc.setDirectionOfVariation(CompassPoint.EAST);
assertEquals(CompassPoint.EAST, rmc.getDirectionOfVariation());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#getDirectionOfVariation()}
* .
*/
@Test
public void testSetDirectionOfVariationWithInvalidDirection() {
try {
rmc.setDirectionOfVariation(CompassPoint.NORTH);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#setFaaMode()}.
*/
@Test
public void testSetFaaMode() {
rmc.setMode(FaaMode.SIMULATED);
assertEquals(FaaMode.SIMULATED, rmc.getMode());
rmc.setMode(FaaMode.ESTIMATED);
assertEquals(FaaMode.ESTIMATED, rmc.getMode());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#setFaaMode()}.
*/
@Test
public void testSetFaaModeWhenOmitted() {
RMCParser parser = new RMCParser("$GPRMC,120044.567,A,6011.552,N,02501.941,E,000.0,360.0,160705,006.1,E");
parser.setMode(FaaMode.SIMULATED);
assertEquals(FaaMode.SIMULATED, parser.getMode());
parser.setMode(FaaMode.ESTIMATED);
assertEquals(FaaMode.ESTIMATED, parser.getMode());
}
@Test
public void testSetPosition() {
final double lat = 61 + (1.111 / 60);
final double lon = 27 + (7.777 / 60);
Position p = new Position(lat, lon);
rmc.setPosition(p);
String str = rmc.toString();
Position wp = rmc.getPosition();
assertTrue(str.contains(",6101.111,N,02707.777,E,"));
assertNotNull(wp);
assertEquals(lat, wp.getLatitude(), 0.0000001);
assertEquals(lon, wp.getLongitude(), 0.0000001);
assertEquals(CompassPoint.NORTH, wp.getLatitudeHemisphere());
assertEquals(CompassPoint.EAST, wp.getLongitudeHemisphere());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#setSpeed(double)} .
*/
@Test
public void testSetSpeed() {
final double sog = 35.23456;
rmc.setSpeed(sog);
assertTrue(rmc.toString().contains(",35.2,"));
assertEquals(sog, rmc.getSpeed(), 0.1);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RMCParser#getTime()}.
*/
@Test
public void testSetTime() {
Time t = new Time(1, 2, 3.456);
rmc.setTime(t);
assertTrue(rmc.toString().contains("$GPRMC,010203.456,A,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RMCParser#setVariation(double)} .
*/
@Test
public void testSetVariation() {
final double var = 1.55555;
rmc.setVariation(var);
rmc.setDirectionOfVariation(CompassPoint.WEST);
assertTrue(rmc.toString().contains(",001.6,W,"));
assertEquals(var, rmc.getVariation(), 0.1);
assertEquals(CompassPoint.WEST, rmc.getDirectionOfVariation());
}
}
@@ -0,0 +1,67 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.ROTSentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.DataStatus;
import org.junit.Before;
import org.junit.Test;
/**
* Created by SJK on 22/01/14.
*/
public class ROTTest {
public static final String EXAMPLE = "$HCROT,-0.3,A";
public static final String INVALID_EXAMPLE = "$HCROT,-0.3,V";
ROTSentence rot;
ROTSentence irot;
@Before
public void setUp() throws Exception {
rot = new ROTParser(EXAMPLE);
irot = new ROTParser(INVALID_EXAMPLE);
}
@Test
public void testConstructor() {
ROTSentence empty = new ROTParser(TalkerId.HE);
assertEquals(TalkerId.HE, empty.getTalkerId());
assertEquals(SentenceId.ROT.toString(), empty.getSentenceId());
try {
empty.getRateOfTurn();
} catch (DataNotAvailableException e) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testGetStatus() {
assertEquals(DataStatus.ACTIVE, rot.getStatus());
assertEquals(DataStatus.VOID, irot.getStatus());
}
@Test
public void testSetStatus() {
rot.setStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, rot.getStatus());
}
@Test
public void testGetRateOfTurn() {
double value = rot.getRateOfTurn();
assertEquals(-0.3, value, 0.1);
}
@Test
public void testSetRateOfTurn() {
final double newValue = 0.5;
rot.setRateOfTurn(newValue);
assertEquals(newValue, rot.getRateOfTurn(), 0.1);
}
}
@@ -0,0 +1,111 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.RPMSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.DataStatus;
import org.junit.Before;
import org.junit.Test;
public class RPMTest {
public static final String EXAMPLE = "$IIRPM,E,1,2418.2,10.5,A";
RPMSentence rpm;
RPMSentence empty;
@Before
public void setUp() throws Exception {
rpm = new RPMParser(EXAMPLE);
empty = new RPMParser(TalkerId.II);
}
@Test
public void testRPMParserString() {
assertEquals(TalkerId.II, rpm.getTalkerId());
assertEquals("RPM", rpm.getSentenceId());
assertEquals(5, rpm.getFieldCount());
}
@Test
public void testRPMParserTalkerId() {
assertEquals(TalkerId.II, empty.getTalkerId());
assertEquals("RPM", empty.getSentenceId());
assertEquals(5, empty.getFieldCount());
}
@Test
public void testGetId() {
assertEquals(1, rpm.getId());
}
@Test
public void testGetPitch() {
assertEquals(10.5, rpm.getPitch(), 0.1);
}
@Test
public void testGetRPM() {
assertEquals(2418.2, rpm.getRPM(), 0.1);
}
@Test
public void testGetSource() {
assertEquals('E', rpm.getSource());
}
@Test
public void testGetStatus() {
assertEquals(DataStatus.ACTIVE, rpm.getStatus());
}
@Test
public void testIsEngine() {
assertTrue(rpm.isEngine());
}
@Test
public void testIsShaft() {
assertFalse(rpm.isShaft());
}
@Test
public void testSetId() {
empty.setId(2);
assertEquals(2, empty.getId());
}
@Test
public void testSetPitch() {
empty.setPitch(3.14);
assertEquals(3.1, empty.getPitch(), 0.1);
}
@Test
public void testSetSource() {
empty.setSource(RPMSentence.SHAFT);
assertTrue(empty.isShaft());
assertEquals(RPMSentence.SHAFT, empty.getSource());
}
@Test
public void testSetInvalidSource() {
try {
empty.setSource('A');
fail("Didn't throw exception");
} catch (Exception e) {
// pass
}
}
@Test
public void testSetStatus() {
empty.setStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, empty.getStatus());
}
}
@@ -0,0 +1,73 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import net.sf.marineapi.nmea.sentence.RSASentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.DataStatus;
import net.sf.marineapi.nmea.util.Side;
import org.junit.Before;
import org.junit.Test;
public class RSATest {
public static final String EXAMPLE = "$IIRSA,1.2,A,2.3,V";
RSASentence empty;
RSASentence instance;
@Before
public void setUp() throws Exception {
empty = new RSAParser(TalkerId.II);
instance = new RSAParser(EXAMPLE);
}
@Test
public void testRSAParserString() {
assertEquals(TalkerId.II, instance.getTalkerId());
assertEquals(SentenceId.RSA.name(), instance.getSentenceId());
}
@Test
public void testRSAParserTalkerId() {
assertEquals(TalkerId.II, empty.getTalkerId());
assertEquals(SentenceId.RSA.name(), empty.getSentenceId());
assertEquals(DataStatus.VOID, empty.getStatus(Side.STARBOARD));
assertEquals(DataStatus.VOID, empty.getStatus(Side.PORT));
}
@Test
public void testGetRudderAngle() {
assertEquals(1.2, instance.getRudderAngle(Side.STARBOARD), 0.1);
assertEquals(2.3, instance.getRudderAngle(Side.PORT), 0.1);
}
@Test
public void testSetRudderAngle() {
final double portAngle = 4.5;
final double starboardAngle = 5.6;
instance.setRudderAngle(Side.PORT, portAngle);
instance.setRudderAngle(Side.STARBOARD, starboardAngle);
assertEquals(portAngle, instance.getRudderAngle(Side.PORT), 0.1);
assertEquals(starboardAngle, instance.getRudderAngle(Side.STARBOARD), 0.1);
}
@Test
public void testGetStatus() {
assertEquals(DataStatus.ACTIVE, instance.getStatus(Side.STARBOARD));
assertEquals(DataStatus.VOID, instance.getStatus(Side.PORT));
}
@Test
public void testSetStatusPort() {
empty.setStatus(Side.PORT, DataStatus.ACTIVE);
assertEquals(DataStatus.ACTIVE, empty.getStatus(Side.PORT));
}
@Test
public void testSetStatusStarboard() {
empty.setStatus(Side.STARBOARD, DataStatus.ACTIVE);
assertEquals(DataStatus.ACTIVE, empty.getStatus(Side.STARBOARD));
}
}
@@ -0,0 +1,250 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Arrays;
import net.sf.marineapi.nmea.sentence.RTESentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.RouteType;
import org.junit.Before;
import org.junit.Test;
/**
* RTETest
*
* @author Kimmo Tuukkanen
*/
public class RTETest {
/** Example sentence */
public static final String EXAMPLE = "$GPRTE,1,1,c,0,MELIN,RUSKI,KNUDAN*25";
private RTESentence empty;
private RTESentence rte;
@Before
public void setUp() {
try {
empty = new RTEParser(TalkerId.GP);
rte = new RTEParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(4, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#addWaypointId(String)}.
*/
@Test
public void testAddWaypointId() {
empty.addWaypointId("1ST");
assertTrue(empty.toString().contains(",1ST*"));
empty.addWaypointId("2ND");
assertTrue(empty.toString().contains(",1ST,2ND*"));
empty.addWaypointId("3RD");
assertTrue(empty.toString().contains(",1ST,2ND,3RD*"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#getRouteId()}.
*/
@Test
public void testGetRouteId() {
assertEquals("0", rte.getRouteId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#getSentenceCount()}.
*/
@Test
public void testGetSentenceCount() {
assertEquals(1, rte.getSentenceCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#getSentenceIndex()}.
*/
@Test
public void testGetSentenceIndex() {
assertEquals(1, rte.getSentenceIndex());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#getWaypointCount()}.
*/
@Test
public void testGetWaypointCount() {
assertEquals(3, rte.getWaypointCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#getWaypointIds()}.
*/
@Test
public void testGetWaypointIds() {
String[] ids = rte.getWaypointIds();
assertNotNull(ids);
assertEquals(3, ids.length);
assertEquals("MELIN", ids[0]);
assertEquals("RUSKI", ids[1]);
assertEquals("KNUDAN", ids[2]);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#isActiveRoute()}.
*/
@Test
public void testIsActiveRoute() {
assertTrue(rte.isActiveRoute());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RTEParser#isFirst()}.
*/
@Test
public void testIsFirst() {
assertTrue(rte.isFirst());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.RTEParser#isLast()}.
*/
@Test
public void testIsLast() {
assertTrue(rte.isLast());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#isWorkingRoute()}.
*/
@Test
public void testIsWorkingRoute() {
assertFalse(rte.isWorkingRoute());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#getRouteId()}.
*/
@Test
public void testSetRouteId() {
rte.setRouteId("ID");
assertEquals("ID", rte.getRouteId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#isActiveRoute()}.
*/
@Test
public void testSetRouteTypeActive() {
rte.setRouteType(RouteType.ACTIVE);
assertTrue(rte.isActiveRoute());
assertFalse(rte.isWorkingRoute());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#isActiveRoute()}.
*/
@Test
public void testSetRouteTypeWorking() {
rte.setRouteType(RouteType.WORKING);
assertTrue(rte.isWorkingRoute());
assertFalse(rte.isActiveRoute());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#setSentenceCount(int)}.
*/
@Test
public void testSetSentenceCount() {
rte.setSentenceCount(3);
assertEquals(3, rte.getSentenceCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#setSentenceCount(int)}.
*/
@Test
public void testSetSentenceCountWithNegativeValue() {
try {
rte.setSentenceCount(-1);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("cannot be negative"));
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#setSentenceIndex(int)}.
*/
@Test
public void testSetSentenceIndex() {
rte.setSentenceIndex(2);
assertEquals(2, rte.getSentenceIndex());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#setSentenceIndex(int)}.
*/
@Test
public void testSetSentenceIndexWithNegativeValue() {
try {
rte.setSentenceIndex(-1);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("cannot be negative"));
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.RTEParser#setWaypointIds(String[])}.
*/
@Test
public void testSetWaypointIds() {
final String[] ids = { "ONE", "TWO", "THREE", "FOUR", "FIVE" };
final String expected = "$GPRTE,1,1,c,0,ONE,TWO,THREE,FOUR,FIVE*7F";
rte.setWaypointIds(ids);
assertEquals(5, rte.getWaypointCount());
assertEquals(expected, rte.toString());
assertTrue(Arrays.equals(ids, rte.getWaypointIds()));
empty.setWaypointIds(ids);
assertEquals(5, empty.getWaypointCount());
assertTrue(empty.toString().startsWith(
"$GPRTE,,,,,ONE,TWO,THREE,FOUR,FIVE*"));
}
}
@@ -0,0 +1,304 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.List;
import net.sf.marineapi.nmea.sentence.BODSentence;
import net.sf.marineapi.nmea.sentence.Sentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.test.util.BARParser;
import net.sf.marineapi.test.util.FOOParser;
import net.sf.marineapi.test.util.FOOSentence;
import net.sf.marineapi.test.util.VDMParser;
import org.junit.Before;
import org.junit.Test;
/**
* @author Kimmo Tuukkanen
*/
public class SentenceFactoryTest {
private final SentenceFactory instance = SentenceFactory.getInstance();
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
instance.reset();
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testSupportedTypesRegistered() {
for (SentenceId id : SentenceId.values()) {
String msg = "Parser not registered: " + id;
assertTrue(msg, instance.hasParser(id.toString()));
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testCreateParser() {
Sentence bod = instance.createParser(BODTest.EXAMPLE);
assertNotNull(bod);
assertTrue(bod instanceof Sentence);
assertTrue(bod instanceof BODSentence);
assertTrue(bod instanceof BODParser);
assertEquals(BODTest.EXAMPLE, bod.toSentence());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(TalkerId, SentenceId)
* .
*/
@Test
public void testCreateEmptyParserWithSentenceId() {
for (SentenceId id : SentenceId.values()) {
Sentence s = instance.createParser(TalkerId.II, id);
assertNotNull(s);
assertTrue(s instanceof Sentence);
assertTrue(s instanceof SentenceParser);
assertEquals(TalkerId.II, s.getTalkerId());
assertEquals(id.name(), s.getSentenceId());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testCreateEmptyParserWithSentenceIdStr() {
for (SentenceId id : SentenceId.values()) {
Sentence s = instance.createParser(TalkerId.II, id.name());
assertNotNull(s);
assertTrue(s instanceof Sentence);
assertTrue(s instanceof SentenceParser);
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testCreateCustomParser() {
try {
instance.registerParser("FOO", FOOParser.class);
assertTrue(instance.hasParser("FOO"));
} catch (Exception e) {
fail("parser registering failed");
}
Sentence s = null;
try {
s = instance.createParser("$IIFOO,aa,bb,cc");
} catch (Exception e) {
fail("sentence parsing failed");
}
assertNotNull(s);
assertTrue(s instanceof Sentence);
assertTrue(s instanceof SentenceParser);
assertTrue(s instanceof FOOParser);
assertEquals(TalkerId.II, s.getTalkerId());
assertEquals("FOO", s.getSentenceId());
assertEquals("aa", ((FOOSentence)s).getValueA());
assertEquals("bb", ((FOOSentence)s).getValueB());
assertEquals("cc", ((FOOSentence)s).getValueC());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testCreateEmptyCustomParser() {
try {
instance.registerParser("FOO", FOOParser.class);
assertTrue(instance.hasParser("FOO"));
} catch (Exception e) {
fail("parser registering failed");
}
Sentence s = instance.createParser(TalkerId.II, "FOO");
assertNotNull(s);
assertTrue(s instanceof Sentence);
assertTrue(s instanceof SentenceParser);
assertTrue(s instanceof FOOParser);
assertEquals("FOO", s.getSentenceId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testCreateParserWithEmptyString() {
try {
instance.createParser("");
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testCreateParserWithNull() {
try {
instance.createParser(null);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testCreateParserWithRandom() {
try {
instance.createParser("asdqas,dwersa,dsdfas,das");
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testCreateParserWithUnregistered() {
try {
instance.createParser("$GPXYZ,1,2,3,4,5,6,7,8");
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#registerParser(java.lang.String, java.lang.Class)}
* .
*/
@Test
public void testRegisterParserWithAlternativeBeginChar() {
try {
instance.registerParser("VDM", VDMParser.class);
assertTrue(instance.hasParser("VDM"));
} catch (Exception e) {
fail("parser registering failed");
}
Sentence s = instance.createParser("!AIVDM,1,2,3");
assertNotNull(s);
assertTrue(s instanceof Sentence);
assertTrue(s instanceof SentenceParser);
assertTrue(s instanceof VDMParser);
instance.unregisterParser(VDMParser.class);
assertFalse(instance.hasParser("VDM"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#registerParser(java.lang.String, java.lang.Class)}
* .
*/
@Test
public void testRegisterInvalidParser() {
try {
instance.registerParser("BAR", BARParser.class);
fail("did not throw exception");
} catch (IllegalArgumentException iae) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#registerParser(java.lang.String, java.lang.Class)}
* .
*/
@Test
public void testUnregisterParser() {
instance.registerParser("FOO", FOOParser.class);
assertTrue(instance.hasParser("FOO"));
instance.unregisterParser(FOOParser.class);
assertFalse(instance.hasParser("FOO"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#hasParser(java.lang.String)}
* .
*/
@Test
public void testHasParser() {
assertTrue(instance.hasParser("GLL"));
assertFalse(instance.hasParser("ABC"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(TalkerId, SentenceId)
* .
*/
@Test
public void testListParsers() {
List<String> types = instance.listParsers();
assertEquals(SentenceId.values().length, types.size());
for (SentenceId id : SentenceId.values()) {
assertTrue(types.contains(id.name()));
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#getInstance()}.
*/
@Test
public void testGetInstance() {
assertNotNull(instance);
assertTrue(instance == SentenceFactory.getInstance());
assertEquals(instance, SentenceFactory.getInstance());
}
}
@@ -0,0 +1,598 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.Sentence;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.test.util.FOOParser;
import net.sf.marineapi.test.util.FOOSentence;
import org.junit.Before;
import org.junit.Test;
/**
* Tests the sentence parser base class.
*
* @author Kimmo Tuukkanen
*/
public class SentenceParserTest {
public static final String VDO_EXAMPLE = "!AIVDO,1,1,,,13:r`R5P1orpG60JeHgRSj4l0000,0*56";
public static final String VDM_EXAMPLE = "!AIVDM,1,1,,B,177KQJ5000G?tO`K>RA1wUbN0TKH,0*5C";
private SentenceParser instance;
/**
* setUp
*/
@Before
public void setUp() {
instance = new SentenceParser(RMCTest.EXAMPLE);
}
/**
* Test method for SenteceParser constructor.
*/
@Test
public void testConstructorForEmptySentence() {
Sentence s = new SentenceParser(TalkerId.GP, SentenceId.GLL, 5);
assertEquals("$GPGLL,,,,,*7C", s.toString());
}
/**
* Test method for SentenceParser constructors called from derived custom
* parsers.
*/
@Test
public void testConstructorWithCustomParser() {
final String foo = "FOO";
SentenceFactory sf = SentenceFactory.getInstance();
sf.registerParser(foo, FOOParser.class);
final String fooSentence = "$GPFOO,B,A,R";
final FOOSentence fp = new FOOParser(fooSentence);
final Sentence s = sf.createParser(fooSentence);
assertTrue(s instanceof SentenceParser);
assertTrue(s instanceof FOOParser);
assertEquals(foo, s.getSentenceId());
assertEquals(TalkerId.GP, s.getTalkerId());
assertEquals(s, fp);
}
/**
* Test method for SenteceParser constructor.
*/
@Test
public void testConstructorWithInvalidSentence() {
try {
String sent = "GPBOD,234.9,T,228.8,M,RUSKI,*1D";
new SentenceParser(sent);
fail("Did not throw exception");
} catch (IllegalArgumentException se) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for SenteceParser constructor.
*/
@Test
public void testConstructorWithAIVDO() {
Sentence s = new SentenceParser(VDO_EXAMPLE);
assertTrue(s.isValid());
assertFalse(s.isProprietary());
assertEquals(Sentence.ALTERNATIVE_BEGIN_CHAR, s.getBeginChar());
assertEquals(VDO_EXAMPLE, s.toString());
}
/**
* Test method for SenteceParser constructor.
*/
@Test
public void testConstructorWithAIVDM() {
Sentence s = new SentenceParser(VDM_EXAMPLE);
assertTrue(s.isValid());
assertFalse(s.isProprietary());
assertEquals(Sentence.ALTERNATIVE_BEGIN_CHAR, s.getBeginChar());
assertEquals(VDM_EXAMPLE, s.toString());
}
/**
* Test method for SenteceParser constructor.
*/
@Test
public void testConstructorWithNulls() {
try {
new SentenceParser((String) null, (String) null);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// OK
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for SenteceParser constructor.
*/
@Test
public void testConstructorWithNullType() {
try {
new SentenceParser(RMCTest.EXAMPLE, (String) null);
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// OK
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for SenteceParser constructor.
*/
@Test
public void testConstructorWithUnsupportedTalker() {
try {
new SentenceParser("$XZGGA,VALID,BUT,TALKER,NOT,SUPPORTED");
fail("Did not throw exception");
} catch (IllegalArgumentException se) {
assertTrue(se.getMessage().endsWith(".TalkerId.XZ"));
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for SenteceParser constructor.
*/
@Test
public void testConstructorWithWrongType() {
try {
new SentenceParser(BODTest.EXAMPLE, SentenceId.GLL.toString());
fail("Did not throw exception");
} catch (IllegalArgumentException iae) {
// OK
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getCharValue(int)}.
*/
@Test
public void testGetCharValueWithEmptyFields() {
String nmea = "$GPGLL,,,,,,";
SentenceParser s = new SentenceParser(nmea);
try {
s.getCharValue(3);
fail("Did not throw exception");
} catch (DataNotAvailableException ex) {
// pass
} catch (Exception ex) {
fail(ex.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getDoubleValue(int)}.
*/
@Test
public void testGetDoubleValueWithEmptyFields() {
String nmea = "$GPGLL,,,,,,";
SentenceParser s = new SentenceParser(nmea);
try {
s.getDoubleValue(2);
fail("Did not throw exception");
} catch (DataNotAvailableException ex) {
// pass
} catch (Exception ex) {
fail(ex.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getDoubleValue(int)}.
*/
@Test
public void testGetDoubleValueWithInvalidValue() {
String nmea = "$GPGLL,a,b,c,d,e,f";
SentenceParser s = new SentenceParser(nmea);
try {
s.getDoubleValue(2);
fail("Did not throw exception");
} catch (ParseException ex) {
// pass
} catch (Exception ex) {
fail(ex.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getSentenceId()}.
*/
@Test
public void testGetSentenceId() {
SentenceId sid = SentenceId.valueOf(instance.getSentenceId());
assertEquals(SentenceId.RMC, sid);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getStringValue(int)}.
*/
@Test
public void testGetStringValue() {
final String nmea = "$GPGLL,6011.552,N,02501.941,E,120045,A";
final SentenceParser s = new SentenceParser(nmea);
final String data = "6011.552,N,02501.941,E,120045,A";
final String[] expected = data.split(",", -1);
for (int i = 0; i < expected.length; i++) {
assertEquals(expected[i], s.getStringValue(i));
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getStringValue(int)}.
*/
@Test
public void testGetStringValueWithEmptyFields() {
String nmea = "$GPGLL,,,,,,";
SentenceParser s = new SentenceParser(nmea);
try {
s.getStringValue(2);
fail("Did not throw exception");
} catch (DataNotAvailableException ex) {
// pass
} catch (Exception ex) {
fail(ex.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getStringValue(int)}.
*/
@Test
public void testGetStringValueWithIndexGreaterThanAllowed() {
try {
instance.getStringValue(instance.getFieldCount());
fail("Did not throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// pass
} catch (Exception e) {
fail("Unexpected exception was thrown");
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getStringValue(int)}.
*/
@Test
public void testGetStringValueWithNegativeIndex() {
try {
instance.getStringValue(-1);
fail("Did not throw IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException e) {
// pass
} catch (Exception e) {
fail("Unexpected exception was thrown");
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getStringValue(int)}.
*/
@Test
public void testGetStringValueWithValidIndex() {
try {
String val = instance.getStringValue(0);
assertEquals("120044.567", val);
val = instance.getStringValue(instance.getFieldCount() - 1);
assertEquals("A", val);
} catch (IndexOutOfBoundsException e) {
fail("Unexpected IndexOutOfBoundsException");
} catch (Exception e) {
fail("Unexpected exception was thrown");
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#getTalkerId()}.
*/
@Test
public void testGetTalkerId() {
assertEquals(TalkerId.GP, instance.getTalkerId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#isProprietary()}.
*/
public void testIsProprietary() {
assertFalse(instance.isProprietary());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#setBeginChar()}.
*/
public void testSetBeginChar() {
assertEquals(Sentence.BEGIN_CHAR, instance.getBeginChar());
instance.setBeginChar(Sentence.ALTERNATIVE_BEGIN_CHAR);
assertEquals(Sentence.ALTERNATIVE_BEGIN_CHAR, instance.getBeginChar());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#isValid()}.
*/
@Test
public void testIsValid() {
assertTrue(instance.isValid());
instance.setStringValue(0, "\t");
assertFalse(instance.isValid());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#setDoubleValue(int, double, int, int)}
* .
*/
@Test
public void testSetDoubleValue() {
final int field = 0;
final double value = 123.456789;
instance.setDoubleValue(field, value);
assertEquals(String.valueOf(value), instance.getStringValue(field));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#setDoubleValue(int, double, int, int)}
* .
*/
@Test
public void testSetDoubleValueWithPrecision() {
instance.setDoubleValue(0, 3.14, 0, 0);
assertEquals("3", instance.getStringValue(0));
instance.setDoubleValue(0, 3.14, 2, 0);
assertEquals("03", instance.getStringValue(0));
instance.setDoubleValue(0, 3.14, 1, 4);
assertEquals("3.1400", instance.getStringValue(0));
instance.setDoubleValue(0, 678.910, 3, 3);
assertEquals("678.910", instance.getStringValue(0));
instance.setDoubleValue(0, 123.456, 4, 1);
assertEquals("0123.5", instance.getStringValue(0));
instance.setDoubleValue(0, 78.910, 1, 1);
assertEquals("78.9", instance.getStringValue(0));
instance.setDoubleValue(0, 0.910, 0, 3);
assertEquals(".910", instance.getStringValue(0));
instance.setDoubleValue(0, 0.910, 3, 2);
assertEquals("000.91", instance.getStringValue(0));
instance.setDoubleValue(0, 0.910, 0, 2);
assertEquals(".91", instance.getStringValue(0));
}
@Test
public void testSetDoubleValueJDK7RoundingIssue() {
// 2016-11-06: open-jdk7 has rounding issues that were not caught by this test
// until now. All good in jdk8, thus testing conditionally.
// https://bugs.openjdk.java.net/browse/JDK-8029896
// https://bugs.openjdk.java.net/browse/JDK-8039915
String version = System.getProperty("java.version");
org.junit.Assume.assumeTrue(!version.startsWith("1.7."));
// would fail in jdk7 claiming "12.35" not equal to "12.34"
instance.setDoubleValue(0, 12.345, 1, 2);
assertEquals("12.35", instance.getStringValue(0));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#setIntValue(int, int, int)}
* .
*/
@Test
public void testSetIntValueWithLeading() {
instance.setIntValue(0, 0, 0);
assertEquals("0", instance.getStringValue(0));
instance.setIntValue(0, 0, 1);
assertEquals("0", instance.getStringValue(0));
instance.setIntValue(0, 1, 2);
assertEquals("01", instance.getStringValue(0));
instance.setIntValue(0, 1, 3);
assertEquals("001", instance.getStringValue(0));
instance.setIntValue(0, 12, 1);
assertEquals("12", instance.getStringValue(0));
instance.setIntValue(0, 12, 2);
assertEquals("12", instance.getStringValue(0));
instance.setIntValue(0, 12, 3);
assertEquals("012", instance.getStringValue(0));
instance.setIntValue(0, -1, 3);
assertEquals("-01", instance.getStringValue(0));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#toString()}.
*/
@Test
public void testToString() {
assertEquals(RMCTest.EXAMPLE, instance.toString());
assertEquals(instance.toString(), instance.toSentence());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#toSentence(int)}.
*/
@Test
public void testToSentenceWithMaxLength() {
int max = instance.toString().length() + 1;
assertEquals(RMCTest.EXAMPLE, instance.toSentence(max));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#§(int)}.
*/
@Test
public void testToSentenceWithMaxLengthOnLimit() {
int max = instance.toString().length();
assertEquals(RMCTest.EXAMPLE, instance.toSentence(max));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#toSentence(int)}.
*/
@Test
public void testToSentenceWithMaxLengthExceeded() {
try {
int max = instance.toString().length() - 1;
assertEquals(RMCTest.EXAMPLE, instance.toSentence(max));
fail("didn't throw exception");
} catch (Exception e) {
// pass
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#equals(Object)
*/
@Test
public void testEquals() {
assertTrue(instance.equals(new SentenceParser(RMCTest.EXAMPLE)));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#equals(Object)
*/
@Test
public void testEqualsWithNonEqual() {
assertFalse(instance.equals(new SentenceParser(RMBTest.EXAMPLE)));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#equals(Object)
*/
@Test
public void testEqualsWithNull() {
assertFalse(instance.equals(null));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceParser#equals(Object)
*/
@Test
public void testEqualsWithSelf() {
assertTrue(instance.equals(instance));
}
@Test
public void testSetFieldCountLowerByOne() {
final int count = instance.getFieldCount() - 1;
final int lastIndex = instance.getFieldCount() - 2;
final String value = instance.getStringValue(lastIndex);
instance.setFieldCount(count);
assertEquals(count, instance.getFieldCount());
assertEquals(value, instance.getStringValue(lastIndex));
}
@Test
public void testSetFieldCountLower() {
SentenceParser parser = new SentenceParser("$GPGGA,1,2,3,4");
parser.setFieldCount(2);
assertEquals(2, parser.getFieldCount());
assertEquals("1", parser.getStringValue(0));
assertEquals("2", parser.getStringValue(1));
assertTrue(parser.toString().startsWith("$GPGGA,1,2*"));
}
@Test
public void testSetFieldCountHigherByOne() {
final int count = instance.getFieldCount() + 1;
final int lastIndex = instance.getFieldCount() - 1;
final String value = instance.getStringValue(lastIndex);
instance.setFieldCount(count);
assertEquals(count, instance.getFieldCount());
assertEquals(value, instance.getStringValue(lastIndex));
}
@Test
public void testSetFieldCountHigher() {
SentenceParser parser = new SentenceParser("$GPGGA,1,2,3,4");
parser.setFieldCount(8);
assertEquals(8, parser.getFieldCount());
assertTrue(parser.toString().startsWith("$GPGGA,1,2,3,4,,,,*"));
}
@Test
public void testSetStringValuesReplaceAll() {
SentenceParser parser = new SentenceParser("$GPGGA,1,2,3,4");
String[] values = { "5", "6", "7" };
parser.setStringValues(0, values);
assertEquals(3, parser.getFieldCount());
assertEquals("5", parser.getStringValue(0));
assertEquals("6", parser.getStringValue(1));
assertEquals("7", parser.getStringValue(2));
}
@Test
public void testSetStringValuesReplaceTail() {
SentenceParser parser = new SentenceParser("$GPGGA,1,2,3,4");
String[] values = { "5", "6", "7" };
parser.setStringValues(1, values);
assertEquals(4, parser.getFieldCount());
assertEquals("1", parser.getStringValue(0));
assertEquals("5", parser.getStringValue(1));
assertEquals("6", parser.getStringValue(2));
assertEquals("7", parser.getStringValue(3));
}
}
@@ -0,0 +1,275 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.AcquisitionType;
import net.sf.marineapi.nmea.util.TargetStatus;
import net.sf.marineapi.nmea.util.Time;
import org.junit.Before;
import org.junit.Test;
/**
* Tests the RMC sentence parser.
*
* @author Johan Bergkvist
*/
public class TTMTest {
/** Example sentence */
public static final String EXAMPLE = "$RATTM,11,25.3,13.7,T,7.0,20.0,T,10.1,20.2,N,NAME,Q,,175550.24,A*34";
TTMParser empty;
TTMParser ttm;
@Before
public void setUp() {
try {
empty = new TTMParser(TalkerId.RA);
ttm = new TTMParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(15, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getNumber()} .
*/
@Test
public void testGetNumber() {
assertEquals(11, ttm.getNumber());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getDistance()} .
*/
@Test
public void testGetDistance() {
assertEquals(25.3, ttm.getDistance(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getBearing()} .
*/
@Test
public void testGetBearing() {
assertEquals(13.7, ttm.getBearing(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getSpeed()} .
*/
@Test
public void testGetSpeed() {
assertEquals(7.0, ttm.getSpeed(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getCourse()} .
*/
@Test
public void testGetCourse() {
assertEquals(20.0, ttm.getCourse(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getDistanceOfCPA()} .
*/
@Test
public void testGetDistanceOfCPA() {
assertEquals(10.1, ttm.getDistanceOfCPA(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getTimeToCPA()} .
*/
@Test
public void testGetTimeToCPA() {
assertEquals(20.2, ttm.getTimeToCPA(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getTimeToCPA()} .
*/
@Test
public void testGetName() {
assertEquals("NAME", ttm.getName());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getStatus()} .
*/
@Test
public void testGetStatus() {
assertEquals(TargetStatus.QUERY, ttm.getStatus());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getTime()} .
*/
@Test
public void testGetTime() {
Time t = ttm.getTime();
assertNotNull(t);
assertEquals(17, t.getHour());
assertEquals(55, t.getMinutes());
assertEquals(50.24, t.getSeconds(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#getAcquisitionType()} .
*/
@Test
public void testGetAcquisitionType() {
assertEquals(AcquisitionType.AUTO, ttm.getAcquisitionType());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setNumber()} .
*/
@Test
public void testSetNumber() {
final int number = 90;
ttm.setNumber(number);
assertTrue(ttm.toString().contains(",90,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setDistance()} .
*/
@Test
public void testSetDistance() {
ttm.setDistance(56.4);
assertTrue(ttm.toString().contains(",56.4,"));
assertTrue(ttm.toString().contains(",N,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setBearing()} .
*/
@Test
public void testSetBearing() {
ttm.setBearing(34.1);
assertTrue(ttm.toString().contains(",34.1,T,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setSpeed()} .
*/
@Test
public void testSetSpeed() {
ttm.setBearing(44.1);
assertTrue(ttm.toString().contains(",44.1,"));
assertTrue(ttm.toString().contains(",N,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setCourse()} .
*/
@Test
public void testSetCourse() {
ttm.setCourse(234.9);
assertTrue(ttm.toString().contains(",234.9,T,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setDistanceOfCPA()} .
*/
@Test
public void testSetDistanceOfCPA() {
ttm.setDistanceOfCPA(55.2);
assertTrue(ttm.toString().contains(",55.2,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setTimeToCPA()} .
*/
@Test
public void testSetTimeToCPA() {
ttm.setTimeToCPA(15.0);
assertTrue(ttm.toString().contains(",15.0,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setName()} .
*/
@Test
public void testSetName() {
ttm.setName("FRED");
assertTrue(ttm.toString().contains(",FRED,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setStatus()} .
*/
@Test
public void testSetStatus() {
ttm.setStatus(TargetStatus.LOST);
assertTrue(ttm.toString().contains(",T,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setStatus()} .
*/
@Test
public void testSetReferenceTrue() {
ttm.setReference(true);
assertTrue(ttm.toString().contains(",R,"));
}
@Test
public void testSetReferenceFalse() {
ttm.setReference(false);
assertTrue(!ttm.toString().contains(",R,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setTime()} .
*/
@Test
public void testSetTime() {
Time t = new Time(1, 2, 3.45);
ttm.setTime(t);
assertTrue(ttm.toString().contains(",010203.45,"));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.TTMParser#setAcquisitionType()} .
*/
@Test
public void testSetAcquisitionType() {
ttm.setAcquisitionType(AcquisitionType.MANUAL);
assertTrue(ttm.toString().contains(",M*"));
}
}
@@ -0,0 +1,156 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.sentence.VBWSentence;
import net.sf.marineapi.nmea.util.DataStatus;
import org.junit.Before;
import org.junit.Test;
public class VBWTest {
public static final String EXAMPLE = "$IIVBW,11.0,02.0,A,07.5,13.3,A,06.65,A,12.3,A";
private VBWSentence vbw;
private VBWSentence empty;
@Before
public void setUp() throws Exception {
vbw = new VBWParser(EXAMPLE);
empty = new VBWParser(TalkerId.II);
}
@Test
public void testVBWParserString() {
assertEquals(TalkerId.II, vbw.getTalkerId());
assertEquals(SentenceId.VBW.name(), vbw.getSentenceId());
assertEquals(10, vbw.getFieldCount());
}
@Test
public void testVBWParserTalkerId() {
assertEquals(TalkerId.II, empty.getTalkerId());
assertEquals(SentenceId.VBW.name(), empty.getSentenceId());
assertEquals(10, empty.getFieldCount());
assertTrue(empty.toString().startsWith("$IIVBW,"));
}
@Test
public void testGetLongWaterSpeed() {
assertEquals(11.0, vbw.getLongWaterSpeed(), 0.1);
}
@Test
public void testGetTravWaterSpeed() {
assertEquals(2.0, vbw.getTravWaterSpeed(), 0.1);
}
@Test
public void testGetWaterSpeedStatus() {
assertEquals(DataStatus.ACTIVE, vbw.getWaterSpeedStatus());
}
@Test
public void testGetLongGroundSpeed() {
assertEquals(07.5, vbw.getLongGroundSpeed(), 0.1);
}
@Test
public void testGetTravGroundSpeed() {
assertEquals(13.3, vbw.getTravGroundSpeed(), 0.1);
}
@Test
public void testGetGroundSpeedStatus() {
assertEquals(DataStatus.ACTIVE, vbw.getGroundSpeedStatus());
}
@Test
public void testGetSternWaterSpeed() {
assertEquals(06.65, vbw.getSternWaterSpeed(), 0.1);
}
@Test
public void testGetSternWaterSpeedStatus() {
assertEquals(DataStatus.ACTIVE, vbw.getSternWaterSpeedStatus());
}
@Test
public void testGetSternGroundSpeed() {
assertEquals(12.3, vbw.getSternGroundSpeed(), 0.1);
}
@Test
public void testGetSternGroundSpeedStatus() {
assertEquals(DataStatus.ACTIVE, vbw.getSternGroundSpeedStatus());
}
@Test
public void testSetLongWaterSpeed() {
final double dir = 23.3;
empty.setLongWaterSpeed(dir);
assertEquals(dir, empty.getLongWaterSpeed(), 0.1);
}
@Test
public void testSetTravWaterSpeed() {
final double dir = 23.3;
empty.setTravWaterSpeed(dir);
assertEquals(dir, empty.getTravWaterSpeed(), 0.1);
}
@Test
public void testSetWaterSpeedStatus() {
empty.setWaterSpeedStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, empty.getWaterSpeedStatus());
}
@Test
public void testSetLongGroundSpeed() {
final double dir = 23.3;
empty.setLongGroundSpeed(dir);
assertEquals(dir, empty.getLongGroundSpeed(), 0.1);
}
@Test
public void testSetTravGroundSpeed() {
final double dir = 23.3;
empty.setTravGroundSpeed(dir);
assertEquals(dir, empty.getTravGroundSpeed(), 0.1);
}
@Test
public void testSetGroundSpeedStatus() {
empty.setGroundSpeedStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, empty.getGroundSpeedStatus());
}
@Test
public void testSetSternWaterSpeed() {
final double dir = 23.3;
empty.setSternWaterSpeed(dir);
assertEquals(dir, empty.getSternWaterSpeed(), 0.1);
}
@Test
public void testSetSternWaterSpeedStatus() {
empty.setSternWaterSpeedStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, empty.getSternWaterSpeedStatus());
}
@Test
public void testSetSternGroundSpeed() {
final double dir = 23.3;
empty.setSternGroundSpeed(dir);
assertEquals(dir, empty.getSternGroundSpeed(), 0.1);
}
@Test
public void testSetSternGroundSpeedStatus() {
empty.setSternGroundSpeedStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, empty.getSternGroundSpeedStatus());
}
}
@@ -0,0 +1,167 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.sentence.AISSentence;
import org.junit.Before;
import org.junit.Test;
/**
* @author Kimmo Tuukkanen
*/
public class VDMTest {
public static final String EXAMPLE = "!AIVDM,1,1,,A,403OviQuMGCqWrRO9>E6fE700@GO,0*4D";
public static final String PART1 = "!AIVDM,2,1,1,A,55?MbV02;H;s<HtKR20EHE:0@T4@Dn2222222216L961O5Gf0NSQEp6ClRp8,0*1C";
public static final String PART2 = "!AIVDM,2,2,1,A,88888888880,2*25";
private AISSentence vdm;
private AISSentence frag1;
private AISSentence frag2;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
vdm = new VDMParser(EXAMPLE);
frag1 = new VDMParser(PART1);
frag2 = new VDMParser(PART2);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#VDMParser(net.sf.marineapi.nmea.sentence.TalkerId)}
* .
*/
@Test
public void testVDMParserTalkerId() {
AISSentence empty = new VDMParser(TalkerId.AI);
assertEquals(TalkerId.AI, empty.getTalkerId());
assertEquals("VDM", empty.getSentenceId());
assertEquals(6, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#getNumberOfFragments()}.
*/
@Test
public void testGetNumberOfFragments() {
assertEquals(1, vdm.getNumberOfFragments());
assertEquals(2, frag1.getNumberOfFragments());
assertEquals(2, frag2.getNumberOfFragments());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#getFragmentNumber()}.
*/
@Test
public void testGetFragmentNumber() {
assertEquals(1, vdm.getFragmentNumber());
assertEquals(1, frag1.getFragmentNumber());
assertEquals(2, frag2.getFragmentNumber());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#getMessageId()}.
*/
@Test
public void testGetMessageId() {
assertEquals("1", frag1.getMessageId());
assertEquals("1", frag2.getMessageId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#getRadioChannel()}.
*/
@Test
public void testGetRadioChannel() {
assertEquals("A", vdm.getRadioChannel());
assertEquals("A", frag1.getRadioChannel());
assertEquals("A", frag2.getRadioChannel());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#getPayload()}.
*/
@Test
public void testGetPayload() {
assertEquals("403OviQuMGCqWrRO9>E6fE700@GO", vdm.getPayload());
assertEquals("88888888880", frag2.getPayload());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#getFillBits()}.
*/
@Test
public void testGetFillBits() {
assertEquals(0, vdm.getFillBits());
assertEquals(0, frag1.getFillBits());
assertEquals(2, frag2.getFillBits());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#isFragmented()}.
*/
@Test
public void testIsFragmented() {
assertFalse(vdm.isFragmented());
assertTrue(frag1.isFragmented());
assertTrue(frag2.isFragmented());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#isFirstFragment()}.
*/
@Test
public void testIsFirstFragment() {
assertTrue(vdm.isFirstFragment());
assertTrue(frag1.isFirstFragment());
assertFalse(frag2.isFirstFragment());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#isLastFragment()}.
*/
@Test
public void testIsLastFragment() {
assertTrue(vdm.isLastFragment());
assertFalse(frag1.isLastFragment());
assertTrue(frag2.isLastFragment());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDMParser#isPartOfMessage(net.sf.marineapi.nmea.sentence.AISSentence)}
* .
*/
@Test
public void testIsPartOfMessage() {
assertFalse(vdm.isPartOfMessage(frag1));
assertFalse(vdm.isPartOfMessage(frag2));
assertFalse(frag1.isPartOfMessage(vdm));
assertFalse(frag2.isPartOfMessage(vdm));
assertTrue(frag1.isPartOfMessage(frag2));
assertFalse(frag2.isPartOfMessage(frag1));
}
@Test
public void testToStringWithAIS() {
AISSentence vdm = new VDMParser(EXAMPLE);
AISSentence empty = new VDMParser(TalkerId.AI);
assertEquals(EXAMPLE, vdm.toString());
assertEquals("!AIVDM,,,,,,*57", empty.toString());
}
}
@@ -0,0 +1,194 @@
/*
* VDOTest.java
* Copyright (C) 2016 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import net.sf.marineapi.nmea.sentence.AISSentence;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* VDOTest
*
* @author Kimmo Tuukkanen
*/
public class VDOTest {
public static final String EXAMPLE = "!AIVDO,1,1,,B,H1c2;qA@PU>0U>060<h5=>0:1Dp,2*7D";
public static final String PART1 = "!AIVDO,2,1,5,B,E1c2;q@b44ah4ah0h:2ab@70VRpU<Bgpm4:gP50HH`Th`QF5,0*7B";
public static final String PART2 = "!AIVDO,2,2,5,B,1CQ1A83PCAH0,0*60";
private AISSentence vdo;
private AISSentence frag1;
private AISSentence frag2;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
vdo = new VDOParser(EXAMPLE);
frag1 = new VDOParser(PART1);
frag2 = new VDOParser(PART2);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#VDOParser(net.sf.marineapi.nmea.sentence.TalkerId)}
* .
*/
@Test
public void testVDOParserTalkerId() {
AISSentence empty = new VDOParser(TalkerId.AI);
assertEquals('!', empty.getBeginChar());
assertEquals(TalkerId.AI, empty.getTalkerId());
assertEquals("VDO", empty.getSentenceId());
assertEquals(6, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#getNumberOfFragments()}.
*/
@Test
public void testGetNumberOfFragments() {
assertEquals(1, vdo.getNumberOfFragments());
assertEquals(2, frag1.getNumberOfFragments());
assertEquals(2, frag2.getNumberOfFragments());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#getFragmentNumber()}.
*/
@Test
public void testGetFragmentNumber() {
assertEquals(1, vdo.getFragmentNumber());
assertEquals(1, frag1.getFragmentNumber());
assertEquals(2, frag2.getFragmentNumber());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#getMessageId()}.
*/
@Test
public void testGetMessageId() {
assertEquals("5", frag1.getMessageId());
assertEquals("5", frag2.getMessageId());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#getRadioChannel()}.
*/
@Test
public void testGetRadioChannel() {
assertEquals("B", vdo.getRadioChannel());
assertEquals("B", frag1.getRadioChannel());
assertEquals("B", frag2.getRadioChannel());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#getPayload()}.
*/
@Test
public void testGetPayload() {
final String pl = "H1c2;qA@PU>0U>060<h5=>0:1Dp";
final String f1 = "E1c2;q@b44ah4ah0h:2ab@70VRpU<Bgpm4:gP50HH`Th`QF5";
final String f2 = "1CQ1A83PCAH0";
assertEquals(pl, vdo.getPayload());
assertEquals(f1, frag1.getPayload());
assertEquals(f2, frag2.getPayload());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#getFillBits()}.
*/
@Test
public void testGetFillBits() {
assertEquals(2, vdo.getFillBits());
assertEquals(0, frag1.getFillBits());
assertEquals(0, frag2.getFillBits());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#isFragmented()}.
*/
@Test
public void testIsFragmented() {
assertFalse(vdo.isFragmented());
assertTrue(frag1.isFragmented());
assertTrue(frag2.isFragmented());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#isFirstFragment()}.
*/
@Test
public void testIsFirstFragment() {
assertTrue(vdo.isFirstFragment());
assertTrue(frag1.isFirstFragment());
assertFalse(frag2.isFirstFragment());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#isLastFragment()}.
*/
@Test
public void testIsLastFragment() {
assertTrue(vdo.isLastFragment());
assertFalse(frag1.isLastFragment());
assertTrue(frag2.isLastFragment());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VDOParser#isPartOfMessage(net.sf.marineapi.nmea.sentence.AISSentence)}
* .
*/
@Test
public void testIsPartOfMessage() {
assertFalse(vdo.isPartOfMessage(frag1));
assertFalse(vdo.isPartOfMessage(frag2));
assertFalse(frag1.isPartOfMessage(vdo));
assertFalse(frag2.isPartOfMessage(vdo));
assertTrue(frag1.isPartOfMessage(frag2));
assertFalse(frag2.isPartOfMessage(frag1));
}
@Test
public void testToStringWithAIS() {
AISSentence example = new VDOParser(EXAMPLE);
AISSentence empty = new VDOParser(TalkerId.AI);
assertEquals(EXAMPLE, example.toString());
assertEquals("!AIVDO,,,,,,*55", empty.toString());
}
}
@@ -0,0 +1,76 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.sentence.VDRSentence;
import org.junit.Before;
import org.junit.Test;
public class VDRTest {
public static final String EXAMPLE = "$IIVDR,123.4,T,124.5,M,1.2,N";
private VDRSentence vdr;
private VDRSentence empty;
@Before
public void setUp() throws Exception {
vdr = new VDRParser(EXAMPLE);
empty = new VDRParser(TalkerId.IN);
}
@Test
public void testVDRParserString() {
assertEquals(TalkerId.II, vdr.getTalkerId());
assertEquals(SentenceId.VDR.name(), vdr.getSentenceId());
assertEquals(6, vdr.getFieldCount());
}
@Test
public void testVDRParserTalkerId() {
assertEquals(TalkerId.IN, empty.getTalkerId());
assertEquals(SentenceId.VDR.name(), empty.getSentenceId());
assertEquals(6, empty.getFieldCount());
assertTrue(empty.toString().startsWith("$INVDR,,T,,M,,N*"));
}
@Test
public void testGetMagneticDirection() {
assertEquals(124.5, vdr.getMagneticDirection(), 0.1);
}
@Test
public void testGetSpeed() {
assertEquals(1.2, vdr.getSpeed(), 0.1);
}
@Test
public void testGetTrueDirection() {
assertEquals(123.4, vdr.getTrueDirection(), 0.1);
}
@Test
public void testSetMagneticDirection() {
final double dir = 45.123;
empty.setMagneticDirection(dir);
assertEquals(dir, empty.getMagneticDirection(), 0.1);
}
@Test
public void testSetSpeed() {
final double speed = 2.124;
empty.setSpeed(speed);
assertEquals(speed, empty.getSpeed(), 0.1);
}
@Test
public void testSetTrueDirection() {
final double dir = 55.234;
empty.setTrueDirection(dir);
assertEquals(dir, empty.getTrueDirection(), 0.1);
}
}
@@ -0,0 +1,161 @@
/*
* VHWTest.java
* Copyright (C) 2011 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import org.junit.Before;
import org.junit.Test;
/**
* @author Kimmo Tuukkanen
*/
public class VHWTest {
public static final String EXAMPLE = "$VWVHW,000.0,T,001.5,M,1.0,N,1.85,K";
private VHWParser vhw;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
vhw = new VHWParser(EXAMPLE);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#VHWParser(java.lang.String)}
* .
*/
@Test
public void testConstructorString() {
assertTrue(vhw.getTalkerId() == TalkerId.VW);
assertTrue(SentenceId.valueOf(vhw.getSentenceId()) == SentenceId.VHW);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#VHWParser(java.lang.String)}
* .
*/
@Test
public void testConstructorTalkerId() {
VHWParser empty = new VHWParser(TalkerId.II);
assertEquals(8, empty.getFieldCount());
assertTrue('T' == empty.getCharValue(1));
assertTrue('M' == empty.getCharValue(3));
assertTrue('N' == empty.getCharValue(5));
assertTrue('K' == empty.getCharValue(7));
assertEquals("VHW", empty.getSentenceId());
assertTrue(empty.getTalkerId() == TalkerId.II);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#getHeading()}.
*/
@Test
public void testGetHeading() {
assertEquals(0.0, vhw.getHeading(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#getMagneticHeading()}.
*/
@Test
public void testGetMagneticHeading() {
assertEquals(1.5, vhw.getMagneticHeading(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#getSpeedKmh()}.
*/
@Test
public void testGetSpeedKilometres() {
assertEquals(1.85, vhw.getSpeedKmh(), 0.01);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#getSpeedKnots()}.
*/
@Test
public void testGetSpeedKnots() {
assertEquals(1.0, vhw.getSpeedKnots(), 0.1);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.VHWParser#isTrue()}.
*/
@Test
public void testIsTrue() {
// should always return true
assertTrue(vhw.isTrue());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#setHeading(double)}.
*/
@Test
public void testSetHeading() {
vhw.setHeading(90.456);
assertEquals(90.5, vhw.getHeading(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#setMagneticHeading()}.
*/
@Test
public void testSetMagneticHeading() {
vhw.setMagneticHeading(123.4567);
assertEquals(123.5, vhw.getMagneticHeading(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#setSpeedKilometres()}.
*/
@Test
public void testSetSpeedKilometres() {
vhw.setSpeedKmh(5.5555);
assertEquals(5.6, vhw.getSpeedKmh(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VHWParser#setSpeedKnots()}.
*/
@Test
public void testSetSpeedKnots() {
vhw.setSpeedKnots(12.155);
assertEquals(12.2, vhw.getSpeedKnots(), 0.1);
}
}
@@ -0,0 +1,81 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.sentence.VLWSentence;
import org.junit.Before;
import org.junit.Test;
public class VLWTest {
public static final String EXAMPLE = "$VWVLW,2.8,N,0.8,N";
VLWSentence vlw;
VLWSentence empty;
@Before
public void setUp() throws Exception {
vlw = new VLWParser(EXAMPLE);
empty = new VLWParser(TalkerId.VD);
}
@Test
public void testVLWParserString() {
assertEquals(TalkerId.VW, vlw.getTalkerId());
assertEquals("VLW", vlw.getSentenceId());
assertEquals(4, vlw.getFieldCount());
}
@Test
public void testVLWParserTalkerId() {
assertEquals(TalkerId.VD, empty.getTalkerId());
assertEquals("VLW", empty.getSentenceId());
assertEquals(4, empty.getFieldCount());
}
@Test
public void testGetTotal() {
assertEquals(2.8, vlw.getTotal(), 0.1);
}
@Test
public void testGetTotalUnits() {
assertEquals('N', vlw.getTotalUnits());
}
@Test
public void testGetTrip() {
assertEquals(0.8, vlw.getTrip(), 0.1);
}
@Test
public void testGetTripUnits() {
assertEquals('N', vlw.getTripUnits());
}
@Test
public void testSetTotal() {
empty.setTotal(3.14);
assertEquals(3.1, empty.getTotal(), 0.1);
}
@Test
public void testSetTotalUnits() {
empty.setTotalUnits(VLWSentence.KM);
assertEquals(VLWSentence.KM, empty.getTotalUnits());
}
@Test
public void testSetTrip() {
empty.setTrip(0.0);
assertEquals(0.0, empty.getTrip(), 0.1);
}
@Test
public void testSetTripUnits() {
empty.setTripUnits(VLWSentence.NM);
assertEquals(VLWSentence.NM, empty.getTripUnits());
}
}
@@ -0,0 +1,248 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.sentence.VTGSentence;
import net.sf.marineapi.nmea.util.FaaMode;
import org.junit.Before;
import org.junit.Test;
/**
* Tests the VTG sentence parser.
*
* @author Kimmo Tuukkanen
*/
public class VTGTest {
/** Example sentence */
public static final String EXAMPLE = "$GPVTG,360.0,T,348.7,M,16.89,N,31.28,K,A";
private VTGSentence empty;
private VTGSentence vtg;
@Before
public void setUp() {
try {
empty = new VTGParser(TalkerId.GP);
vtg = new VTGParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(9, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#getMagneticCourse()}.
*/
@Test
public void testGetMagneticCourse() {
assertEquals(348.7, vtg.getMagneticCourse(), 0.001);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.VTGParser#getMode()}.
*/
@Test
public void testGetMode() {
assertEquals(FaaMode.AUTOMATIC, vtg.getMode());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#getSpeedKmh()}.
*/
@Test
public void testGetSpeedKmh() {
assertEquals(31.28, vtg.getSpeedKmh(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#getSpeedKnots()}.
*/
@Test
public void testGetSpeedKnots() {
assertEquals(16.89, vtg.getSpeedKnots(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#getTrueCourse()}.
*/
@Test
public void testGetTrueCourse() {
assertEquals(360.0, vtg.getTrueCourse(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setMagneticCourse(double)}.
*/
@Test
public void testSetMagneticCourse() {
final double mcog = 95.56789;
vtg.setMagneticCourse(mcog);
assertTrue(vtg.toString().contains(",095.6,M,"));
assertEquals(mcog, vtg.getMagneticCourse(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setMagneticCourse(double)}.
*/
@Test
public void testSetMagneticCourseWithNegativeValue() {
try {
vtg.setMagneticCourse(-0.001);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("0..360"));
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setMagneticCourse(double)}.
*/
@Test
public void testSetMagneticCourseWithValueGreaterThanAllowed() {
try {
vtg.setMagneticCourse(360.001);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("0..360"));
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setMode(FaaMode)}.
*/
@Test
public void testSetMode() {
vtg.setMode(FaaMode.MANUAL);
assertEquals(FaaMode.MANUAL, vtg.getMode());
vtg.setMode(FaaMode.SIMULATED);
assertEquals(FaaMode.SIMULATED, vtg.getMode());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setMode(FaaMode)}.
*/
@Test
public void testSetModeWhenOmitted() {
VTGParser parser = new VTGParser("$GPVTG,360.0,T,348.7,M,16.89,N,31.28,K");
parser.setMode(FaaMode.MANUAL);
assertEquals(FaaMode.MANUAL, parser.getMode());
parser.setMode(FaaMode.SIMULATED);
assertEquals(FaaMode.SIMULATED, parser.getMode());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setSpeedKmh(double)}.
*/
@Test
public void testSetSpeedKmh() {
final double kmh = 12.56789;
vtg.setSpeedKmh(kmh);
assertTrue(vtg.toString().contains(",12.57,K,"));
assertEquals(kmh, vtg.getSpeedKmh(), 0.01);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setSpeedKmh(double)}.
*/
@Test
public void testSetSpeedKmhWithNegativeValue() {
try {
vtg.setSpeedKmh(-0.0001);
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("cannot be negative"));
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setSpeedKnots(double)}.
*/
@Test
public void testSetSpeedKnots() {
final double kn = 11.6789;
vtg.setSpeedKnots(kn);
assertTrue(vtg.toString().contains(",11.68,N,"));
assertEquals(kn, vtg.getSpeedKnots(), 0.01);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setSpeedKnots(double)}.
*/
@Test
public void testSetSpeedKnotsWithNegativeValue() {
try {
vtg.setSpeedKnots(-0.0001);
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("cannot be negative"));
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setTrueCourse(double)}.
*/
@Test
public void testSetTrueCourse() {
final double tcog = 90.56789;
vtg.setTrueCourse(tcog);
assertTrue(vtg.toString().contains(",090.6,T,"));
assertEquals(tcog, vtg.getTrueCourse(), 0.1);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setTrueCourse(double)}.
*/
@Test
public void testSetTrueCourseWithNegativeValue() {
try {
vtg.setTrueCourse(-0.001);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("0..360"));
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.VTGParser#setTrueCourse(double)}.
*/
@Test
public void testSetTrueCourseWithValueGreaterThanAllowed() {
try {
vtg.setTrueCourse(360.001);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("0..360"));
} catch (Exception e) {
fail(e.getMessage());
}
}
}
@@ -0,0 +1,103 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.sentence.WPLSentence;
import net.sf.marineapi.nmea.util.CompassPoint;
import net.sf.marineapi.nmea.util.Waypoint;
import org.junit.Before;
import org.junit.Test;
/**
* WPLTest
*
* @author Kimmo Tuukkanen
*/
public class WPLTest {
/** Example sentence */
public static final String EXAMPLE = "$GPWPL,5536.200,N,01436.500,E,RUSKI*1F";
private WPLSentence empty;
private WPLSentence wpl;
@Before
public void setUp() {
try {
empty = new WPLParser(TalkerId.GP);
wpl = new WPLParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(5, empty.getFieldCount());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.WPLParser#getWaypoint()}.
*/
@Test
public void testGetWaypoint() {
final Double lat = new Double(55 + (36.200 / 60));
final Double lon = new Double(14 + (36.500 / 60));
Waypoint wp = wpl.getWaypoint();
assertNotNull(wp);
assertEquals("RUSKI", wp.getId());
assertEquals(CompassPoint.NORTH, wp.getLatitudeHemisphere());
assertEquals(CompassPoint.EAST, wp.getLongitudeHemisphere());
assertEquals(lat, new Double(wp.getLatitude()));
assertEquals(lon, new Double(wp.getLongitude()));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.WPLParser#setWaypoint(Waypoint)}.
*/
@Test
public void testSetWaypointWithNonZeroValues() {
final double lat = 60 + (11.552 / 60);
final double lon = 25 + (1.941 / 60);
Waypoint p2 = new Waypoint("WAYP2", lat, lon);
wpl.setWaypoint(p2);
String s2 = wpl.toString();
assertTrue(s2.contains(",6011.552,N,02501.941,E,WAYP2*"));
Waypoint p = wpl.getWaypoint();
assertNotNull(p);
assertEquals(lat, p.getLatitude(), 0.0000001);
assertEquals(lon, p.getLongitude(), 0.0000001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.WPLParser#setWaypoint(Waypoint)}.
*/
@Test
public void testSetWaypointWithZeroValues() {
Waypoint p1 = new Waypoint("WAYP1", 0.0, 0.0);
wpl.setWaypoint(p1);
String s1 = wpl.toString();
assertTrue(s1.contains(",0000.000,N,00000.000,E,WAYP1*"));
Waypoint p = wpl.getWaypoint();
assertNotNull(p);
assertEquals(0.0, p.getLatitude(), 0.0000001);
assertEquals(0.0, p.getLongitude(), 0.0000001);
}
}
@@ -0,0 +1,201 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.Measurement;
import org.junit.Test;
/**
* @author Kimmo Tuukkanen
*/
public class XDRTest {
public static final String EXAMPLE = "$IIXDR,P,1.02481,B,Barometer";
/**
* Test method for {@link net.sf.marineapi.nmea.parser.XDRParser#XDRParser(String)}.
*/
@Test
public void testConstructor() {
XDRParser xdr = new XDRParser(EXAMPLE);
assertTrue(xdr.isValid());
assertEquals("XDR", xdr.getSentenceId());
assertEquals(4, xdr.getFieldCount());
assertEquals('P', xdr.getCharValue(0));
assertEquals(1.02481, xdr.getDoubleValue(1), 0.00001);
assertEquals('B', xdr.getCharValue(2));
assertEquals("Barometer", xdr.getStringValue(3));
}
@Test
public void testConstructorWithThreeFields() {
XDRParser xdr = new XDRParser("$WIXDR,U,014.9,V,");
List<Measurement> ml = xdr.getMeasurements();
assertEquals(1, ml.size());
Measurement m = ml.get(0);
assertEquals("U", m.getType());
assertEquals(14.9, m.getValue(), 0.1);
assertEquals("V", m.getUnits());
assertNull(m.getName());
}
@Test
public void testConstructorWithMultipleMeasurements() {
XDRParser xdr = new XDRParser("$WIXDR,P,111.1,B,3,C,222.2,C,0,H,333.3,P,2,C,444.4,C,1");
List<Measurement> ml = xdr.getMeasurements();
assertEquals(4, ml.size());
Measurement m1 = ml.get(0);
assertEquals("P", m1.getType());
assertEquals(111.1, m1.getValue(), 0.1);
assertEquals("B", m1.getUnits());
assertEquals("3", m1.getName());
Measurement m2 = ml.get(1);
assertEquals("C", m2.getType());
assertEquals(222.2, m2.getValue(), 0.1);
assertEquals("C", m2.getUnits());
assertEquals("0", m2.getName());
Measurement m3 = ml.get(2);
assertEquals("H", m3.getType());
assertEquals(333.3, m3.getValue(), 0.1);
assertEquals("P", m3.getUnits());
assertEquals("2", m3.getName());
Measurement m4 = ml.get(3);
assertEquals("C", m4.getType());
assertEquals(444.4, m4.getValue(), 0.1);
assertEquals("C", m4.getUnits());
assertEquals("1", m4.getName());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.XDRParser#addMeasurement(Measurement...))}.
*/
@Test
public void testAddAnotherMeasurement() {
XDRParser xdr = new XDRParser(EXAMPLE);
Measurement value = new Measurement("C", 19.9, "C", "TempAir");
xdr.addMeasurement(value);
assertEquals(8, xdr.getFieldCount());
assertTrue(xdr.toString().startsWith("$IIXDR,P,1.02481,B,Barometer,C,19.9,C,TempAir*"));
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.XDRParser#addMeasurement(Measurement...))}.
*/
@Test
public void testAddMeasurementToEmpty() {
XDRParser xdr = new XDRParser(TalkerId.II);
Measurement value = new Measurement("C", 19.9, "C", "TempAir");
xdr.addMeasurement(value);
assertEquals(4, xdr.getFieldCount());
assertTrue(xdr.toString().startsWith("$IIXDR,C,19.9,C,TempAir*"));
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.XDRParser#addMeasurement(Measurement...))))}.
*/
@Test
public void testAddMultipleMeasurements() {
XDRParser xdr = new XDRParser(TalkerId.II);
Measurement m1 = new Measurement("C", 19.9, "C", "TempAir");
Measurement m2 = new Measurement("P", 1.08, "B", "Barometer");
xdr.addMeasurement(m1, m2);
assertEquals(8, xdr.getFieldCount());
assertTrue(xdr.toString().startsWith("$IIXDR,C,19.9,C,TempAir,P,1.08,B,Barometer*"));
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.XDRParser#getMeasurements()}.
*/
@Test
public void testGetMeasurements() {
XDRParser xdr = new XDRParser(EXAMPLE);
List<Measurement> values = xdr.getMeasurements();
assertEquals(1, values.size());
Measurement value = values.get(0);
assertEquals("P", value.getType());
assertEquals(1.02481, value.getValue(), 0.00001);
assertEquals("B", value.getUnits());
assertEquals("Barometer", value.getName());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.XDRParser#setMeasurement(java.util.List)}.
*/
@Test
public void testSetMeasurement() {
XDRParser xdr = new XDRParser(TalkerId.II);
Measurement value = new Measurement("C", 19.9, "C", "TempAir");
xdr.setMeasurement(value);
assertEquals(4, xdr.getFieldCount());
assertTrue(xdr.toString().startsWith("$IIXDR,C,19.9,C,TempAir*"));
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.XDRParser#setMeasurements(java.util.List)}.
*/
@Test
public void testSetMeasurementAsList() {
XDRParser xdr = new XDRParser(TalkerId.II);
Measurement value = new Measurement("C", 19.9, "C", "TempAir");
List<Measurement> values = new ArrayList<Measurement>();
values.add(value);
xdr.setMeasurements(values);
assertEquals(4, xdr.getFieldCount());
assertTrue(xdr.toString().startsWith("$IIXDR,C,19.9,C,TempAir*"));
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.XDRParser#setMeasurements(java.util.List)}.
*/
@Test
public void testSetMeasurementsList() {
XDRParser xdr = new XDRParser(TalkerId.II);
Measurement v1 = new Measurement("C", 19.9, "C", "TempAir");
Measurement v2 = new Measurement("P", 1.08, "B", "Barometer");
List<Measurement> values = new ArrayList<Measurement>();
values.add(v1);
values.add(v2);
xdr.setMeasurements(values);
assertEquals(8, xdr.getFieldCount());
assertTrue(xdr.toString().startsWith("$IIXDR,C,19.9,C,TempAir,P,1.08,B,Barometer*"));
}
}
@@ -0,0 +1,100 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.sf.marineapi.nmea.sentence.SentenceId;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.sentence.XTESentence;
import net.sf.marineapi.nmea.util.DataStatus;
import net.sf.marineapi.nmea.util.Direction;
import net.sf.marineapi.nmea.util.FaaMode;
import org.junit.Before;
import org.junit.Test;
public class XTETest {
public static final String EXAMPLE = "$IIXTE,A,A,5.36,R,N*67";
private XTESentence empty;
private XTESentence instance;
@Before
public void setUp() throws Exception {
instance = new XTEParser(EXAMPLE);
empty = new XTEParser(TalkerId.GP);
}
@Test
public void testXTEParserString() {
assertEquals(TalkerId.II, instance.getTalkerId());
assertEquals(SentenceId.XTE.name(), instance.getSentenceId());
assertEquals(6, instance.getFieldCount());
assertTrue(instance.isValid());
}
@Test
public void testXTEParserTalkerId() {
assertEquals(TalkerId.GP, empty.getTalkerId());
assertEquals(SentenceId.XTE.name(), empty.getSentenceId());
assertEquals(6, empty.getFieldCount());
assertTrue(empty.isValid());
}
@Test
public void testGetCycleLockStatus() {
assertEquals(DataStatus.ACTIVE, instance.getCycleLockStatus());
}
@Test
public void testGetMagnitude() {
assertEquals(5.36, instance.getMagnitude(), 0.001);
}
@Test
public void testGetMode() {
assertEquals(FaaMode.NONE, empty.getMode());
}
@Test
public void testGetStatus() {
assertEquals(DataStatus.VOID, empty.getStatus());
}
@Test
public void testGetSteerTo() {
assertEquals(Direction.RIGHT, instance.getSteerTo());
}
@Test
public void testSetCycleLockStatus() {
instance.setCycleLockStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, instance.getCycleLockStatus());
}
@Test
public void testSetMagnitude() {
final double distance = 1.234;
empty.setMagnitude(1.234);
assertEquals(distance, empty.getMagnitude(), 0.01);
}
@Test
public void testSetMode() {
instance.setMode(FaaMode.DGPS);
assertEquals(FaaMode.DGPS, instance.getMode());
}
@Test
public void testSetStatus() {
instance.setStatus(DataStatus.VOID);
assertEquals(DataStatus.VOID, instance.getStatus());
}
@Test
public void testSetSteerTo() {
instance.setSteerTo(Direction.LEFT);
assertEquals(Direction.LEFT, instance.getSteerTo());
}
}
@@ -0,0 +1,197 @@
package net.sf.marineapi.nmea.parser;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Calendar;
import java.util.GregorianCalendar;
import net.sf.marineapi.nmea.sentence.TalkerId;
import net.sf.marineapi.nmea.util.Date;
import net.sf.marineapi.nmea.util.Time;
import org.junit.Before;
import org.junit.Test;
/**
* Tests the ZDA sentence parser.
*
* @author Kimmo Tuukkanen
*/
public class ZDATest {
/** Example sentence */
public static final String EXAMPLE = "$GPZDA,032915,07,08,2004,00,00*4D";
private ZDAParser empty;
private ZDAParser zda;
@Before
public void setUp() {
try {
empty = new ZDAParser(TalkerId.GP);
zda = new ZDAParser(EXAMPLE);
} catch (Exception e) {
fail(e.getMessage());
}
}
@Test
public void testConstructor() {
assertEquals(6, empty.getFieldCount());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#getDate()}.
*/
@Test
public void testGetDate() {
Date expected = new Date(2004, 8, 7);
Date parsed = zda.getDate();
assertEquals(expected, parsed);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#getDay()}.
*/
@Test
public void testGetDay() {
assertEquals(7, zda.getDate().getDay());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.ZDAParser#getLocalZoneHours()}.
*/
@Test
public void testGetLocalZoneHours() {
assertEquals(0, zda.getLocalZoneHours());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.ZDAParser#setLocalZoneHours()}.
*/
@Test
public void testSetLocalZoneHours() {
final int hours = 7;
zda.setLocalZoneHours(hours);
assertTrue(zda.toString().contains(",2004,07,00*"));
assertEquals(hours, zda.getLocalZoneHours());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.ZDAParser#getLocalZoneMinutes()}.
*/
@Test
public void testGetLocalZoneMinutes() {
assertEquals(0, zda.getLocalZoneMinutes());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.ZDAParser#setLocalZoneMinutes()}.
*/
@Test
public void testSetLocalZoneMinutes() {
final int min = 9;
zda.setLocalZoneMinutes(min);
assertTrue(zda.toString().contains(",2004,00,09*"));
assertEquals(min, zda.getLocalZoneMinutes());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#getMonth()}
* .
*/
@Test
public void testGetMonth() {
assertEquals(8, zda.getDate().getMonth());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#getTime()}.
*/
@Test
public void testGetTime() {
Time t = zda.getTime();
assertNotNull(t);
assertEquals(3, t.getHour());
assertEquals(29, t.getMinutes());
assertEquals(15.0, t.getSeconds(), 0.1);
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#getYear()}.
*/
@Test
public void testGetYear() {
assertEquals(2004, zda.getDate().getYear());
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#getTime()}.
*/
@Test
public void testSetDate() {
zda.setDate(new Date(10, 6, 9));
assertTrue(zda.toString().contains(",032915,09,06,2010,00,"));
zda.setDate(new Date(85, 12, 11));
assertTrue(zda.toString().contains(",032915,11,12,1985,00,"));
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#setTime()}.
*/
@Test
public void testSetTime() {
// 09:08:07.6
Time t = new Time(9, 8, 7.6);
zda.setTime(t);
assertTrue(zda.toString().startsWith("$GPZDA,090807.600,07,"));
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#setTimeAndLocalZone()}.
*/
@Test
public void testSetTimeAndLocalZone() {
// 09:08:07.6+01:02
Time t = new Time(9, 8, 7.6, 1, 2);
zda.setTimeAndLocalZone(t);
assertEquals(1, zda.getLocalZoneHours());
assertEquals(2, zda.getLocalZoneMinutes());
assertTrue(zda.toString().startsWith("$GPZDA,090807.600,07,"));
assertTrue(zda.toString().contains("2004,01,02*"));
}
/**
* Test method for {@link net.sf.marineapi.nmea.parser.ZDAParser#toDate()}.
*/
@Test
public void testToDate() {
Date d = new Date(2010, 6, 15);
Time t = new Time(12, 15, 30.246, 2, 0);
zda.setDate(d);
zda.setTime(t);
GregorianCalendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, 2010);
cal.set(Calendar.MONTH, 5);
cal.set(Calendar.DAY_OF_MONTH, 15);
cal.set(Calendar.HOUR_OF_DAY, 12);
cal.set(Calendar.MINUTE, 15);
cal.set(Calendar.SECOND, 30);
cal.set(Calendar.MILLISECOND, 246);
java.util.Date result = zda.toDate();
java.util.Date expected = cal.getTime();
assertEquals(expected, result);
assertEquals(expected.getTime(), result.getTime());
}
}
@@ -0,0 +1,363 @@
/*
* DateTest.java
* Copyright (C) 2010 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Calendar;
import java.util.GregorianCalendar;
import org.junit.Before;
import org.junit.Test;
/**
* @author Kimmo Tuukkanen
*/
public class DateTest {
private Date instance;
private GregorianCalendar cal;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
instance = new Date();
cal = new GregorianCalendar();
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#Date()}.
*/
@Test
public void testConstructor() {
assertEquals(cal.get(Calendar.YEAR), instance.getYear());
assertEquals(cal.get(Calendar.MONTH) + 1, instance.getMonth());
assertEquals(cal.get(Calendar.DAY_OF_MONTH), instance.getDay());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Date#Date(int, int, int)}.
*/
@Test
public void testConstructorWithValues() {
Date d = new Date(2010, 6, 15);
assertEquals(2010, d.getYear());
assertEquals(6, d.getMonth());
assertEquals(15, d.getDay());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Date#Date(String)}.
*/
@Test
public void testConstructorWithString() {
Date d = new Date("150610");
assertEquals(2010, d.getYear());
assertEquals(6, d.getMonth());
assertEquals(15, d.getDay());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Date#equals(java.lang.Object)}.
*/
@Test
public void testEqualsAfterInit() {
Date d = new Date();
assertTrue(d.equals(instance));
Date one = new Date(2010, 6, 15);
Date two = new Date(2010, 6, 15);
assertTrue(one.equals(two));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Date#equals(java.lang.Object)}.
*/
@Test
public void testEqualsItself() {
assertTrue(instance.equals(instance));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Date#equals(java.lang.Object)}.
*/
@Test
public void testEqualsWhenChanged() {
final int y = 2011;
final int m = 6;
final int d = 15;
final Date a = new Date(y, m, d);
final Date b = new Date(y, m, d);
a.setDay(b.getDay() - 1);
assertFalse(a.equals(b));
b.setDay(a.getDay());
assertTrue(a.equals(b));
a.setMonth(b.getMonth() - 1);
assertFalse(a.equals(b));
b.setMonth(a.getMonth());
assertTrue(a.equals(b));
a.setYear(b.getYear() - 1);
assertFalse(a.equals(b));
b.setYear(a.getYear());
assertTrue(a.equals(b));
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Date#equals(java.lang.Object)}.
*/
@Test
public void testEqualsWrongType() {
Object str = new String("foobar");
Object dbl = new Double(123);
assertFalse(instance.equals(str));
assertFalse(instance.equals(dbl));
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#getDay()}.
*/
@Test
public void testGetDay() {
assertEquals(cal.get(Calendar.DAY_OF_MONTH), instance.getDay());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#getMonth()}.
*/
@Test
public void testGetMonth() {
assertEquals(cal.get(Calendar.MONTH) + 1, instance.getMonth());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#getYear()}.
*/
@Test
public void testGetYear() {
assertEquals(cal.get(Calendar.YEAR), instance.getYear());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#setDay(int)}.
*/
@Test
public void testSetDay() {
final int day = 10;
instance.setDay(day);
assertEquals(day, instance.getDay());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#setDay(int)}.
*/
@Test
public void testSetDayOutOfBounds() {
int day = 0;
try {
instance.setDay(day);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
day = 32;
try {
instance.setDay(day);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#setMonth(int)}.
*/
@Test
public void testSetMonth() {
final int month = 10;
instance.setMonth(month);
assertEquals(month, instance.getMonth());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#setMonth(int)}.
*/
@Test
public void testSetMonthOutOfBounds() {
int month = 0;
try {
instance.setMonth(month);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
month = 32;
try {
instance.setMonth(month);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#setYear(int)}.
*/
@Test
public void testSetYearFiveDigits() {
try {
instance.setYear(10000);
fail("Did not throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#setYear(int)}.
*/
@Test
public void testSetYearFourDigit() {
for (int year = 1000; year < 10000; year++) {
instance.setYear(year);
assertEquals(year, instance.getYear());
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#setYear(int)}.
*/
@Test
public void testSetYearNegative() {
try {
instance.setYear(-1);
fail("Did not throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#setYear(int)}.
*/
@Test
public void testSetYearThreeDigits() {
try {
instance.setYear(100);
fail("Did not throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// pass
}
try {
instance.setYear(999);
fail("Did not throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Date#setYear(int)}.
*/
@Test
public void testSetYearTwoDigit() {
int century = 2000;
for (int year = 0; year < 100; year++) {
instance.setYear(year);
assertEquals((century + year), instance.getYear());
if (year == Date.PIVOT_YEAR) {
century = 1900;
}
}
}
@Test
public void testToStringTwoDigitYear() {
Date d = new Date(13, 9, 2);
assertEquals("020913", d.toString());
}
@Test
public void testToStringFourDigitYear() {
Date d = new Date(2013, 9, 2);
assertEquals("020913", d.toString());
}
@Test
public void testToISO8601TwoDigitYear() {
Date d = new Date(13, 9, 2);
assertEquals("2013-09-02", d.toISO8601());
}
@Test
public void testToISO8601FourDigitYear() {
Date d = new Date(2013, 9, 2);
assertEquals("2013-09-02", d.toISO8601());
}
@Test
public void testToISO8601WithTime() {
Date d = new Date(2013, 9, 2);
Time t = new Time(2, 7, 9);
assertEquals("2013-09-02T02:07:09+00:00", d.toISO8601(t));
}
@Test
public void testToISO8601WithTimeAndZeroZone() {
Date d = new Date(2013, 9, 2);
Time t = new Time(2, 7, 9, 0, 0);
assertEquals("2013-09-02T02:07:09+00:00", d.toISO8601(t));
}
@Test
public void testToISO8601WithTimeAndPositiveOffset() {
Date d = new Date(2013, 9, 2);
Time t = new Time(2, 7, 9, 2, 0);
assertEquals("2013-09-02T02:07:09+02:00", d.toISO8601(t));
}
@Test
public void testToISO8601WithTimeAndNegativeOffset() {
Date d = new Date(2013, 9, 2);
Time t = new Time(2, 7, 9, -2, 5);
assertEquals("2013-09-02T02:07:09-02:05", d.toISO8601(t));
}
}
@@ -0,0 +1,209 @@
package net.sf.marineapi.nmea.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.Test;
public class PositionTest {
Position instance;
/**
* Setup
*/
@Before
public void setUp() {
instance = new Position(60.0, 25.0, Datum.WGS84);
}
/**
* Test for distanceTo()
*/
@Test
public void testDistanceTo() {
// TODO: not exactly correct as 1 degree is *approximately* 60 NM
Position origin = new Position(0.123, 25.0);
for (int n = 0; n < 90; n++) {
// 1 degree north from instance's position
Position destination = new Position(0.123 + n, 25.0);
double distance = origin.distanceTo(destination);
// one degree equals 60 NM
double expected = (60 * n * 1852.0);
assertEquals(expected, distance, 1.0);
}
}
/**
* Test for distanceTo()
*/
@Test
public void testDistanceToSelf() {
Position origin = new Position(60.567, 26.123);
assertEquals(0.0, origin.distanceTo(origin), 0.00001);
}
/**
* Test for getDatum()
*/
@Test
public void testGetDatum() {
assertEquals(Datum.WGS84, instance.getDatum());
}
/**
* Test for getLatitude()
*/
@Test
public void testGetLatitude() {
assertEquals(60.0, instance.getLatitude(), 0.0000001);
}
/**
* Test for getLatHemisphere()
*/
@Test
public void testGetLatitudeHemisphere() {
assertEquals(CompassPoint.NORTH, instance.getLatitudeHemisphere());
}
/**
* Test for getLongitude()
*/
@Test
public void testGetLongitude() {
assertEquals(25.0, instance.getLongitude(), 0.0000001);
}
/**
* Test for getLonHemisphere()
*/
@Test
public void testGetLongitudeHemisphere() {
assertEquals(CompassPoint.EAST, instance.getLongitudeHemisphere());
}
/**
* Test for setLatitude()
*/
@Test
public void testSetIllegalLatitudeNorth() {
try {
instance.setLatitude(90.001);
fail("Did not throw IllegalArgumentExcetpion");
} catch (IllegalArgumentException e) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test for setLatitude()
*/
@Test
public void testSetIllegalLatitudeSouth() {
try {
instance.setLatitude(-90.001);
fail("Did not throw IllegalArgumentExcetpion");
} catch (IllegalArgumentException e) {
// pass
} catch (Exception e) {
fail(e.getMessage());
}
}
/**
* Test for setLongitude()
*/
@Test
public void testSetIllegalLongitudeEast() {
try {
instance.setLongitude(180.0001);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test for setLongitude()
*/
@Test
public void testSetIllegalLongitudeWest() {
try {
instance.setLongitude(-180.0001);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test for setLatitude()
*/
@Test
public void testSetLatitudeNorth() {
assertEquals(60.0, instance.getLatitude(), 0.0000001);
instance.setLatitude(90.0);
assertEquals(90.0, instance.getLatitude(), 0.0000001);
assertEquals(CompassPoint.NORTH, instance.getLatitudeHemisphere());
}
/**
* Test for setLatitude()
*/
@Test
public void testSetLatitudeSouth() {
assertEquals(60.0, instance.getLatitude(), 0.0000001);
instance.setLatitude(-90.0);
assertEquals(-90.0, instance.getLatitude(), 0.0000001);
assertEquals(CompassPoint.SOUTH, instance.getLatitudeHemisphere());
}
/**
* Test for setLongitude()
*/
@Test
public void testSetLongitudeEast() {
assertEquals(25.0, instance.getLongitude(), 0.0000001);
instance.setLongitude(180.0);
assertEquals(180, instance.getLongitude(), 0.0000001);
assertEquals(CompassPoint.EAST, instance.getLongitudeHemisphere());
}
/**
* Test for setLongitude()
*/
@Test
public void testSetLongitudeWest() {
assertEquals(25.0, instance.getLongitude(), 0.0000001);
instance.setLongitude(-180.0);
assertEquals(-180, instance.getLongitude(), 0.0000001);
assertEquals(CompassPoint.WEST, instance.getLongitudeHemisphere());
}
/**
* Test for toWaypoint()
*/
@Test
public void testToWaypoint() {
final String name = "TEST";
final Waypoint wp = instance.toWaypoint(name);
assertEquals(name, wp.getId());
assertEquals("", wp.getDescription());
assertEquals(instance.getLatitude(), wp.getLatitude(), 0.00001);
assertEquals(instance.getLongitude(), wp.getLongitude(), 0.00001);
assertEquals(instance.getLatitudeHemisphere(), wp.getLatitudeHemisphere());
assertEquals(instance.getLongitudeHemisphere(), wp.getLongitudeHemisphere());
assertEquals(instance.getDatum(), wp.getDatum());
}
}
@@ -0,0 +1,355 @@
/*
* TimeTest.java
* Copyright (C) 2010 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import org.junit.Before;
import org.junit.Test;
/**
* @author Kimmo Tuukkanen
*/
public class TimeTest {
private Time time;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
time = new Time(1, 2, 3.4, 0, 0);
}
/**
* Test method for setTime() and toDate() round-trip.
*/
@Test
public void testDateRoundTrip() {
Date now = new Date();
time.setTime(now);
Date result = time.toDate(now);
assertEquals(now, result);
assertEquals(now.getTime(), result.getTime());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Time#toString(net.sf.marineapi.nmea.util.Time)}
* .
*/
@Test
public void testFormatTimeNoDecimals() {
Time t = new Time(1, 2, 3);
assertEquals("010203.000", t.toString());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Time#toString(net.sf.marineapi.nmea.util.Time)}
* .
*/
@Test
public void testFormatTimeWithDecimals() {
Time t = new Time(1, 2, 3.456);
assertEquals("010203.456", t.toString());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Time#toString(net.sf.marineapi.nmea.util.Time)}
* .
*/
@Test
public void testFormatTimeWithOneDecimal() {
Time t = new Time(1, 2, 3.4);
assertEquals("010203.400", t.toString());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#getHour()}.
*/
@Test
public void testGetHour() {
assertEquals(1, time.getHour());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#getMilliseconds()}
* .
*/
@Test
public void testGetMilliseconds() {
time.setHour(12);
time.setMinutes(1);
time.setSeconds(1.0);
assertEquals(43261000, time.getMilliseconds());
time.setHour(18);
time.setMinutes(1);
time.setSeconds(1.123);
assertEquals(64861123, time.getMilliseconds());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#getMinutes()}.
*/
@Test
public void testGetMinutes() {
assertEquals(2, time.getMinutes());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#getSeconds()}.
*/
@Test
public void testGetSeconds() {
assertEquals(3.4, time.getSeconds(), 0.001);
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time(java.lang.String)}
* .
*/
@Test
public void testParseTimeWithDecimals() {
Time t = new Time("010203.456");
assertEquals(1, t.getHour());
assertEquals(2, t.getMinutes());
assertEquals(3.456, t.getSeconds(), 0.001);
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time(java.lang.String)}
* .
*/
@Test
public void testParseTimeWithOneDecimal() {
Time t = new Time("010203.4");
assertEquals(1, t.getHour());
assertEquals(2, t.getMinutes());
assertEquals(3.4, t.getSeconds(), 0.001);
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time(java.lang.String)}
* .
*/
@Test
public void testParseTimeWithoutDecimals() {
Time t = new Time("010203");
assertEquals(1, t.getHour());
assertEquals(2, t.getMinutes());
assertEquals(3.0, t.getSeconds(), 0.001);
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#setHour(int)}.
*/
@Test
public void testSetHour() {
time.setHour(12);
assertEquals(12, time.getHour());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#setHour(int)}.
*/
@Test
public void testSetInvalidHour() {
try {
time.setHour(60);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#setMinutes(int)}.
*/
@Test
public void testSetInvalidMinutes() {
try {
time.setMinutes(60);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Time#setSeconds(double)}.
*/
@Test
public void testSetInvalidSeconds() {
try {
time.setSeconds(60.0);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#setMinutes(int)}.
*/
@Test
public void testSetMinutes() {
time.setMinutes(30);
assertEquals(30, time.getMinutes());
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#setHour(int)}.
*/
@Test
public void testSetNegativeHour() {
try {
time.setHour(-1);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#setMinutes(int)}.
*/
@Test
public void testSetNegativeMinutes() {
try {
time.setMinutes(-1);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Time#setSeconds(double)}.
*/
@Test
public void testSetNegativeSeconds() {
try {
time.setSeconds(-0.001);
fail("Did not throw exception");
} catch (IllegalArgumentException e) {
// pass
}
}
/**
* Test method for {@link net.sf.marineapi.nmea.util.Time#setSeconds(int)}.
*/
@Test
public void testSetSeconds() {
time.setSeconds(45.12345);
assertEquals(45.12345, time.getSeconds(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Time#setTime(java.util.Date)}.
*/
@Test
public void testSetTime() {
Date now = new Date();
time.setTime(now);
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(now);
int hours = cal.get(Calendar.HOUR_OF_DAY);
int minutes = cal.get(Calendar.MINUTE);
int fullSeconds = cal.get(Calendar.SECOND);
int milliSeconds = cal.get(Calendar.MILLISECOND);
double seconds = fullSeconds + (milliSeconds / 1000.0);
assertEquals(hours, time.getHour());
assertEquals(minutes, time.getMinutes());
assertEquals(seconds, time.getSeconds(), 0.001);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Time#toDate(java.util.Date)}.
*/
@Test
public void testToDate() {
Calendar cal = new GregorianCalendar();
Calendar result = new GregorianCalendar();
// set cal to reference date/time (date portion not significant)
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 3);
cal.set(Calendar.MILLISECOND, 400);
// convert Time to Date and insert to result Calendar for comparison
Date d = time.toDate(cal.getTime());
result.setTime(d);
int resultHour = result.get(Calendar.HOUR_OF_DAY);
int resultMinute = result.get(Calendar.MINUTE);
int resultFullSeconds = result.get(Calendar.SECOND);
int resultMilliseconds = result.get(Calendar.MILLISECOND);
double resultSeconds = resultFullSeconds + (resultMilliseconds / 1000.0);
// Time portion, should match values in Time exactly
assertEquals(time.getHour(), resultHour);
assertEquals(time.getMinutes(), resultMinute);
assertEquals(time.getSeconds(), resultSeconds, 0.001);
// Date portion should not have changed
assertEquals(cal.get(Calendar.YEAR), result.get(Calendar.YEAR));
assertEquals(cal.get(Calendar.MONTH), result.get(Calendar.MONTH));
assertEquals(cal.get(Calendar.DAY_OF_YEAR),
result.get(Calendar.DAY_OF_YEAR));
}
@Test
public void testEquals() {
Time a = new Time(1, 2, 3.456);
Time b = new Time(1, 2, 3.456);
Time c = new Time(2, 3, 4.567);
assertTrue(a.equals(a));
assertTrue(a.equals(b));
assertFalse(a.equals(c));
assertFalse(a.equals(new Object()));
assertEquals(a.hashCode(), b.hashCode());
}
}
@@ -0,0 +1,68 @@
/*
* WaypointTest.java
* Copyright 2010 Kimmo Tuukkanen
*
* This file is part of Java Marine API.
* <http://ktuukkan.github.io/marine-api/>
*
* Java Marine API is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* Java Marine API is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Java Marine API. If not, see <http://www.gnu.org/licenses/>.
*/
package net.sf.marineapi.nmea.util;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
/**
* WaypointTest
*
* @author Kimmo Tuukkanen
*/
public class WaypointTest {
private final String id1 = "FOO";
private final String id2 = "BAR";
private final String desc = "Description text";
Waypoint point;
@Before
public void setUp() {
point = new Waypoint(id1, 60.0, 25.0, Datum.WGS84);
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Waypoint#setDescription(java.lang.String)}
* .
*/
@Test
public void testDescription() {
assertEquals("", point.getDescription());
point.setDescription(desc);
assertEquals(desc, point.getDescription());
}
/**
* Test method for
* {@link net.sf.marineapi.nmea.util.Waypoint#setId(java.lang.String)}.
*/
@Test
public void testId() {
assertEquals(id1, point.getId());
point.setId(id2);
assertEquals(id2, point.getId());
}
}