public void testCompilerOutputInheritance() throws Exception {
   File moduleFile = new File(getTestRoot(), "test.iml");
   Module module = createModule(moduleFile);
   final ModuleRootManagerImpl moduleRootManager =
       (ModuleRootManagerImpl) ModuleRootManager.getInstance(module);
   final ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
   rootModel.getModuleExtension(CompilerModuleExtension.class).inheritCompilerOutputPath(true);
   ApplicationManager.getApplication()
       .runWriteAction(
           new Runnable() {
             @Override
             public void run() {
               rootModel.commit();
             }
           });
   Element element = new Element("root");
   moduleRootManager.getState().writeExternal(element);
   assertElementEquals(
       element,
       "<root inherit-compiler-output=\"true\">"
           + "<exclude-output />"
           + "<orderEntry type=\"sourceFolder\" forTests=\"false\" />"
           + "</root>",
       module);
 }
  public void testModuleLibraries() throws Exception {
    File moduleFile = new File(getTestRoot(), "test.iml");
    Module module = createModule(moduleFile);
    final ModuleRootManagerImpl moduleRootManager =
        (ModuleRootManagerImpl) ModuleRootManager.getInstance(module);
    final ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
    final LibraryTable moduleLibraryTable = rootModel.getModuleLibraryTable();

    final Library unnamedLibrary = moduleLibraryTable.createLibrary();
    final File unnamedLibClasses = new File(getTestRoot(), "unnamedLibClasses");
    final VirtualFile unnamedLibClassesRoot =
        LocalFileSystem.getInstance().findFileByIoFile(unnamedLibClasses);
    final Library.ModifiableModel libraryModifyableModel = unnamedLibrary.getModifiableModel();
    libraryModifyableModel.addRoot(unnamedLibClassesRoot.getUrl(), OrderRootType.CLASSES);

    final Library namedLibrary = moduleLibraryTable.createLibrary("namedLibrary");
    final File namedLibClasses = new File(getTestRoot(), "namedLibClasses");
    final VirtualFile namedLibClassesRoot =
        LocalFileSystem.getInstance().findFileByIoFile(namedLibClasses);
    final Library.ModifiableModel namedLibraryModel = namedLibrary.getModifiableModel();
    namedLibraryModel.addRoot(namedLibClassesRoot.getUrl(), OrderRootType.CLASSES);

    ApplicationManager.getApplication()
        .runWriteAction(
            new Runnable() {
              @Override
              public void run() {
                libraryModifyableModel.commit();
                namedLibraryModel.commit();
              }
            });

    final Iterator libraryIterator = moduleLibraryTable.getLibraryIterator();
    assertEquals(libraryIterator.next(), unnamedLibrary);
    assertEquals(libraryIterator.next(), namedLibrary);

    ApplicationManager.getApplication()
        .runWriteAction(
            new Runnable() {
              @Override
              public void run() {
                rootModel.commit();
              }
            });
    final Element element = new Element("root");
    moduleRootManager.getState().writeExternal(element);
    assertElementEquals(
        element,
        "<root inherit-compiler-output=\"true\">"
            + "<exclude-output />"
            + "<orderEntry type=\"sourceFolder\" forTests=\"false\" />"
            + "<orderEntry type=\"module-library\">"
            + "<library>"
            + "<CLASSES><root url=\"file://$MODULE_DIR$/unnamedLibClasses\" /></CLASSES>"
            + "<JAVADOC />"
            + "<SOURCES />"
            + "</library>"
            + "</orderEntry>"
            + "<orderEntry type=\"module-library\">"
            + "<library name=\"namedLibrary\">"
            + "<CLASSES><root url=\"file://$MODULE_DIR$/namedLibClasses\" /></CLASSES>"
            + "<JAVADOC />"
            + "<SOURCES />"
            + "</library>"
            + "</orderEntry>"
            + "</root>",
        module);
  }