log.info( "DELETE test repo dir: " + repoDir.getAbsolutePath() );
RepositorySessionUtil.deleteDir( repoDir );
log.info( "TEST repo dir deleted." );
}
RulesRepositoryConfigurator config = RulesRepositoryConfigurator.getInstance( null );
String home = System.getProperty( "guvnor.repository.dir" );
Properties properties = new Properties();
if ( home != null ) {
properties.setProperty( JCRRepositoryConfigurator.REPOSITORY_ROOT_DIRECTORY,
home );
}
repository = config.getJCRRepository();
//-->Workaround for lock problems
int retries = 3;
Session testSession = null;
while ( retries > 0 ) {
try {
testSession = repository.login( new SimpleCredentials( "alan_parsons",
"password".toCharArray() ) );
retries = 0;
} catch ( RepositoryException re ) {
System.err.println( "Failed to get the repository session: Retrying... " );
re.printStackTrace();
System.err.println( "Attemptng to shutdown repository... " );
shutdown();
repository = config.getJCRRepository();
retries--;
try {
Thread.sleep( 500 );
} catch ( InterruptedException ie ) {
}
}
}
if ( testSession == null ) {
throw new IllegalStateException( "Unable to get Repository Session. Refer to previous messages for details." );
}
//<--
RulesRepositoryAdministrator admin = new RulesRepositoryAdministrator( testSession );
if ( erase && admin.isRepositoryInitialized() ) {
admin.clearRulesRepository();
}
config.setupRepository( testSession );
File file = File.createTempFile( "pete",
"txt" );
file.deleteOnExit();
PrintWriter out = new PrintWriter( new FileOutputStream( file ) );
out.close();