Search in sources :

Example 6 with SourceFolder

use of org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles.SourceFolder in project spring-boot by spring-projects.

the class ClassLoaderFilesTests method addAll.

@Test
public void addAll() throws Exception {
    ClassLoaderFile file1 = new ClassLoaderFile(Kind.ADDED, new byte[10]);
    this.files.addFile("a", "myfile1", file1);
    ClassLoaderFiles toAdd = new ClassLoaderFiles();
    ClassLoaderFile file2 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]);
    ClassLoaderFile file3 = new ClassLoaderFile(Kind.MODIFIED, new byte[10]);
    toAdd.addFile("a", "myfile2", file2);
    toAdd.addFile("b", "myfile3", file3);
    this.files.addAll(toAdd);
    Iterator<SourceFolder> sourceFolders = this.files.getSourceFolders().iterator();
    SourceFolder sourceFolder1 = sourceFolders.next();
    SourceFolder sourceFolder2 = sourceFolders.next();
    assertThat(sourceFolders.hasNext()).isFalse();
    assertThat(sourceFolder1.getName()).isEqualTo("a");
    assertThat(sourceFolder2.getName()).isEqualTo("b");
    assertThat(sourceFolder1.getFiles()).containsOnly(file1, file2);
}
Also used : SourceFolder(org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles.SourceFolder) Test(org.junit.Test)

Aggregations

SourceFolder (org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles.SourceFolder)6 ClassLoaderFile (org.springframework.boot.devtools.restart.classloader.ClassLoaderFile)4 URL (java.net.URL)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 ClassLoaderFileURLStreamHandler (org.springframework.boot.devtools.restart.classloader.ClassLoaderFileURLStreamHandler)1 ClassLoaderFiles (org.springframework.boot.devtools.restart.classloader.ClassLoaderFiles)1 AbstractResource (org.springframework.core.io.AbstractResource)1 Resource (org.springframework.core.io.Resource)1 UrlResource (org.springframework.core.io.UrlResource)1 ServletContextResource (org.springframework.web.context.support.ServletContextResource)1