Author: hardy.ferentschik
Date: 2010-09-23 06:43:19 -0400 (Thu, 23 Sep 2010)
New Revision: 20685
Modified:
search/trunk/hibernate-search-testing/src/main/java/org/hibernate/search/test/SearchTestCase.java
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java
Log:
HSEARCH-592 Removed the need for the baseDir system property.
Modified:
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java
===================================================================
---
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java 2010-09-23
09:31:14 UTC (rev 20684)
+++
search/trunk/hibernate-search/src/test/java/org/hibernate/search/test/SearchTestCase.java 2010-09-23
10:43:19 UTC (rev 20685)
@@ -72,17 +72,26 @@
protected static SessionFactory sessions;
protected Session session;
+ private static File targetDir;
private static File indexDir;
private SearchFactoryImplementor searchFactory;
static {
- String buildDir = System.getProperty( "build.dir" );
- if ( buildDir == null ) {
- buildDir = ".";
- }
- File current = new File( buildDir );
- indexDir = new File( current, "indextemp" );
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ // get a URL reference to something we now is part of the classpath (us)
+ URL myUrl = contextClassLoader.getResource( SearchTestCase.class.getName().replace(
'.', '/' ) + ".class" );
+ File myPath = new File( myUrl.getFile() );
+ // navigate back to '/target'
+ targetDir = myPath
+ .getParentFile() // target/classes/org/hibernate/search/test
+ .getParentFile() // target/classes/org/hibernate/search
+ .getParentFile() // target/classes/org/hibernate/
+ .getParentFile() // target/classes/org
+ .getParentFile() // target/classes/
+ .getParentFile(); // target
+
+ indexDir = new File( targetDir, "indextemp" );
log.debug( "Using {} as index directory.", indexDir.getAbsolutePath() );
}
@@ -259,17 +268,6 @@
* @return the target directory of the build
*/
public static File getTargetDir() {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- // get a URL reference to something we now is part of the classpath (us)
- URL myUrl = contextClassLoader.getResource( SearchTestCase.class.getName().replace(
'.', '/' ) + ".class" );
- File myPath = new File( myUrl.getFile() );
- // navigate back to '/target'
- return myPath
- .getParentFile() // target/classes/org/hibernate/search/test
- .getParentFile() // target/classes/org/hibernate/search
- .getParentFile() // target/classes/org/hibernate/
- .getParentFile() // target/classes/org
- .getParentFile() // target/classes/
- .getParentFile(); // target
+ return targetDir;
}
}
Modified:
search/trunk/hibernate-search-testing/src/main/java/org/hibernate/search/test/SearchTestCase.java
===================================================================
---
search/trunk/hibernate-search-testing/src/main/java/org/hibernate/search/test/SearchTestCase.java 2010-09-23
09:31:14 UTC (rev 20684)
+++
search/trunk/hibernate-search-testing/src/main/java/org/hibernate/search/test/SearchTestCase.java 2010-09-23
10:43:19 UTC (rev 20685)
@@ -72,17 +72,26 @@
protected static SessionFactory sessions;
protected Session session;
+ private static File targetDir;
private static File indexDir;
private SearchFactoryImplementor searchFactory;
static {
- String buildDir = System.getProperty( "build.dir" );
- if ( buildDir == null ) {
- buildDir = ".";
- }
- File current = new File( buildDir );
- indexDir = new File( current, "indextemp" );
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ // get a URL reference to something we now is part of the classpath (us)
+ URL myUrl = contextClassLoader.getResource( SearchTestCase.class.getName().replace(
'.', '/' ) + ".class" );
+ File myPath = new File( myUrl.getFile() );
+ // navigate back to '/target'
+ targetDir = myPath
+ .getParentFile() // target/classes/org/hibernate/search/test
+ .getParentFile() // target/classes/org/hibernate/search
+ .getParentFile() // target/classes/org/hibernate/
+ .getParentFile() // target/classes/org
+ .getParentFile() // target/classes/
+ .getParentFile(); // target
+
+ indexDir = new File( targetDir, "indextemp" );
log.debug( "Using {} as index directory.", indexDir.getAbsolutePath() );
}
@@ -258,18 +267,7 @@
*
* @return the target directory of the build
*/
- public File getTargetDir() {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- // get a URL reference to something we now is part of the classpath (us)
- URL myUrl = contextClassLoader.getResource( SearchTestCase.class.getName().replace(
'.', '/' ) + ".class" );
- File myPath = new File( myUrl.getFile() );
- // navigate back to '/target'
- return myPath
- .getParentFile() // target/classes/org/hibernate/search/test
- .getParentFile() // target/classes/org/hibernate/search
- .getParentFile() // target/classes/org/hibernate/
- .getParentFile() // target/classes/org
- .getParentFile() // target/classes/
- .getParentFile(); // target
+ public static File getTargetDir() {
+ return targetDir;
}
}
Show replies by date