Пример #1
0
 public void testReadFamily2() {
   // setup the test object with guts
   DecoderIndexFile di = new DecoderIndexFile();
   setupDoc();
   di.readMfgSection(decoderIndexElement);
   // parse a single Family
   di.readFamily(family2);
   // expect to find two decoders in a single family
   Assert.assertEquals("number of decoders ", 3, di.numDecoders());
   // check family entry
   Assert.assertEquals("1st decoder model ", "FX2 family", (di.decoderList.get(0)).getModel());
   Assert.assertEquals("1st decoder mfg ", "Digitrax", (di.decoderList.get(0)).getMfg());
   Assert.assertEquals("1st decoder mfgID ", "129", (di.decoderList.get(0)).getMfgID());
   Assert.assertEquals("1st decoder family ", "FX2 family", (di.decoderList.get(0)).getFamily());
   Assert.assertEquals("1st decoder numFns ", -1, (di.decoderList.get(0)).getNumFunctions());
   Assert.assertEquals("1st decoder numOuts ", -1, (di.decoderList.get(0)).getNumOutputs());
   // check first read decoder
   Assert.assertEquals("1st decoder model ", "DH142", (di.decoderList.get(1)).getModel());
   Assert.assertEquals("1st decoder mfg ", "Digitrax", (di.decoderList.get(1)).getMfg());
   Assert.assertEquals("1st decoder mfgID ", "129", (di.decoderList.get(1)).getMfgID());
   Assert.assertEquals("1st decoder family ", "FX2 family", (di.decoderList.get(1)).getFamily());
   Assert.assertEquals("1st decoder numFns ", 4, (di.decoderList.get(1)).getNumFunctions());
   Assert.assertEquals("1st decoder numOuts ", 2, (di.decoderList.get(1)).getNumOutputs());
   // check second real decoder
   Assert.assertEquals("2nd decoder model ", "DN142", (di.decoderList.get(2)).getModel());
   Assert.assertEquals("2nd decoder mfg ", "Digitrax", (di.decoderList.get(2)).getMfg());
   Assert.assertEquals("2nd decoder mfgID ", "129", (di.decoderList.get(2)).getMfgID());
   Assert.assertEquals("2nd decoder family ", "FX2 family", (di.decoderList.get(2)).getFamily());
   Assert.assertEquals("2nd decoder numFns ", 5, (di.decoderList.get(2)).getNumFunctions());
   Assert.assertEquals("2nd decoder numOuts ", 1, (di.decoderList.get(2)).getNumOutputs());
 }
Пример #2
0
 public void testLoading() {
   // setup the test object with guts
   DecoderIndexFile di = new DecoderIndexFile();
   setupDoc();
   // invoke parsing
   di.readMfgSection(decoderIndexElement);
   di.readFamilySection(decoderIndexElement);
   // success here is getting to the end
 }
Пример #3
0
 public void testMfgSection() {
   // setup the test object with guts
   DecoderIndexFile di = new DecoderIndexFile();
   setupDoc();
   // invoke parsing
   di.readMfgSection(decoderIndexElement);
   // check results
   Assert.assertEquals("Digitrax ID from name ", "129", di.mfgIdFromName("Digitrax"));
   Assert.assertEquals("NMRA ID from name ", null, di.mfgIdFromName("NMRA"));
   Assert.assertEquals("Digitrax name from id ", "Digitrax", di.mfgNameFromId("129"));
 }
Пример #4
0
 public void testReadFamilySection() {
   // setup the test object with guts
   DecoderIndexFile di = new DecoderIndexFile();
   setupDoc();
   // invoke parsing
   di.readMfgSection(decoderIndexElement);
   di.readFamilySection(decoderIndexElement);
   // check first Digitrax decoder in test tree; actually the 5th decoder (counting 2 families)
   Assert.assertEquals("1st decoder model ", "DH142", (di.decoderList.get(4)).getModel());
   Assert.assertEquals("1st decoder mfg ", "Digitrax", (di.decoderList.get(4)).getMfg());
   Assert.assertEquals("1st decoder mfgID ", "129", (di.decoderList.get(4)).getMfgID());
   Assert.assertEquals("1st decoder family ", "FX2 family", (di.decoderList.get(4)).getFamily());
 }
Пример #5
0
 public void testReadFamily1() {
   // setup the test object with guts
   DecoderIndexFile di = new DecoderIndexFile();
   setupDoc();
   di.readMfgSection(decoderIndexElement);
   // parse a single Family
   di.readFamily(family1);
   // expect to find two decoders in a single family
   Assert.assertEquals("number of decoders ", 3, di.numDecoders());
   // check second one
   Assert.assertEquals("2nd decoder model ", "full set", (di.decoderList.get(1)).getModel());
   Assert.assertEquals("2nd decoder mfg ", "NMRA", (di.decoderList.get(1)).getMfg());
   Assert.assertEquals("2nd decoder mfgID ", null, (di.decoderList.get(1)).getMfgID());
   Assert.assertEquals(
       "2nd decoder family ", "NMRA S&RP definitions", (di.decoderList.get(1)).getFamily());
 }
Пример #6
0
 public void testMatchingVersionRange() {
   // setup the test object with guts
   DecoderIndexFile di = new DecoderIndexFile();
   setupDoc();
   // invoke parsing
   di.readMfgSection(decoderIndexElement);
   di.readFamilySection(decoderIndexElement);
   // search for the one with various version IDs
   List<DecoderFile> l3;
   l3 = di.matchingDecoderList(null, null, null, "20", null, null);
   Assert.assertEquals("Found with version 20 ", 0, l3.size());
   l3 = di.matchingDecoderList(null, null, null, "21", null, null);
   Assert.assertEquals("Found with version 21 ", 1, l3.size());
   l3 = di.matchingDecoderList(null, null, null, "22", null, null);
   Assert.assertEquals("Found with version 22 ", 1, l3.size());
   l3 = di.matchingDecoderList(null, null, null, "23", null, null);
   Assert.assertEquals("Found with version 23 ", 1, l3.size());
   l3 = di.matchingDecoderList(null, null, null, "24", null, null);
   Assert.assertEquals("Found with version 24 ", 1, l3.size());
   l3 = di.matchingDecoderList(null, null, null, "25", null, null);
   Assert.assertEquals("Found with version 25 ", 0, l3.size());
 }
Пример #7
0
 public void testMatchingComboBox() {
   // setup the test object with guts
   DecoderIndexFile di = new DecoderIndexFile();
   setupDoc();
   // invoke parsing
   di.readMfgSection(decoderIndexElement);
   di.readFamilySection(decoderIndexElement);
   // search for the two Digitrax decoders
   JComboBox<String> l1 = di.matchingComboBox("Digitrax", null, null, null, null, null);
   Assert.assertEquals("Found with name Digitrax ", 3, l1.getItemCount());
   Assert.assertEquals("Found with name Digitrax ", "DH142 (FX2 family)", l1.getItemAt(1));
   Assert.assertEquals("Found with name Digitrax ", "DN142 (FX2 family)", l1.getItemAt(2));
   // search for the two decoders from mfgID 129
   JComboBox<String> l2 = di.matchingComboBox(null, null, "129", null, null, null);
   Assert.assertEquals("Found with id 129 ", 3, l2.getItemCount());
   // search for the two from the NMRA family
   JComboBox<String> l4 =
       di.matchingComboBox(null, "NMRA S&RP definitions", null, null, null, null);
   Assert.assertEquals("Found from NMRA family ", 3, l4.getItemCount());
   // search for the one with version ID 21
   JComboBox<String> l3 = di.matchingComboBox(null, null, null, "21", null, null);
   Assert.assertEquals("Found with version 21 ", 1, l3.getItemCount());
 }
Пример #8
0
 public void testMatchingDecoderList() {
   // setup the test object with guts
   DecoderIndexFile di = new DecoderIndexFile();
   setupDoc();
   // invoke parsing
   di.readMfgSection(decoderIndexElement);
   di.readFamilySection(decoderIndexElement);
   // search for the two Digitrax decoders
   List<DecoderFile> l1 = di.matchingDecoderList("Digitrax", null, null, null, null, null);
   Assert.assertEquals("Found with name Digitrax ", 3, l1.size());
   Assert.assertEquals("Found with name Digitrax ", "DH142", (l1.get(1)).getModel());
   Assert.assertEquals("Found with name Digitrax ", "DN142", (l1.get(2)).getModel());
   // search for the two decoders from mfgID 129
   List<DecoderFile> l2 = di.matchingDecoderList(null, null, "129", null, null, null);
   Assert.assertEquals("Found with id 129 ", 3, l2.size());
   // search for the two from the NMRA family
   List<DecoderFile> l4 =
       di.matchingDecoderList(null, "NMRA S&RP definitions", null, null, null, null);
   Assert.assertEquals("Found from NMRA family ", 3, l4.size());
   // search for the one with version ID 21
   List<DecoderFile> l3 = di.matchingDecoderList(null, null, null, "21", null, null);
   Assert.assertEquals("Found with version 21 ", 1, l3.size());
 }