Пример #1
0
 protected Sdk setupJdkForModule(final String moduleName) {
   final Sdk sdk =
       useJps()
           ? JavaAwareProjectJdkTableImpl.getInstanceEx().getInternalJdk()
           : createJdk("Java 1.5");
   ModuleRootModificationUtil.setModuleSdk(getModule(moduleName), sdk);
   return sdk;
 }
 protected void setUpJdk() {
   // final ProjectJdkEx jdk = ProjectJdkUtil.getDefaultJdk("java 1.4");
   final Sdk jdk = getTestProjectJdk();
   //    ProjectJdkImpl jdk = ProjectJdkTable.getInstance().addJdk(defaultJdk);
   Module[] modules = ModuleManager.getInstance(myProject).getModules();
   for (Module module : modules) {
     ModuleRootModificationUtil.setModuleSdk(module, jdk);
   }
 }
  public void testContentWrite() throws Exception {
    File content = getTestRoot();
    File source = new File(content, "source");
    File testSource = new File(content, "testSource");
    File exclude = new File(content, "exclude");
    File classes = new File(content, "classes");
    File testClasses = new File(content, "testClasses");
    final VirtualFile contentFile = LocalFileSystem.getInstance().findFileByIoFile(content);
    assertNotNull(contentFile);
    final VirtualFile sourceFile = LocalFileSystem.getInstance().findFileByIoFile(source);
    assertNotNull(sourceFile);
    final VirtualFile testSourceFile = LocalFileSystem.getInstance().findFileByIoFile(testSource);
    assertNotNull(testSourceFile);
    final VirtualFile excludeFile = LocalFileSystem.getInstance().findFileByIoFile(exclude);

    assertNotNull(excludeFile);
    final VirtualFile classesFile = LocalFileSystem.getInstance().findFileByIoFile(classes);

    assertNotNull(classesFile);
    final VirtualFile testClassesFile = LocalFileSystem.getInstance().findFileByIoFile(testClasses);

    assertNotNull(testClassesFile);

    final File moduleFile = new File(content, "test.iml");
    final Module module = createModule(moduleFile);
    final ModuleRootManagerImpl moduleRootManager =
        (ModuleRootManagerImpl) ModuleRootManager.getInstance(module);

    PsiTestUtil.addContentRoot(module, contentFile);
    PsiTestUtil.addSourceRoot(module, sourceFile);
    PsiTestUtil.addSourceRoot(module, testSourceFile, true);
    ModuleRootModificationUtil.setModuleSdk(module, JavaSdkImpl.getMockJdk17());
    PsiTestUtil.addExcludedRoot(module, excludeFile);
    PsiTestUtil.setCompilerOutputPath(module, classesFile.getUrl(), false);
    PsiTestUtil.setCompilerOutputPath(module, testClassesFile.getUrl(), true);

    final Element element = new Element("root");
    moduleRootManager.getState().writeExternal(element);
    assertElementEquals(
        element,
        "<root inherit-compiler-output=\"false\">"
            + "<output url=\"file://$MODULE_DIR$/classes\" />"
            + "<output-test url=\"file://$MODULE_DIR$/testClasses\" />"
            + "<exclude-output />"
            + "<content url=\"file://$MODULE_DIR$\">"
            + "<sourceFolder url=\"file://$MODULE_DIR$/source\" isTestSource=\"false\" />"
            + "<sourceFolder url=\"file://$MODULE_DIR$/testSource\" isTestSource=\"true\" />"
            + "<excludeFolder url=\"file://$MODULE_DIR$/exclude\" />"
            + "</content>"
            + "<orderEntry type=\"jdk\" jdkName=\"java 1.7\" jdkType=\"JavaSDK\" />"
            + "<orderEntry type=\"sourceFolder\" forTests=\"false\" />"
            + "</root>",
        module);
  }
 private void assignJdk(Module module) {
   myJdk = ModuleRootManager.getInstance(myModule).getSdk();
   ModuleRootModificationUtil.setModuleSdk(module, myJdk);
 }
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   ModuleRootModificationUtil.setModuleSdk(myModule, IdeaTestUtil.getMockJdk18());
   myFixture.enableInspections(myInspection);
 }