Search in sources :

Example 1 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence 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());
}
Also used : FOOParser(net.sf.marineapi.test.util.FOOParser) FOOSentence(net.sf.marineapi.test.util.FOOSentence) BODSentence(net.sf.marineapi.nmea.sentence.BODSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence) Test(org.junit.Test)

Example 2 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence in project marine-api by ktuukkan.

the class SentenceFactoryTest method testCreateEmptyCustomParser.

/**
	 * Test method for
	 * {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
	 * .
	 */
@Test
public void testCreateEmptyCustomParser() {
    try {
        instance.registerParser("FOO", FOOParser.class);
        assertTrue(instance.hasParser("FOO"));
    } catch (Exception e) {
        fail("parser registering failed");
    }
    Sentence s = instance.createParser(TalkerId.II, "FOO");
    assertNotNull(s);
    assertTrue(s instanceof Sentence);
    assertTrue(s instanceof SentenceParser);
    assertTrue(s instanceof FOOParser);
    assertEquals("FOO", s.getSentenceId());
}
Also used : FOOParser(net.sf.marineapi.test.util.FOOParser) FOOSentence(net.sf.marineapi.test.util.FOOSentence) BODSentence(net.sf.marineapi.nmea.sentence.BODSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence) Test(org.junit.Test)

Example 3 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence 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);
}
Also used : FOOSentence(net.sf.marineapi.test.util.FOOSentence) FOOParser(net.sf.marineapi.test.util.FOOParser) FOOSentence(net.sf.marineapi.test.util.FOOSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence) Test(org.junit.Test)

Example 4 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence in project marine-api by ktuukkan.

the class SentenceParserTest method testConstructorWithAIVDM.

/**
	 * Test method for SenteceParser constructor.
	 */
@Test
public void testConstructorWithAIVDM() {
    Sentence s = new SentenceParser(VDM_EXAMPLE);
    assertTrue(s.isValid());
    assertFalse(s.isProprietary());
    assertEquals(Sentence.ALTERNATIVE_BEGIN_CHAR, s.getBeginChar());
    assertEquals(VDM_EXAMPLE, s.toString());
}
Also used : FOOSentence(net.sf.marineapi.test.util.FOOSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence) Test(org.junit.Test)

Example 5 with Sentence

use of net.sf.marineapi.nmea.sentence.Sentence in project marine-api by ktuukkan.

the class SentenceParserTest method testConstructorWithAIVDO.

/**
	 * Test method for SenteceParser constructor.
	 */
@Test
public void testConstructorWithAIVDO() {
    Sentence s = new SentenceParser(VDO_EXAMPLE);
    assertTrue(s.isValid());
    assertFalse(s.isProprietary());
    assertEquals(Sentence.ALTERNATIVE_BEGIN_CHAR, s.getBeginChar());
    assertEquals(VDO_EXAMPLE, s.toString());
}
Also used : FOOSentence(net.sf.marineapi.test.util.FOOSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence) Test(org.junit.Test)

Aggregations

Sentence (net.sf.marineapi.nmea.sentence.Sentence)27 Test (org.junit.Test)20 FOOSentence (net.sf.marineapi.test.util.FOOSentence)10 BODSentence (net.sf.marineapi.nmea.sentence.BODSentence)8 GGATest (net.sf.marineapi.nmea.parser.GGATest)7 SentenceEvent (net.sf.marineapi.nmea.event.SentenceEvent)6 SentenceFactory (net.sf.marineapi.nmea.parser.SentenceFactory)6 BODTest (net.sf.marineapi.nmea.parser.BODTest)4 GLLTest (net.sf.marineapi.nmea.parser.GLLTest)3 HDGTest (net.sf.marineapi.nmea.parser.HDGTest)3 HDMTest (net.sf.marineapi.nmea.parser.HDMTest)3 HDTTest (net.sf.marineapi.nmea.parser.HDTTest)3 RMCTest (net.sf.marineapi.nmea.parser.RMCTest)3 FOOParser (net.sf.marineapi.test.util.FOOParser)3 GGASentence (net.sf.marineapi.nmea.sentence.GGASentence)2 GLLSentence (net.sf.marineapi.nmea.sentence.GLLSentence)2 GSASentence (net.sf.marineapi.nmea.sentence.GSASentence)2 GSVSentence (net.sf.marineapi.nmea.sentence.GSVSentence)2 RMCSentence (net.sf.marineapi.nmea.sentence.RMCSentence)2 SentenceId (net.sf.marineapi.nmea.sentence.SentenceId)2