
package org.glowroot.agent.weaving;

import java.io.File;
import java.io.IOException;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class ClassLoadersTest {

    @Test
    public void shouldDeleteRegularFile() throws IOException {
        // given
        File file = File.createTempFile("glowroot-unit-test-", "");
        // when
        ClassLoaders.createDirectoryOrCleanPreviousContentsWithPrefix(file, "abc");
        // then
        assertThat(file.isDirectory()).isTrue();
    }

    @Test
    public void shouldCreateDirectory() throws IOException {
        // given
        File file = File.createTempFile("glowroot-unit-test-", "");
        file.delete();
        // when
        ClassLoaders.createDirectoryOrCleanPreviousContentsWithPrefix(file, "abc");
        // then
        assertThat(file.isDirectory()).isTrue();
    }
}
