@@ -0,0 +1,2095 @@
+package org.firmata4j.firmata.parser;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0Aimport java.util.concurrent.atomic.AtomicInteger;%0A%0Aimport org.firmata4j.fsm.Event;%0Aimport org.junit.After;%0Aimport org.junit.Test;%0A%0Apublic class FirmataParserTest %7B%0A    @After%0A    public void tearDown() throws InterruptedException %7B%0A        assertIfThreadStillRunning(%22firmata%22);%0A        assertIfThreadStillRunning(%22parser%22);%0A    %7D%0A%0A    @Test%0A    public void testConstruct() %7B%0A        FirmataParser parser = new FirmataParser() %7B%0A            @Override%0A            public void onEvent(Event event) %7B%0A%0A            %7D%0A        %7D;%0A%0A        parser.start();%0A%0A        parser.stop();%0A    %7D%0A%0A    @Test%0A    public void testStartAndStopTwice() %7B%0A        FirmataParser parser = new FirmataParser() %7B%0A            @Override%0A            public void onEvent(Event event) %7B%0A%0A            %7D%0A        %7D;%0A%0A        parser.start();%0A        parser.start();%0A%0A        parser.stop();%0A        parser.stop();%0A    %7D%0A%0A    @Test%0A    public void testParse() throws InterruptedException %7B%0A        final AtomicInteger eventCount = new AtomicInteger(0);%0A        FirmataParser parser = new FirmataParser() %7B%0A            @Override%0A            public void onEvent(Event event) %7B%0A                eventCount.incrementAndGet();%0A            %7D%0A        %7D;%0A%0A        parser.start();%0A%0A        parser.parse(new byte%5B%5D %7B1, 2, 3%7D);%0A%0A        int i = 0;%0A        while(eventCount.get() %3C 3 && i %3C 20) %7B%0A            Thread.sleep(100);%0A            i++;%0A        %7D%0A        assertEquals(%22Should receive 3 events for each byte an 'unknown' error event%22,%0A                3, eventCount.get());%0A%0A        parser.stop();%0A    %7D%0A%0A    private static void assertIfThreadStillRunning(final String contains) throws InterruptedException %7B%0A        int count = Thread.currentThread().getThreadGroup().activeCount();%0A%0A        Thread%5B%5D threads = new Thread%5Bcount%5D;%0A        Thread.currentThread().getThreadGroup().enumerate(threads);%0A%0A        for (Thread t : threads) %7B%0A            if (t != null && t.getName().contains(contains)) %7B%0A                t.join();%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add initial unit-test for FirmataParser