Java Code Examples for org.apache.directory.api.util.FileUtils#deleteDirectory()

The following examples show how to use org.apache.directory.api.util.FileUtils#deleteDirectory() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@BeforeAll
public static void setup() throws Exception
{
    workingDirectory = System.getProperty( "workingDirectory" );

    if ( workingDirectory == null )
    {
        String path = SchemaManagerLoadTest.class.getResource( "" ).getPath();
        int targetPos = path.indexOf( "target" );
        workingDirectory = path.substring( 0, targetPos + 6 );
    }

    // Make sure every test class has its own schema directory
    workingDirectory = new File( workingDirectory, "SchemaManagerLoadTest" ).getAbsolutePath();

    schemaRepository = new File( workingDirectory, "schema" );

    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository );

    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
    extractor.extractOrCopy();
}
 
Example 2
@BeforeAll
public static void setup() throws Exception
{
    workingDirectory = System.getProperty( "workingDirectory" );

    if ( workingDirectory == null )
    {
        String path = SchemaManagerDelTest.class.getResource( "" ).getPath();
        int targetPos = path.indexOf( "target" );
        workingDirectory = path.substring( 0, targetPos + 6 );
    }

    // Make sure every test class has its own schema directory
    workingDirectory = new File( workingDirectory, "SchemaManagerDelTest" ).getAbsolutePath();

    schemaRepository = new File( workingDirectory, "schema" );

    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository );

    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
    extractor.extractOrCopy();
}
 
Example 3
@BeforeAll
public static void setup() throws Exception
{
    workingDirectory = System.getProperty( "workingDirectory" );

    if ( workingDirectory == null )
    {
        String path = SchemaManagerLoadWithDepsTest.class.getResource( "" ).getPath();
        int targetPos = path.indexOf( "target" );
        workingDirectory = path.substring( 0, targetPos + 6 );
    }

    // Make sure every test class has its own schema directory
    workingDirectory = new File( workingDirectory, "SchemaManagerLoadWithDepsTest" ).getAbsolutePath();

    schemaRepository = new File( workingDirectory, "schema" );

    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository );

    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
    extractor.extractOrCopy();
}
 
Example 4
@BeforeAll
public static void setup() throws Exception
{
    workingDirectory = System.getProperty( "workingDirectory" );

    if ( workingDirectory == null )
    {
        String path = SchemaManagerAddTest.class.getResource( "" ).getPath();
        int targetPos = path.indexOf( "target" );
        workingDirectory = path.substring( 0, targetPos + 6 );
    }

    // Make sure every test class has its own schema directory
    workingDirectory = new File( workingDirectory, "SchemaManagerAddTest" ).getAbsolutePath();

    schemaRepository = new File( workingDirectory, "schema" );

    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository );

    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
    extractor.extractOrCopy();
}
 
Example 5
@BeforeAll
public static void setup() throws Exception
{
    workingDirectory = System.getProperty( "workingDirectory" );

    if ( workingDirectory == null )
    {
        String path = SchemaManagerEnableDisableLoadTest.class.getResource( "" ).getPath();
        int targetPos = path.indexOf( "target" );
        workingDirectory = path.substring( 0, targetPos + 6 );
    }

    // Make sure every test class has its own schema directory
    workingDirectory = new File( workingDirectory, "SchemaManagerEnableDisableLoadTest" ).getAbsolutePath();

    schemaRepository = new File( workingDirectory, "schema" );

    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository );

    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
    extractor.extractOrCopy();
}
 
Example 6
@BeforeAll
public static void setup() throws IOException
{
    workingDirectory = System.getProperty( "workingDirectory" );

    if ( workingDirectory == null )
    {
        String path = SchemaLdifExtractorTest.class.getResource( "" ).getPath();
        int targetPos = path.indexOf( "target" );
        workingDirectory = path.substring( 0, targetPos + 6 );
    }

    // Cleanup the target directory
    FileUtils.deleteDirectory( new File( workingDirectory + "/schema" ) );
}
 
Example 7
@Override
public void afterAll(ExtensionContext context) throws Exception {
	log.trace("Stopping ldap server");
	ldapServer.stop();

	log.trace("Shutting down directory service");
	directoryService.shutdown();
	FileUtils.deleteDirectory(directoryService.getInstanceLayout().getInstanceDirectory());
}
 
Example 8
Source Project: knox   File: SimpleLdapDirectoryServer.java    License: Apache License 2.0 5 votes vote down vote up
public void stop( boolean clean ) throws Exception {
  server.stop();
  service.shutdown();
  if( clean ) {
    FileUtils.deleteDirectory( service.getInstanceLayout().getInstanceDirectory() );
  }
}
 
Example 9
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 10
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 11
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 12
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 13
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 14
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( new File( workingDirectory + "/schema" ) );
}
 
Example 15
/**
 * {@inheritDoc}
 */
public void init(String name) throws Exception {
    if ((directoryService != null) && directoryService.isStarted()) {
        return;
    }

    directoryService.setInstanceId(name);

    // instance layout
    InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name);
    if (instanceLayout.getInstanceDirectory().exists()) {
        try {
            FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory());
        } catch (IOException e) {
            LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e);
        }
    }
    directoryService.setInstanceLayout(instanceLayout);

    // EhCache in disabled-like-mode
    Configuration ehCacheConfig = new Configuration();
    CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30)
            .timeToLiveSeconds(30).overflowToDisk(false);
    ehCacheConfig.addDefaultCache(defaultCache);
    CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig));
    directoryService.setCacheService(cacheService);

    // Init the schema
    // SchemaLoader loader = new SingleLdifSchemaLoader();
    SchemaLoader loader = new JarLdifSchemaLoader();
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    schemaManager.loadAllEnabled();
    ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry();
    for (LdapComparator<?> comparator : comparatorRegistry) {
        if (comparator instanceof NormalizingComparator) {
            ((NormalizingComparator) comparator).setOnServer();
        }
    }
    directoryService.setSchemaManager(schemaManager);
    InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager);

    SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
    schemaPartition.setWrappedPartition(inMemorySchemaPartition);
    directoryService.setSchemaPartition(schemaPartition);
    List<Throwable> errors = schemaManager.getErrors();
    if (errors.size() != 0) {
        throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
    }

    // Init system partition
    Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(),
            directoryService.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500,
            new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system"));
    systemPartition.setSchemaManager(directoryService.getSchemaManager());
    partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100);
    directoryService.setSystemPartition(systemPartition);

    directoryService.startup();
}