Example #1
0
    // TODO FIX-TEST
    public final void NtestRead() {
      final DebriefXMLReaderWriter reader = new DebriefXMLReaderWriter(null);
      final Layers res = new Layers();
      final String fName = "../org.mwc.debrief.legacy/src/test_tma_read_write.xml";

      final java.io.File fileTest = new File(fName);
      assertTrue("Test file not found:" + fName, fileTest.exists());

      try {
        final java.io.FileInputStream fis = new java.io.FileInputStream(fName);
        reader.importThis(fName, fis, res);

        // right, now check it contains our data
        final Layer layer = res.findLayer("TOMATO");
        assertNotNull("found tomato track");

        final TrackWrapper tw = (TrackWrapper) layer;
        final Enumeration<Editable> solutions = tw.getSolutions().elements();
        assertNotNull("found solutions", solutions);

        // find our solution track
        while (solutions.hasMoreElements()) {
          final TMAWrapper wrapper = (TMAWrapper) solutions.nextElement();
          assertEquals("found our solution", "TRACK_060", wrapper.getName());

          final Enumeration<Editable> contacts = wrapper.elements();
          while (contacts.hasMoreElements()) {
            final TMAContactWrapper contactWrapper = (TMAContactWrapper) contacts.nextElement();
            assertEquals("found first contact", "Trial label", contactWrapper.getLabel());
            assertEquals("correct symbol set", "Submarine", contactWrapper.getSymbol());
            assertEquals("correct vis set", true, contactWrapper.getVisible());
            assertEquals("correct label vis", true, contactWrapper.getLabelVisible());
            assertEquals("correct colour set", new Color(230, 200, 20), contactWrapper.getColor());
            assertEquals("correct ellipse vis", true, contactWrapper.getEllipseVisible());
            assertEquals("correct symbol vis", true, contactWrapper.getSymbolVisible());
            assertEquals("correct line vis", true, contactWrapper.getLineVisible());
            assertEquals(
                "correct label loc",
                new Integer(MWC.GUI.Properties.LocationPropertyEditor.RIGHT),
                contactWrapper.getLabelLocation());
            assertEquals("correct line course", 50, contactWrapper.getTargetCourse(), 0d);
            assertEquals("correct line speed", 12.4, contactWrapper.getSpeed(), 0d);
            assertEquals("correct line depth", 100, contactWrapper.getDepth(), 0d);
            final EllipseShape es = contactWrapper.buildGetEllipse();
            assertEquals("correct orientation", 45, es.getOrientation(), 0d);
            assertEquals(
                "correct maxima", 4000, es.getMaxima().getValueIn(WorldDistance.YARDS), 0.00001d);
            assertEquals(
                "correct minima", 2000, es.getMinima().getValueIn(WorldDistance.YARDS), 0.0001d);
          }
        }
      } catch (final FileNotFoundException e) {
        e.printStackTrace(); // To change body of catch statement use Options |
        // File Templates.
      }
    }
Example #2
0
    public void testLists() {
      final TrackWrapper ta = new TrackWrapper();
      ta.setName("ta");
      final TrackWrapper tb = new TrackWrapper();
      tb.setName("tb");
      final TrackWrapper tc = new TrackWrapper();
      tc.setName("tc");
      final Layers theLayers = new Layers();
      theLayers.addThisLayer(ta);
      theLayers.addThisLayer(tb);
      theLayers.addThisLayer(tc);

      final String pri_a = "ta";
      final String pri_b = "tz";
      final String sec_b = "tb";
      final String sec_c = "tc";
      final String sec_d = "tz";
      final Vector<String> secs = new Vector<String>(0, 1);
      secs.add(sec_b);
      secs.add(sec_c);

      // create the mgr
      final TrackManager tm = new TrackManager(theLayers);

      // do some checks
      assertNull("pri empty", tm._thePrimary);
      assertNull("secs empty", tm._theSecondaries);
      assertNotNull("layers assigned", tm._theLayers);

      // now get going
      tm.assignTracks(pri_a, secs);

      // and do the tests
      assertNotNull("pri assigned", tm._thePrimary);
      assertEquals("pri matches", tm._thePrimary, ta);

      // and the secs
      assertNotNull("sec assigned", tm._theSecondaries);
      assertEquals("correct num", 2, tm._theSecondaries.length);

      // setup duff data
      secs.clear();
      secs.add(sec_b);
      secs.add(sec_d);

      // assign duff data
      tm.assignTracks(pri_b, secs);

      // and test duff data
      assertNotNull("pri still assigned", tm._thePrimary);
      assertEquals("pri matches", tm._thePrimary, ta);
      assertNotNull("sec assigned", tm._theSecondaries);
      assertEquals("correct num", 1, tm._theSecondaries.length);

      // assign more real data
      tm.assignTracks(sec_c, secs);

      // and test duff data
      assertNotNull("pri still assigned", tm._thePrimary);
      assertEquals("pri matches", tm._thePrimary, tc);
      assertNotNull("sec assigned", tm._theSecondaries);
      assertEquals("correct num", 1, tm._theSecondaries.length);
    }