示例#1
0
  /** add a blue participant */
  void addBlueFile(final String val) {
    // read in this participant
    try {
      final ParticipantType newPart =
          ASSET.Util.XML.ASSETReaderWriter.importParticipant(val, new java.io.FileInputStream(val));

      if (newPart != null) {
        // update the time to match the scenario
        newPart.getStatus().setTime(_myScenario.getTime());

        // and add to the scenario
        _myScenario.addBlueParticipant(0, newPart);
      }
    } catch (java.io.FileNotFoundException fe) {
      fe.printStackTrace();
    }

    // inform the listener
    _listener.propertyChange(new PropertyChangeEvent(this, "blue", null, null));
  }
示例#2
0
    /** test case for importing a Launch command from XML (because it's fiddly) */
    public void NOTtestImportXML() {

      /** create the scenario */
      final CoreScenario scenario = new CoreScenario();
      scenario.setScenarioStepTime(10000);
      scenario.setTime(0);
      scenario.setName("Testing importing Launch");

      final Waterfall theWaterfall = new Waterfall();

      /** read in the file */
      String root = System.getProperty("TEST_ROOT");
      if (root == null) {
        System.err.println("Don't know test root, using hard-coded.");
        root = "src";
      }

      final String fName = root + "TEST_LAUNCH.XML";

      // check it exists
      assertTrue("Couldn't find tests data file", new java.io.File(fName).exists());

      try {
        //        ASSET.Util.XML.ASSETReaderWriter.importThis(scenario, fName, new
        // java.io.FileInputStream(fName));
        ASSET.Util.XML.ASSETReaderWriter.importThis(
            theWaterfall, fName, new java.io.FileInputStream(fName));
      } catch (java.io.IOException ee) {
        ee.printStackTrace();
      }

      final Waterfall newWaterfall = (Waterfall) theWaterfall.getModels().firstElement();
      assertEquals(
          "Read in launch behaviour",
          newWaterfall.getModels().firstElement().toString(),
          "Destroy Red");
      final LaunchWeapon theLaunch = (LaunchWeapon) newWaterfall.getModels().firstElement();
      //      final String launchType = theLaunch.getLaunchType();
      assertEquals("Behaviour is correct length", 1719, theLaunch.getLaunchType().length());
    }