/** Test of a minimized mode with additional names. */
  public void testLoadMode08() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testLoadMode08 START");

    ModeParser modeParser = createModeParser("data/valid/Windows/Modes", "mode08");

    ModeConfig modeCfg = modeParser.load();

    // Check loaded data
    assertNotNull("Could not load data.", modeCfg);

    InternalConfig internalCfg = modeParser.getInternalConfig();

    assertNotNull("Could not load internal data.", internalCfg);

    // Check data
    assertTrue("Mode minimized", modeCfg.minimized);

    assertEquals("Other names", 2, modeCfg.otherNames.size());

    assertTrue("Other names", modeCfg.otherNames.contains("mode00"));
    assertTrue("Other names", modeCfg.otherNames.contains("mode01"));

    System.out.println("ModeParserTest.testLoadMode08 FINISH");
  }
  /** Test of a mode with with previously active tc */
  public void testLoadMode07() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testLoadMode07 START");

    ModeParser modeParser = createModeParser("data/valid/Windows/Modes", "mode07");

    ModeConfig modeCfg = modeParser.load();

    // Check loaded data
    assertNotNull("Could not load data.", modeCfg);

    InternalConfig internalCfg = modeParser.getInternalConfig();

    assertNotNull("Could not load internal data.", internalCfg);

    // Check data
    assertEquals("Mode state", Constants.MODE_STATE_JOINED, modeCfg.state);

    assertEquals("Mode type", Constants.MODE_KIND_VIEW, modeCfg.kind);

    assertEquals("Active TC", "filesystems", modeCfg.selectedTopComponentID);
    assertEquals("Previous active TC", "explorer", modeCfg.previousSelectedTopComponentID);
    assertTrue("Permanent", modeCfg.permanent);

    System.out.println("ModeParserTest.testLoadMode07 FINISH");
  }
  /** Test of sliding mode with pre-defined slide-in sizes */
  public void testLoadMode06() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testLoadMode06 START");

    ModeParser modeParser = createModeParser("data/valid/Windows/Modes", "mode06");

    ModeConfig modeCfg = modeParser.load();

    // Check loaded data
    assertNotNull("Could not load data.", modeCfg);

    // Check data
    assertEquals("Mode kind", Constants.MODE_KIND_SLIDING, modeCfg.kind);
    assertEquals("Mode sliding side", Constants.LEFT, modeCfg.side);

    assertEquals("Active TC", "output", modeCfg.selectedTopComponentID);
    assertTrue("Permanent", modeCfg.permanent);

    Map<String, Integer> slideInSizes = modeCfg.slideInSizes;
    assertNotNull(slideInSizes);
    assertEquals(2, slideInSizes.size());
    assertEquals(Integer.valueOf(123), slideInSizes.get("output"));
    assertEquals(Integer.valueOf(321), slideInSizes.get("someOtherTopComponentId"));

    System.out.println("ModeParserTest.testLoadMode06 FINISH");
  }
  /** Test of loaded data */
  public void testLoadMode05() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testLoadMode05 START");

    ModeParser modeParser = createModeParser("data/valid/Windows/Modes", "mode05");

    ModeConfig modeCfg = modeParser.load();

    // Check loaded data
    assertNotNull("Could not load data.", modeCfg);

    // Check data
    assertEquals("Mode kind", Constants.MODE_KIND_SLIDING, modeCfg.kind);
    assertEquals("Mode sliding side", Constants.LEFT, modeCfg.side);
    //        assertEquals("Mode state",Constants.MODE_STATE_SEPARATED,modeCfg.state);

    //        assertNotNull("Mode constraints are null",modeCfg.constraints);
    //        assertEquals("Mode constraints are not empty",0,modeCfg.constraints.length);

    //        assertNull("Mode bounds are not null",modeCfg.bounds);

    //        assertNotNull("Mode relative bounds are null",modeCfg.relativeBounds);

    //        assertEquals("Mode relative bounds x",0,modeCfg.relativeBounds.x);
    //        assertEquals("Mode relative bounds y",0,modeCfg.relativeBounds.y);
    //        assertEquals("Mode relative bounds width",40,modeCfg.relativeBounds.width);
    //        assertEquals("Mode relative bounds height",20,modeCfg.relativeBounds.height);

    //        assertEquals("Mode frame state",Frame.MAXIMIZED_BOTH,modeCfg.frameState);

    assertEquals("Active TC", "output", modeCfg.selectedTopComponentID);
    assertTrue("Permanent", modeCfg.permanent);

    System.out.println("ModeParserTest.testLoadMode05 FINISH");
  }
  private ModeParser createModeParser(String path, String name) {
    URL url;
    url = ModeParserTest.class.getResource(path);
    assertNotNull("url not found.", url);

    FileObject parentFolder = URLMapper.findFileObject(url);
    assertNotNull("Test parent folder not found. ParentFolder is null.", url);

    Set setLocal = new HashSet();
    ModeParser modeParser = new ModeParser(name, setLocal);
    modeParser.setInLocalFolder(true);
    modeParser.setLocalParentFolder(parentFolder);

    return modeParser;
  }
  /** Test of file name and value of attribute "unique" mismatch. */
  public void testLoadMode06Invalid() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testLoadMode06Invalid START");

    ModeParser modeParser = createModeParser("data/invalid/Windows/Modes", "mode06");

    try {
      modeParser.load();
    } catch (IOException exc) {
      // ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, exc);
      System.out.println("ModeParserTest.testLoadMode06Invalid FINISH");
      return;
    }

    fail("Sliding mode is not allowed to have other mode names.");
  }
  /** Test of missing required attribute "unique" of element "name". */
  public void testLoadMode03Invalid() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testLoadMode03Invalid START");

    ModeParser modeParser = createModeParser("data/invalid/Windows/Modes", "mode03");

    try {
      modeParser.load();
    } catch (IOException exc) {
      // ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, exc);
      System.out.println("ModeParserTest.testLoadMode03Invalid FINISH");
      return;
    }

    fail("Missing required attribute \"unique\" of element \"name\" was not detected.");
  }
  /** Test of empty file */
  public void testLoadMode02Invalid() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testLoadMode02Invalid START");

    ModeParser modeParser = createModeParser("data/invalid/Windows/Modes", "mode02");

    try {
      modeParser.load();
    } catch (IOException exc) {
      // ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, exc);
      System.out.println("ModeParserTest.testLoadMode02Invalid FINISH");
      return;
    }

    fail("Empty file was not detected.");
  }
  /** Test of saving a minimized mode with other names. */
  public void testSaveMode08() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testSaveMode08 START");

    ModeParser modeParser = createModeParser("data/valid/Windows/Modes", "mode08");

    ModeConfig modeCfg1 = modeParser.load();

    modeParser.save(modeCfg1);

    ModeConfig modeCfg2 = modeParser.load();

    // Compare data
    assertTrue("Compare configuration data", modeCfg1.equals(modeCfg2));

    System.out.println("ModeParserTest.testSaveMode08 FINISH");
  }
  /** Test of loaded data */
  public void testLoadMode01() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testLoadMode01 START");

    ModeParser modeParser = createModeParser("data/valid/Windows/Modes", "mode01");

    ModeConfig modeCfg = modeParser.load();

    // Check loaded data
    assertNotNull("Could not load data.", modeCfg);

    InternalConfig internalCfg = modeParser.getInternalConfig();

    assertNotNull("Could not load internal data.", internalCfg);

    // Check internal data
    assertEquals("moduleCodeNameBase", "org.netbeans.core.ui", internalCfg.moduleCodeNameBase);
    assertEquals("moduleCodeNameBase", "1", internalCfg.moduleCodeNameRelease);
    assertEquals("moduleCodeNameBase", "1.2", internalCfg.moduleSpecificationVersion);

    // Check data
    assertEquals("Mode state", Constants.MODE_STATE_JOINED, modeCfg.state);
    assertFalse("Mode minimized", modeCfg.minimized);

    assertNull("Other mode names", modeCfg.otherNames);

    assertNotNull("Mode constraints are null", modeCfg.constraints);
    assertEquals("Mode constraints are not empty", 0, modeCfg.constraints.length);

    assertEquals("Mode type", Constants.MODE_KIND_EDITOR, modeCfg.kind);

    assertNull("Mode bounds are not null", modeCfg.bounds);
    assertNull("Mode relative bounds are not null", modeCfg.relativeBounds);

    assertNotNull("Active TC is null", modeCfg.selectedTopComponentID);
    assertEquals("Active TC is not empty", "", modeCfg.selectedTopComponentID);
    assertNotNull("Previous active TC is null", modeCfg.previousSelectedTopComponentID);
    assertEquals("Previous active TC is not empty", "", modeCfg.previousSelectedTopComponentID);
    assertTrue("Permanent", modeCfg.permanent);

    System.out.println("ModeParserTest.testLoadMode01 FINISH");
  }
  /** Test of loaded data */
  public void testLoadMode02() throws Exception {
    System.out.println("");
    System.out.println("ModeParserTest.testLoadMode02 START");

    ModeParser modeParser = createModeParser("data/valid/Windows/Modes", "mode02");

    ModeConfig modeCfg = modeParser.load();

    // Check loaded data
    assertNotNull("Could not load data.", modeCfg);

    // Check data
    assertEquals("Mode state", Constants.MODE_STATE_JOINED, modeCfg.state);

    assertNotNull("Mode constraints are null", modeCfg.constraints);
    assertEquals("Mode constraints array has incorrect size", 2, modeCfg.constraints.length);
    SplitConstraint item;
    item = modeCfg.constraints[0];
    assertEquals("Mode constraint 0 - orientation", Constants.VERTICAL, item.orientation);
    assertEquals("Mode constraint 0 - index", 1, item.index);
    assertEquals("Mode constraint 0 - weight", 0.3, item.splitWeight, 0.0);

    item = modeCfg.constraints[1];
    assertEquals("Mode constraint 1 - orientation", Constants.HORIZONTAL, item.orientation);
    assertEquals("Mode constraint 1 - index", 0, item.index);
    assertEquals("Mode constraint 1 - weight", 0.5, item.splitWeight, 0.0);

    assertNull("Mode bounds are not null", modeCfg.bounds);
    assertNull("Mode relative bounds are not null", modeCfg.relativeBounds);

    assertEquals("Mode type", Constants.MODE_KIND_VIEW, modeCfg.kind);
    assertEquals("Active TC", "output", modeCfg.selectedTopComponentID);
    assertFalse("Permanent", modeCfg.permanent);

    System.out.println("ModeParserTest.testLoadMode02 FINISH");
  }