FileDocCategorySizeDatePackage
TestSelector.javaAPI DocHibernate 3.2.51931Tue Dec 12 16:22:26 GMT 2006org.hibernate.test

TestSelector

public class TestSelector extends Object implements org.apache.tools.ant.types.selectors.FileSelector
A custom Ant FileSelector used to limit the tests run from the Ant build script to only those defined in the {@link org.hibernate.test.AllTests} suite.

{@link org.hibernate.test.AllTests} is used/maintained by the developers to easily run the test suite in all IDEs. It represents all the tests which should actually be run and included in test results.

author
Steve Ebersole

Fields Summary
private final Set
allTestClassNames
Constructors Summary
public TestSelector()


	  
		TestSuiteVisitor.Handler handler = new TestSuiteVisitor.Handler() {
			public void handleTestCase(Test test) {
				allTestClassNames.add( test.getClass().getName() );
			}
			public void startingTestSuite(TestSuite suite) {}
			public void completedTestSuite(TestSuite suite) {}
		};
		TestSuiteVisitor visitor = new TestSuiteVisitor( handler );
		visitor.visit( ( TestSuite ) AllTests.suite() );
	
Methods Summary
private java.lang.StringdetermineClassName(java.lang.String file)

		if ( file.endsWith( ".class" ) ) {
			file = file.substring( 0, file.length() - 6 );
		}
		else if ( file.endsWith( ".java" ) ) {
			file = file.substring( 0, file.length() - 5 );
		}
		else {
			return null;
		}
		file = file.replace( '\\", '." );
		file = file.replace( '/", '." );
		return file;
	
public booleanisSelected(java.io.File dir, java.lang.String fileFromDir, java.io.File fullFile)

		String correspondingClassName = determineClassName( fileFromDir );
		return allTestClassNames.contains( correspondingClassName );