Issue #2208 moving ncep unit tests to tests project
Change-Id: I723edf8936970d57108796ca1bc775b93e5e2507 Former-commit-id:838554cf98
[formerly b027914534dc808a616e2b5b2ee55ed3dd304b2e] Former-commit-id:d7be59a97e
This commit is contained in:
parent
fd38b63609
commit
43f8386f7c
121 changed files with 3201 additions and 3173 deletions
|
@ -12,7 +12,6 @@ Import-Package: com.raytheon.uf.edex.decodertools.core,
|
|||
com.raytheon.uf.edex.decodertools.time,
|
||||
com.raytheon.uf.edex.wmo.message,
|
||||
gov.noaa.nws.ncep.edex.common.dao,
|
||||
org.junit,
|
||||
org.osgi.framework
|
||||
Export-Package: gov.noaa.nws.ncep.common.dataplugin.aww,
|
||||
gov.noaa.nws.ncep.common.dataplugin.aww.dao
|
||||
|
|
|
@ -13,5 +13,4 @@ Export-Package: gov.noaa.nws.ncep.common.dataplugin.ncscat,
|
|||
Bundle-Vendor: AWIPS II migration
|
||||
Import-Package: com.raytheon.uf.edex.decodertools.core,
|
||||
com.raytheon.uf.edex.decodertools.time,
|
||||
com.raytheon.uf.edex.wmo.message,
|
||||
org.junit
|
||||
com.raytheon.uf.edex.wmo.message
|
||||
|
|
|
@ -13,5 +13,4 @@ Export-Package: gov.noaa.nws.ncep.common.dataplugin.ntrans,
|
|||
Bundle-Vendor: AWIPS II migration
|
||||
Import-Package: com.raytheon.uf.edex.decodertools.core,
|
||||
com.raytheon.uf.edex.decodertools.time,
|
||||
com.raytheon.uf.edex.wmo.message,
|
||||
org.junit
|
||||
com.raytheon.uf.edex.wmo.message
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -15,5 +15,4 @@ Require-Bundle: gov.noaa.nws.ncep.common.dataplugin.airmet;bundle-version="1.0.0
|
|||
javax.persistence,
|
||||
javax.measure
|
||||
Import-Package: org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the AIRMET decoder separator.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 05/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.airmet.decoder;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
|
||||
public class AirmetSeparatorTest {
|
||||
AirmetSeparator sep;
|
||||
char[] cbuf;
|
||||
int ntime = 0;
|
||||
StringBuffer contents = new StringBuffer();
|
||||
byte[] actual = null;
|
||||
|
||||
@Before
|
||||
public void initialize () {
|
||||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new AirmetSeparator();
|
||||
File file = new File ("unit-test/gov/noaa/nws/ncep/edex/plugin/airmet/decoder/2009051211.airm");
|
||||
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String text = null;
|
||||
|
||||
/*
|
||||
* Repeat until all lines is read. Add control characters.
|
||||
*/
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if ( text.length() != 0 ) {
|
||||
contents.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("File is not found");
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
sep = new AirmetSeparator();
|
||||
actual = contents.toString().getBytes();
|
||||
sep.setData(actual, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
assertTrue("Find AWW separator! ", sep.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecord() {
|
||||
byte[] expected = sep.next();
|
||||
String a = new String (actual);
|
||||
String e = new String (expected);
|
||||
String b = a.substring(0);
|
||||
assertEquals(e.trim(),b.trim());
|
||||
}
|
||||
}
|
|
@ -1,336 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the airmet parser.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 05/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.airmet.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.airmet.AirmetLocation;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.airmet.AirmetRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.airmet.AirmetReport;
|
||||
import gov.noaa.nws.ncep.edex.plugin.airmet.util.AirmetParser;
|
||||
import gov.noaa.nws.ncep.edex.util.UtilN;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.raytheon.edex.plugin.AbstractDecoder;
|
||||
import com.raytheon.edex.util.Util;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.Calendar;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class AirmetParserTest extends AbstractDecoder {
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
|
||||
final String wmoHeader = "WAUS45";
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
AirmetRecord record = null;
|
||||
|
||||
record = AirmetParser.processWMO(testBull, null);
|
||||
String wmo=record.getWmoHeader();
|
||||
assertEquals(wmo, wmoHeader);
|
||||
|
||||
final String issueString = "121112";
|
||||
|
||||
Calendar timeGroup = null;
|
||||
try {
|
||||
timeGroup = Util.findCurrentTime(issueString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get issue time");
|
||||
}
|
||||
Calendar issueTime=record.getIssueTime();
|
||||
System.out.println("======= This is the issue date:");
|
||||
System.out.println("issue date:year= " + timeGroup.get(Calendar.YEAR) );
|
||||
System.out.println("issue date:month= " + timeGroup.get(Calendar.MONTH) );
|
||||
System.out.println("issue date:day= " + timeGroup.get(Calendar.DAY_OF_MONTH) );
|
||||
System.out.println("issue date:hour= " + timeGroup.get(Calendar.HOUR) );
|
||||
System.out.println("issue date:minute= " + timeGroup.get(Calendar.MINUTE) );
|
||||
|
||||
assertEquals(timeGroup, issueTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetReportType() {
|
||||
|
||||
final String reportType = "SIERRA";
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
String retType = AirmetParser.getReportName(testBull);
|
||||
|
||||
assertEquals(reportType, retType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUpdateNumber() {
|
||||
|
||||
final Integer updateNumber = 2;
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
Integer retUpdate = AirmetParser.getUpdateNumber(testBull);
|
||||
|
||||
assertEquals(updateNumber, retUpdate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCorrectionFlag() {
|
||||
|
||||
final Integer correctionFlag = 2;
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
Integer retCorrection = AirmetParser.getCorrectionFlag(testBull);
|
||||
|
||||
assertEquals(correctionFlag, retCorrection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCancelFlag() {
|
||||
|
||||
final Integer cancelFlag = 1;
|
||||
final String testReport = "AIRMET MTN OBSCN...CO NM...UPDT\n\n\r" +
|
||||
"FROM TBE TO CME TO 60W INK TO 50E ELP TO 50W CME TO 50ESE ABQ TO\n\n\r" +
|
||||
"30SSW ALS TO TBE\n\n\r" +
|
||||
"CANCEL AIRMET. CONDS HV ENDED.\n\n\r";
|
||||
|
||||
Integer retCancel = AirmetParser.getCancelFlag(testReport);
|
||||
|
||||
assertEquals(cancelFlag, retCancel);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetClassType() {
|
||||
|
||||
final String hazardType = "INSTRUMENT FLIGHT RULES";
|
||||
final String testReport = "AIRMET IFR...CO NM\n\n\r" +
|
||||
"FROM TBE TO CME TO 60W INK TO 50E ELP TO 50W CME TO 50ESE ABQ TO\n\n\r" +
|
||||
"30SSW ALS TO TBE\n\n\r" +
|
||||
"CIG BLW 010/VIS BLW 3SM BR. CONDS CONTG BYD 15Z ENDG 15-18Z.\n\n\r";
|
||||
|
||||
String retType = AirmetParser.getHazardType(testReport);
|
||||
|
||||
assertEquals(hazardType, retType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRegion() {
|
||||
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
AirmetRecord record = null;
|
||||
|
||||
record = AirmetParser.processWMO(testBull, null);
|
||||
|
||||
String retRegion = AirmetParser.getRegion("SIERRA");
|
||||
|
||||
assertEquals("S", retRegion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStartTime() {
|
||||
|
||||
final String timeString ="121112";
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
Calendar startTime = null;
|
||||
|
||||
try {
|
||||
startTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get start time");
|
||||
}
|
||||
Calendar retStart = AirmetParser.getStartTime(testBull, null);
|
||||
assertEquals(startTime, retStart);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEndTime() {
|
||||
|
||||
final String timeString ="121500";
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
Calendar endTime = null;
|
||||
|
||||
try {
|
||||
endTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get end time");
|
||||
}
|
||||
Calendar retEnd = AirmetParser.getEndTime(testBull, null);
|
||||
assertEquals(endTime, retEnd);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetValidDay() {
|
||||
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
String validDay = "12";
|
||||
String retDay = AirmetParser.getValidDay(testBull);
|
||||
|
||||
assertEquals(validDay, retDay);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessSequenceID() {
|
||||
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
Integer series = 1;
|
||||
final String sequenceID = "SLC21";
|
||||
|
||||
String idRet = AirmetParser.getSequenceID(testBull, series);
|
||||
assertEquals(sequenceID, idRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessValidTime() {
|
||||
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r" +
|
||||
"OTLK VALID 2100-0300Z\n\n\r" +
|
||||
"AREA 1...TURB ND SD NE KS MN IA MO WI LS MI\n\n\r" +
|
||||
"BOUNDED BY 30N INL-YQT-70N SAW-20E IOW-MCI-SLN-20WSW GLD-40E SNY-\n\n\r" +
|
||||
"50SSW BFF-50NNW ISN-30N INL\n\n\r" +
|
||||
"MOD TURB BTN FL240 AND FL410. CONDS CONTG THRU 03Z.\n\n\r";
|
||||
|
||||
final String startString = "122100";
|
||||
final String endString = "130300";
|
||||
final String validDay = "12";
|
||||
|
||||
Calendar startTime = null;
|
||||
Calendar mndTime = null;
|
||||
startTime = UtilN.findDataTime(startString, mndTime);
|
||||
|
||||
Calendar endTime = null;
|
||||
endTime = UtilN.findDataTime(endString, mndTime);
|
||||
|
||||
AirmetReport curSection = new AirmetReport();
|
||||
|
||||
AirmetParser.processValidTime(testBull, curSection, validDay, null);
|
||||
Calendar startRet = curSection.getStartTime();
|
||||
Calendar endRet = curSection.getEndTime();
|
||||
|
||||
assertEquals(endTime, endRet);
|
||||
assertEquals(startTime, startRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessReport() {
|
||||
|
||||
AirmetReport section = new AirmetReport();
|
||||
|
||||
final String level1 = "240";
|
||||
final String level2 = "410";
|
||||
|
||||
final String testReport = "WAUS45 KKCI 121112 AAA\n\n\r" +
|
||||
"WA5S \n\n\r" +
|
||||
"\036SLCS WA 121112 AMD\n\n\r" +
|
||||
"AIRMET TURB...ND SD NE KS MN IA MO WI LS MI\n\n\r" +
|
||||
"FROM 30N INL TO YQT TO 60ESE YQT TO 20SE ODI TO DSM TO PWE\n\n\r" +
|
||||
"MOD TURB BTN FL240 AND FL410. CONDS CONTG BYD 21Z THRU 03Z.\n\n\r";
|
||||
|
||||
ArrayList<String> locationList = new ArrayList<String>();
|
||||
|
||||
locationList.add("30N INL");
|
||||
locationList.add("YQT");
|
||||
locationList.add("60ESE YQT");
|
||||
locationList.add("20SE ODI");
|
||||
locationList.add("DSM");
|
||||
locationList.add("PWE");
|
||||
|
||||
//section = AirmetParser.processReport(testReport);
|
||||
|
||||
//assertEquals(level1, section.getFlightLevel1());
|
||||
//assertEquals(level2, section.getFlightLevel2());
|
||||
|
||||
|
||||
if (section.getAirmetLocation() != null && section.getAirmetLocation().size() > 0) {
|
||||
for (Iterator<AirmetLocation> iter = section.getAirmetLocation().iterator(); iter.hasNext();) {
|
||||
AirmetLocation loc = iter.next();
|
||||
String location = loc.getLocation();
|
||||
System.out.println("location=" + location);
|
||||
//assertTrue(locationList.contains(location));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessOutLook() {
|
||||
|
||||
AirmetReport section = new AirmetReport();
|
||||
|
||||
final String sequenceID = "1Z";
|
||||
final String forecastRegion = "Z";
|
||||
|
||||
final String testReport = "OTLK VALID 2100-0300Z\n\n\r" +
|
||||
"AREA 1...TURB ND SD NE KS MN IA MO WI LS MI\n\n\r" +
|
||||
"BOUNDED BY 30N INL-YQT-70N SAW-20E IOW-MCI-SLN\n\n\r" +
|
||||
"MOD TURB BTN FL240 AND FL410. CONDS CONTG THRU 03Z.\n\n\r";
|
||||
|
||||
|
||||
ArrayList<String> locationList = new ArrayList<String>();
|
||||
|
||||
locationList.add("30N INL");
|
||||
locationList.add("YQT");
|
||||
locationList.add("70N SAW");
|
||||
locationList.add("20E IOW");
|
||||
locationList.add("YQT");
|
||||
locationList.add("MCI");
|
||||
locationList.add("SLN");
|
||||
|
||||
|
||||
|
||||
//section = AirmetParser.processOutLook(testReport, forecastRegion);
|
||||
|
||||
|
||||
//assertEquals(sequenceID, section.getSequenceID());
|
||||
|
||||
|
||||
if (section.getAirmetLocation() != null && section.getAirmetLocation().size() > 0) {
|
||||
for (Iterator<AirmetLocation> iter = section.getAirmetLocation().iterator(); iter.hasNext();) {
|
||||
AirmetLocation loc = iter.next();
|
||||
String location = loc.getLocation();
|
||||
System.out.println("location=" + location);
|
||||
//assertTrue(locationList.contains(location));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -16,7 +16,4 @@ Import-Package: gov.noaa.nws.ncep.common.dataplugin.atcf,
|
|||
gov.noaa.nws.ncep.edex.tools.decoder,
|
||||
gov.noaa.nws.ncep.edex.util,
|
||||
org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
Export-Package: gov.noaa.nws.ncep.edex.plugin.atcf.decoder,
|
||||
gov.noaa.nws.ncep.edex.plugin.atcf.util
|
||||
org.apache.log4j
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -18,5 +18,4 @@ Import-Package: com.raytheon.uf.edex.decodertools.core,
|
|||
com.raytheon.uf.edex.decodertools.time,
|
||||
com.raytheon.uf.edex.wmo.message,
|
||||
org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the AwwUgc.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.aww.common;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwUgc;
|
||||
import gov.noaa.nws.ncep.edex.plugin.aww.util.AwwParser;
|
||||
import java.util.Calendar;
|
||||
import org.junit.Test;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class AwwUgcTest {
|
||||
|
||||
private final String testUgcLine = "MIC075-151705-\r\r\n";
|
||||
private static final String testSegment = "MIC075-151705-\r\r\n"+
|
||||
"/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"+
|
||||
"/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"+
|
||||
"1105 AM EDT SUN SEP 14 2008\r\r\n" +
|
||||
"ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"+
|
||||
"\r\r\n";
|
||||
|
||||
AwwUgc ugc = new AwwUgc();
|
||||
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessUgc() {
|
||||
|
||||
ArrayList<String> watchesList = new ArrayList<String>();
|
||||
Calendar mndTime = null;
|
||||
|
||||
AwwUgc ugc=AwwParser.processUgc(testUgcLine, testSegment, mndTime, watchesList);
|
||||
|
||||
String ugcLine=ugc.getUgc();
|
||||
assertEquals(ugcLine, testUgcLine);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.aww.decoder;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AwwDecoderTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// AwwDecoder aww=new AwwDecoder();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAwwDecoder() {
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecode() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
|
@ -1,427 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the AwwParser.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.aww.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import java.util.Calendar;
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwFips;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwHVtec;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwVtec;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwUgc;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwLatlons;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.tools.decoder.MndTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class AwwParserTest {
|
||||
|
||||
String ddhhmm;
|
||||
@Before
|
||||
public void initialize () {
|
||||
ddhhmm = "041540";
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTransformTime() {
|
||||
final String zeroTime = "000000T0000";
|
||||
final String timeString ="080914T2157";
|
||||
|
||||
/*
|
||||
* test the transform time
|
||||
* case 1 - null
|
||||
*/
|
||||
Calendar timeGroup = null;
|
||||
timeGroup=AwwParser.findEventTime(zeroTime);
|
||||
assertEquals(timeGroup, null);
|
||||
|
||||
timeGroup=AwwParser.findEventTime(timeString);
|
||||
/*
|
||||
* test the transform time
|
||||
* case 2 - normal
|
||||
*/
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.YEAR, 2008);
|
||||
cal.set(Calendar.MONTH, 8);
|
||||
cal.set(Calendar.DATE, 14);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 21);
|
||||
cal.set(Calendar.MINUTE, 57);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(cal,timeGroup);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessATTN() {
|
||||
final String testBull = "MIC075-151705-\r\r\n"+
|
||||
"/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\r\r\n"+
|
||||
"/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"+
|
||||
"1105 AM EDT SUN SEP 14 2008\r\r\n" +
|
||||
"ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"+
|
||||
"\r\r\n";
|
||||
final String attnLine="BMX;HUN;JAN;MEG;OHX";
|
||||
|
||||
String attention = AwwParser.processATTN(testBull);
|
||||
assertEquals(attention, attnLine);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
Calendar mndTime = null;
|
||||
AwwRecord record;
|
||||
final String wmoHeader = "WOUS64";
|
||||
final String testBull = "WOUS64 KWNS 190404\n\n\r"+
|
||||
"/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"+
|
||||
"/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"+
|
||||
"1105 AM EDT SUN SEP 14 2008\r\r\n" +
|
||||
"ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"+
|
||||
"\r\r\n";
|
||||
|
||||
// Set MND (Mass News Disseminator) time string and convert it into Calendar object
|
||||
MndTime mt = new MndTime(testBull.getBytes());
|
||||
mndTime = mt.getMndTime();
|
||||
|
||||
record = new AwwRecord();
|
||||
|
||||
record = AwwParser.processWMO(testBull, mndTime);
|
||||
String wmo=record.getWmoHeader();
|
||||
assertEquals(wmo, wmoHeader);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetReportType() {
|
||||
|
||||
// Case A
|
||||
final String testBull = "WOUS64 KWNS 190404\n\n\r"+
|
||||
"FLWDTX\n\n\r" +
|
||||
"SEVERE THUNDERSTORM OUTLINE UPDATE" +
|
||||
"NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" +
|
||||
"\r\r\n";
|
||||
|
||||
String reportType = "SEVERE THUNDERSTORM OUTLINE UPDATE";
|
||||
String retType = AwwParser.getReportType(testBull);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case B
|
||||
final String bullB = "WOUS64 KWNS 190404\n\n\r"+
|
||||
"FLWDTX\n\n\r" +
|
||||
"FLOOD WARNING" +
|
||||
"NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" +
|
||||
"\r\r\n";
|
||||
|
||||
reportType = "FLOOD WARNING";
|
||||
retType = AwwParser.getReportType(bullB);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case C
|
||||
final String bullC = "WOUS64 KWNS 190404\n\n\r"+
|
||||
"FLWDTX\n\n\r" +
|
||||
"TORNADO WATCH" +
|
||||
"NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" +
|
||||
"\r\r\n";
|
||||
|
||||
reportType = "TORNADO WATCH";
|
||||
retType = AwwParser.getReportType(bullC);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case D
|
||||
final String bullD = "WOUS64 KWNS 190404\n\n\r"+
|
||||
"FLWDTX\n\n\r" +
|
||||
"FLASH FLOOD WATCH" +
|
||||
"NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" +
|
||||
"\r\r\n";
|
||||
|
||||
reportType = "FLASH FLOOD WATCH";
|
||||
retType = AwwParser.getReportType(bullD);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case E
|
||||
final String bullE = "WOUS64 KWNS 190404\n\n\r"+
|
||||
"FLWDTX\n\n\r" +
|
||||
"WINTER STORM WARNING" +
|
||||
"NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" +
|
||||
"\r\r\n";
|
||||
|
||||
reportType = "WINTER STORM WARNING";
|
||||
retType = AwwParser.getReportType(bullE);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case F
|
||||
final String bullF = "WOUS64 KWNS 190404\n\n\r"+
|
||||
"FLWDTX\n\n\r" +
|
||||
"WATCH COUNTY NOTIFICATION" +
|
||||
"NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" +
|
||||
"\r\r\n";
|
||||
|
||||
reportType = "WATCH COUNTY NOTIFICATION";
|
||||
retType = AwwParser.getReportType(bullF);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case G
|
||||
final String bullG = "WOUS64 KWNS 190404\n\n\r"+
|
||||
"FLWDTX\n\n\r" +
|
||||
"DENSE FOG ADVISORY" +
|
||||
"NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" +
|
||||
"\r\r\n";
|
||||
|
||||
reportType = "FOG ADVISORY";
|
||||
retType = AwwParser.getReportType(bullG);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case H
|
||||
final String bullH = "WOUS64 KWNS 190404\n\n\r"+
|
||||
"FLWDTX\n\n\r" +
|
||||
"HIGH WIND WARNING" +
|
||||
"NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" +
|
||||
"\r\r\n";
|
||||
|
||||
reportType = "HIGH WIND WARNING";
|
||||
retType = AwwParser.getReportType(bullH);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessFips() {
|
||||
|
||||
final String testMndLine = "1005 AM EDT TUE SEP 16 2008\r\r\n";
|
||||
final String testUgcLine = "NDZ031-076-MIC094-162205-";
|
||||
|
||||
MndTime mt = new MndTime(testMndLine.getBytes());
|
||||
Calendar mndTime = mt.getMndTime();
|
||||
|
||||
AwwUgc testUgc = new AwwUgc();
|
||||
ArrayList<String> cfipsList = new ArrayList<String>();
|
||||
|
||||
cfipsList.add("NDZ031");
|
||||
cfipsList.add("NDZ076");
|
||||
cfipsList.add("MIC094");
|
||||
|
||||
AwwParser.processFips(testUgcLine, testUgc, mndTime);
|
||||
|
||||
/*
|
||||
* test the product purge date
|
||||
*/
|
||||
//Calendar cal = Calendar.getInstance();
|
||||
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
cal.set(Calendar.YEAR, 2008);
|
||||
cal.set(Calendar.MONTH, 8);
|
||||
cal.set(Calendar.DATE, 16);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 22);
|
||||
cal.set(Calendar.MINUTE, 5);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
Calendar cc = testUgc.getProdPurgeTime();
|
||||
assertEquals(cal,cc);
|
||||
|
||||
// test the county fips
|
||||
if (testUgc.getAwwFIPS() !=null && testUgc.getAwwFIPS().size() >0) {
|
||||
for (Iterator<AwwFips> iter = testUgc.getAwwFIPS().iterator(); iter.hasNext();) {
|
||||
AwwFips cond = iter.next();
|
||||
String fips = cond.getFips();
|
||||
assertTrue(cfipsList.contains(fips));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessUgc() {
|
||||
|
||||
final String testUgcLine = "MIC075-151705-\r\r\n";
|
||||
final String testSegment = "MIC075-151705-\r\r\n"+
|
||||
"/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"+
|
||||
"/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"+
|
||||
"1105 AM EDT SUN SEP 14 2008\r\r\n" +
|
||||
"ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"+
|
||||
"\r\r\n";
|
||||
|
||||
AwwUgc ugc = new AwwUgc();
|
||||
|
||||
|
||||
ArrayList<String> watchesList = new ArrayList<String>();
|
||||
Calendar mndTime = null;
|
||||
|
||||
ugc=AwwParser.processUgc(testUgcLine, testSegment, mndTime, watchesList);
|
||||
|
||||
String ugcLine=ugc.getUgc();
|
||||
assertEquals(ugcLine, testUgcLine);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessVtec() {
|
||||
|
||||
final String testVtecLine = "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\r\r\n";
|
||||
|
||||
final String testSegment = "MIC075-151705-\r\r\n"+
|
||||
"/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"+
|
||||
"/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"+
|
||||
"1105 AM EDT SUN SEP 14 2008\r\r\n" +
|
||||
"ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"+
|
||||
"\r\r\n";
|
||||
|
||||
AwwVtec vtec = new AwwVtec();
|
||||
vtec = AwwParser.processVtec(testVtecLine, testSegment);
|
||||
|
||||
// Compare the differences
|
||||
String vtecLine = vtec.getVtecLine();
|
||||
assertEquals(vtecLine, testVtecLine);
|
||||
|
||||
String prodClass = vtec.getProductClass();
|
||||
assertEquals(prodClass, "O");
|
||||
|
||||
String action = vtec.getAction();
|
||||
assertEquals(action, "EXT");
|
||||
|
||||
String officeID = vtec.getOfficeID();
|
||||
assertEquals(officeID, "KGRR");
|
||||
|
||||
String phenomena = vtec.getPhenomena();
|
||||
assertEquals(phenomena, "FL");
|
||||
|
||||
String significance = vtec.getSignificance();
|
||||
assertEquals(significance, "W");
|
||||
|
||||
String eventTrackingNumber = vtec.getEventTrackingNumber();
|
||||
assertEquals(eventTrackingNumber, "0020");
|
||||
|
||||
Calendar startTime = vtec.getEventStartTime();
|
||||
Calendar calstart = Calendar.getInstance();
|
||||
calstart.set(Calendar.YEAR, 2008);
|
||||
calstart.set(Calendar.MONTH, 8);
|
||||
calstart.set(Calendar.DATE, 14);
|
||||
calstart.set(Calendar.HOUR_OF_DAY, 21);
|
||||
calstart.set(Calendar.MINUTE, 57);
|
||||
calstart.set(Calendar.SECOND, 0);
|
||||
calstart.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calstart, startTime);
|
||||
|
||||
Calendar endTime = vtec.getEventEndTime();
|
||||
Calendar calend = Calendar.getInstance();
|
||||
calend.set(Calendar.YEAR, 2008);
|
||||
calend.set(Calendar.MONTH, 8);
|
||||
calend.set(Calendar.DATE, 15);
|
||||
calend.set(Calendar.HOUR_OF_DAY, 18);
|
||||
calend.set(Calendar.MINUTE, 00);
|
||||
calend.set(Calendar.SECOND, 0);
|
||||
calend.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calend, endTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessLatlons() {
|
||||
|
||||
final String testLatlons = "LAT...LON 4257 8255 4255 8265 4264 8269 4265 8268";
|
||||
|
||||
AwwUgc testUgc = new AwwUgc();
|
||||
ArrayList<Float> flatList = new ArrayList<Float>();
|
||||
ArrayList<Float> flonList = new ArrayList<Float>();
|
||||
|
||||
int[] latlonIndex = new int[1];
|
||||
|
||||
latlonIndex[0] = 0;
|
||||
|
||||
flatList.add((float)(4257/100.0));
|
||||
flonList.add((float)(-8255/100.0));
|
||||
flatList.add((float)(4255/100.0));
|
||||
flonList.add((float)(-8265/100.0));
|
||||
flatList.add((float)(4264/100.0));
|
||||
flonList.add((float)(-8269/100.0));
|
||||
flatList.add((float)(4265/100.0));
|
||||
flonList.add((float)(-8268/100.0));
|
||||
|
||||
AwwParser.processLatlons(testLatlons, testUgc, latlonIndex);
|
||||
|
||||
// test the county fips
|
||||
if (testUgc.getAwwLatLon() !=null && testUgc.getAwwLatLon().size() >0) {
|
||||
for (Iterator<AwwLatlons> iter = testUgc.getAwwLatLon().iterator(); iter.hasNext();) {
|
||||
AwwLatlons cond = iter.next();
|
||||
assertTrue(flatList.contains(cond.getLat()));
|
||||
assertTrue(flonList.contains(cond.getLon()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessHVtec() {
|
||||
final String testVtecLine = "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\r\r\n";
|
||||
final String testHVtecLine = "/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/";
|
||||
final String testSegment = "MIC075-151705-\r\r\n"+
|
||||
"/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"+
|
||||
"/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"+
|
||||
"1105 AM EDT SUN SEP 14 2008\r\r\n" +
|
||||
"ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"+
|
||||
"\r\r\n";
|
||||
|
||||
AwwHVtec hvtec = new AwwHVtec();
|
||||
AwwVtec vtec = new AwwVtec();
|
||||
|
||||
vtec = AwwParser.processVtec(testVtecLine, testSegment);
|
||||
|
||||
if(vtec.getAwwHVtecLine() != null && vtec.getAwwHVtecLine().size() > 0)
|
||||
{
|
||||
for (Iterator<AwwHVtec> iter = vtec.getAwwHVtecLine().iterator(); iter.hasNext();) {
|
||||
hvtec = iter.next();
|
||||
|
||||
// Compare the differences
|
||||
String hvtecLine = hvtec.getHvtecLine();
|
||||
assertEquals(hvtecLine, testHVtecLine);
|
||||
|
||||
String floodSeverity = hvtec.getFloodSeverity();
|
||||
assertEquals(floodSeverity, "2");
|
||||
|
||||
String immediateCause = hvtec.getImmediateCause();
|
||||
assertEquals(immediateCause, "ER");
|
||||
|
||||
Calendar startTime = hvtec.getEventStartTime();
|
||||
Calendar calstart = Calendar.getInstance();
|
||||
calstart.set(Calendar.YEAR, 2008);
|
||||
calstart.set(Calendar.MONTH, 8);
|
||||
calstart.set(Calendar.DATE, 14);
|
||||
calstart.set(Calendar.HOUR_OF_DAY, 21);
|
||||
calstart.set(Calendar.MINUTE, 57);
|
||||
calstart.set(Calendar.SECOND, 0);
|
||||
calstart.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calstart, startTime);
|
||||
|
||||
Calendar crestTime = hvtec.getEventCrestTime();
|
||||
Calendar calcrest = Calendar.getInstance();
|
||||
calcrest.set(Calendar.YEAR, 2008);
|
||||
calcrest.set(Calendar.MONTH, 8);
|
||||
calcrest.set(Calendar.DATE, 15);
|
||||
calcrest.set(Calendar.HOUR_OF_DAY, 00);
|
||||
calcrest.set(Calendar.MINUTE, 00);
|
||||
calcrest.set(Calendar.SECOND, 0);
|
||||
calcrest.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calcrest, crestTime);
|
||||
|
||||
Calendar endTime = hvtec.getEventEndTime();
|
||||
Calendar calend = Calendar.getInstance();
|
||||
calend.set(Calendar.YEAR, 2008);
|
||||
calend.set(Calendar.MONTH, 8);
|
||||
calend.set(Calendar.DATE, 15);
|
||||
calend.set(Calendar.HOUR_OF_DAY, 06);
|
||||
calend.set(Calendar.MINUTE, 00);
|
||||
calend.set(Calendar.SECOND, 0);
|
||||
calend.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calend, endTime);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -14,5 +14,4 @@ Require-Bundle: gov.noaa.nws.ncep.common.dataplugin.convsigmet;bundle-version="1
|
|||
org.geotools,
|
||||
javax.persistence,
|
||||
javax.measure
|
||||
Import-Package: org.apache.commons.logging,
|
||||
org.junit
|
||||
Import-Package: org.apache.commons.logging
|
||||
|
|
|
@ -1,85 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the convsigmet decoder separator.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.convsigmet.decoder;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class ConvSigmetSeparatorTest {
|
||||
ConvSigmetSeparator sep;
|
||||
char[] cbuf;
|
||||
int ntime = 0;
|
||||
StringBuffer contents = new StringBuffer();
|
||||
byte[] actual = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
sep = new ConvSigmetSeparator();
|
||||
File file = new File ("unit-test/gov/noaa/nws/ncep/edex/plugin/convsigmet/decoder/2009022414.conv");
|
||||
System.out.println(file.toString());
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String text = null;
|
||||
|
||||
// repeat until all lines is read
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if ( text.length() != 0 ) {
|
||||
contents.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
sep = new ConvSigmetSeparator();
|
||||
actual = contents.toString().getBytes();
|
||||
sep.setData(actual, null);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
assertTrue("Find Convsigmet separator! ", sep.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecord() {
|
||||
byte[] expected = sep.next();
|
||||
String a = new String (actual);
|
||||
String e = new String (expected);
|
||||
System.out.println("expected=\n" + e);
|
||||
String b = a.substring(3);
|
||||
System.out.println("actual b=\n" + b);
|
||||
assertEquals(e.trim(),b.trim());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,268 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the convsigmet parser.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.convsigmet.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.convsigmet.ConvSigmetRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.convsigmet.ConvSigmetSection;
|
||||
import gov.noaa.nws.ncep.edex.plugin.convsigmet.util.ConvSigmetParser;
|
||||
import gov.noaa.nws.ncep.edex.util.UtilN;
|
||||
|
||||
import com.raytheon.edex.plugin.AbstractDecoder;
|
||||
import com.raytheon.edex.util.Util;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.Calendar;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class ConvSigmetParserTest extends AbstractDecoder {
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
|
||||
final String wmoHeader = "WSUS33";
|
||||
final String testBull = "WSUS33 KKCI 011455\n\n\r" +
|
||||
"SIGW \n\n\r";
|
||||
|
||||
ConvSigmetRecord record = null;
|
||||
|
||||
record = ConvSigmetParser.processWMO(testBull, null);
|
||||
String wmo=record.getWmoHeader();
|
||||
assertEquals(wmo, wmoHeader);
|
||||
|
||||
final String issueString = "011455";
|
||||
//Calendar mndTime = Calendar.getInstance();
|
||||
//Calendar timeGroup=ConvsigmetParser.convertDdhhmmToStandardCal(issueString, mndTime);
|
||||
Calendar timeGroup = null;
|
||||
try {
|
||||
timeGroup = Util.findCurrentTime(issueString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get issue time");
|
||||
}
|
||||
Calendar issueTime=record.getIssueTime();
|
||||
System.out.println("======= This is the issue date:");
|
||||
System.out.println("issue date:year= " + timeGroup.get(Calendar.YEAR) );
|
||||
System.out.println("issue date:month= " + timeGroup.get(Calendar.MONTH) );
|
||||
System.out.println("issue date:day= " + timeGroup.get(Calendar.DAY_OF_MONTH) );
|
||||
System.out.println("issue date:hour= " + timeGroup.get(Calendar.HOUR) );
|
||||
System.out.println("issue date:minute= " + timeGroup.get(Calendar.MINUTE) );
|
||||
|
||||
assertEquals(timeGroup, issueTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessFcstRegion() {
|
||||
|
||||
|
||||
final String fcstRegion = "W";
|
||||
final String testBull = "WSUS33 KKCI 241455\n\n\r" +
|
||||
"SIGW \n\n\r";
|
||||
|
||||
String regionRet = ConvSigmetParser.processFcstRegion(testBull);
|
||||
assertEquals(fcstRegion, regionRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessStartTime() {
|
||||
|
||||
final String timeString ="261755";
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r" +
|
||||
"SIGE \n\n\r" +
|
||||
"\036MKCE WST 261755\n\n\r" +
|
||||
"CONVECTIVE SIGMET...NONE\n\n\r" +
|
||||
"\n\n\r" +
|
||||
"OUTLOOK VALID 261955-262355\n\n\r" +
|
||||
"FROM 50E GRB-ROD-TTH-50E GRB\n\n\r" +
|
||||
"WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r" +
|
||||
"PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
|
||||
//Calendar mndTime = Calendar.getInstance();
|
||||
//Calendar startTime=ConvsigmetParser.convertDdhhmmToStandardCal(timeString, mndTime);
|
||||
Calendar startTime = null;
|
||||
try {
|
||||
startTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get start time");
|
||||
}
|
||||
Calendar timeRet=ConvSigmetParser.processStartTime(testBull, null);
|
||||
|
||||
assertEquals(startTime,timeRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessEndTime() {
|
||||
|
||||
final String timeString ="261855";
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r" +
|
||||
"SIGE \n\n\r" +
|
||||
"\036MKCE WST 261755\n\n\r" +
|
||||
"CONVECTIVE SIGMET 19C\n\n\r" +
|
||||
"VALID UNTIL 1855Z\n\n\r" +
|
||||
"MN IA NE\n\n\r" +
|
||||
"FROM 50SE RWF-30W MCW-20SSE OVR\n\n\r" +
|
||||
"LINE EMBD SEV TS 30 NM WIDE MOV FROM 26035KT. TOPS TO FL350.\n\n\r" +
|
||||
"HAIL TO 1 IN...WIND GUSTS TO 50KT POSS.\n\n\r" +
|
||||
"\n\n\r" +
|
||||
"OUTLOOK VALID 261955-262355\n\n\r" +
|
||||
"FROM 50E GRB-ROD-TTH-50E GRB\n\n\r" +
|
||||
"WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r" +
|
||||
"PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
|
||||
//Calendar mndTime = Calendar.getInstance();
|
||||
//Calendar endTime=ConvsigmetParser.convertDdhhmmToStandardCal(timeString, mndTime);
|
||||
Calendar endTime = null;
|
||||
try {
|
||||
endTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get end time");
|
||||
}
|
||||
ConvSigmetSection curSection = new ConvSigmetSection();
|
||||
curSection.setStartTime(endTime);
|
||||
Calendar timeRet=ConvSigmetParser.processEndTime(testBull, curSection, null);
|
||||
|
||||
assertEquals(endTime,timeRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessCorrectionFlag() {
|
||||
|
||||
final String testBull1 = "WSUS31 KKCI 261755\n\n\r" +
|
||||
"SIGE \n\n\r" +
|
||||
"\036MKCE WST 261755 COR\n\n\r" +
|
||||
"CONVECTIVE SIGMET...NONE\n\n\r" +
|
||||
"\n\n\r" +
|
||||
"OUTLOOK VALID 261955-262355\n\n\r" +
|
||||
"FROM 50E GRB-ROD-TTH-50E GRB\n\n\r" +
|
||||
"WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r" +
|
||||
"PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
final String testBull2 = "WSUS31 KKCI 261755\n\n\r" +
|
||||
"SIGE \n\n\r" +
|
||||
"\036MKCE WST 261755\n\n\r" +
|
||||
"CONVECTIVE SIGMET...NONE\n\n\r" +
|
||||
"\n\n\r" +
|
||||
"OUTLOOK VALID 261955-262355\n\n\r" +
|
||||
"FROM 50E GRB-ROD-TTH-50E GRB\n\n\r" +
|
||||
"WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r" +
|
||||
"PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
final boolean YES=true;
|
||||
final boolean NO=false;
|
||||
|
||||
boolean corRet = ConvSigmetParser.processCorrectionFlag(testBull1);
|
||||
assertEquals(YES,corRet);
|
||||
|
||||
corRet = ConvSigmetParser.processCorrectionFlag(testBull2);
|
||||
assertEquals(NO,corRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessSequenceID() {
|
||||
|
||||
final String sequenceID = "19C";
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r" +
|
||||
"SIGE \n\n\r" +
|
||||
"\036MKCE WST 261755\n\n\r" +
|
||||
"CONVECTIVE SIGMET 19C\n\n\r" +
|
||||
"VALID UNTIL 1855Z\n\n\r" +
|
||||
"MN IA NE\n\n\r" +
|
||||
"FROM 50SE RWF-30W MCW-20SSE OVR\n\n\r" +
|
||||
"LINE EMBD SEV TS 30 NM WIDE MOV FROM 26035KT. TOPS TO FL350.\n\n\r" +
|
||||
"HAIL TO 1 IN...WIND GUSTS TO 50KT POSS.\n\n\r" +
|
||||
"\n\n\r" +
|
||||
"OUTLOOK VALID 261955-262355\n\n\r" +
|
||||
"FROM 50E GRB-ROD-TTH-50E GRB\n\n\r" +
|
||||
"WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r" +
|
||||
"PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
|
||||
String idRet = ConvSigmetParser.processSequenceID(testBull);
|
||||
assertEquals(sequenceID, idRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessValidTime() {
|
||||
|
||||
final String startString = "261955";
|
||||
final String endString = "262355";
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r" +
|
||||
"SIGE \n\n\r" +
|
||||
"\036MKCE WST 261755\n\n\r" +
|
||||
"CONVECTIVE SIGMET 19C\n\n\r" +
|
||||
"VALID UNTIL 1855Z\n\n\r" +
|
||||
"MN IA NE\n\n\r" +
|
||||
"FROM 50SE RWF-30W MCW-20SSE OVR\n\n\r" +
|
||||
"LINE EMBD SEV TS 30 NM WIDE MOV FROM 26035KT. TOPS TO FL350.\n\n\r" +
|
||||
"HAIL TO 1 IN...WIND GUSTS TO 50KT POSS.\n\n\r" +
|
||||
"\n\n\r" +
|
||||
"OUTLOOK VALID 261955-262355\n\n\r" +
|
||||
"FROM 50E GRB-ROD-TTH-50E GRB\n\n\r" +
|
||||
"WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r" +
|
||||
"PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
Calendar startTime = null;
|
||||
Calendar mndTime = null;
|
||||
startTime = UtilN.findDataTime(startString, mndTime);
|
||||
|
||||
Calendar endTime = null;
|
||||
endTime = UtilN.findDataTime(endString, mndTime);
|
||||
|
||||
ConvSigmetSection curSection = new ConvSigmetSection();
|
||||
|
||||
ConvSigmetParser.processValidTime(testBull, curSection, null);
|
||||
Calendar startRet = curSection.getStartTime();
|
||||
Calendar endRet = curSection.getEndTime();
|
||||
|
||||
assertEquals(endTime, endRet);
|
||||
assertEquals(startTime, startRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessFlightLevel() {
|
||||
|
||||
final String classType = "LINE";
|
||||
final int direction = 260;
|
||||
final int speed = 35;
|
||||
final int flightLevel = 350;
|
||||
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r" +
|
||||
"SIGE \n\n\r" +
|
||||
"\036MKCE WST 261755\n\n\r" +
|
||||
"CONVECTIVE SIGMET 19C\n\n\r" +
|
||||
"VALID UNTIL 1855Z\n\n\r" +
|
||||
"MN IA NE\n\n\r" +
|
||||
"FROM 50SE RWF-30W MCW-20SSE OVR\n\n\r" +
|
||||
"LINE EMBD SEV TS 30 NM WIDE MOV FROM 26035KT. TOPS TO FL350.\n\n\r" +
|
||||
"HAIL TO 1 IN...WIND GUSTS TO 50KT POSS.\n\n\r" +
|
||||
"\n\n\r" +
|
||||
"OUTLOOK VALID 261955-262355\n\n\r" +
|
||||
"FROM 50E GRB-ROD-TTH-50E GRB\n\n\r" +
|
||||
"WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r" +
|
||||
"PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
|
||||
ConvSigmetSection retSection = ConvSigmetParser.processPhenomena(testBull);
|
||||
|
||||
assertEquals(classType, retSection.getClassType());
|
||||
assertEquals(direction, retSection.getDirection());
|
||||
assertEquals(speed, retSection.getSpeed());
|
||||
assertEquals(flightLevel, retSection.getFlightLevel());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -17,6 +17,5 @@ Import-Package: com.raytheon.uf.edex.decodertools.core,
|
|||
gov.noaa.nws.ncep.common.tools,
|
||||
gov.noaa.nws.ncep.edex.tools.decoder,
|
||||
gov.noaa.nws.ncep.edex.util,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
|
|
|
@ -1,155 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ffg.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ffg.FfgPrecip;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ffg.FfgRecord;
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FfgParserTest {
|
||||
FfgRecord record = new FfgRecord();
|
||||
Set<FfgPrecip> ppp;
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
record = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1ProcessAWIPSID() {
|
||||
/* Case I: Good report with a string of five characters*/
|
||||
String str_t1 = "FFGMD \r\r\n" + "Dummying Strings";
|
||||
String retStr = FfgParser.processAwipsID ( str_t1 );
|
||||
assertEquals("FFGMD",retStr);
|
||||
}
|
||||
@Test
|
||||
public void test2ProcessAWIPSID() {
|
||||
/* Case II: Good report with a string of six characters*/
|
||||
String str_t2 = "FFGNY2\r\r\n" + "Dummying Strings";
|
||||
String retStr = FfgParser.processAwipsID ( str_t2 );
|
||||
assertEquals("FFGNY2",retStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3ProcessAWIPSID() {
|
||||
/* Case III: Return null */
|
||||
String str_t3 = "FFGNY2 \r\r\n" + "Dummying Strings";
|
||||
String retStr = FfgParser.processAwipsID ( str_t3 );
|
||||
Object nu = null;
|
||||
assertNull((String)(nu),retStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
String hdr = "FOUS61 KRHA 041504\r\r\n" + "FFGMD \r\r\n";
|
||||
byte[] wmo_hdr = hdr.getBytes();
|
||||
Calendar cal = null;
|
||||
try {
|
||||
FfgParser.processWMO(wmo_hdr, record, cal);
|
||||
String retHdr = record.getWmoHeader();
|
||||
assertEquals ( "FOUS61 KRHA 041504",retHdr );
|
||||
String issue_office = record.getIssueOffice();
|
||||
assertEquals ( "KRHA", issue_office );
|
||||
String nu = record.getDesignatorBBB();
|
||||
assertEquals ("", nu);
|
||||
} catch (Exception e) {
|
||||
// empty block
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1ProcessPrecip () {
|
||||
/* Case I: good case. */
|
||||
String precip = "DEZ001 3.0/ 4.2/ 4.5/ 4.8 / 6.0 :New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals (3.0, pr.getFf01());
|
||||
assertEquals (4.2, pr.getFf03());
|
||||
assertEquals (4.5, pr.getFf06());
|
||||
assertEquals (4.8, pr.getFf12());
|
||||
assertEquals (6.0, pr.getFf24());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2ProcessPrecip () {
|
||||
/* Case II: good case with "/" attached at the end of data */
|
||||
String precip = "DEZ001 3.0/ 4.2/ 4.5/ 4.8 / 6.0 / :New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals (3.0, pr.getFf01());
|
||||
assertEquals (4.2, pr.getFf03());
|
||||
assertEquals (4.5, pr.getFf06());
|
||||
assertEquals (4.8, pr.getFf12());
|
||||
assertEquals (6.0, pr.getFf24());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3ProcessPrecip () {
|
||||
/* Case III: Bad case with blank report */
|
||||
String precip = "DEZ001 3.0/ / 4.5/ / 6.0 /:New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals (3.0, pr.getFf01());
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf03(), 0.0);
|
||||
assertEquals (4.5, pr.getFf06());
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf12(), 0.0);
|
||||
assertEquals (6.0, pr.getFf24());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test4ProcessPrecip () {
|
||||
/* Case IV: Bad case without "/" */
|
||||
String precip = "DEZ001 3.0 :New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals (3.0, pr.getFf01());
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf03(), 0.0);
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf06(), 0.0);
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf12(), 0.0);
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf24(), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test5ProcessPrecip () {
|
||||
/* Case V: Bad case with no report */
|
||||
String precip = "DEZ001 :New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf01(), 0.0);
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf03(), 0.0);
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf06(), 0.0);
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf12(), 0.0);
|
||||
assertEquals (IDecoderConstantsN.FLOAT_MISSING.doubleValue(), (double)pr.getFf24(), 0.0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -15,7 +15,4 @@ Import-Package: com.raytheon.uf.edex.decodertools.core,
|
|||
com.raytheon.uf.edex.wmo.message,
|
||||
gov.noaa.nws.ncep.common.dataplugin.idft,
|
||||
gov.noaa.nws.ncep.edex.util,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
Export-Package: gov.noaa.nws.ncep.edex.plugin.idft.decoder,
|
||||
gov.noaa.nws.ncep.edex.plugin.idft.util
|
||||
org.apache.log4j
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/**
|
||||
* IdftParserTest.java
|
||||
*
|
||||
* Junit test for IdftParser
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 02Jun2009 100 F. J. Yen Initial creation
|
||||
* 27May2010 100 F. J. Yen Migrated from to11dr3 to to11dr11
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author Fee Jing Yen, SIB
|
||||
* @version 1
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.idft.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.idft.IdftRecord;
|
||||
|
||||
public class IdftParserTest {
|
||||
IdftRecord record = new IdftRecord();
|
||||
/*
|
||||
* Unable to test method readIdftLocs due to edex localization methods used
|
||||
* and junit test does not run edex. Unable to test for itype = 0 for the
|
||||
* same reason since the idftLocs.xml table is needed to obtain the lat/lon.
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testProcessIdft(){
|
||||
final String IDFT_DATALN2 = "(\\d{1,4}) +(\\d{0,2})\\.(\\d)(N|S) +(\\d{0,3})\\.(\\d)(W|E) +(\\d{1,3}) +(\\d{1,4})\\.(\\d)\\r\\r\\n";
|
||||
final Pattern dataLnPattern2 = Pattern.compile(IDFT_DATALN2);
|
||||
String thePntRec2 = " 410 66.8S 73.3W 253 2.4\r\r\n";
|
||||
Matcher m2 = dataLnPattern2.matcher(thePntRec2);
|
||||
if (m2.find()) {
|
||||
IdftParser.processIdft(m2, 6, record);
|
||||
assertEquals (410, record.getPointNum().intValue());
|
||||
assertEquals (-66.8, record.getLat());
|
||||
assertEquals (-73.3, record.getLon());
|
||||
assertEquals (253.0F, record.getDirection());
|
||||
assertEquals (2.4F, record.getDistanceNm());
|
||||
}
|
||||
thePntRec2 = " 390 50.5N 10.3E 180 4.5\r\r\n";
|
||||
m2 = dataLnPattern2.matcher(thePntRec2);
|
||||
if (m2.find()) {
|
||||
IdftParser.processIdft(m2, 6, record);
|
||||
assertEquals (390, record.getPointNum().intValue());
|
||||
assertEquals (50.5, record.getLat());
|
||||
assertEquals (10.3, record.getLon());
|
||||
assertEquals (180.0F, record.getDirection());
|
||||
assertEquals (4.5F, record.getDistanceNm());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -14,5 +14,4 @@ Require-Bundle: gov.noaa.nws.ncep.common.dataplugin.intlsigmet;bundle-version="1
|
|||
org.geotools,
|
||||
javax.persistence,
|
||||
javax.measure
|
||||
Import-Package: org.apache.commons.logging,
|
||||
org.junit
|
||||
Import-Package: org.apache.commons.logging
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the intlsigmet decoder separator.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 07/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.intlsigmet.decoder;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class IntlSigmetSeparatorTest {
|
||||
IntlSigmetSeparator sep;
|
||||
char[] cbuf;
|
||||
int ntime = 0;
|
||||
StringBuffer contents = new StringBuffer();
|
||||
byte[] actual = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
sep = new IntlSigmetSeparator();
|
||||
File file = new File ("unit-test/gov/noaa/nws/ncep/edex/plugin/intlsigmet/decoder/2009060816.isig");
|
||||
System.out.println(file.toString());
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String text = null;
|
||||
|
||||
// repeat until all lines is read
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if ( text.length() != 0 ) {
|
||||
contents.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
sep = new IntlSigmetSeparator();
|
||||
actual = contents.toString().getBytes();
|
||||
sep.setData(actual, null);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
assertTrue("Find Convsigmet separator! ", sep.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecord() {
|
||||
byte[] expected = sep.next();
|
||||
String a = new String (actual);
|
||||
String e = new String (expected);
|
||||
assertEquals(e.trim(),a.trim());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,354 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the intlsigmet parser.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 07/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.intlsigmet.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.intlsigmet.IntlSigmetLocation;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.intlsigmet.IntlSigmetRecord;
|
||||
import gov.noaa.nws.ncep.edex.plugin.intlsigmet.util.IntlSigmetParser;
|
||||
|
||||
import com.raytheon.edex.plugin.AbstractDecoder;
|
||||
import com.raytheon.edex.util.Util;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.Calendar;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class IntlSigmetParserTest extends AbstractDecoder {
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
|
||||
final String wmoHeader = "WSNT08";
|
||||
final String testBull = "WSNT08 KKCI 081620\n\n\r" +
|
||||
"SIGA0H\n\n\r";
|
||||
|
||||
IntlSigmetRecord record = null;
|
||||
|
||||
record = IntlSigmetParser.processWMO(testBull, null);
|
||||
String wmo=record.getWmoHeader();
|
||||
assertEquals(wmo, wmoHeader);
|
||||
|
||||
final String issueString = "081620";
|
||||
Calendar timeGroup = null;
|
||||
try {
|
||||
timeGroup = Util.findCurrentTime(issueString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get issue time");
|
||||
}
|
||||
Calendar issueTime=record.getIssueTime();
|
||||
System.out.println("======= This is the issue date:");
|
||||
System.out.println("issue date:year= " + timeGroup.get(Calendar.YEAR) );
|
||||
System.out.println("issue date:month= " + timeGroup.get(Calendar.MONTH) );
|
||||
System.out.println("issue date:day= " + timeGroup.get(Calendar.DAY_OF_MONTH) );
|
||||
System.out.println("issue date:hour= " + timeGroup.get(Calendar.HOUR) );
|
||||
System.out.println("issue date:minute= " + timeGroup.get(Calendar.MINUTE) );
|
||||
|
||||
assertEquals(timeGroup, issueTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHazardType() {
|
||||
|
||||
final String hazardType = "FREQUENT THUNDERSTORMS";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String typeRet = IntlSigmetParser.getHazardType(testBull);
|
||||
assertEquals(hazardType, typeRet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMessageID() {
|
||||
|
||||
final String messageID = "HOTEL";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String idRet = IntlSigmetParser.getMessageID(testBull);
|
||||
assertEquals(messageID, idRet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSequenceNumber() {
|
||||
|
||||
final String sequenceNo = "1";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String retSeq = IntlSigmetParser.getSequenceNumber(testBull);
|
||||
assertEquals(sequenceNo, retSeq);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAtsu() {
|
||||
|
||||
final String atsu = "KZMA ";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String retAtsu = IntlSigmetParser.getAtsu(testBull);
|
||||
assertEquals(atsu, retAtsu);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOmwo() {
|
||||
|
||||
final String omwo = "KKCI";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String retOmwo = IntlSigmetParser.getOmwo(testBull);
|
||||
assertEquals(omwo, retOmwo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStartTime() {
|
||||
|
||||
final String timeString ="081620";
|
||||
final String testBull = "WSNT08 KKCI 081620\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
Calendar startTime = null;
|
||||
try {
|
||||
startTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get start time");
|
||||
}
|
||||
Calendar timeRet=IntlSigmetParser.getStartTime(testBull, null);
|
||||
|
||||
assertEquals(startTime,timeRet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEndTime() {
|
||||
|
||||
final String timeString ="082020";
|
||||
final String testBull = "WSNT08 KKCI 081620\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
Calendar endTime = null;
|
||||
try {
|
||||
endTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get end time");
|
||||
}
|
||||
Calendar timeRet=IntlSigmetParser.getEndTime(testBull, null);
|
||||
|
||||
assertEquals(endTime,timeRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessFlightLevel() {
|
||||
|
||||
final int flightLevel = 460;
|
||||
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
IntlSigmetRecord retRecord = IntlSigmetParser.processWMO(testBull, null);
|
||||
IntlSigmetParser.processFlightLevels(testBull,retRecord);
|
||||
int retLevel = retRecord.getFlightlevel1();
|
||||
|
||||
assertEquals(flightLevel, retLevel);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRemarks() {
|
||||
|
||||
final String remarks =" CCA";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String retRemarks = IntlSigmetParser.getRemarks(testBull);
|
||||
assertEquals(remarks, retRemarks);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSpeed() {
|
||||
|
||||
final int speed = 20;
|
||||
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. MOV NE 20KT NC=\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
int retSpeed = IntlSigmetParser.getSpeed(testBull);
|
||||
|
||||
assertEquals(speed, retSpeed);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIntensity() {
|
||||
|
||||
final String intensity = "INTSF";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String retIntensity = IntlSigmetParser.getIntensity(testBull);
|
||||
assertEquals(intensity,retIntensity);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDirection() {
|
||||
|
||||
final String direction = "SE";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. MOV SE 30KMH NC\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String retDirection = IntlSigmetParser.getDirection(testBull);
|
||||
assertEquals(direction,retDirection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDistance() {
|
||||
|
||||
final int distance = 180;
|
||||
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. \n\n\r" +
|
||||
"WI 180NM OF CENTRE MOV NE 20KT NC=\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
int retDistance = IntlSigmetParser.getDistance(testBull);
|
||||
|
||||
assertEquals(distance, retDistance);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNameLocation() {
|
||||
|
||||
final String location = "HURRICANE IRENE LOCATED AT 23.4N 82.6W";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"HURRICANE IRENE LOCATED AT 23.4N 82.6W MOVG N AT 2 KT.\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. MOV SE 30KMH NC\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String retLocation = IntlSigmetParser.getNameLocation(testBull);
|
||||
assertEquals(location, retLocation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessLatLon() {
|
||||
|
||||
final String location = "N2500 W07400";
|
||||
final float locLat = (float)25.0;
|
||||
final float locLon = (float)-74.0;
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"HURRICANE IRENE LOCATED AT 23.4N 82.6W MOVG N AT 2 KT.\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. MOV SE 30KMH NC\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
IntlSigmetRecord record = IntlSigmetParser.processWMO(testBull, null);
|
||||
IntlSigmetLocation locTB = new IntlSigmetLocation();
|
||||
Integer index = 0;
|
||||
IntlSigmetParser.processLatLon(location, locTB, index, record);
|
||||
double lat = locTB.getLatitude();
|
||||
double lon = locTB.getLongitude();
|
||||
|
||||
assertEquals(lat, locLat);
|
||||
assertEquals(lon, locLon);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThunderStorm() {
|
||||
|
||||
final String type="FREQUENT THUNDERSTORMS";
|
||||
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r" +
|
||||
"SIGA0H\n\n\r" +
|
||||
"KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r" +
|
||||
"MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r" +
|
||||
"W07445 - N2315 W07715 - N2500 W07400. TOP FL460. \n\n\r" +
|
||||
"WI 180NM OF CENTRE MOV NE 20KT NC=\n\n\r" +
|
||||
"\n\n\r";
|
||||
|
||||
String retType = IntlSigmetParser.getThunderStorm(testBull);
|
||||
|
||||
assertEquals(type, retType);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveChar() {
|
||||
|
||||
final String type="FREQUENT THUNDERSTORMS";
|
||||
final String retType="FREQUENTTHUNDERSTORMS";
|
||||
|
||||
String retRemove = IntlSigmetParser.removeChar(type,' ');
|
||||
|
||||
assertEquals(retRemove, retType);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -14,12 +14,9 @@ Require-Bundle: com.raytheon.edex.common,
|
|||
javax.persistence,
|
||||
gov.noaa.nws.ncep.edex.common;bundle-version="1.0.0"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: gov.noaa.nws.ncep.edex.plugin.mosaic.decoder,
|
||||
gov.noaa.nws.ncep.edex.plugin.mosaic.common,
|
||||
Export-Package: gov.noaa.nws.ncep.edex.plugin.mosaic.common,
|
||||
gov.noaa.nws.ncep.edex.plugin.mosaic.common.dao,
|
||||
gov.noaa.nws.ncep.edex.plugin.mosaic.util.level3,
|
||||
gov.noaa.nws.ncep.edex.plugin.mosaic.uengine,
|
||||
gov.noaa.nws.ncep.edex.plugin.mosaic.util
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Import-Package: org.apache.commons.logging,
|
||||
org.junit
|
||||
Import-Package: org.apache.commons.logging
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -17,7 +17,6 @@ Import-Package: com.raytheon.uf.common.pointdata,
|
|||
gov.noaa.nws.ncep.edex.tools.decoder,
|
||||
gov.noaa.nws.ncep.edex.util,
|
||||
org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
Export-Package: gov.noaa.nws.ncep.edex.plugin.ncpafm.decoder,
|
||||
gov.noaa.nws.ncep.edex.plugin.ncpafm.util
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<!-- classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" / -->
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -22,5 +22,4 @@ Import-Package: com.raytheon.edex.exception,
|
|||
gov.noaa.nws.ncep.common.dataplugin.tcm,
|
||||
gov.noaa.nws.ncep.common.tools,
|
||||
org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
|
|
|
@ -1,171 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ncscd.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import com.raytheon.edex.util.Util;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncscd.NcScdRecord;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncscd.util.NcScdParser;
|
||||
import gov.noaa.nws.ncep.edex.util.UtilN;
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
|
||||
public class NcScdParserTest {
|
||||
final double EPSILON = 0.01;
|
||||
String good_report_case1;
|
||||
String good_report_case2;
|
||||
String good_report_case3;
|
||||
String bad_report;
|
||||
String issueTime_case1;
|
||||
String issueTime_case2;
|
||||
NcScdRecord record;
|
||||
Calendar cal;
|
||||
Integer month;
|
||||
|
||||
@Before
|
||||
public void initialize () {
|
||||
good_report_case1 = "KDCA SCD 0045 8123456 70041 400500024\r\r\n";
|
||||
good_report_case2 = "KDCA SCD COR 0550 -SHRA FZRA FZDZ SHPL 888/3// 931022 933003\r\r\n"
|
||||
+ "4/030 60012 98122 24/931043 70041 400501094\r\r\n";
|
||||
good_report_case3 = "KDCA SCD 2355 410511094\r\r\n";
|
||||
bad_report = "KDCA SCD XXX 2355 -RA\r\r\n";
|
||||
issueTime_case1 = "280050";
|
||||
/*
|
||||
* Find month based on the date of the issuance time
|
||||
*/
|
||||
Calendar cdr = UtilN.findDataTime(issueTime_case1, (Calendar)null);
|
||||
month = cdr.get(Calendar.MONTH);
|
||||
record = new NcScdRecord();
|
||||
cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
try {
|
||||
record.setIssueTime(Util.findCurrentTime(issueTime_case1));
|
||||
} catch (Exception e) {
|
||||
// no statement block
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1ProcessNcScd() {
|
||||
|
||||
/*
|
||||
* Case I: Good report
|
||||
*/
|
||||
try {
|
||||
NcScdParser.processNcScd(good_report_case1, record);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("KDCA",record.getStationId());
|
||||
assertEquals("REG",record.getCorIndicator());
|
||||
assertEquals(1L,(long)record.getCFRT());
|
||||
assertEquals(2L,(long)record.getCFRL());
|
||||
assertEquals(3L,(long)record.getCTYL());
|
||||
assertEquals(4L,(long)record.getCBAS());
|
||||
assertEquals(5L,(long)record.getCTYM());
|
||||
assertEquals(6L,(long)record.getCTYH());
|
||||
assertEquals(5.0D,(double)record.getTDXC(),EPSILON);
|
||||
assertEquals(2.4D,(double)record.getTDNC(),EPSILON);
|
||||
assertEquals(0.41D,(double)record.getP24I(),EPSILON);
|
||||
|
||||
/*
|
||||
* Test observation time for the 1st case.
|
||||
*/
|
||||
cal.set(Calendar.MONTH,month);
|
||||
cal.set(Calendar.DAY_OF_MONTH,28);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
cal.set(Calendar.MINUTE,45);
|
||||
cal.set(Calendar.SECOND,0);
|
||||
cal.set(Calendar.MILLISECOND,0);
|
||||
assertEquals(cal,record.getObsTime());
|
||||
assertEquals(record.getSuspectTimeFlag(), "false");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2ProcessNcScd() {
|
||||
|
||||
/*
|
||||
* Case II: Good report with COR, two liners and lengthy weather report
|
||||
*/
|
||||
try {
|
||||
NcScdParser.processNcScd(good_report_case2, record);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("COR",record.getCorIndicator());
|
||||
assertEquals(8L,(long)record.getCFRT());
|
||||
assertEquals(8L,(long)record.getCFRL());
|
||||
assertEquals(IDecoderConstantsN.INTEGER_MISSING.longValue(),(long)record.getCTYL());
|
||||
assertEquals(IDecoderConstantsN.INTEGER_MISSING.longValue(),(long)record.getCTYM());
|
||||
assertEquals(IDecoderConstantsN.INTEGER_MISSING.longValue(),(long)record.getCTYH());
|
||||
assertEquals(3L,(long)record.getCBAS());
|
||||
assertEquals(122L,(long)record.getMSUN());
|
||||
assertEquals(2.2D,(double)record.getSNEW(),EPSILON);
|
||||
assertEquals(0.3D,(double)record.getWEQS(),EPSILON);
|
||||
assertEquals(3.0D,(double)record.getSNOW(),EPSILON);
|
||||
assertEquals(4.3D,(double)record.getS24I(),EPSILON);
|
||||
assertEquals(5.0D,(double)record.getTDXC(),EPSILON);
|
||||
assertEquals(-9.4D,(double)record.getTDNC(),EPSILON);
|
||||
assertEquals(0.12D,(double)record.getP06I(),EPSILON);
|
||||
assertEquals(0.41D,(double)record.getP24I(),EPSILON);
|
||||
assertEquals("-SHRA FZRA FZDZ SHPL",record.getWTHR());
|
||||
|
||||
/*
|
||||
* Test observation time 2nd case.
|
||||
* Issue Time: 250050
|
||||
* Obs Time: 0550
|
||||
*/
|
||||
cal.set(Calendar.MONTH,month);
|
||||
cal.set(Calendar.DAY_OF_MONTH,27);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 5);
|
||||
cal.set(Calendar.MINUTE,50);
|
||||
cal.set(Calendar.SECOND,0);
|
||||
cal.set(Calendar.MILLISECOND,0);
|
||||
assertEquals(cal,record.getObsTime());
|
||||
assertEquals(record.getSuspectTimeFlag(), "true");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3ProcessNcScd() {
|
||||
|
||||
/*
|
||||
* Case III: Good report with date change
|
||||
*/
|
||||
try {
|
||||
NcScdParser.processNcScd(good_report_case3, record);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals(-5.1D,(double)record.getTDXC(),EPSILON);
|
||||
assertEquals(-9.4D,(double)record.getTDNC(),EPSILON);
|
||||
|
||||
/*
|
||||
* Test observation time for the 3rd case.
|
||||
* Issue time: 250050.
|
||||
* Obs time: 2355.
|
||||
*/
|
||||
cal.set(Calendar.MONTH,month);
|
||||
cal.set(Calendar.DAY_OF_MONTH,27);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 23);
|
||||
cal.set(Calendar.MINUTE,55);
|
||||
cal.set(Calendar.SECOND,0);
|
||||
cal.set(Calendar.MILLISECOND,0);
|
||||
assertEquals(cal,record.getObsTime());
|
||||
assertEquals(record.getSuspectTimeFlag(), "false");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test4ProcessNcScd() {
|
||||
|
||||
/*
|
||||
* Case IV: Bad report with "XXX" instead of "COR"
|
||||
*/
|
||||
try {
|
||||
NcScdParser.processNcScd(bad_report, record);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("XXX",record.getCorIndicator());
|
||||
}
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -21,5 +21,4 @@ Import-Package: com.raytheon.edex.exception,
|
|||
gov.noaa.nws.ncep.common.dataplugin.tcm,
|
||||
gov.noaa.nws.ncep.common.tools,
|
||||
org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -18,5 +18,4 @@ Import-Package: com.raytheon.edex.exception,
|
|||
com.raytheon.uf.edex.pointdata,
|
||||
gov.noaa.nws.ncep.common.tools,
|
||||
org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the decoder separator.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* T. Lee 11/08 Creation
|
||||
* T. Lee 3/09 Migrate to TO10
|
||||
* S. Gurung 09/11 Renamed H5 to Nc and h5 to nc
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.ncuair.decoder;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncuair.decoder.NcUairSeparator;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class NcUairSeparatorTest {
|
||||
NcUairSeparator sep;
|
||||
char[] cbuf;
|
||||
int ntime = 0;
|
||||
StringBuffer contents = new StringBuffer();
|
||||
byte[] actual = null;
|
||||
|
||||
@Before
|
||||
public void initialize () {
|
||||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new NcUairSeparator();
|
||||
File file = new File ("unit-test/gov/noaa/nws/ncep/edex/plugin/ncuair/decoder/20100327.uair");
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String text = null;
|
||||
|
||||
/*
|
||||
* Repeat until all lines is read. Add control characters.
|
||||
*/
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if ( text.length() != 0 ) {
|
||||
contents.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("File is not found");
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
sep = new NcUairSeparator();
|
||||
actual = contents.toString().getBytes();
|
||||
sep.setData(actual, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
assertTrue("Find Uair separator! ", sep.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecord() {
|
||||
byte[] expected = sep.next();
|
||||
String a = new String (actual);
|
||||
String e = new String (expected);
|
||||
//assertEquals(e.trim(),a.trim());
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ncuair.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncuair.util.NcUairPressureHeightGroup;
|
||||
import gov.noaa.nws.ncep.edex.util.UtilN;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncuair.NcUairRecord;
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NcUairPressureHeightGroupTest {
|
||||
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPressHeightField() {
|
||||
|
||||
String presgroup = "00104";
|
||||
Boolean above = false;
|
||||
int level = 1;
|
||||
String stationNumber = "72403";
|
||||
String dataType = "TTAA";
|
||||
NcUairRecord record = null;
|
||||
NcUairPressureHeightGroup.PressureHeightField(presgroup, above, level, stationNumber, dataType, record);
|
||||
float height = NcUairPressureHeightGroup.getHeight();
|
||||
float pres = NcUairPressureHeightGroup.getPressure();
|
||||
assertEquals(104.0, height);
|
||||
assertEquals(1000.0, pres);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ncuair.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncuair.util.NcUairTempGroup;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class NcUairTempGroupTest {
|
||||
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTempField() {
|
||||
String tempgroup = "12424";
|
||||
NcUairTempGroup.TempField(tempgroup);
|
||||
float temp = NcUairTempGroup.getTemperature();
|
||||
float dt = NcUairTempGroup.getDewpointTemp();
|
||||
assertEquals(12.4,temp);
|
||||
assertEquals(10.0,dt);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ncuair.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncuair.util.NcUairWindGroup;
|
||||
import gov.noaa.nws.ncep.edex.util.UtilN;
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NcUairWindGroupTest {
|
||||
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWindField() {
|
||||
String windgroup = "27049";
|
||||
NcUairWindGroup.WindField(windgroup, false);
|
||||
float windSpeed = NcUairWindGroup.getSped();
|
||||
float winddir = NcUairWindGroup.getDrct();
|
||||
assertEquals(49.0,windSpeed);
|
||||
assertEquals(270.0,winddir);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -14,5 +14,4 @@ Require-Bundle: gov.noaa.nws.ncep.common.dataplugin.nonconvsigmet;bundle-version
|
|||
org.geotools,
|
||||
javax.persistence,
|
||||
javax.measure
|
||||
Import-Package: org.apache.commons.logging,
|
||||
org.junit
|
||||
Import-Package: org.apache.commons.logging
|
||||
|
|
|
@ -1,86 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the non-convsigmet decoder separator.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* UmaJosyula 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.nonconvsigmet.decoder;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.plugin.nonconvsigmet.decoder.NonConvSigmetSeparator;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
public class NonConvSigmetSeparatorTest {
|
||||
NonConvSigmetSeparator sep;
|
||||
char[] cbuf;
|
||||
int ntime = 0;
|
||||
StringBuffer contents = new StringBuffer();
|
||||
byte[] actual = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
sep = new NonConvSigmetSeparator();
|
||||
File file = new File ("unit-test/gov/noaa/nws/ncep/edex/plugin/nonconvsigmet/decoder/2009010715.nconv");
|
||||
System.out.println(file.toString());
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String text = null;
|
||||
|
||||
// repeat until all lines is read
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if ( text.length() != 0 ) {
|
||||
contents.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
sep = new NonConvSigmetSeparator();
|
||||
actual = contents.toString().getBytes();
|
||||
sep.setData(actual, null);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
assertTrue("Find NonConvsigmet separator! ", sep.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecord() {
|
||||
byte[] expected = sep.next();
|
||||
String a = new String (actual);
|
||||
String e = new String (expected);
|
||||
assertEquals(e.trim(),a.trim());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the non-convsigmet parser.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* Uma Josyula 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.nonconvsigmet.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.nonconvsigmet.NonConvSigmetRecord;
|
||||
import gov.noaa.nws.ncep.edex.plugin.nonconvsigmet.util.NonConvSigmetParser;
|
||||
//import gov.noaa.nws.ncep.edex.util.UtilN;
|
||||
|
||||
import com.raytheon.edex.plugin.AbstractDecoder;
|
||||
import com.raytheon.edex.util.Util;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.Calendar;
|
||||
import org.junit.Test;
|
||||
|
||||
public class NonConvSigmetParserTest extends AbstractDecoder {
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
|
||||
final String wmoHeader = "WSUS01";
|
||||
final String testBull = "WSUS01 KKCI 071510\n\n\r";
|
||||
|
||||
NonConvSigmetRecord record = null;
|
||||
|
||||
record = NonConvSigmetParser.processWMO(testBull, null);
|
||||
String wmo=record.getWmoHeader();
|
||||
assertEquals(wmo, wmoHeader);
|
||||
|
||||
final String issueString = "071510";
|
||||
|
||||
Calendar timeGroup = null;
|
||||
try {
|
||||
timeGroup = Util.findCurrentTime(issueString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get issue time");
|
||||
}
|
||||
Calendar issueTime=record.getIssueTime();
|
||||
System.out.println("******* This is the issue date:");
|
||||
System.out.println("issue date:year= " + timeGroup.get(Calendar.YEAR) );
|
||||
System.out.println("issue date:month= " + timeGroup.get(Calendar.MONTH) );
|
||||
System.out.println("issue date:day= " + timeGroup.get(Calendar.DAY_OF_MONTH) );
|
||||
System.out.println("issue date:hour= " + timeGroup.get(Calendar.HOUR) );
|
||||
System.out.println("issue date:minute= " + timeGroup.get(Calendar.MINUTE) );
|
||||
|
||||
assertEquals(timeGroup, issueTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessStartEndTime() {
|
||||
|
||||
final String stTimeString ="071510";
|
||||
final String endTimeString ="071910";
|
||||
final String fcstRegion = "BOSN";
|
||||
|
||||
NonConvSigmetRecord record = new NonConvSigmetRecord();
|
||||
final String testBull = "WSUS01 KKCI 071510\n\n\r" +
|
||||
"WS1N \n\n\r"+
|
||||
"BOSN WS 071510 \n\n\r" +
|
||||
"SIGMET NOVEMBER 3 VALID UNTIL 071910Z\n\n\r" +
|
||||
"NY LO PA OH LE WV VA MD NC SC GA \n\n\r" +
|
||||
"FROM MSS TO FLO TO LGC TO GQO TO HMV TO CLE TO 30NNW BUF TO MSS \n\n\r" +
|
||||
"OCNL SEV TURB BTN 080 AND FL250. RPRTD BY ACFT. REPLACES SIGMET \n\n\r" +
|
||||
"NOVEMBER 2. CONDS CONTG BYD 1910Z.";
|
||||
|
||||
Calendar startTime = null;
|
||||
Calendar endTime = null;
|
||||
try {
|
||||
startTime = Util.findCurrentTime(stTimeString);
|
||||
endTime = Util.findCurrentTime(endTimeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get start and end time");
|
||||
}
|
||||
record = NonConvSigmetParser.processStartEndTime(testBull, record, null);
|
||||
Calendar sttimeRet=record.getStartTime();
|
||||
Calendar endtimeRet=record.getEndTime();
|
||||
String regionRet= record.getForecastRegion();
|
||||
|
||||
assertEquals(startTime,sttimeRet);
|
||||
assertEquals(endTime,endtimeRet);
|
||||
assertEquals(fcstRegion, regionRet);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessPhenomena() {
|
||||
|
||||
final String corRemarks = " ";
|
||||
final int flightLevel1 = 80;
|
||||
final int flightLevel2 = 250;
|
||||
final String hazardType ="TURB";
|
||||
final String hazardIntensity="OCNL SEV";
|
||||
final String hazardCause="RPRTD BY ACFT";
|
||||
final String hazardCondition="CONDS CONTG BYD 1910Z";
|
||||
final String stateList ="NY LO PA OH LE WV VA MD NC SC GA";
|
||||
final String awipsId = "WS1N";
|
||||
NonConvSigmetRecord record = new NonConvSigmetRecord();
|
||||
final String testBull = "WSUS01 KKCI 071510\n\n\r" +
|
||||
"WS1N\n\n\r"+
|
||||
"BOSN WS 071510\n\n\r" +
|
||||
"SIGMET NOVEMBER 3 VALID UNTIL 071910\n\n\r" +
|
||||
"NY LO PA OH LE WV VA MD NC SC GA\n\n\r" +
|
||||
"FROM MSS TO FLO TO LGC TO GQO TO HMV TO CLE TO 30NNW BUF TO MSS\n\n\r" +
|
||||
"OCNL SEV TURB BTN 080 AND FL250. RPRTD BY ACFT. REPLACES SIGMET\n\n\r" +
|
||||
"NOVEMBER 2. CONDS CONTG BYD 1910Z.";
|
||||
|
||||
record = NonConvSigmetParser.processPhenomena(testBull, record);
|
||||
String corrRet = record.getCorrectionRemarks();
|
||||
int flLevelRet1 =record.getFlightLevel1();
|
||||
int flLevelRet2 =record.getFlightLevel2();
|
||||
String hazardTypeRet=record.getHazardType();
|
||||
String hazardIntensityRet=record.getHazardIntensity();
|
||||
String hazardCauseRet=record.getHazardCause();
|
||||
String hazardConditionRet=record.getHazardCondition();
|
||||
String stListRet=record.getStateList();
|
||||
String awipsIdRet=record.getAwipsId();
|
||||
|
||||
|
||||
|
||||
assertEquals(flightLevel1, flLevelRet1);
|
||||
assertEquals(flightLevel2, flLevelRet2);
|
||||
assertEquals(hazardType, hazardTypeRet);
|
||||
assertEquals(hazardIntensity, hazardIntensityRet);
|
||||
assertEquals(hazardCause, hazardCauseRet);
|
||||
assertEquals(hazardCondition, hazardConditionRet);
|
||||
assertEquals(stateList, stListRet);
|
||||
assertEquals(awipsId, awipsIdRet);
|
||||
assertEquals(corRemarks, corrRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessSigmetId() {
|
||||
|
||||
final String sigmetId = "NOVEMBER 3";
|
||||
|
||||
NonConvSigmetRecord record = new NonConvSigmetRecord();
|
||||
final String testBull = "WSUS01 KKCI 071510\n\n\r" +
|
||||
"WS1N \n\n\r"+
|
||||
"BOSN WS 071510 \n\n\r" +
|
||||
"SIGMET NOVEMBER 3 VALID UNTIL 071910\n\n\r" +
|
||||
"NY LO PA OH LE WV VA MD NC SC GA \n\n\r" +
|
||||
"FROM MSS TO FLO TO LGC TO GQO TO HMV TO CLE TO 30NNW BUF TO MSS \n\n\r" +
|
||||
"OCNL SEV TURB BTN 080 AND FL250. RPRTD BY ACFT. REPLACES SIGMET \n\n\r" +
|
||||
"NOVEMBER 2. CONDS CONTG BYD 1910Z.";
|
||||
|
||||
record = NonConvSigmetParser.processSigmetId(testBull, record);
|
||||
String sigmetIdRet = record.getSigmetId();
|
||||
assertEquals(sigmetId, sigmetIdRet);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -18,5 +18,4 @@ Import-Package: com.raytheon.uf.edex.decodertools.bufr,
|
|||
com.raytheon.uf.edex.decodertools.bufr.packets,
|
||||
com.raytheon.uf.edex.decodertools.time,
|
||||
com.raytheon.uf.edex.wmo.message,
|
||||
org.apache.commons.logging,
|
||||
org.junit
|
||||
org.apache.commons.logging
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -16,7 +16,6 @@ Import-Package: gov.noaa.nws.ncep.common.dataplugin.stormtrack,
|
|||
gov.noaa.nws.ncep.edex.tools.decoder,
|
||||
gov.noaa.nws.ncep.edex.util,
|
||||
org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
Export-Package: gov.noaa.nws.ncep.edex.plugin.stormtrack.decoder,
|
||||
gov.noaa.nws.ncep.edex.plugin.stormtrack.util
|
||||
|
|
|
@ -1,156 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.stormtrack.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.stormtrack.StormTrackRecord;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class StormTrackParserTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessLatLon() {
|
||||
Float latLon;
|
||||
latLon = StormTrackParser.processLatLon("975W");
|
||||
assertEquals(-97.5, latLon.doubleValue());
|
||||
latLon = StormTrackParser.processLatLon("1605E");
|
||||
assertEquals(160.5, latLon.doubleValue());
|
||||
latLon = StormTrackParser.processLatLon("1605W");
|
||||
assertEquals(-160.5, latLon.doubleValue());
|
||||
latLon = StormTrackParser.processLatLon("623E");
|
||||
assertEquals(62.3, latLon.doubleValue());
|
||||
latLon = StormTrackParser.processLatLon("62N");
|
||||
assertEquals(6.2, latLon.doubleValue());
|
||||
latLon = StormTrackParser.processLatLon("847S");
|
||||
assertEquals(-84.7, latLon.doubleValue());
|
||||
latLon = StormTrackParser.processLatLon("847G");
|
||||
assertEquals(999999., latLon.doubleValue());
|
||||
latLon = StormTrackParser.processLatLon("");
|
||||
assertEquals(999999., latLon.doubleValue());
|
||||
latLon = StormTrackParser.processLatLon(" ");
|
||||
assertEquals(999999., latLon.doubleValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessWarnTime() {
|
||||
Calendar warnTime;
|
||||
|
||||
warnTime = StormTrackParser.processWarnTime("2010061706");
|
||||
assertEquals (2010, warnTime.get(Calendar.YEAR));
|
||||
assertEquals (5, warnTime.get(Calendar.MONTH));
|
||||
assertEquals (17, warnTime.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (6, warnTime.get(Calendar.HOUR_OF_DAY));
|
||||
|
||||
warnTime = StormTrackParser.processWarnTime("2010062006");
|
||||
assertEquals (2010, warnTime.get(Calendar.YEAR));
|
||||
assertEquals (5, warnTime.get(Calendar.MONTH));
|
||||
assertEquals (20, warnTime.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (6, warnTime.get(Calendar.HOUR_OF_DAY));
|
||||
|
||||
warnTime = StormTrackParser.processWarnTime("2010062022");
|
||||
assertEquals (2010, warnTime.get(Calendar.YEAR));
|
||||
assertEquals (5, warnTime.get(Calendar.MONTH));
|
||||
assertEquals (20, warnTime.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (22, warnTime.get(Calendar.HOUR_OF_DAY));
|
||||
|
||||
warnTime = StormTrackParser.processWarnTime("2010123021");
|
||||
assertEquals (2010, warnTime.get(Calendar.YEAR));
|
||||
assertEquals (11, warnTime.get(Calendar.MONTH));
|
||||
assertEquals (30, warnTime.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (21, warnTime.get(Calendar.HOUR_OF_DAY));
|
||||
|
||||
warnTime = StormTrackParser.processWarnTime("2010101012");
|
||||
assertEquals (2010, warnTime.get(Calendar.YEAR));
|
||||
assertEquals (9, warnTime.get(Calendar.MONTH));
|
||||
assertEquals (10, warnTime.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (12, warnTime.get(Calendar.HOUR_OF_DAY));
|
||||
|
||||
warnTime = StormTrackParser.processWarnTime(" ");
|
||||
Calendar warnTimeD = Calendar.getInstance();
|
||||
assertEquals (warnTimeD.get(Calendar.YEAR), warnTime.get(Calendar.YEAR));
|
||||
assertEquals (warnTimeD.get(Calendar.MONTH), warnTime.get(Calendar.MONTH));
|
||||
assertEquals (warnTimeD.get(Calendar.DAY_OF_MONTH), warnTime.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (warnTimeD.get(Calendar.HOUR_OF_DAY), warnTime.get(Calendar.HOUR_OF_DAY));
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testProcessFields() {
|
||||
StormTrackRecord record;
|
||||
String theBulletin;
|
||||
Calendar warnDateTime;
|
||||
theBulletin = "EP, 20, 2009101518, 2, ZGFS, 0, 116M, 966W, 25, 1008, XX, 34, NEQ, 100, 85, 70, 85,\n";
|
||||
record = StormTrackParser.processFields(theBulletin);
|
||||
assertEquals ("EP", record.getBasin());
|
||||
assertEquals (20, record.getCycloneNum());
|
||||
warnDateTime = record.getWarnTime();
|
||||
assertEquals (2009, warnDateTime.get(Calendar.YEAR));
|
||||
assertEquals (9, warnDateTime.get(Calendar.MONTH));
|
||||
assertEquals (15, warnDateTime.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (18, warnDateTime.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals (2, record.getTechniqueNum());
|
||||
assertEquals ("ZGFS", record.getModel());
|
||||
assertEquals (0, record.getFcstHour());
|
||||
assertEquals (999999., record.getClat());
|
||||
assertEquals (-96.6, record.getClon());
|
||||
assertEquals (25., record.getWindMax());
|
||||
assertEquals (1008., record.getMslp());
|
||||
assertEquals ("XX", record.getStormType());
|
||||
assertEquals (34., record.getWindCategory());
|
||||
assertEquals ("NEQ", record.getWindCode());
|
||||
assertEquals (100., record.getQuad1WindRad());
|
||||
assertEquals (85., record.getQuad2WindRad());
|
||||
assertEquals (70., record.getQuad3WindRad());
|
||||
assertEquals (85., record.getQuad4WindRad());
|
||||
assertEquals (999999., record.getClosedP());
|
||||
assertEquals (999999., record.getRadClosedP());
|
||||
//
|
||||
theBulletin = "CP, 85, 2010053012, 03, OFCL, 3, 242N, 1568W, 100, 960, HU, 34, NEQ, 130, 132, 134, 135, 0, 0, 0, 120, 20, C, 0, RMT, 25, 9, HURCNAME, , 12, NEQ, 130, 131, 132, 133\n";
|
||||
record = StormTrackParser.processFields(theBulletin);
|
||||
assertEquals ("CP", record.getBasin());
|
||||
assertEquals (85, record.getCycloneNum());
|
||||
warnDateTime = record.getWarnTime();
|
||||
assertEquals (2010, warnDateTime.get(Calendar.YEAR));
|
||||
assertEquals (4, warnDateTime.get(Calendar.MONTH));
|
||||
assertEquals (30, warnDateTime.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (12, warnDateTime.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals (3, record.getTechniqueNum());
|
||||
assertEquals ("OFCL", record.getModel());
|
||||
assertEquals (3, record.getFcstHour());
|
||||
assertEquals (24.2, record.getClat());
|
||||
assertEquals (-156.8, record.getClon());
|
||||
assertEquals (100., record.getWindMax());
|
||||
assertEquals (960., record.getMslp());
|
||||
assertEquals ("HU", record.getStormType());
|
||||
assertEquals (34., record.getWindCategory());
|
||||
assertEquals ("NEQ", record.getWindCode());
|
||||
assertEquals (130., record.getQuad1WindRad());
|
||||
assertEquals (132., record.getQuad2WindRad());
|
||||
assertEquals (134., record.getQuad3WindRad());
|
||||
assertEquals (135., record.getQuad4WindRad());
|
||||
assertEquals (0., record.getClosedP());
|
||||
assertEquals (0., record.getRadClosedP());
|
||||
assertEquals (0., record.getMaxWindRad());
|
||||
assertEquals (120., record.getGust());
|
||||
assertEquals (20., record.getEyeSize());
|
||||
assertEquals ("C", record.getSubRegion());
|
||||
assertEquals (0., record.getMaxSeas());
|
||||
assertEquals ("RMT", record.getForecaster());
|
||||
assertEquals (25., record.getStormDrct());
|
||||
assertEquals (9., record.getStormSped());
|
||||
assertEquals ("HURCNAME", record.getStormName());
|
||||
assertEquals (" ", record.getStormDepth());
|
||||
assertEquals (12., record.getWaveHght());
|
||||
assertEquals ("NEQ", record.getWaveCode());
|
||||
assertEquals (130., record.getQuad1WaveRad());
|
||||
assertEquals (131., record.getQuad2WaveRad());
|
||||
assertEquals (132., record.getQuad3WaveRad());
|
||||
assertEquals (133., record.getQuad4WaveRad());
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -14,5 +14,4 @@ Import-Package: com.raytheon.uf.edex.decodertools.core,
|
|||
com.raytheon.uf.edex.wmo.message,
|
||||
gov.noaa.nws.ncep.common.tools,
|
||||
org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
|
|
|
@ -1,150 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.tcm.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.tcm.TcmPositionWinds;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.tcm.TcmRecord;
|
||||
import gov.noaa.nws.ncep.edex.plugin.tcm.decoder.TcmSeparator;
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TcmParserJtwcTest {
|
||||
TcmSeparator sep;
|
||||
TcmRecord record = new TcmRecord();
|
||||
Set<TcmPositionWinds> tpw_pgtw;
|
||||
StringBuffer contents_pgtw = new StringBuffer();
|
||||
String data_pgtw = null;
|
||||
|
||||
@Before
|
||||
public void initialize () {
|
||||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new TcmSeparator();
|
||||
File file_pgtw = new File ("unit-test/gov/noaa/nws/ncep/edex/plugin/tcm/decoder/20090316.mar");
|
||||
|
||||
BufferedReader reader = null;
|
||||
|
||||
// Create data file
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file_pgtw));
|
||||
String text = null;
|
||||
|
||||
/*
|
||||
* Repeat until all lines is read. Add control characters.
|
||||
*/
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if ( text.length() != 0 ) {
|
||||
contents_pgtw.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("File is not found");
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
sep = new TcmSeparator();
|
||||
data_pgtw = contents_pgtw.toString();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
record = null;
|
||||
sep = null;
|
||||
tpw_pgtw = null;
|
||||
contents_pgtw = null;
|
||||
data_pgtw = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPgtwProcessTcm () {
|
||||
|
||||
TcmParser tp = new TcmParser();
|
||||
tp.processTcm(data_pgtw, record);
|
||||
assertEquals ("WP", record.getBasin());
|
||||
assertEquals ("KEN",record.getStormName());
|
||||
assertEquals ("21P", record.getStormNumber());
|
||||
assertEquals ("003", record.getAdvisoryNumber());
|
||||
assertEquals ("TROPICAL CYCLONE", record.getStormType());
|
||||
assertEquals (null, record.getEyeSize());
|
||||
assertEquals (null, record.getMndTime());
|
||||
assertEquals (IDecoderConstantsN.INTEGER_MISSING, record.getCentralPressure());
|
||||
assertEquals (null,record.getNe12ft());
|
||||
assertEquals (null,record.getSe12ft());
|
||||
assertEquals (null,record.getSw12ft());
|
||||
assertEquals (null,record.getNw12ft());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPgtwProcessPositionWinds () {
|
||||
TcmParser tp = new TcmParser();
|
||||
byte[] data = data_pgtw.getBytes();
|
||||
Calendar cal = null;
|
||||
tp.processWMO(data, record, cal);
|
||||
tp.processTcm(data_pgtw, record);
|
||||
tpw_pgtw = record.getTcmPosWinds();
|
||||
Iterator<TcmPositionWinds> it = tpw_pgtw.iterator();
|
||||
|
||||
// Check observation time
|
||||
cal = record.getObsTime();
|
||||
assertEquals (18,cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (12,cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals (0,cal.get(Calendar.MINUTE));
|
||||
|
||||
// Current condition
|
||||
TcmPositionWinds pw = it.next();
|
||||
assertEquals (-23.9, pw.getClat().doubleValue(), 0.0);
|
||||
assertEquals (-161.7, pw.getClon().doubleValue(), 0.0);
|
||||
assertEquals (35L, pw.getWindMax().longValue());
|
||||
assertEquals (45L, (long)pw.getGust().longValue());
|
||||
assertEquals (145L, (long)pw.getStormDrct().longValue());
|
||||
assertEquals (8L, pw.getStormSped().longValue());
|
||||
assertEquals (60L, record.getPositionAccuracy().longValue());
|
||||
assertEquals (true,record.getCorr());
|
||||
cal = pw.getValidTime();
|
||||
assertEquals (18,cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (12,cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals (0,cal.get(Calendar.MINUTE));
|
||||
|
||||
// 12 hr forecast
|
||||
pw = it.next();
|
||||
assertEquals (-25.7, pw.getClat().doubleValue());
|
||||
assertEquals (-160.4, pw.getClon().doubleValue());
|
||||
assertEquals (35L, pw.getWindMax().longValue());
|
||||
assertEquals (45L, pw.getGust().longValue());
|
||||
assertEquals (145L, pw.getStormDrct().longValue());
|
||||
assertEquals (16L, pw.getStormSped().longValue());
|
||||
cal = pw.getValidTime();
|
||||
assertEquals (19,cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (0,cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals (0,cal.get(Calendar.MINUTE));
|
||||
}
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.tcm.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.tcm.TcmPositionWinds;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.tcm.TcmRecord;
|
||||
import gov.noaa.nws.ncep.edex.plugin.tcm.decoder.TcmSeparator;
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TcmParserTpcTest {
|
||||
TcmSeparator sep;
|
||||
TcmRecord record = new TcmRecord();
|
||||
Set<TcmPositionWinds> tpw;
|
||||
StringBuffer contents_tpc = new StringBuffer();
|
||||
String tpc_data = null;
|
||||
|
||||
@Before
|
||||
public void initialize () {
|
||||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new TcmSeparator();
|
||||
File file_tpc = new File ("unit-test/gov/noaa/nws/ncep/edex/plugin/tcm/decoder/2009061820.mar");
|
||||
|
||||
BufferedReader reader = null;
|
||||
|
||||
// create data file
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file_tpc));
|
||||
String text = null;
|
||||
|
||||
/*
|
||||
* Repeat until all lines is read. Add control characters.
|
||||
*/
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if ( text.length() != 0 ) {
|
||||
contents_tpc.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("File is not found");
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
sep = new TcmSeparator();
|
||||
tpc_data = contents_tpc.toString();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
record = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTpcProcessTcm () {
|
||||
TcmParser tp = new TcmParser();
|
||||
tp.processTcm(tpc_data, record);
|
||||
assertEquals ("EP", record.getBasin());
|
||||
assertEquals ("ONE-E",record.getStormName());
|
||||
assertEquals ("01", record.getStormNumber());
|
||||
assertEquals ("2", record.getAdvisoryNumber());
|
||||
assertEquals ("TROPICAL DEPRESSION", record.getStormType());
|
||||
assertEquals (true,record.getCorr());
|
||||
assertEquals (null, record.getEyeSize());
|
||||
assertEquals (30L,record.getPositionAccuracy().longValue());
|
||||
assertEquals (null, record.getMndTime());
|
||||
assertEquals (1005L, record.getCentralPressure().longValue());
|
||||
assertEquals ("0",record.getNe12ft());
|
||||
assertEquals ("60",record.getSe12ft());
|
||||
assertEquals ("0",record.getSw12ft());
|
||||
assertEquals ("0",record.getNw12ft());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTpcProcessPositionWinds () {
|
||||
TcmParser tp = new TcmParser();
|
||||
byte[] data = tpc_data.getBytes();
|
||||
Calendar cal = null;
|
||||
tp.processWMO(data, record, cal);
|
||||
tp.processTcm(tpc_data, record);
|
||||
tpw = record.getTcmPosWinds();
|
||||
Iterator<TcmPositionWinds> it = tpw.iterator();
|
||||
|
||||
// Check observation time
|
||||
cal = record.getObsTime();
|
||||
assertEquals (18,cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (21,cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals (0,cal.get(Calendar.MINUTE));;
|
||||
|
||||
// F00
|
||||
TcmPositionWinds pw = it.next();
|
||||
System.out.println (pw.getClat());
|
||||
assertEquals (17.9, pw.getClat().doubleValue());
|
||||
assertEquals (-108.2, pw.getClon().doubleValue());
|
||||
assertEquals (-9999L, pw.getWindMax().longValue());
|
||||
assertEquals (-9999L, pw.getGust().longValue());
|
||||
assertEquals (null, pw.getNe34k());
|
||||
assertEquals (null, pw.getSe34k());
|
||||
assertEquals (null, pw.getSw34k());
|
||||
assertEquals (null, pw.getNw34k());
|
||||
cal = pw.getValidTime();
|
||||
assertEquals (18,cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (18,cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals (0,cal.get(Calendar.MINUTE));
|
||||
assertEquals ("F00", pw.getFcstHour());
|
||||
|
||||
// F48
|
||||
pw = it.next();
|
||||
assertEquals (24.1, pw.getClat().doubleValue());
|
||||
assertEquals (-106.9, pw.getClon().doubleValue());
|
||||
assertEquals (25L, pw.getWindMax().longValue());
|
||||
assertEquals (35L, pw.getGust().longValue());
|
||||
assertEquals (-9999L, pw.getStormDrct().longValue());
|
||||
assertEquals (-9999L, pw.getStormSped().longValue());
|
||||
cal = pw.getValidTime();
|
||||
assertEquals (20,cal.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals (18,cal.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals (0,cal.get(Calendar.MINUTE));;
|
||||
assertEquals ("F48", pw.getFcstHour());
|
||||
}
|
||||
}
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -10,11 +10,8 @@ Require-Bundle: com.raytheon.edex.common;bundle-version="1.10.13",
|
|||
gov.noaa.nws.ncep.edex.common;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.common;bundle-version="1.0.0",
|
||||
gov.noaa.nws.ncep.common.dataplugin.wcp;bundle-version="1.0.0"
|
||||
Export-Package: gov.noaa.nws.ncep.edex.plugin.wcp.decoder,
|
||||
gov.noaa.nws.ncep.edex.plugin.wcp.util
|
||||
Import-Package: com.raytheon.uf.edex.decodertools.core,
|
||||
gov.noaa.nws.ncep.edex.util,
|
||||
org.apache.commons.logging,
|
||||
org.apache.log4j,
|
||||
org.junit
|
||||
org.apache.log4j
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
|
|
|
@ -3,6 +3,5 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="unit-test"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -43,6 +43,5 @@ Import-Package: com.raytheon.edex.plugin.modelsounding.common,
|
|||
gov.noaa.nws.ncep.edex.plugin.ncgrib.dao,
|
||||
javax.measure.converter,
|
||||
javax.measure.unit,
|
||||
org.apache.commons.logging,
|
||||
org.junit
|
||||
org.apache.commons.logging
|
||||
|
||||
|
|
|
@ -107,5 +107,38 @@
|
|||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.obs"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.uf.common.dataplugin.pirep"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/com.raytheon.edex.plugin.pirep"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.ffg"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.ffg"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.airmet"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.airmet"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.common"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.atcf"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.atcf"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.aww"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.aww"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.convsigmet"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.convsigmet"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.idft"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.idft"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.intlsigmet"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.ncpafm"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.intlsigmet"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.ncpafm"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.ncscd"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.nctaf"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.ncuair"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.ncscd"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.nctaf"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.ncuair"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.nonconvsigmet"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.stormtrack"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.tcm"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.nonconvsigmet"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.stormtrack"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.tcm"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.common.dataplugin.wcp"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.plugin.wcp"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/gov.noaa.nws.ncep.edex.uengine"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the AIRMET decoder separator.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 05/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.airmet.decoder;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AirmetSeparatorTest {
|
||||
AirmetSeparator sep;
|
||||
|
||||
char[] cbuf;
|
||||
|
||||
int ntime = 0;
|
||||
|
||||
StringBuffer contents = new StringBuffer();
|
||||
|
||||
byte[] actual = null;
|
||||
|
||||
@Before
|
||||
public void initialize() {
|
||||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new AirmetSeparator();
|
||||
File file = new File(
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/airmet/decoder/2009051211.airm");
|
||||
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String text = null;
|
||||
|
||||
/*
|
||||
* Repeat until all lines is read. Add control characters.
|
||||
*/
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if (text.length() != 0) {
|
||||
contents.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("File is not found");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("I/O Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
sep = new AirmetSeparator();
|
||||
actual = contents.toString().getBytes();
|
||||
sep.setData(actual, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
assertTrue("Find AWW separator! ", sep.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecord() {
|
||||
byte[] expected = sep.next();
|
||||
String a = new String(actual);
|
||||
String e = new String(expected);
|
||||
String b = a.substring(0);
|
||||
assertEquals(e.trim(), b.trim());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,339 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the airmet parser.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 05/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.airmet.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.airmet.AirmetLocation;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.airmet.AirmetRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.airmet.AirmetReport;
|
||||
import gov.noaa.nws.ncep.edex.util.UtilN;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.edex.plugin.AbstractDecoder;
|
||||
import com.raytheon.edex.util.Util;
|
||||
|
||||
//TODO fix?
|
||||
@Ignore
|
||||
public class AirmetParserTest extends AbstractDecoder {
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
|
||||
final String wmoHeader = "WAUS45";
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
AirmetRecord record = null;
|
||||
|
||||
record = AirmetParser.processWMO(testBull, null);
|
||||
String wmo = record.getWmoHeader();
|
||||
assertEquals(wmo, wmoHeader);
|
||||
|
||||
final String issueString = "121112";
|
||||
|
||||
Calendar timeGroup = null;
|
||||
try {
|
||||
timeGroup = Util.findCurrentTime(issueString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get issue time");
|
||||
}
|
||||
Calendar issueTime = record.getIssueTime();
|
||||
System.out.println("======= This is the issue date:");
|
||||
System.out.println("issue date:year= " + timeGroup.get(Calendar.YEAR));
|
||||
System.out
|
||||
.println("issue date:month= " + timeGroup.get(Calendar.MONTH));
|
||||
System.out.println("issue date:day= "
|
||||
+ timeGroup.get(Calendar.DAY_OF_MONTH));
|
||||
System.out.println("issue date:hour= " + timeGroup.get(Calendar.HOUR));
|
||||
System.out.println("issue date:minute= "
|
||||
+ timeGroup.get(Calendar.MINUTE));
|
||||
|
||||
assertEquals(timeGroup, issueTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetReportType() {
|
||||
|
||||
final String reportType = "SIERRA";
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
String retType = AirmetParser.getReportName(testBull);
|
||||
|
||||
assertEquals(reportType, retType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUpdateNumber() {
|
||||
|
||||
final Integer updateNumber = 2;
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
Integer retUpdate = AirmetParser.getUpdateNumber(testBull);
|
||||
|
||||
assertEquals(updateNumber, retUpdate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCorrectionFlag() {
|
||||
|
||||
final Integer correctionFlag = 2;
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
Integer retCorrection = AirmetParser.getCorrectionFlag(testBull);
|
||||
|
||||
assertEquals(correctionFlag, retCorrection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetCancelFlag() {
|
||||
|
||||
final Integer cancelFlag = 1;
|
||||
final String testReport = "AIRMET MTN OBSCN...CO NM...UPDT\n\n\r"
|
||||
+ "FROM TBE TO CME TO 60W INK TO 50E ELP TO 50W CME TO 50ESE ABQ TO\n\n\r"
|
||||
+ "30SSW ALS TO TBE\n\n\r"
|
||||
+ "CANCEL AIRMET. CONDS HV ENDED.\n\n\r";
|
||||
|
||||
Integer retCancel = AirmetParser.getCancelFlag(testReport);
|
||||
|
||||
assertEquals(cancelFlag, retCancel);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetClassType() {
|
||||
|
||||
final String hazardType = "INSTRUMENT FLIGHT RULES";
|
||||
final String testReport = "AIRMET IFR...CO NM\n\n\r"
|
||||
+ "FROM TBE TO CME TO 60W INK TO 50E ELP TO 50W CME TO 50ESE ABQ TO\n\n\r"
|
||||
+ "30SSW ALS TO TBE\n\n\r"
|
||||
+ "CIG BLW 010/VIS BLW 3SM BR. CONDS CONTG BYD 15Z ENDG 15-18Z.\n\n\r";
|
||||
|
||||
String retType = AirmetParser.getHazardType(testReport);
|
||||
|
||||
assertEquals(hazardType, retType);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRegion() {
|
||||
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
AirmetRecord record = null;
|
||||
|
||||
record = AirmetParser.processWMO(testBull, null);
|
||||
|
||||
String retRegion = AirmetParser.getRegion("SIERRA");
|
||||
|
||||
assertEquals("S", retRegion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStartTime() {
|
||||
|
||||
final String timeString = "121112";
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
Calendar startTime = null;
|
||||
|
||||
try {
|
||||
startTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get start time");
|
||||
}
|
||||
Calendar retStart = AirmetParser.getStartTime(testBull, null);
|
||||
assertEquals(startTime, retStart);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEndTime() {
|
||||
|
||||
final String timeString = "121500";
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
Calendar endTime = null;
|
||||
|
||||
try {
|
||||
endTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get end time");
|
||||
}
|
||||
Calendar retEnd = AirmetParser.getEndTime(testBull, null);
|
||||
assertEquals(endTime, retEnd);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetValidDay() {
|
||||
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
String validDay = "12";
|
||||
String retDay = AirmetParser.getValidDay(testBull);
|
||||
|
||||
assertEquals(validDay, retDay);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessSequenceID() {
|
||||
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r";
|
||||
|
||||
Integer series = 1;
|
||||
final String sequenceID = "SLC21";
|
||||
|
||||
String idRet = AirmetParser.getSequenceID(testBull, series);
|
||||
assertEquals(sequenceID, idRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessValidTime() {
|
||||
|
||||
final String testBull = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET SIERRA UPDT 2 FOR IFR AND MTN OBSCN VALID UNTIL 121500\n\n\r"
|
||||
+ "OTLK VALID 2100-0300Z\n\n\r"
|
||||
+ "AREA 1...TURB ND SD NE KS MN IA MO WI LS MI\n\n\r"
|
||||
+ "BOUNDED BY 30N INL-YQT-70N SAW-20E IOW-MCI-SLN-20WSW GLD-40E SNY-\n\n\r"
|
||||
+ "50SSW BFF-50NNW ISN-30N INL\n\n\r"
|
||||
+ "MOD TURB BTN FL240 AND FL410. CONDS CONTG THRU 03Z.\n\n\r";
|
||||
|
||||
final String startString = "122100";
|
||||
final String endString = "130300";
|
||||
final String validDay = "12";
|
||||
|
||||
Calendar startTime = null;
|
||||
Calendar mndTime = null;
|
||||
startTime = UtilN.findDataTime(startString, mndTime);
|
||||
|
||||
Calendar endTime = null;
|
||||
endTime = UtilN.findDataTime(endString, mndTime);
|
||||
|
||||
AirmetReport curSection = new AirmetReport();
|
||||
|
||||
AirmetParser.processValidTime(testBull, curSection, validDay, null);
|
||||
Calendar startRet = curSection.getStartTime();
|
||||
Calendar endRet = curSection.getEndTime();
|
||||
|
||||
assertEquals(endTime, endRet);
|
||||
assertEquals(startTime, startRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessReport() {
|
||||
|
||||
AirmetReport section = new AirmetReport();
|
||||
|
||||
final String level1 = "240";
|
||||
final String level2 = "410";
|
||||
|
||||
final String testReport = "WAUS45 KKCI 121112 AAA\n\n\r"
|
||||
+ "WA5S \n\n\r"
|
||||
+ "\036SLCS WA 121112 AMD\n\n\r"
|
||||
+ "AIRMET TURB...ND SD NE KS MN IA MO WI LS MI\n\n\r"
|
||||
+ "FROM 30N INL TO YQT TO 60ESE YQT TO 20SE ODI TO DSM TO PWE\n\n\r"
|
||||
+ "MOD TURB BTN FL240 AND FL410. CONDS CONTG BYD 21Z THRU 03Z.\n\n\r";
|
||||
|
||||
ArrayList<String> locationList = new ArrayList<String>();
|
||||
|
||||
locationList.add("30N INL");
|
||||
locationList.add("YQT");
|
||||
locationList.add("60ESE YQT");
|
||||
locationList.add("20SE ODI");
|
||||
locationList.add("DSM");
|
||||
locationList.add("PWE");
|
||||
|
||||
// section = AirmetParser.processReport(testReport);
|
||||
|
||||
// assertEquals(level1, section.getFlightLevel1());
|
||||
// assertEquals(level2, section.getFlightLevel2());
|
||||
|
||||
if (section.getAirmetLocation() != null
|
||||
&& section.getAirmetLocation().size() > 0) {
|
||||
for (Iterator<AirmetLocation> iter = section.getAirmetLocation()
|
||||
.iterator(); iter.hasNext();) {
|
||||
AirmetLocation loc = iter.next();
|
||||
String location = loc.getLocation();
|
||||
System.out.println("location=" + location);
|
||||
// assertTrue(locationList.contains(location));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessOutLook() {
|
||||
|
||||
AirmetReport section = new AirmetReport();
|
||||
|
||||
final String sequenceID = "1Z";
|
||||
final String forecastRegion = "Z";
|
||||
|
||||
final String testReport = "OTLK VALID 2100-0300Z\n\n\r"
|
||||
+ "AREA 1...TURB ND SD NE KS MN IA MO WI LS MI\n\n\r"
|
||||
+ "BOUNDED BY 30N INL-YQT-70N SAW-20E IOW-MCI-SLN\n\n\r"
|
||||
+ "MOD TURB BTN FL240 AND FL410. CONDS CONTG THRU 03Z.\n\n\r";
|
||||
|
||||
ArrayList<String> locationList = new ArrayList<String>();
|
||||
|
||||
locationList.add("30N INL");
|
||||
locationList.add("YQT");
|
||||
locationList.add("70N SAW");
|
||||
locationList.add("20E IOW");
|
||||
locationList.add("YQT");
|
||||
locationList.add("MCI");
|
||||
locationList.add("SLN");
|
||||
|
||||
// section = AirmetParser.processOutLook(testReport, forecastRegion);
|
||||
|
||||
// assertEquals(sequenceID, section.getSequenceID());
|
||||
|
||||
if (section.getAirmetLocation() != null
|
||||
&& section.getAirmetLocation().size() > 0) {
|
||||
for (Iterator<AirmetLocation> iter = section.getAirmetLocation()
|
||||
.iterator(); iter.hasNext();) {
|
||||
AirmetLocation loc = iter.next();
|
||||
String location = loc.getLocation();
|
||||
System.out.println("location=" + location);
|
||||
// assertTrue(locationList.contains(location));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -43,7 +43,7 @@ public class AtcfSeparatorTest {
|
|||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new AtcfSeparator();
|
||||
File file = new File(
|
||||
"unit-test/gov/noaa/nws/ncep/edex/plugin/atcf/decoder/aep202009.dat");
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/atcf/decoder/aep202009.dat");
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the AwwUgc.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.aww.common;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwUgc;
|
||||
import gov.noaa.nws.ncep.edex.plugin.aww.util.AwwParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
//TODO fix?
|
||||
@Ignore
|
||||
public class AwwUgcTest {
|
||||
|
||||
private final String testUgcLine = "MIC075-151705-\r\r\n";
|
||||
|
||||
private static final String testSegment = "MIC075-151705-\r\r\n"
|
||||
+ "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"
|
||||
+ "/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"
|
||||
+ "1105 AM EDT SUN SEP 14 2008\r\r\n"
|
||||
+ "ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n" + "\r\r\n";
|
||||
|
||||
AwwUgc ugc = new AwwUgc();
|
||||
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessUgc() {
|
||||
|
||||
ArrayList<String> watchesList = new ArrayList<String>();
|
||||
Calendar mndTime = null;
|
||||
|
||||
AwwUgc ugc = AwwParser.processUgc(testUgcLine, testSegment, mndTime,
|
||||
watchesList);
|
||||
|
||||
String ugcLine = ugc.getUgc();
|
||||
assertEquals(ugcLine, testUgcLine);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.aww.decoder;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
//TODO fix?
|
||||
@Ignore
|
||||
public class AwwDecoderTest {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// AwwDecoder aww=new AwwDecoder();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAwwDecoder() {
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecode() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
}
|
|
@ -38,7 +38,7 @@ public class AwwSeparatorTest {
|
|||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new AwwSeparator();
|
||||
File file = new File(
|
||||
"unit-test/gov/noaa/nws/ncep/edex/plugin/aww/decoder/2008091614.warn");
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/aww/decoder/2008091614.warn");
|
||||
|
||||
BufferedReader reader = null;
|
||||
|
|
@ -0,0 +1,416 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the AwwParser.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.aww.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwFips;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwHVtec;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwLatlons;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwUgc;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.aww.AwwVtec;
|
||||
import gov.noaa.nws.ncep.edex.tools.decoder.MndTime;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
//TODO fix?
|
||||
@Ignore
|
||||
public class AwwParserTest {
|
||||
|
||||
String ddhhmm;
|
||||
|
||||
@Before
|
||||
public void initialize() {
|
||||
ddhhmm = "041540";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransformTime() {
|
||||
final String zeroTime = "000000T0000";
|
||||
final String timeString = "080914T2157";
|
||||
|
||||
/*
|
||||
* test the transform time case 1 - null
|
||||
*/
|
||||
Calendar timeGroup = null;
|
||||
timeGroup = AwwParser.findEventTime(zeroTime);
|
||||
assertEquals(timeGroup, null);
|
||||
|
||||
timeGroup = AwwParser.findEventTime(timeString);
|
||||
/*
|
||||
* test the transform time case 2 - normal
|
||||
*/
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.YEAR, 2008);
|
||||
cal.set(Calendar.MONTH, 8);
|
||||
cal.set(Calendar.DATE, 14);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 21);
|
||||
cal.set(Calendar.MINUTE, 57);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(cal, timeGroup);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessATTN() {
|
||||
final String testBull = "MIC075-151705-\r\r\n"
|
||||
+ "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\r\r\n"
|
||||
+ "/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"
|
||||
+ "1105 AM EDT SUN SEP 14 2008\r\r\n"
|
||||
+ "ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"
|
||||
+ "\r\r\n";
|
||||
final String attnLine = "BMX;HUN;JAN;MEG;OHX";
|
||||
|
||||
String attention = AwwParser.processATTN(testBull);
|
||||
assertEquals(attention, attnLine);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
Calendar mndTime = null;
|
||||
AwwRecord record;
|
||||
final String wmoHeader = "WOUS64";
|
||||
final String testBull = "WOUS64 KWNS 190404\n\n\r"
|
||||
+ "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"
|
||||
+ "/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"
|
||||
+ "1105 AM EDT SUN SEP 14 2008\r\r\n"
|
||||
+ "ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"
|
||||
+ "\r\r\n";
|
||||
|
||||
// Set MND (Mass News Disseminator) time string and convert it into
|
||||
// Calendar object
|
||||
MndTime mt = new MndTime(testBull.getBytes());
|
||||
mndTime = mt.getMndTime();
|
||||
|
||||
record = new AwwRecord();
|
||||
|
||||
record = AwwParser.processWMO(testBull, mndTime);
|
||||
String wmo = record.getWmoHeader();
|
||||
assertEquals(wmo, wmoHeader);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetReportType() {
|
||||
|
||||
// Case A
|
||||
final String testBull = "WOUS64 KWNS 190404\n\n\r" + "FLWDTX\n\n\r"
|
||||
+ "SEVERE THUNDERSTORM OUTLINE UPDATE"
|
||||
+ "NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" + "\r\r\n";
|
||||
|
||||
String reportType = "SEVERE THUNDERSTORM OUTLINE UPDATE";
|
||||
String retType = AwwParser.getReportType(testBull);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case B
|
||||
final String bullB = "WOUS64 KWNS 190404\n\n\r" + "FLWDTX\n\n\r"
|
||||
+ "FLOOD WARNING"
|
||||
+ "NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" + "\r\r\n";
|
||||
|
||||
reportType = "FLOOD WARNING";
|
||||
retType = AwwParser.getReportType(bullB);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case C
|
||||
final String bullC = "WOUS64 KWNS 190404\n\n\r" + "FLWDTX\n\n\r"
|
||||
+ "TORNADO WATCH"
|
||||
+ "NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" + "\r\r\n";
|
||||
|
||||
reportType = "TORNADO WATCH";
|
||||
retType = AwwParser.getReportType(bullC);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case D
|
||||
final String bullD = "WOUS64 KWNS 190404\n\n\r" + "FLWDTX\n\n\r"
|
||||
+ "FLASH FLOOD WATCH"
|
||||
+ "NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" + "\r\r\n";
|
||||
|
||||
reportType = "FLASH FLOOD WATCH";
|
||||
retType = AwwParser.getReportType(bullD);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case E
|
||||
final String bullE = "WOUS64 KWNS 190404\n\n\r" + "FLWDTX\n\n\r"
|
||||
+ "WINTER STORM WARNING"
|
||||
+ "NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" + "\r\r\n";
|
||||
|
||||
reportType = "WINTER STORM WARNING";
|
||||
retType = AwwParser.getReportType(bullE);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case F
|
||||
final String bullF = "WOUS64 KWNS 190404\n\n\r" + "FLWDTX\n\n\r"
|
||||
+ "WATCH COUNTY NOTIFICATION"
|
||||
+ "NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" + "\r\r\n";
|
||||
|
||||
reportType = "WATCH COUNTY NOTIFICATION";
|
||||
retType = AwwParser.getReportType(bullF);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case G
|
||||
final String bullG = "WOUS64 KWNS 190404\n\n\r" + "FLWDTX\n\n\r"
|
||||
+ "DENSE FOG ADVISORY"
|
||||
+ "NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" + "\r\r\n";
|
||||
|
||||
reportType = "FOG ADVISORY";
|
||||
retType = AwwParser.getReportType(bullG);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
// Case H
|
||||
final String bullH = "WOUS64 KWNS 190404\n\n\r" + "FLWDTX\n\n\r"
|
||||
+ "HIGH WIND WARNING"
|
||||
+ "NATIONAL WEATHER SERVICE DETROIT/PONTIAC MI" + "\r\r\n";
|
||||
|
||||
reportType = "HIGH WIND WARNING";
|
||||
retType = AwwParser.getReportType(bullH);
|
||||
assertEquals(reportType, retType);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessFips() {
|
||||
|
||||
final String testMndLine = "1005 AM EDT TUE SEP 16 2008\r\r\n";
|
||||
final String testUgcLine = "NDZ031-076-MIC094-162205-";
|
||||
|
||||
MndTime mt = new MndTime(testMndLine.getBytes());
|
||||
Calendar mndTime = mt.getMndTime();
|
||||
|
||||
AwwUgc testUgc = new AwwUgc();
|
||||
ArrayList<String> cfipsList = new ArrayList<String>();
|
||||
|
||||
cfipsList.add("NDZ031");
|
||||
cfipsList.add("NDZ076");
|
||||
cfipsList.add("MIC094");
|
||||
|
||||
AwwParser.processFips(testUgcLine, testUgc, mndTime);
|
||||
|
||||
/*
|
||||
* test the product purge date
|
||||
*/
|
||||
// Calendar cal = Calendar.getInstance();
|
||||
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
cal.set(Calendar.YEAR, 2008);
|
||||
cal.set(Calendar.MONTH, 8);
|
||||
cal.set(Calendar.DATE, 16);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 22);
|
||||
cal.set(Calendar.MINUTE, 5);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
Calendar cc = testUgc.getProdPurgeTime();
|
||||
assertEquals(cal, cc);
|
||||
|
||||
// test the county fips
|
||||
if (testUgc.getAwwFIPS() != null && testUgc.getAwwFIPS().size() > 0) {
|
||||
for (Iterator<AwwFips> iter = testUgc.getAwwFIPS().iterator(); iter
|
||||
.hasNext();) {
|
||||
AwwFips cond = iter.next();
|
||||
String fips = cond.getFips();
|
||||
assertTrue(cfipsList.contains(fips));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessUgc() {
|
||||
|
||||
final String testUgcLine = "MIC075-151705-\r\r\n";
|
||||
final String testSegment = "MIC075-151705-\r\r\n"
|
||||
+ "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"
|
||||
+ "/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"
|
||||
+ "1105 AM EDT SUN SEP 14 2008\r\r\n"
|
||||
+ "ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"
|
||||
+ "\r\r\n";
|
||||
|
||||
AwwUgc ugc = new AwwUgc();
|
||||
|
||||
ArrayList<String> watchesList = new ArrayList<String>();
|
||||
Calendar mndTime = null;
|
||||
|
||||
ugc = AwwParser.processUgc(testUgcLine, testSegment, mndTime,
|
||||
watchesList);
|
||||
|
||||
String ugcLine = ugc.getUgc();
|
||||
assertEquals(ugcLine, testUgcLine);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessVtec() {
|
||||
|
||||
final String testVtecLine = "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\r\r\n";
|
||||
|
||||
final String testSegment = "MIC075-151705-\r\r\n"
|
||||
+ "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"
|
||||
+ "/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"
|
||||
+ "1105 AM EDT SUN SEP 14 2008\r\r\n"
|
||||
+ "ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"
|
||||
+ "\r\r\n";
|
||||
|
||||
AwwVtec vtec = new AwwVtec();
|
||||
vtec = AwwParser.processVtec(testVtecLine, testSegment);
|
||||
|
||||
// Compare the differences
|
||||
String vtecLine = vtec.getVtecLine();
|
||||
assertEquals(vtecLine, testVtecLine);
|
||||
|
||||
String prodClass = vtec.getProductClass();
|
||||
assertEquals(prodClass, "O");
|
||||
|
||||
String action = vtec.getAction();
|
||||
assertEquals(action, "EXT");
|
||||
|
||||
String officeID = vtec.getOfficeID();
|
||||
assertEquals(officeID, "KGRR");
|
||||
|
||||
String phenomena = vtec.getPhenomena();
|
||||
assertEquals(phenomena, "FL");
|
||||
|
||||
String significance = vtec.getSignificance();
|
||||
assertEquals(significance, "W");
|
||||
|
||||
String eventTrackingNumber = vtec.getEventTrackingNumber();
|
||||
assertEquals(eventTrackingNumber, "0020");
|
||||
|
||||
Calendar startTime = vtec.getEventStartTime();
|
||||
Calendar calstart = Calendar.getInstance();
|
||||
calstart.set(Calendar.YEAR, 2008);
|
||||
calstart.set(Calendar.MONTH, 8);
|
||||
calstart.set(Calendar.DATE, 14);
|
||||
calstart.set(Calendar.HOUR_OF_DAY, 21);
|
||||
calstart.set(Calendar.MINUTE, 57);
|
||||
calstart.set(Calendar.SECOND, 0);
|
||||
calstart.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calstart, startTime);
|
||||
|
||||
Calendar endTime = vtec.getEventEndTime();
|
||||
Calendar calend = Calendar.getInstance();
|
||||
calend.set(Calendar.YEAR, 2008);
|
||||
calend.set(Calendar.MONTH, 8);
|
||||
calend.set(Calendar.DATE, 15);
|
||||
calend.set(Calendar.HOUR_OF_DAY, 18);
|
||||
calend.set(Calendar.MINUTE, 00);
|
||||
calend.set(Calendar.SECOND, 0);
|
||||
calend.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calend, endTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessLatlons() {
|
||||
|
||||
final String testLatlons = "LAT...LON 4257 8255 4255 8265 4264 8269 4265 8268";
|
||||
|
||||
AwwUgc testUgc = new AwwUgc();
|
||||
ArrayList<Float> flatList = new ArrayList<Float>();
|
||||
ArrayList<Float> flonList = new ArrayList<Float>();
|
||||
|
||||
int[] latlonIndex = new int[1];
|
||||
|
||||
latlonIndex[0] = 0;
|
||||
|
||||
flatList.add((float) (4257 / 100.0));
|
||||
flonList.add((float) (-8255 / 100.0));
|
||||
flatList.add((float) (4255 / 100.0));
|
||||
flonList.add((float) (-8265 / 100.0));
|
||||
flatList.add((float) (4264 / 100.0));
|
||||
flonList.add((float) (-8269 / 100.0));
|
||||
flatList.add((float) (4265 / 100.0));
|
||||
flonList.add((float) (-8268 / 100.0));
|
||||
|
||||
AwwParser.processLatlons(testLatlons, testUgc, latlonIndex);
|
||||
|
||||
// test the county fips
|
||||
if (testUgc.getAwwLatLon() != null && testUgc.getAwwLatLon().size() > 0) {
|
||||
for (Iterator<AwwLatlons> iter = testUgc.getAwwLatLon().iterator(); iter
|
||||
.hasNext();) {
|
||||
AwwLatlons cond = iter.next();
|
||||
assertTrue(flatList.contains(cond.getLat()));
|
||||
assertTrue(flonList.contains(cond.getLon()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessHVtec() {
|
||||
final String testVtecLine = "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\r\r\n";
|
||||
final String testHVtecLine = "/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/";
|
||||
final String testSegment = "MIC075-151705-\r\r\n"
|
||||
+ "/O.EXT.KGRR.FL.W.0020.080914T2157Z-080915T1800Z/\n\n\r"
|
||||
+ "/JACM4.2.ER.080914T2157Z.080915T0000Z.080915T0600Z.NR/\r\r\n"
|
||||
+ "1105 AM EDT SUN SEP 14 2008\r\r\n"
|
||||
+ "ATTN...WFO...BMX...HUN...JAN...MEG...OHX...\r\r\n"
|
||||
+ "\r\r\n";
|
||||
|
||||
AwwHVtec hvtec = new AwwHVtec();
|
||||
AwwVtec vtec = new AwwVtec();
|
||||
|
||||
vtec = AwwParser.processVtec(testVtecLine, testSegment);
|
||||
|
||||
if (vtec.getAwwHVtecLine() != null && vtec.getAwwHVtecLine().size() > 0) {
|
||||
for (Iterator<AwwHVtec> iter = vtec.getAwwHVtecLine().iterator(); iter
|
||||
.hasNext();) {
|
||||
hvtec = iter.next();
|
||||
|
||||
// Compare the differences
|
||||
String hvtecLine = hvtec.getHvtecLine();
|
||||
assertEquals(hvtecLine, testHVtecLine);
|
||||
|
||||
String floodSeverity = hvtec.getFloodSeverity();
|
||||
assertEquals(floodSeverity, "2");
|
||||
|
||||
String immediateCause = hvtec.getImmediateCause();
|
||||
assertEquals(immediateCause, "ER");
|
||||
|
||||
Calendar startTime = hvtec.getEventStartTime();
|
||||
Calendar calstart = Calendar.getInstance();
|
||||
calstart.set(Calendar.YEAR, 2008);
|
||||
calstart.set(Calendar.MONTH, 8);
|
||||
calstart.set(Calendar.DATE, 14);
|
||||
calstart.set(Calendar.HOUR_OF_DAY, 21);
|
||||
calstart.set(Calendar.MINUTE, 57);
|
||||
calstart.set(Calendar.SECOND, 0);
|
||||
calstart.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calstart, startTime);
|
||||
|
||||
Calendar crestTime = hvtec.getEventCrestTime();
|
||||
Calendar calcrest = Calendar.getInstance();
|
||||
calcrest.set(Calendar.YEAR, 2008);
|
||||
calcrest.set(Calendar.MONTH, 8);
|
||||
calcrest.set(Calendar.DATE, 15);
|
||||
calcrest.set(Calendar.HOUR_OF_DAY, 00);
|
||||
calcrest.set(Calendar.MINUTE, 00);
|
||||
calcrest.set(Calendar.SECOND, 0);
|
||||
calcrest.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calcrest, crestTime);
|
||||
|
||||
Calendar endTime = hvtec.getEventEndTime();
|
||||
Calendar calend = Calendar.getInstance();
|
||||
calend.set(Calendar.YEAR, 2008);
|
||||
calend.set(Calendar.MONTH, 8);
|
||||
calend.set(Calendar.DATE, 15);
|
||||
calend.set(Calendar.HOUR_OF_DAY, 06);
|
||||
calend.set(Calendar.MINUTE, 00);
|
||||
calend.set(Calendar.SECOND, 0);
|
||||
calend.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(calend, endTime);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the convsigmet decoder separator.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.convsigmet.decoder;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ConvSigmetSeparatorTest {
|
||||
ConvSigmetSeparator sep;
|
||||
|
||||
char[] cbuf;
|
||||
|
||||
int ntime = 0;
|
||||
|
||||
StringBuffer contents = new StringBuffer();
|
||||
|
||||
byte[] actual = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
sep = new ConvSigmetSeparator();
|
||||
File file = new File(
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/convsigmet/decoder/2009022414.conv");
|
||||
System.out.println(file.toString());
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String text = null;
|
||||
|
||||
// repeat until all lines is read
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if (text.length() != 0) {
|
||||
contents.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
sep = new ConvSigmetSeparator();
|
||||
actual = contents.toString().getBytes();
|
||||
sep.setData(actual, null);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
assertTrue("Find Convsigmet separator! ", sep.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecord() {
|
||||
byte[] expected = sep.next();
|
||||
String a = new String(actual);
|
||||
String e = new String(expected);
|
||||
System.out.println("expected=\n" + e);
|
||||
String b = a.substring(3);
|
||||
System.out.println("actual b=\n" + b);
|
||||
assertEquals(e.trim(), b.trim());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,275 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the convsigmet parser.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 04/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.convsigmet.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.convsigmet.ConvSigmetRecord;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.convsigmet.ConvSigmetSection;
|
||||
import gov.noaa.nws.ncep.edex.util.UtilN;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.edex.plugin.AbstractDecoder;
|
||||
import com.raytheon.edex.util.Util;
|
||||
|
||||
//TODO fix?
|
||||
@Ignore
|
||||
public class ConvSigmetParserTest extends AbstractDecoder {
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
|
||||
final String wmoHeader = "WSUS33";
|
||||
final String testBull = "WSUS33 KKCI 011455\n\n\r" + "SIGW \n\n\r";
|
||||
|
||||
ConvSigmetRecord record = null;
|
||||
|
||||
record = ConvSigmetParser.processWMO(testBull, null);
|
||||
String wmo = record.getWmoHeader();
|
||||
assertEquals(wmo, wmoHeader);
|
||||
|
||||
final String issueString = "011455";
|
||||
// Calendar mndTime = Calendar.getInstance();
|
||||
// Calendar
|
||||
// timeGroup=ConvsigmetParser.convertDdhhmmToStandardCal(issueString,
|
||||
// mndTime);
|
||||
Calendar timeGroup = null;
|
||||
try {
|
||||
timeGroup = Util.findCurrentTime(issueString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get issue time");
|
||||
}
|
||||
Calendar issueTime = record.getIssueTime();
|
||||
System.out.println("======= This is the issue date:");
|
||||
System.out.println("issue date:year= " + timeGroup.get(Calendar.YEAR));
|
||||
System.out
|
||||
.println("issue date:month= " + timeGroup.get(Calendar.MONTH));
|
||||
System.out.println("issue date:day= "
|
||||
+ timeGroup.get(Calendar.DAY_OF_MONTH));
|
||||
System.out.println("issue date:hour= " + timeGroup.get(Calendar.HOUR));
|
||||
System.out.println("issue date:minute= "
|
||||
+ timeGroup.get(Calendar.MINUTE));
|
||||
|
||||
assertEquals(timeGroup, issueTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessFcstRegion() {
|
||||
|
||||
final String fcstRegion = "W";
|
||||
final String testBull = "WSUS33 KKCI 241455\n\n\r" + "SIGW \n\n\r";
|
||||
|
||||
String regionRet = ConvSigmetParser.processFcstRegion(testBull);
|
||||
assertEquals(fcstRegion, regionRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessStartTime() {
|
||||
|
||||
final String timeString = "261755";
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r"
|
||||
+ "SIGE \n\n\r"
|
||||
+ "\036MKCE WST 261755\n\n\r"
|
||||
+ "CONVECTIVE SIGMET...NONE\n\n\r"
|
||||
+ "\n\n\r"
|
||||
+ "OUTLOOK VALID 261955-262355\n\n\r"
|
||||
+ "FROM 50E GRB-ROD-TTH-50E GRB\n\n\r"
|
||||
+ "WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r"
|
||||
+ "PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
// Calendar mndTime = Calendar.getInstance();
|
||||
// Calendar
|
||||
// startTime=ConvsigmetParser.convertDdhhmmToStandardCal(timeString,
|
||||
// mndTime);
|
||||
Calendar startTime = null;
|
||||
try {
|
||||
startTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get start time");
|
||||
}
|
||||
Calendar timeRet = ConvSigmetParser.processStartTime(testBull, null);
|
||||
|
||||
assertEquals(startTime, timeRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessEndTime() {
|
||||
|
||||
final String timeString = "261855";
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r"
|
||||
+ "SIGE \n\n\r"
|
||||
+ "\036MKCE WST 261755\n\n\r"
|
||||
+ "CONVECTIVE SIGMET 19C\n\n\r"
|
||||
+ "VALID UNTIL 1855Z\n\n\r"
|
||||
+ "MN IA NE\n\n\r"
|
||||
+ "FROM 50SE RWF-30W MCW-20SSE OVR\n\n\r"
|
||||
+ "LINE EMBD SEV TS 30 NM WIDE MOV FROM 26035KT. TOPS TO FL350.\n\n\r"
|
||||
+ "HAIL TO 1 IN...WIND GUSTS TO 50KT POSS.\n\n\r"
|
||||
+ "\n\n\r"
|
||||
+ "OUTLOOK VALID 261955-262355\n\n\r"
|
||||
+ "FROM 50E GRB-ROD-TTH-50E GRB\n\n\r"
|
||||
+ "WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r"
|
||||
+ "PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
// Calendar mndTime = Calendar.getInstance();
|
||||
// Calendar
|
||||
// endTime=ConvsigmetParser.convertDdhhmmToStandardCal(timeString,
|
||||
// mndTime);
|
||||
Calendar endTime = null;
|
||||
try {
|
||||
endTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get end time");
|
||||
}
|
||||
ConvSigmetSection curSection = new ConvSigmetSection();
|
||||
curSection.setStartTime(endTime);
|
||||
Calendar timeRet = ConvSigmetParser.processEndTime(testBull,
|
||||
curSection, null);
|
||||
|
||||
assertEquals(endTime, timeRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessCorrectionFlag() {
|
||||
|
||||
final String testBull1 = "WSUS31 KKCI 261755\n\n\r"
|
||||
+ "SIGE \n\n\r"
|
||||
+ "\036MKCE WST 261755 COR\n\n\r"
|
||||
+ "CONVECTIVE SIGMET...NONE\n\n\r"
|
||||
+ "\n\n\r"
|
||||
+ "OUTLOOK VALID 261955-262355\n\n\r"
|
||||
+ "FROM 50E GRB-ROD-TTH-50E GRB\n\n\r"
|
||||
+ "WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r"
|
||||
+ "PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
final String testBull2 = "WSUS31 KKCI 261755\n\n\r"
|
||||
+ "SIGE \n\n\r"
|
||||
+ "\036MKCE WST 261755\n\n\r"
|
||||
+ "CONVECTIVE SIGMET...NONE\n\n\r"
|
||||
+ "\n\n\r"
|
||||
+ "OUTLOOK VALID 261955-262355\n\n\r"
|
||||
+ "FROM 50E GRB-ROD-TTH-50E GRB\n\n\r"
|
||||
+ "WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r"
|
||||
+ "PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
final boolean YES = true;
|
||||
final boolean NO = false;
|
||||
|
||||
boolean corRet = ConvSigmetParser.processCorrectionFlag(testBull1);
|
||||
assertEquals(YES, corRet);
|
||||
|
||||
corRet = ConvSigmetParser.processCorrectionFlag(testBull2);
|
||||
assertEquals(NO, corRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessSequenceID() {
|
||||
|
||||
final String sequenceID = "19C";
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r"
|
||||
+ "SIGE \n\n\r"
|
||||
+ "\036MKCE WST 261755\n\n\r"
|
||||
+ "CONVECTIVE SIGMET 19C\n\n\r"
|
||||
+ "VALID UNTIL 1855Z\n\n\r"
|
||||
+ "MN IA NE\n\n\r"
|
||||
+ "FROM 50SE RWF-30W MCW-20SSE OVR\n\n\r"
|
||||
+ "LINE EMBD SEV TS 30 NM WIDE MOV FROM 26035KT. TOPS TO FL350.\n\n\r"
|
||||
+ "HAIL TO 1 IN...WIND GUSTS TO 50KT POSS.\n\n\r"
|
||||
+ "\n\n\r"
|
||||
+ "OUTLOOK VALID 261955-262355\n\n\r"
|
||||
+ "FROM 50E GRB-ROD-TTH-50E GRB\n\n\r"
|
||||
+ "WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r"
|
||||
+ "PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
String idRet = ConvSigmetParser.processSequenceID(testBull);
|
||||
assertEquals(sequenceID, idRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessValidTime() {
|
||||
|
||||
final String startString = "261955";
|
||||
final String endString = "262355";
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r"
|
||||
+ "SIGE \n\n\r"
|
||||
+ "\036MKCE WST 261755\n\n\r"
|
||||
+ "CONVECTIVE SIGMET 19C\n\n\r"
|
||||
+ "VALID UNTIL 1855Z\n\n\r"
|
||||
+ "MN IA NE\n\n\r"
|
||||
+ "FROM 50SE RWF-30W MCW-20SSE OVR\n\n\r"
|
||||
+ "LINE EMBD SEV TS 30 NM WIDE MOV FROM 26035KT. TOPS TO FL350.\n\n\r"
|
||||
+ "HAIL TO 1 IN...WIND GUSTS TO 50KT POSS.\n\n\r"
|
||||
+ "\n\n\r"
|
||||
+ "OUTLOOK VALID 261955-262355\n\n\r"
|
||||
+ "FROM 50E GRB-ROD-TTH-50E GRB\n\n\r"
|
||||
+ "WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r"
|
||||
+ "PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
Calendar startTime = null;
|
||||
Calendar mndTime = null;
|
||||
startTime = UtilN.findDataTime(startString, mndTime);
|
||||
|
||||
Calendar endTime = null;
|
||||
endTime = UtilN.findDataTime(endString, mndTime);
|
||||
|
||||
ConvSigmetSection curSection = new ConvSigmetSection();
|
||||
|
||||
ConvSigmetParser.processValidTime(testBull, curSection, null);
|
||||
Calendar startRet = curSection.getStartTime();
|
||||
Calendar endRet = curSection.getEndTime();
|
||||
|
||||
assertEquals(endTime, endRet);
|
||||
assertEquals(startTime, startRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessFlightLevel() {
|
||||
|
||||
final String classType = "LINE";
|
||||
final int direction = 260;
|
||||
final int speed = 35;
|
||||
final int flightLevel = 350;
|
||||
|
||||
final String testBull = "WSUS31 KKCI 261755\n\n\r"
|
||||
+ "SIGE \n\n\r"
|
||||
+ "\036MKCE WST 261755\n\n\r"
|
||||
+ "CONVECTIVE SIGMET 19C\n\n\r"
|
||||
+ "VALID UNTIL 1855Z\n\n\r"
|
||||
+ "MN IA NE\n\n\r"
|
||||
+ "FROM 50SE RWF-30W MCW-20SSE OVR\n\n\r"
|
||||
+ "LINE EMBD SEV TS 30 NM WIDE MOV FROM 26035KT. TOPS TO FL350.\n\n\r"
|
||||
+ "HAIL TO 1 IN...WIND GUSTS TO 50KT POSS.\n\n\r"
|
||||
+ "\n\n\r"
|
||||
+ "OUTLOOK VALID 261955-262355\n\n\r"
|
||||
+ "FROM 50E GRB-ROD-TTH-50E GRB\n\n\r"
|
||||
+ "WST ISSUANCES POSS. REFER TO MOST RECENT ACUS01 KWNS FROM STORM\n\n\r"
|
||||
+ "PREDICTION CENTER FOR SYNOPSIS AND METEOROLOGICAL DETAILS.\n\n\r";
|
||||
|
||||
ConvSigmetSection retSection = ConvSigmetParser
|
||||
.processPhenomena(testBull);
|
||||
|
||||
assertEquals(classType, retSection.getClassType());
|
||||
assertEquals(direction, retSection.getDirection());
|
||||
assertEquals(speed, retSection.getSpeed());
|
||||
assertEquals(flightLevel, retSection.getFlightLevel());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -39,7 +39,7 @@ public class FfgSeparatorTest {
|
|||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new FfgSeparator();
|
||||
File file = new File(
|
||||
"unit-test/gov/noaa/nws/ncep/edex/plugin/ffg/decoder/2008080415.FFG");
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/ffg/decoder/2008080415.FFG");
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
|
@ -0,0 +1,172 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ffg.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ffg.FfgPrecip;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ffg.FfgRecord;
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
//TODO fix?
|
||||
@Ignore
|
||||
public class FfgParserTest {
|
||||
FfgRecord record = new FfgRecord();
|
||||
|
||||
Set<FfgPrecip> ppp;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
record = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1ProcessAWIPSID() {
|
||||
/* Case I: Good report with a string of five characters */
|
||||
String str_t1 = "FFGMD \r\r\n" + "Dummying Strings";
|
||||
String retStr = FfgParser.processAwipsID(str_t1);
|
||||
assertEquals("FFGMD", retStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2ProcessAWIPSID() {
|
||||
/* Case II: Good report with a string of six characters */
|
||||
String str_t2 = "FFGNY2\r\r\n" + "Dummying Strings";
|
||||
String retStr = FfgParser.processAwipsID(str_t2);
|
||||
assertEquals("FFGNY2", retStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3ProcessAWIPSID() {
|
||||
/* Case III: Return null */
|
||||
String str_t3 = "FFGNY2 \r\r\n" + "Dummying Strings";
|
||||
String retStr = FfgParser.processAwipsID(str_t3);
|
||||
Object nu = null;
|
||||
assertNull((String) (nu), retStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
String hdr = "FOUS61 KRHA 041504\r\r\n" + "FFGMD \r\r\n";
|
||||
byte[] wmo_hdr = hdr.getBytes();
|
||||
Calendar cal = null;
|
||||
try {
|
||||
FfgParser.processWMO(wmo_hdr, record, cal);
|
||||
String retHdr = record.getWmoHeader();
|
||||
assertEquals("FOUS61 KRHA 041504", retHdr);
|
||||
String issue_office = record.getIssueOffice();
|
||||
assertEquals("KRHA", issue_office);
|
||||
String nu = record.getDesignatorBBB();
|
||||
assertEquals("", nu);
|
||||
} catch (Exception e) {
|
||||
// empty block
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1ProcessPrecip() {
|
||||
/* Case I: good case. */
|
||||
String precip = "DEZ001 3.0/ 4.2/ 4.5/ 4.8 / 6.0 :New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals(3.0, pr.getFf01());
|
||||
assertEquals(4.2, pr.getFf03());
|
||||
assertEquals(4.5, pr.getFf06());
|
||||
assertEquals(4.8, pr.getFf12());
|
||||
assertEquals(6.0, pr.getFf24());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2ProcessPrecip() {
|
||||
/* Case II: good case with "/" attached at the end of data */
|
||||
String precip = "DEZ001 3.0/ 4.2/ 4.5/ 4.8 / 6.0 / :New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals(3.0, pr.getFf01());
|
||||
assertEquals(4.2, pr.getFf03());
|
||||
assertEquals(4.5, pr.getFf06());
|
||||
assertEquals(4.8, pr.getFf12());
|
||||
assertEquals(6.0, pr.getFf24());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3ProcessPrecip() {
|
||||
/* Case III: Bad case with blank report */
|
||||
String precip = "DEZ001 3.0/ / 4.5/ / 6.0 /:New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals(3.0, pr.getFf01());
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf03(), 0.0);
|
||||
assertEquals(4.5, pr.getFf06());
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf12(), 0.0);
|
||||
assertEquals(6.0, pr.getFf24());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test4ProcessPrecip() {
|
||||
/* Case IV: Bad case without "/" */
|
||||
String precip = "DEZ001 3.0 :New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals(3.0, pr.getFf01());
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf03(), 0.0);
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf06(), 0.0);
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf12(), 0.0);
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf24(), 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test5ProcessPrecip() {
|
||||
/* Case V: Bad case with no report */
|
||||
String precip = "DEZ001 :New Castle Co.\r\r\n";
|
||||
FfgParser.processPrecip(precip, record);
|
||||
ppp = record.getFfgP();
|
||||
Iterator<FfgPrecip> it = ppp.iterator();
|
||||
while (it.hasNext()) {
|
||||
FfgPrecip pr = it.next();
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf01(), 0.0);
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf03(), 0.0);
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf06(), 0.0);
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf12(), 0.0);
|
||||
assertEquals(IDecoderConstantsN.FLOAT_MISSING.doubleValue(),
|
||||
(double) pr.getFf24(), 0.0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ public class IdftSeparatorTest {
|
|||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new IdftSeparator();
|
||||
File file = new File(
|
||||
"unit-test/gov/noaa/nws/ncep/edex/plugin/idft/decoder/2009060100.mar");
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/idft/decoder/2009060100.mar");
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* IdftParserTest.java
|
||||
*
|
||||
* Junit test for IdftParser
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 02Jun2009 100 F. J. Yen Initial creation
|
||||
* 27May2010 100 F. J. Yen Migrated from to11dr3 to to11dr11
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author Fee Jing Yen, SIB
|
||||
* @version 1
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.idft.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.idft.IdftRecord;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
// TODO fix?
|
||||
@Ignore
|
||||
public class IdftParserTest {
|
||||
IdftRecord record = new IdftRecord();
|
||||
|
||||
/*
|
||||
* Unable to test method readIdftLocs due to edex localization methods used
|
||||
* and junit test does not run edex. Unable to test for itype = 0 for the
|
||||
* same reason since the idftLocs.xml table is needed to obtain the lat/lon.
|
||||
*/
|
||||
|
||||
@Test
|
||||
public void testProcessIdft() {
|
||||
final String IDFT_DATALN2 = "(\\d{1,4}) +(\\d{0,2})\\.(\\d)(N|S) +(\\d{0,3})\\.(\\d)(W|E) +(\\d{1,3}) +(\\d{1,4})\\.(\\d)\\r\\r\\n";
|
||||
final Pattern dataLnPattern2 = Pattern.compile(IDFT_DATALN2);
|
||||
String thePntRec2 = " 410 66.8S 73.3W 253 2.4\r\r\n";
|
||||
Matcher m2 = dataLnPattern2.matcher(thePntRec2);
|
||||
if (m2.find()) {
|
||||
IdftParser.processIdft(m2, 6, record);
|
||||
assertEquals(410, record.getPointNum().intValue());
|
||||
assertEquals(-66.8, record.getLat());
|
||||
assertEquals(-73.3, record.getLon());
|
||||
assertEquals(253.0F, record.getDirection());
|
||||
assertEquals(2.4F, record.getDistanceNm());
|
||||
}
|
||||
thePntRec2 = " 390 50.5N 10.3E 180 4.5\r\r\n";
|
||||
m2 = dataLnPattern2.matcher(thePntRec2);
|
||||
if (m2.find()) {
|
||||
IdftParser.processIdft(m2, 6, record);
|
||||
assertEquals(390, record.getPointNum().intValue());
|
||||
assertEquals(50.5, record.getLat());
|
||||
assertEquals(10.3, record.getLon());
|
||||
assertEquals(180.0F, record.getDirection());
|
||||
assertEquals(4.5F, record.getDistanceNm());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the intlsigmet decoder separator.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 07/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
|
||||
package gov.noaa.nws.ncep.edex.plugin.intlsigmet.decoder;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class IntlSigmetSeparatorTest {
|
||||
IntlSigmetSeparator sep;
|
||||
|
||||
char[] cbuf;
|
||||
|
||||
int ntime = 0;
|
||||
|
||||
StringBuffer contents = new StringBuffer();
|
||||
|
||||
byte[] actual = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
sep = new IntlSigmetSeparator();
|
||||
File file = new File(
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/intlsigmet/decoder/2009060816.isig");
|
||||
System.out.println(file.toString());
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(file));
|
||||
String text = null;
|
||||
|
||||
// repeat until all lines is read
|
||||
while ((text = reader.readLine()) != null) {
|
||||
if (text.length() != 0) {
|
||||
contents.append(text).append("\r\r\n");
|
||||
}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
sep = new IntlSigmetSeparator();
|
||||
actual = contents.toString().getBytes();
|
||||
sep.setData(actual, null);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHasNext() {
|
||||
assertTrue("Find Convsigmet separator! ", sep.hasNext());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetRecord() {
|
||||
byte[] expected = sep.next();
|
||||
String a = new String(actual);
|
||||
String e = new String(expected);
|
||||
assertEquals(e.trim(), a.trim());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,358 @@
|
|||
/**
|
||||
* This Java class is the JUnit test for the intlsigmet parser.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* L. Lin 07/09 Creation
|
||||
* </pre>
|
||||
*
|
||||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.intlsigmet.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.intlsigmet.IntlSigmetLocation;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.intlsigmet.IntlSigmetRecord;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.zip.DataFormatException;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.edex.plugin.AbstractDecoder;
|
||||
import com.raytheon.edex.util.Util;
|
||||
|
||||
//TODO fix?
|
||||
@Ignore
|
||||
public class IntlSigmetParserTest extends AbstractDecoder {
|
||||
|
||||
@Test
|
||||
public void testProcessWMO() {
|
||||
|
||||
final String wmoHeader = "WSNT08";
|
||||
final String testBull = "WSNT08 KKCI 081620\n\n\r" + "SIGA0H\n\n\r";
|
||||
|
||||
IntlSigmetRecord record = null;
|
||||
|
||||
record = IntlSigmetParser.processWMO(testBull, null);
|
||||
String wmo = record.getWmoHeader();
|
||||
assertEquals(wmo, wmoHeader);
|
||||
|
||||
final String issueString = "081620";
|
||||
Calendar timeGroup = null;
|
||||
try {
|
||||
timeGroup = Util.findCurrentTime(issueString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get issue time");
|
||||
}
|
||||
Calendar issueTime = record.getIssueTime();
|
||||
System.out.println("======= This is the issue date:");
|
||||
System.out.println("issue date:year= " + timeGroup.get(Calendar.YEAR));
|
||||
System.out
|
||||
.println("issue date:month= " + timeGroup.get(Calendar.MONTH));
|
||||
System.out.println("issue date:day= "
|
||||
+ timeGroup.get(Calendar.DAY_OF_MONTH));
|
||||
System.out.println("issue date:hour= " + timeGroup.get(Calendar.HOUR));
|
||||
System.out.println("issue date:minute= "
|
||||
+ timeGroup.get(Calendar.MINUTE));
|
||||
|
||||
assertEquals(timeGroup, issueTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetHazardType() {
|
||||
|
||||
final String hazardType = "FREQUENT THUNDERSTORMS";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
String typeRet = IntlSigmetParser.getHazardType(testBull);
|
||||
assertEquals(hazardType, typeRet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMessageID() {
|
||||
|
||||
final String messageID = "HOTEL";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
String idRet = IntlSigmetParser.getMessageID(testBull);
|
||||
assertEquals(messageID, idRet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSequenceNumber() {
|
||||
|
||||
final String sequenceNo = "1";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
String retSeq = IntlSigmetParser.getSequenceNumber(testBull);
|
||||
assertEquals(sequenceNo, retSeq);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAtsu() {
|
||||
|
||||
final String atsu = "KZMA ";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
String retAtsu = IntlSigmetParser.getAtsu(testBull);
|
||||
assertEquals(atsu, retAtsu);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOmwo() {
|
||||
|
||||
final String omwo = "KKCI";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
String retOmwo = IntlSigmetParser.getOmwo(testBull);
|
||||
assertEquals(omwo, retOmwo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStartTime() {
|
||||
|
||||
final String timeString = "081620";
|
||||
final String testBull = "WSNT08 KKCI 081620\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
Calendar startTime = null;
|
||||
try {
|
||||
startTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get start time");
|
||||
}
|
||||
Calendar timeRet = IntlSigmetParser.getStartTime(testBull, null);
|
||||
|
||||
assertEquals(startTime, timeRet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEndTime() {
|
||||
|
||||
final String timeString = "082020";
|
||||
final String testBull = "WSNT08 KKCI 081620\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
Calendar endTime = null;
|
||||
try {
|
||||
endTime = Util.findCurrentTime(timeString);
|
||||
} catch (DataFormatException e) {
|
||||
System.out.println("Unable to get end time");
|
||||
}
|
||||
Calendar timeRet = IntlSigmetParser.getEndTime(testBull, null);
|
||||
|
||||
assertEquals(endTime, timeRet);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessFlightLevel() {
|
||||
|
||||
final int flightLevel = 460;
|
||||
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
IntlSigmetRecord retRecord = IntlSigmetParser
|
||||
.processWMO(testBull, null);
|
||||
IntlSigmetParser.processFlightLevels(testBull, retRecord);
|
||||
int retLevel = retRecord.getFlightlevel1();
|
||||
|
||||
assertEquals(flightLevel, retLevel);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRemarks() {
|
||||
|
||||
final String remarks = " CCA";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
String retRemarks = IntlSigmetParser.getRemarks(testBull);
|
||||
assertEquals(remarks, retRemarks);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetSpeed() {
|
||||
|
||||
final int speed = 20;
|
||||
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. MOV NE 20KT NC=\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
int retSpeed = IntlSigmetParser.getSpeed(testBull);
|
||||
|
||||
assertEquals(speed, retSpeed);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIntensity() {
|
||||
|
||||
final String intensity = "INTSF";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. STNR. INTSF.\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
String retIntensity = IntlSigmetParser.getIntensity(testBull);
|
||||
assertEquals(intensity, retIntensity);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDirection() {
|
||||
|
||||
final String direction = "SE";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. MOV SE 30KMH NC\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
String retDirection = IntlSigmetParser.getDirection(testBull);
|
||||
assertEquals(direction, retDirection);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDistance() {
|
||||
|
||||
final int distance = 180;
|
||||
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. \n\n\r"
|
||||
+ "WI 180NM OF CENTRE MOV NE 20KT NC=\n\n\r" + "\n\n\r";
|
||||
|
||||
int retDistance = IntlSigmetParser.getDistance(testBull);
|
||||
|
||||
assertEquals(distance, retDistance);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNameLocation() {
|
||||
|
||||
final String location = "HURRICANE IRENE LOCATED AT 23.4N 82.6W";
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "HURRICANE IRENE LOCATED AT 23.4N 82.6W MOVG N AT 2 KT.\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. MOV SE 30KMH NC\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
String retLocation = IntlSigmetParser.getNameLocation(testBull);
|
||||
assertEquals(location, retLocation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessLatLon() {
|
||||
|
||||
final String location = "N2500 W07400";
|
||||
final float locLat = (float) 25.0;
|
||||
final float locLon = (float) -74.0;
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "HURRICANE IRENE LOCATED AT 23.4N 82.6W MOVG N AT 2 KT.\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. MOV SE 30KMH NC\n\n\r"
|
||||
+ "\n\n\r";
|
||||
|
||||
IntlSigmetRecord record = IntlSigmetParser.processWMO(testBull, null);
|
||||
IntlSigmetLocation locTB = new IntlSigmetLocation();
|
||||
Integer index = 0;
|
||||
IntlSigmetParser.processLatLon(location, locTB, index, record);
|
||||
double lat = locTB.getLatitude();
|
||||
double lon = locTB.getLongitude();
|
||||
|
||||
assertEquals(lat, locLat);
|
||||
assertEquals(lon, locLon);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetThunderStorm() {
|
||||
|
||||
final String type = "FREQUENT THUNDERSTORMS";
|
||||
|
||||
final String testBull = "WSNT08 KKCI 081620 CCA\n\n\r"
|
||||
+ "SIGA0H\n\n\r"
|
||||
+ "KZMA SIGMET HOTEL 1 VALID 081620/082020 KKCI-\n\n\r"
|
||||
+ "MIAMI OCEANIC FIR FRQ TS OBS AT 1620Z WI N2500 W07400 - N2145\n\n\r"
|
||||
+ "W07445 - N2315 W07715 - N2500 W07400. TOP FL460. \n\n\r"
|
||||
+ "WI 180NM OF CENTRE MOV NE 20KT NC=\n\n\r" + "\n\n\r";
|
||||
|
||||
String retType = IntlSigmetParser.getThunderStorm(testBull);
|
||||
|
||||
assertEquals(type, retType);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveChar() {
|
||||
|
||||
final String type = "FREQUENT THUNDERSTORMS";
|
||||
final String retType = "FREQUENTTHUNDERSTORMS";
|
||||
|
||||
String retRemove = IntlSigmetParser.removeChar(type, ' ');
|
||||
|
||||
assertEquals(retRemove, retType);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -9,59 +9,50 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.mosaic.util.level3;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import java.util.Calendar;
|
||||
import org.junit.Test;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Level3ParserTest {
|
||||
File afile = new File ("unit-test/gov/noaa/nws/ncep/edex/plugin/mosaic/util/level3/CREF_4.00_20100316_0900");
|
||||
|
||||
@Before
|
||||
public void initialize () {
|
||||
}
|
||||
File afile = new File(
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/mosaic/util/level3/CREF_4.00_20100316_0900");
|
||||
|
||||
@Before
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLevel3Parser() throws IOException {
|
||||
@Test
|
||||
public void testLevel3Parser() throws IOException {
|
||||
|
||||
BufferedInputStream bufferedInput = null;
|
||||
BufferedInputStream bufferedInput = null;
|
||||
byte[] buffer = new byte[1024];
|
||||
try {
|
||||
|
||||
//Construct the BufferedInputStream object
|
||||
|
||||
// Construct the BufferedInputStream object
|
||||
bufferedInput = new BufferedInputStream(new FileInputStream(afile));
|
||||
|
||||
|
||||
int bytesRead = 0;
|
||||
|
||||
//Keep reading from the file while there is any content
|
||||
//when the end of the stream has been reached, -1 is returned
|
||||
bytesRead = bufferedInput.read(buffer);
|
||||
|
||||
|
||||
// Keep reading from the file while there is any content
|
||||
// when the end of the stream has been reached, -1 is returned
|
||||
bytesRead = bufferedInput.read(buffer);
|
||||
|
||||
} catch (FileNotFoundException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
//Close the BufferedInputStream
|
||||
// Close the BufferedInputStream
|
||||
try {
|
||||
if (bufferedInput != null)
|
||||
bufferedInput.close();
|
||||
|
@ -75,35 +66,33 @@ public class Level3ParserTest {
|
|||
|
||||
System.out.println(" theMessageCode=" + theMessageCode);
|
||||
|
||||
assertEquals(30,theMessageCode);
|
||||
|
||||
assertEquals(30, theMessageCode);
|
||||
|
||||
Calendar theMsgTimestamp = Calendar.getInstance();
|
||||
theMsgTimestamp.setTimeInMillis(this.createTimestamp(theMosaicData
|
||||
.readUnsignedShort(), theMosaicData.readInt()));
|
||||
|
||||
theMsgTimestamp.setTimeInMillis(this.createTimestamp(
|
||||
theMosaicData.readUnsignedShort(), theMosaicData.readInt()));
|
||||
|
||||
int theMsgLength = theMosaicData.readInt();
|
||||
System.out.println(" theMsgLength=" + theMsgLength);
|
||||
assertEquals(145930,theMsgLength);
|
||||
assertEquals(145930, theMsgLength);
|
||||
|
||||
// TODO: validate message length here and not everywhere else
|
||||
|
||||
int theSourceId = theMosaicData.readShort();
|
||||
System.out.println(" theSourceId=" + theSourceId);
|
||||
assertEquals(10000,theSourceId);
|
||||
assertEquals(10000, theSourceId);
|
||||
|
||||
int theDestinationId = theMosaicData.readShort();
|
||||
System.out.println(" theDestinationId=" + theDestinationId);
|
||||
assertEquals(0,theDestinationId);
|
||||
assertEquals(0, theDestinationId);
|
||||
|
||||
int numberOfBlocks = theMosaicData.readShort();
|
||||
System.out.println(" the number of blocks=" + numberOfBlocks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private long createTimestamp(int readUnsignedShort, int readInt) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
private long createTimestamp(int readUnsignedShort, int readInt) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -13,8 +13,6 @@ package gov.noaa.nws.ncep.edex.plugin.ncpafm.decoder;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncpafm.decoder.NcPafmSeparator;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -41,7 +39,7 @@ public class NcPafmSeparatorTest {
|
|||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new NcPafmSeparator();
|
||||
File file = new File(
|
||||
"unit-test/gov/noaa/nws/ncep/edex/plugin/ncpafm/decoder/2009060919.rdfFF_SVR");
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/ncpafm/decoder/2009060919.rdfFF_SVR");
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
|
@ -18,8 +18,6 @@ package gov.noaa.nws.ncep.edex.plugin.ncscd.decoder;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import gov.noaa.nws.ncep.edex.plugin.ncscd.decoder.NcScdSeparator;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -28,8 +26,11 @@ import java.io.IOException;
|
|||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
//TODO fix?
|
||||
@Ignore
|
||||
public class NcScdSeparatorTest {
|
||||
NcScdSeparator sep;
|
||||
|
||||
|
@ -46,7 +47,7 @@ public class NcScdSeparatorTest {
|
|||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new NcScdSeparator();
|
||||
File file = new File(
|
||||
"unit-test/gov/noaa/nws/ncep/edex/plugin/ncscd/decoder/2009012900.SCD");
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/ncscd/decoder/2009012900.SCD");
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
|
@ -0,0 +1,184 @@
|
|||
package gov.noaa.nws.ncep.edex.plugin.ncscd.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import gov.noaa.nws.ncep.common.dataplugin.ncscd.NcScdRecord;
|
||||
import gov.noaa.nws.ncep.common.tools.IDecoderConstantsN;
|
||||
import gov.noaa.nws.ncep.edex.util.UtilN;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.edex.util.Util;
|
||||
|
||||
//TODO fix?
|
||||
@Ignore
|
||||
public class NcScdParserTest {
|
||||
final double EPSILON = 0.01;
|
||||
|
||||
String good_report_case1;
|
||||
|
||||
String good_report_case2;
|
||||
|
||||
String good_report_case3;
|
||||
|
||||
String bad_report;
|
||||
|
||||
String issueTime_case1;
|
||||
|
||||
String issueTime_case2;
|
||||
|
||||
NcScdRecord record;
|
||||
|
||||
Calendar cal;
|
||||
|
||||
Integer month;
|
||||
|
||||
@Before
|
||||
public void initialize() {
|
||||
good_report_case1 = "KDCA SCD 0045 8123456 70041 400500024\r\r\n";
|
||||
good_report_case2 = "KDCA SCD COR 0550 -SHRA FZRA FZDZ SHPL 888/3// 931022 933003\r\r\n"
|
||||
+ "4/030 60012 98122 24/931043 70041 400501094\r\r\n";
|
||||
good_report_case3 = "KDCA SCD 2355 410511094\r\r\n";
|
||||
bad_report = "KDCA SCD XXX 2355 -RA\r\r\n";
|
||||
issueTime_case1 = "280050";
|
||||
/*
|
||||
* Find month based on the date of the issuance time
|
||||
*/
|
||||
Calendar cdr = UtilN.findDataTime(issueTime_case1, (Calendar) null);
|
||||
month = cdr.get(Calendar.MONTH);
|
||||
record = new NcScdRecord();
|
||||
cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
|
||||
try {
|
||||
record.setIssueTime(Util.findCurrentTime(issueTime_case1));
|
||||
} catch (Exception e) {
|
||||
// no statement block
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1ProcessNcScd() {
|
||||
|
||||
/*
|
||||
* Case I: Good report
|
||||
*/
|
||||
try {
|
||||
NcScdParser.processNcScd(good_report_case1, record);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("KDCA", record.getStationId());
|
||||
assertEquals("REG", record.getCorIndicator());
|
||||
assertEquals(1L, (long) record.getCFRT());
|
||||
assertEquals(2L, (long) record.getCFRL());
|
||||
assertEquals(3L, (long) record.getCTYL());
|
||||
assertEquals(4L, (long) record.getCBAS());
|
||||
assertEquals(5L, (long) record.getCTYM());
|
||||
assertEquals(6L, (long) record.getCTYH());
|
||||
assertEquals(5.0D, (double) record.getTDXC(), EPSILON);
|
||||
assertEquals(2.4D, (double) record.getTDNC(), EPSILON);
|
||||
assertEquals(0.41D, (double) record.getP24I(), EPSILON);
|
||||
|
||||
/*
|
||||
* Test observation time for the 1st case.
|
||||
*/
|
||||
cal.set(Calendar.MONTH, month);
|
||||
cal.set(Calendar.DAY_OF_MONTH, 28);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
cal.set(Calendar.MINUTE, 45);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(cal, record.getObsTime());
|
||||
assertEquals(record.getSuspectTimeFlag(), "false");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test2ProcessNcScd() {
|
||||
|
||||
/*
|
||||
* Case II: Good report with COR, two liners and lengthy weather report
|
||||
*/
|
||||
try {
|
||||
NcScdParser.processNcScd(good_report_case2, record);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("COR", record.getCorIndicator());
|
||||
assertEquals(8L, (long) record.getCFRT());
|
||||
assertEquals(8L, (long) record.getCFRL());
|
||||
assertEquals(IDecoderConstantsN.INTEGER_MISSING.longValue(),
|
||||
(long) record.getCTYL());
|
||||
assertEquals(IDecoderConstantsN.INTEGER_MISSING.longValue(),
|
||||
(long) record.getCTYM());
|
||||
assertEquals(IDecoderConstantsN.INTEGER_MISSING.longValue(),
|
||||
(long) record.getCTYH());
|
||||
assertEquals(3L, (long) record.getCBAS());
|
||||
assertEquals(122L, (long) record.getMSUN());
|
||||
assertEquals(2.2D, (double) record.getSNEW(), EPSILON);
|
||||
assertEquals(0.3D, (double) record.getWEQS(), EPSILON);
|
||||
assertEquals(3.0D, (double) record.getSNOW(), EPSILON);
|
||||
assertEquals(4.3D, (double) record.getS24I(), EPSILON);
|
||||
assertEquals(5.0D, (double) record.getTDXC(), EPSILON);
|
||||
assertEquals(-9.4D, (double) record.getTDNC(), EPSILON);
|
||||
assertEquals(0.12D, (double) record.getP06I(), EPSILON);
|
||||
assertEquals(0.41D, (double) record.getP24I(), EPSILON);
|
||||
assertEquals("-SHRA FZRA FZDZ SHPL", record.getWTHR());
|
||||
|
||||
/*
|
||||
* Test observation time 2nd case. Issue Time: 250050 Obs Time: 0550
|
||||
*/
|
||||
cal.set(Calendar.MONTH, month);
|
||||
cal.set(Calendar.DAY_OF_MONTH, 27);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 5);
|
||||
cal.set(Calendar.MINUTE, 50);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(cal, record.getObsTime());
|
||||
assertEquals(record.getSuspectTimeFlag(), "true");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test3ProcessNcScd() {
|
||||
|
||||
/*
|
||||
* Case III: Good report with date change
|
||||
*/
|
||||
try {
|
||||
NcScdParser.processNcScd(good_report_case3, record);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals(-5.1D, (double) record.getTDXC(), EPSILON);
|
||||
assertEquals(-9.4D, (double) record.getTDNC(), EPSILON);
|
||||
|
||||
/*
|
||||
* Test observation time for the 3rd case. Issue time: 250050. Obs time:
|
||||
* 2355.
|
||||
*/
|
||||
cal.set(Calendar.MONTH, month);
|
||||
cal.set(Calendar.DAY_OF_MONTH, 27);
|
||||
cal.set(Calendar.HOUR_OF_DAY, 23);
|
||||
cal.set(Calendar.MINUTE, 55);
|
||||
cal.set(Calendar.SECOND, 0);
|
||||
cal.set(Calendar.MILLISECOND, 0);
|
||||
assertEquals(cal, record.getObsTime());
|
||||
assertEquals(record.getSuspectTimeFlag(), "false");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test4ProcessNcScd() {
|
||||
|
||||
/*
|
||||
* Case IV: Bad report with "XXX" instead of "COR"
|
||||
*/
|
||||
try {
|
||||
NcScdParser.processNcScd(bad_report, record);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assertEquals("XXX", record.getCorIndicator());
|
||||
}
|
||||
}
|
|
@ -12,13 +12,8 @@
|
|||
*/
|
||||
package gov.noaa.nws.ncep.edex.plugin.nctaf.decoder;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import gov.noaa.nws.ncep.common.dataplugin.nctaf.NcTafRecord;
|
||||
import gov.noaa.nws.ncep.edex.plugin.nctaf.decoder.NcTafSeparator;
|
||||
import gov.noaa.nws.ncep.edex.plugin.nctaf.decoder.NcTafParser;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -30,7 +25,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
public class NcTafSeparatorTest {
|
||||
NcTafSeparator sep;
|
||||
NcTafSeparator sep;
|
||||
|
||||
char[] cbuf;
|
||||
|
||||
|
@ -45,7 +40,7 @@ public class NcTafSeparatorTest {
|
|||
final Logger log = Logger.getLogger(getClass().getName());
|
||||
sep = new NcTafSeparator();
|
||||
File file = new File(
|
||||
"unit-test/gov/noaa/nws/ncep/edex/plugin/nctaf/decoder/2011091217.TAF");
|
||||
"unit/gov/noaa/nws/ncep/edex/plugin/nctaf/decoder/2011091217.TAF");
|
||||
BufferedReader reader = null;
|
||||
|
||||
try {
|
||||
|
@ -93,22 +88,16 @@ public class NcTafSeparatorTest {
|
|||
/*
|
||||
* "Normal" case.
|
||||
*/
|
||||
/*@Test
|
||||
public void testNext1() {
|
||||
NcTafDecoder.NcTafDecoderInput input = sep.next();
|
||||
NcTafParser parser = null;
|
||||
NcTafRecord record = null;
|
||||
String expected = null;
|
||||
try {
|
||||
parser = new NcTafParser(input.tafParts, input.wmoHeader);
|
||||
record = parser.getDecodedRecord();
|
||||
expected = record.toString();
|
||||
}catch (Exception e) {
|
||||
}
|
||||
String actual = "302 \r\r\n" + "FTUS45 KPUB 121700 RRA\r\r\n"
|
||||
+ "TAFCOS\r\r\n"+ "TAF\r\r\n" + "KCOS 121202Z 1218/1318 16008KT P6SM SCT100\r\r\n" + "FM130200 36010KT P6SM SCT100=\r\r\n";
|
||||
//String e = new String(expected);
|
||||
assertEquals(expected.trim(), actual.trim());
|
||||
}*/
|
||||
|
||||
/*
|
||||
* @Test public void testNext1() { NcTafDecoder.NcTafDecoderInput input =
|
||||
* sep.next(); NcTafParser parser = null; NcTafRecord record = null; String
|
||||
* expected = null; try { parser = new NcTafParser(input.tafParts,
|
||||
* input.wmoHeader); record = parser.getDecodedRecord(); expected =
|
||||
* record.toString(); }catch (Exception e) { } String actual = "302 \r\r\n"
|
||||
* + "FTUS45 KPUB 121700 RRA\r\r\n" + "TAFCOS\r\r\n"+ "TAF\r\r\n" +
|
||||
* "KCOS 121202Z 1218/1318 16008KT P6SM SCT100\r\r\n" +
|
||||
* "FM130200 36010KT P6SM SCT100=\r\r\n"; //String e = new String(expected);
|
||||
* assertEquals(expected.trim(), actual.trim()); }
|
||||
*/
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue