コード例 #1
0
 public void bePatternConfiguration(List<PsiClass> classes, PsiMethod method) {
   myData.TEST_OBJECT = TEST_PATTERN;
   final Set<String> patterns = new HashSet<String>();
   final String methodSufiix;
   if (method != null) {
     myData.METHOD_NAME = method.getName();
     methodSufiix = "," + myData.METHOD_NAME;
   } else {
     methodSufiix = "";
   }
   for (PsiClass pattern : classes) {
     patterns.add(JavaExecutionUtil.getRuntimeQualifiedName(pattern) + methodSufiix);
   }
   myData.setPatterns(patterns);
   final Module module =
       PatternConfigurationProducer.findModule(
           this, getConfigurationModule().getModule(), patterns);
   if (module == null) {
     myData.setScope(TestSearchScope.WHOLE_PROJECT);
     setModule(null);
   } else {
     setModule(module);
   }
   setGeneratedName();
 }
コード例 #2
0
 public Data clone() {
   try {
     Data data = (Data) super.clone();
     data.TEST_SEARCH_SCOPE = new TestSearchScope.Wrapper();
     data.setScope(getScope());
     data.myEnvs = new LinkedHashMap<String, String>(myEnvs);
     return data;
   } catch (CloneNotSupportedException e) {
     throw new RuntimeException(e);
   }
 }
コード例 #3
0
  public Collection<Module> getValidModules() {
    if (TEST_PACKAGE.equals(myData.TEST_OBJECT) || TEST_PATTERN.equals(myData.TEST_OBJECT)) {
      return Arrays.asList(ModuleManager.getInstance(getProject()).getModules());
    }
    try {
      myData.getTestObject(getProject(), this).checkConfiguration();
    } catch (RuntimeConfigurationError e) {
      return Arrays.asList(ModuleManager.getInstance(getProject()).getModules());
    } catch (RuntimeConfigurationException e) {
      // ignore
    }

    return JavaRunConfigurationModule.getModulesForClass(getProject(), myData.getMainClassName());
  }
コード例 #4
0
 public boolean equals(final Object object) {
   if (!(object instanceof Data)) return false;
   final Data second = (Data) object;
   return Comparing.equal(TEST_OBJECT, second.TEST_OBJECT)
       && Comparing.equal(getMainClassName(), second.getMainClassName())
       && Comparing.equal(getPackageName(), second.getPackageName())
       && Comparing.equal(getMethodName(), second.getMethodName())
       && Comparing.equal(getWorkingDirectory(), second.getWorkingDirectory())
       && Comparing.equal(VM_PARAMETERS, second.VM_PARAMETERS)
       && Comparing.equal(PARAMETERS, second.PARAMETERS)
       && Comparing.equal(myPattern, second.myPattern)
       && Comparing.equal(FORK_MODE, second.FORK_MODE)
       && Comparing.equal(DIR_NAME, second.DIR_NAME)
       && Comparing.equal(CATEGORY_NAME, second.CATEGORY_NAME);
 }
コード例 #5
0
 protected ModuleBasedConfiguration createInstance() {
   return new JUnitConfiguration(
       getName(),
       getProject(),
       myData.clone(),
       JUnitConfigurationType.getInstance()
           .getConfigurationFactories()[0]); // throw new RuntimeException("Should not call");
 }
コード例 #6
0
 public void configureClasspath(final JavaParameters javaParameters) throws CantRunException {
   RunConfigurationModule module = getConfigurationModule();
   final String jreHome = isAlternativeJrePathEnabled() ? getAlternativeJrePath() : null;
   final int pathType = JavaParameters.JDK_AND_CLASSES_AND_TESTS;
   if (myData.getScope() == TestSearchScope.WHOLE_PROJECT) {
     JavaParametersUtil.configureProject(module.getProject(), javaParameters, pathType, jreHome);
   } else {
     JavaParametersUtil.configureModule(module, javaParameters, pathType, jreHome);
   }
 }
コード例 #7
0
  public void writeExternal(final Element element) throws WriteExternalException {
    super.writeExternal(element);
    JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
    writeModule(element);
    DefaultJDOMExternalizer.writeExternal(this, element);
    final Data persistentData = getPersistentData();
    DefaultJDOMExternalizer.writeExternal(persistentData, element);
    EnvironmentVariablesComponent.writeExternal(element, persistentData.getEnvs());
    final String dirName = persistentData.getDirName();
    if (!dirName.isEmpty()) {
      final Element dirNameElement = new Element("dir");
      dirNameElement.setAttribute("value", FileUtil.toSystemIndependentName(dirName));
      element.addContent(dirNameElement);
    }

    final String categoryName = persistentData.getCategory();
    if (!categoryName.isEmpty()) {
      final Element categoryNameElement = new Element("category");
      categoryNameElement.setAttribute("value", categoryName);
      element.addContent(categoryNameElement);
    }

    final Element patternsElement = new Element(PATTERNS_EL_NAME);
    for (String o : persistentData.getPatterns()) {
      final Element patternElement = new Element(PATTERN_EL_NAME);
      patternElement.setAttribute(TEST_CLASS_ATT_NAME, o);
      patternsElement.addContent(patternElement);
    }
    final String forkMode = getForkMode();
    if (!forkMode.equals("none")) {
      final Element forkModeElement = new Element("fork_mode");
      forkModeElement.setAttribute("value", forkMode);
      element.addContent(forkModeElement);
    }
    element.addContent(patternsElement);
    PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
  }
コード例 #8
0
  public void readExternal(final Element element) throws InvalidDataException {
    PathMacroManager.getInstance(getProject()).expandPaths(element);
    super.readExternal(element);
    JavaRunConfigurationExtensionManager.getInstance().readExternal(this, element);
    readModule(element);
    DefaultJDOMExternalizer.readExternal(this, element);
    DefaultJDOMExternalizer.readExternal(getPersistentData(), element);
    EnvironmentVariablesComponent.readExternal(element, getPersistentData().getEnvs());
    final Element patternsElement = element.getChild(PATTERNS_EL_NAME);
    if (patternsElement != null) {
      final Set<String> tests = new LinkedHashSet<String>();
      for (Object o : patternsElement.getChildren(PATTERN_EL_NAME)) {
        Element patternElement = (Element) o;
        tests.add(patternElement.getAttributeValue(TEST_CLASS_ATT_NAME));
      }
      myData.setPatterns(tests);
    }
    final Element forkModeElement = element.getChild("fork_mode");
    if (forkModeElement != null) {
      final String mode = forkModeElement.getAttributeValue("value");
      if (mode != null) {
        setForkMode(mode);
      }
    }
    final Element dirNameElement = element.getChild("dir");
    if (dirNameElement != null) {
      final String dirName = dirNameElement.getAttributeValue("value");
      getPersistentData().setDirName(FileUtil.toSystemDependentName(dirName));
    }

    final Element categoryNameElement = element.getChild("category");
    if (categoryNameElement != null) {
      final String categoryName = categoryNameElement.getAttributeValue("value");
      getPersistentData().setCategoryName(categoryName);
    }
  }
コード例 #9
0
 public void setVMParameters(String value) {
   myData.setVMParameters(value);
 }
コード例 #10
0
 public PsiClass getPsiElement() {
   return getConfigurationModule().findClass(myData.getMainClassName());
 }
コード例 #11
0
 public TestObject getTestObject() {
   return myData.getTestObject(getProject(), this);
 }
コード例 #12
0
 public PsiPackage getPsiElement() {
   final String qualifiedName = myData.getPackageName();
   return qualifiedName != null
       ? JavaPsiFacade.getInstance(getProject()).findPackage(qualifiedName)
       : null;
 }
コード例 #13
0
 public void setName(@NotNull final String qualifiedName) {
   final boolean generatedName = isGeneratedName();
   myData.MAIN_CLASS_NAME = qualifiedName;
   if (generatedName) setGeneratedName();
 }
コード例 #14
0
 public void beMethodConfiguration(final Location<PsiMethod> methodLocation) {
   setModule(myData.setTestMethod(methodLocation));
   setGeneratedName();
 }
コード例 #15
0
 public void setName(final String qualifiedName) {
   final boolean generatedName = isGeneratedName();
   myData.PACKAGE_NAME = qualifiedName;
   if (generatedName) setGeneratedName();
 }
コード例 #16
0
 public void setForkMode(@NotNull String forkMode) {
   myData.FORK_MODE = forkMode;
 }
コード例 #17
0
 public void setProgramParameters(String value) {
   myData.setProgramParameters(value);
 }
コード例 #18
0
 public String getRunClass() {
   final Data data = getPersistentData();
   return data.TEST_OBJECT != TEST_CLASS && data.TEST_OBJECT != TEST_METHOD
       ? null
       : data.getMainClassName();
 }
コード例 #19
0
 public String getProgramParameters() {
   return myData.getProgramParameters();
 }
コード例 #20
0
 public void setPassParentEnvs(boolean passParentEnvs) {
   myData.PASS_PARENT_ENVS = passParentEnvs;
 }
コード例 #21
0
 @NotNull
 public Map<String, String> getEnvs() {
   return myData.getEnvs();
 }
コード例 #22
0
 public void setEnvs(@NotNull Map<String, String> envs) {
   myData.setEnvs(envs);
 }
コード例 #23
0
 public String getWorkingDirectory() {
   return myData.getWorkingDirectory();
 }
コード例 #24
0
 public void setWorkingDirectory(String value) {
   myData.setWorkingDirectory(value);
 }
コード例 #25
0
 public String suggestedName() {
   return myData.getGeneratedName(getConfigurationModule());
 }
コード例 #26
0
 public void setMainClass(final PsiClass testClass) {
   final boolean shouldUpdateName = isGeneratedName();
   setModule(myData.setMainClass(testClass));
   if (shouldUpdateName) setGeneratedName();
 }
コード例 #27
0
 public String getPackage() {
   final Data data = getPersistentData();
   return !Comparing.strEqual(data.TEST_OBJECT, TEST_PACKAGE) ? null : data.getPackageName();
 }
コード例 #28
0
 public String getVMParameters() {
   return myData.getVMParameters();
 }
コード例 #29
0
 public void beClassConfiguration(final PsiClass testClass) {
   setMainClass(testClass);
   myData.TEST_OBJECT = TEST_CLASS;
   setGeneratedName();
 }
コード例 #30
0
 public void checkConfiguration() throws RuntimeConfigurationException {
   myData.getTestObject(getProject(), this).checkConfiguration();
   JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this);
 }