@Override public void checkConfiguration() throws RuntimeConfigurationException { final TestData data = myConfig.getPersistantData(); try { final Parser parser = new Parser(data.getSuiteName()); parser.setLoadClasses(false); synchronized (PARSE_LOCK) { parser.parse();//try to parse suite.xml } } catch (Exception e) { throw new RuntimeConfigurationException("Unable to parse '" + data.getSuiteName() + "' specified"); } }
@Override public void checkConfiguration() throws RuntimeConfigurationException { if (data.TEST_OBJECT.equals(TestType.CLASS.getType()) || data.TEST_OBJECT.equals(TestType.METHOD.getType())) { final SourceScope scope = data.getScope().getSourceScope(this); if (scope == null) { throw new RuntimeConfigurationException("Invalid scope specified"); } PsiClass psiClass = JavaPsiFacade.getInstance(project).findClass(data.getMainClassName(), scope.getGlobalSearchScope()); if (psiClass == null) throw new RuntimeConfigurationException("Class '" + data.getMainClassName() + "' not found"); if (data.TEST_OBJECT.equals(TestType.METHOD.getType())) { PsiMethod[] methods = psiClass.findMethodsByName(data.getMethodName(), true); if (methods.length == 0) { throw new RuntimeConfigurationException("Method '" + data.getMethodName() + "' not found"); } for (PsiMethod method : methods) { if (!method.hasModifierProperty(PsiModifier.PUBLIC)) { throw new RuntimeConfigurationException("Non public method '" + data.getMethodName() + "'specified"); } } } } else if (data.TEST_OBJECT.equals(TestType.PACKAGE.getType())) { PsiPackage psiPackage = JavaPsiFacade.getInstance(project).findPackage(data.getPackageName()); if (psiPackage == null) throw new RuntimeConfigurationException("Package '" + data.getPackageName() + "' not found"); } else if (data.TEST_OBJECT.equals(TestType.SUITE.getType())) { try { final Parser parser = new Parser(data.getSuiteName()); parser.setLoadClasses(false); synchronized (PARSE_LOCK) { parser.parse();//try to parse suite.xml } } catch (Exception e) { throw new RuntimeConfigurationException("Unable to parse '" + data.getSuiteName() + "' specified"); } } else if (data.TEST_OBJECT.equals(TestType.PATTERN.getType())) { final Set<String> patterns = data.getPatterns(); if (patterns.isEmpty()) { throw new RuntimeConfigurationWarning("No pattern selected"); } } JavaRunConfigurationExtensionManager.checkConfigurationIsValid(this); ProgramParametersUtil.checkWorkingDirectoryExist(this, getProject(), getConfigurationModule().getModule()); JavaParametersUtil.checkAlternativeJRE(this); //TODO add various checks here }