use of net.sf.marineapi.test.util.FOOSentence in project marine-api by ktuukkan.
the class SentenceFactoryTest method testCreateCustomParser.
/**
* Test method for
* {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
* .
*/
@Test
public void testCreateCustomParser() {
try {
instance.registerParser("FOO", FOOParser.class);
assertTrue(instance.hasParser("FOO"));
} catch (Exception e) {
fail("parser registering failed");
}
Sentence s = null;
try {
s = instance.createParser("$IIFOO,aa,bb,cc");
} catch (Exception e) {
fail("sentence parsing failed");
}
assertNotNull(s);
assertTrue(s instanceof Sentence);
assertTrue(s instanceof SentenceParser);
assertTrue(s instanceof FOOParser);
assertEquals(TalkerId.II, s.getTalkerId());
assertEquals("FOO", s.getSentenceId());
assertEquals("aa", ((FOOSentence) s).getValueA());
assertEquals("bb", ((FOOSentence) s).getValueB());
assertEquals("cc", ((FOOSentence) s).getValueC());
}
use of net.sf.marineapi.test.util.FOOSentence in project marine-api by ktuukkan.
the class SentenceParserTest method testConstructorWithCustomParser.
/**
* Test method for SentenceParser constructors called from derived custom
* parsers.
*/
@Test
public void testConstructorWithCustomParser() {
final String foo = "FOO";
SentenceFactory sf = SentenceFactory.getInstance();
sf.registerParser(foo, FOOParser.class);
final String fooSentence = "$GPFOO,B,A,R";
final FOOSentence fp = new FOOParser(fooSentence);
final Sentence s = sf.createParser(fooSentence);
assertTrue(s instanceof SentenceParser);
assertTrue(s instanceof FOOParser);
assertEquals(foo, s.getSentenceId());
assertEquals(TalkerId.GP, s.getTalkerId());
assertEquals(s, fp);
}
Aggregations