1 package com.atlassian.plugin.loaders;
2
3 import java.io.File;
4 import java.util.Arrays;
5 import java.util.Collection;
6
7 import com.atlassian.plugin.loaders.classloading.DeploymentUnit;
8
9 import org.hamcrest.Matcher;
10 import org.junit.Test;
11
12 import static com.atlassian.plugin.loaders.classloading.TestDeploymentUnit.deploymentUnitWithPath;
13 import static com.atlassian.plugin.test.Matchers.fileNamed;
14 import static org.hamcrest.MatcherAssert.assertThat;
15 import static org.hamcrest.Matchers.contains;
16 import static org.hamcrest.Matchers.empty;
17
18 public class TestFileListScanner
19 {
20 @Test
21 public void testNormalOperation() throws Exception
22 {
23 final FileListScanner scanner = new FileListScanner(Arrays.asList(new File("foo.txt"), new File("bar.txt")));
24 assertContainsFooAndBar(scanner);
25
26
27 assertThat(scanner.scan(), empty());
28
29 scanner.reset();
30
31 assertContainsFooAndBar(scanner);
32 }
33
34 private void assertContainsFooAndBar(final FileListScanner scanner)
35 {
36 final Collection<DeploymentUnit> scan = scanner.scan();
37 final Matcher[] expected = { deploymentUnitWithPath(fileNamed("foo.txt")), deploymentUnitWithPath(fileNamed("bar.txt")) };
38 assertThat(scan, contains(expected));
39 }
40 }