Search in sources :

Example 21 with Sentence

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

the class SentenceFactoryTest method testRegisterParserWithAlternativeBeginChar.

/**
	 * Test method for
	 * {@link net.sf.marineapi.nmea.parser.SentenceFactory#registerParser(java.lang.String, java.lang.Class)}
	 * .
	 */
@Test
public void testRegisterParserWithAlternativeBeginChar() {
    try {
        instance.registerParser("VDM", VDMParser.class);
        assertTrue(instance.hasParser("VDM"));
    } catch (Exception e) {
        fail("parser registering failed");
    }
    Sentence s = instance.createParser("!AIVDM,1,2,3");
    assertNotNull(s);
    assertTrue(s instanceof Sentence);
    assertTrue(s instanceof SentenceParser);
    assertTrue(s instanceof VDMParser);
    instance.unregisterParser(VDMParser.class);
    assertFalse(instance.hasParser("VDM"));
}
Also used : VDMParser(net.sf.marineapi.test.util.VDMParser) 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 22 with Sentence

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

the class SentenceFactoryTest method testCreateParser.

/**
	 * Test method for
	 * {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
	 * .
	 */
@Test
public void testCreateParser() {
    Sentence bod = instance.createParser(BODTest.EXAMPLE);
    assertNotNull(bod);
    assertTrue(bod instanceof Sentence);
    assertTrue(bod instanceof BODSentence);
    assertTrue(bod instanceof BODParser);
    assertEquals(BODTest.EXAMPLE, bod.toSentence());
}
Also used : BODSentence(net.sf.marineapi.nmea.sentence.BODSentence) 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 23 with Sentence

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

the class SentenceFactoryTest method testCreateEmptyParserWithSentenceIdStr.

/**
	 * Test method for
	 * {@link net.sf.marineapi.nmea.parser.SentenceFactory#createParser(java.lang.String)}
	 * .
	 */
@Test
public void testCreateEmptyParserWithSentenceIdStr() {
    for (SentenceId id : SentenceId.values()) {
        Sentence s = instance.createParser(TalkerId.II, id.name());
        assertNotNull(s);
        assertTrue(s instanceof Sentence);
        assertTrue(s instanceof SentenceParser);
    }
}
Also used : SentenceId(net.sf.marineapi.nmea.sentence.SentenceId) 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 24 with Sentence

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

the class SentenceParserTest method testConstructorForEmptySentence.

/**
	 * Test method for SenteceParser constructor.
	 */
@Test
public void testConstructorForEmptySentence() {
    Sentence s = new SentenceParser(TalkerId.GP, SentenceId.GLL, 5);
    assertEquals("$GPGLL,,,,,*7C", s.toString());
}
Also used : FOOSentence(net.sf.marineapi.test.util.FOOSentence) Sentence(net.sf.marineapi.nmea.sentence.Sentence) Test(org.junit.Test)

Example 25 with Sentence

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

the class HeadingProviderTest method testHDMSentenceRead.

/**
	 * Test method for
	 * {@link net.sf.marineapi.provider.AbstractProvider#sentenceRead(net.sf.marineapi.nmea.event.SentenceEvent)}
	 * .
	 */
@Test
public void testHDMSentenceRead() {
    Sentence s = factory.createParser(HDMTest.EXAMPLE);
    assertNull(event);
    instance.sentenceRead(new SentenceEvent(this, s));
    assertNotNull(event);
    assertEquals(90.0, event.getHeading(), 0.1);
    assertFalse(event.isTrue());
}
Also used : SentenceEvent(net.sf.marineapi.nmea.event.SentenceEvent) Sentence(net.sf.marineapi.nmea.sentence.Sentence) HDMTest(net.sf.marineapi.nmea.parser.HDMTest) Test(org.junit.Test) HDTTest(net.sf.marineapi.nmea.parser.HDTTest) HDGTest(net.sf.marineapi.nmea.parser.HDGTest)

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