File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed
main/java/com/tagtraum/perf/gcviewer/view/util
test/java/com/tagtraum/perf/gcviewer/view/util Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change 11package com .tagtraum .perf .gcviewer .view .util ;
22
3- import javax .swing .filechooser .FileFilter ;
43import java .io .File ;
4+ import javax .swing .filechooser .FileFilter ;
55
66/**
77 * ExtensionFileFilter.
@@ -22,7 +22,6 @@ public ExtensionFileFilter(String extension) {
2222 }
2323
2424 public boolean accept (File f ) {
25- // TODO: Can probably be refactored; seems to be the same as in Export class
2625 try {
2726 return f .isDirectory () || f .toString ().toLowerCase ().endsWith ("." + extension );
2827 }
Original file line number Diff line number Diff line change 1+ package com .tagtraum .perf .gcviewer .view .util ;
2+
3+ import static org .hamcrest .Matchers .equalTo ;
4+ import static org .hamcrest .Matchers .is ;
5+ import static org .junit .Assert .assertThat ;
6+
7+ import java .io .File ;
8+
9+ import org .junit .Before ;
10+ import org .junit .Test ;
11+
12+ /**
13+ * @author <a href="mailto:gcviewer@gmx.ch">Joerg Wuethrich</a>
14+ * <p>created on: 01.08.2018</p>
15+ */
16+ public class ExtensionFileFilterTest {
17+
18+ private ExtensionFileFilter extensionFileFilter ;
19+
20+ @ Before
21+ public void setup () {
22+ extensionFileFilter = new ExtensionFileFilter ("txt" );
23+ }
24+
25+ @ Test
26+ public void description () {
27+ assertThat ("extension" , extensionFileFilter .getDescription (), equalTo ("*.txt" ));
28+ }
29+
30+ @ Test
31+ public void acceptFalse () {
32+ boolean doesAccept = extensionFileFilter .accept (new File ("dummy-file-name" ));
33+
34+ assertThat ("accepts" , doesAccept , is (false ));
35+ }
36+
37+ @ Test
38+ public void acceptTrue () {
39+ boolean doesAccept = extensionFileFilter .accept (new File ("dummy-file-name.txt" ));
40+
41+ assertThat ("accepts" , doesAccept , is (true ));
42+ }
43+
44+ @ Test
45+ public void acceptNull () {
46+ assertThat ("null parameter" , extensionFileFilter .accept (null ), is (false ));
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments