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() . 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
Source File: SchemaManagerLoadTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
@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
Source File: SchemaManagerDelTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
@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
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
@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
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
@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
Source File: SchemaManagerEnableDisableLoadTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
@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
Source File: SchemaLdifExtractorTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
@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
Source File: CreateLdapServerExtension.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@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 File: SimpleLdapDirectoryServer.java    From knox with 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
Source File: SchemaManagerLoadTest.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 10
Source File: SchemaManagerDelTest.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 11
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 12
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 13
Source File: SchemaManagerEnableDisableLoadTest.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( schemaRepository.getParentFile() );
}
 
Example 14
Source File: SchemaLdifExtractorTest.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
@AfterAll
public static void cleanup() throws IOException
{
    // Cleanup the target directory
    FileUtils.deleteDirectory( new File( workingDirectory + "/schema" ) );
}
 
Example 15
Source File: InMemoryDirectoryServiceFactory.java    From bouncr with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@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();
}