/*
 * Copyright 2000-2010 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * User: anna
 * Date: 28-Nov-2008
 */
package org.jetbrains.idea.eclipse;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PluginPathManager;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.ModifiableRootModel;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.testFramework.IdeaTestCase;

import java.io.File;
import java.io.IOException;

public class EclipseMultimoduleTest extends IdeaTestCase {
  @Override
  protected void setUpModule() {
    super.setUpModule();
    final File testRoot = new File(PluginPathManager.getPluginHomePath("eclipse") + "/testData", "round");
    assertTrue(testRoot.getAbsolutePath(), testRoot.isDirectory());

    final File currentTestRoot = new File(testRoot, getTestName(true));
    assertTrue(currentTestRoot.getAbsolutePath(), currentTestRoot.isDirectory());

    try {
      FileUtil.copyDir(currentTestRoot, new File(getProject().getBaseDir().getPath()));
    }
    catch (IOException e) {
      LOG.error(e);
    }
    final ModifiableRootModel model = ModuleRootManager.getInstance(getModule()).getModifiableModel();
    model.addContentEntry(LocalFileSystem.getInstance().findFileByPath(getProject().getBaseDir().getPath() + "/eclipse-ws-3.4.1-a/ws-internals"));
    ApplicationManager.getApplication().runWriteAction(new Runnable() {
        public void run(){
            model.commit();
        }
    });
  }

  @Override
  protected Module createMainModule() throws IOException {
    return createModule("ws-internals");
  }

  public void testAllProps() throws Exception {
    EclipseClasspathTest.doTest("/eclipse-ws-3.4.1-a/all-props", getProject());
  }


}
@@ -936,32 +936,77 @@
 uleRootManager;%0A
+import com.intellij.openapi.util.Computable;%0A
 import com.intel
@@ -1108,34 +1108,110 @@
 lij.
-testFramework.IdeaTestCase
+openapi.vfs.VirtualFile;%0Aimport com.intellij.testFramework.IdeaTestCase;%0Aimport junit.framework.Assert
 ;%0A%0Ai
@@ -1988,30 +1988,197 @@
     
-model.addContentEntry(
+final VirtualFile file =%0A      ApplicationManager.getApplication().runWriteAction(%0A          new Computable%3CVirtualFile%3E() %7B%0A            public VirtualFile compute() %7B%0A              return 
 Loca
@@ -2203,17 +2203,27 @@
 tance().
-f
+refreshAndF
 indFileB
@@ -2301,18 +2301,203 @@
 ernals%22)
-)
 ;
+%0A            %7D%0A          %7D%0A      );%0A    if (file != null) %7B%0A      model.addContentEntry(file);%0A    %7D else %7B%0A      model.dispose();%0A      Assert.assertTrue(%22File not found%22, false);%0A    %7D
 %0A    App

debug test