1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.codehaus.gmavenplus.groovyworkarounds;
18
19 import org.junit.Test;
20
21 import java.io.File;
22 import java.util.HashSet;
23 import java.util.Set;
24
25 import static java.util.Collections.singletonList;
26 import static org.junit.Assert.*;
27
28
29
30
31
32
33
34 public class DotGroovyFileTest {
35
36 @Test
37 public void testGroovyWithCustomExtension() {
38 DotGroovyFile[] dotGroovyFiles = new DotGroovyFile[]{
39 new DotGroovyFile("pathname.ext").setScriptExtensions(new HashSet<>(singletonList("ext"))),
40 new DotGroovyFile("parent", "child.ext").setScriptExtensions(new HashSet<>(singletonList("ext"))),
41 new DotGroovyFile(new File("parent"), "child.ext").setScriptExtensions(new HashSet<>(singletonList("ext"))),
42 new DotGroovyFile(new File("filename.ext")).setScriptExtensions(new HashSet<>(singletonList("ext"))),
43 new DotGroovyFile(new File("filename.ext").toURI()).setScriptExtensions(new HashSet<>(singletonList("ext")))
44 };
45 for (DotGroovyFile dotGroovyFile : dotGroovyFiles) {
46 assertTrue(dotGroovyFile.getName() + " doesn't end with .groovy", dotGroovyFile.getName().endsWith(".groovy"));
47 }
48 }
49
50 @Test
51 public void testNonGroovyFile() {
52 DotGroovyFile[] dotGroovyFiles = new DotGroovyFile[]{
53 new DotGroovyFile("pathname.ext"),
54 new DotGroovyFile("parent", "child.ext"),
55 new DotGroovyFile(new File("parent"), "child.ext"),
56 new DotGroovyFile(new File("filename.ext")),
57 new DotGroovyFile(new File("filename.ext").toURI())
58 };
59 for (DotGroovyFile dotGroovyFile : dotGroovyFiles) {
60 assertFalse(dotGroovyFile.getName() + " ends with .groovy", dotGroovyFile.getName().endsWith(".groovy"));
61 }
62 }
63
64 @Test
65 public void testGettersAndSetters() {
66 Set<String> extensions = new HashSet<>();
67 extensions.add("ext");
68 DotGroovyFile dotGroovyFile = new DotGroovyFile("")
69 .setScriptExtensions(extensions);
70 assertEquals(extensions, dotGroovyFile.getScriptExtensions());
71 }
72
73 }