use of org.eclipse.jdt.internal.core.PackageFragmentRoot in project jbosstools-hibernate by jbosstools.
the class MappingTestsBase method allTestsRunForProject.
/**
* Inspect all it's packages of the current testProject and
* execute all tests from TestSet, considering one test package as active.
* @throws CoreException
*/
public void allTestsRunForProject() throws CoreException {
testProject.fullBuild();
IPackageFragmentRoot[] roots = testProject.getIJavaProject().getAllPackageFragmentRoots();
for (int i = 0; i < roots.length; i++) {
if (roots[i].getClass() != PackageFragmentRoot.class) {
continue;
}
PackageFragmentRoot packageFragmentRoot = (PackageFragmentRoot) roots[i];
IJavaElement[] els = packageFragmentRoot.getChildren();
for (int j = 0; j < els.length; j++) {
IJavaElement javaElement = els[j];
if (!(javaElement instanceof IPackageFragment)) {
continue;
}
testPackage = (IPackageFragment) javaElement;
// use packages only with compilation units
if (testPackage.getCompilationUnits().length == 0) {
continue;
}
if (Customization.U_TEST_PACKS_PATTERN) {
if (!Pattern.matches(Customization.TEST_PACKS_PATTERN, javaElement.getElementName())) {
continue;
}
}
long st_pack_time = System.currentTimeMillis();
int prev_failCount = result.failureCount();
int prev_errCount = result.errorCount();
//
TestSuite suite = TestSet.createTestSuite(consoleConfigName, testPackage, testProject);
//
customizeCfgXml(testPackage);
/**
* /
* suite.run(result);
* /*
*/
for (int k = 0; k < suite.testCount(); k++) {
Test test = suite.testAt(k);
test.run(result);
closeAllEditors();
}
/**/
closeAllEditors();
// ==============================
executions++;
if (Customization.USE_CONSOLE_OUTPUT) {
// $NON-NLS-1$
System.out.print(result.errorCount() - prev_errCount + ConsoleTestMessages.HibernateAllMappingTests_errors + " \t");
// $NON-NLS-1$
System.out.print(result.failureCount() - prev_failCount + ConsoleTestMessages.HibernateAllMappingTests_fails + "\t");
long period = System.currentTimeMillis() - st_pack_time;
// $NON-NLS-1$
String time = period / 1000 + "." + (period % 1000) / 100;
System.out.println(time + ConsoleTestMessages.HibernateAllMappingTests_seconds + " {" + javaElement.getElementName() + // $NON-NLS-1$//$NON-NLS-2$
"}");
}
if (Customization.STOP_AFTER_MISSING_PACK) {
if (result.failureCount() > prev_failCount) {
break;
}
}
prev_failCount = result.failureCount();
prev_errCount = result.errorCount();
}
}
}
use of org.eclipse.jdt.internal.core.PackageFragmentRoot in project jbosstools-hibernate by jbosstools.
the class NewHibernateMappingFileWizard method processJavaElements.
protected void processJavaElements(Object obj, int depth) {
if (depth < 0) {
return;
}
try {
if (obj instanceof ICompilationUnit) {
ICompilationUnit cu = (ICompilationUnit) obj;
selectionCU.add(cu);
} else if (obj instanceof JavaProject && depth > 0) {
JavaProject javaProject = (JavaProject) obj;
IPackageFragmentRoot[] pfr = javaProject.getAllPackageFragmentRoots();
for (IPackageFragmentRoot element : pfr) {
processJavaElements(element, depth - 1);
}
} else if (obj instanceof PackageFragment) {
PackageFragment packageFragment = (PackageFragment) obj;
ICompilationUnit[] cus = packageFragment.getCompilationUnits();
for (ICompilationUnit cu : cus) {
selectionCU.add(cu);
}
} else if (obj instanceof PackageFragmentRoot && depth > 0) {
JavaElement javaElement = (JavaElement) obj;
JavaElementInfo javaElementInfo = (JavaElementInfo) javaElement.getElementInfo();
IJavaElement[] je = javaElementInfo.getChildren();
for (IJavaElement element : je) {
processJavaElements(element, depth - 1);
}
} else if (obj instanceof JavaElement) {
JavaElement javaElement = (JavaElement) obj;
ICompilationUnit cu = javaElement.getCompilationUnit();
selectionCU.add(cu);
}
} catch (JavaModelException e) {
// just ignore it!
// HibernateConsolePlugin.getDefault().logErrorMessage("JavaModelException: ", e); //$NON-NLS-1$
}
}
Aggregations