1 | BaseSelector getInstance() {↵ | | 1 | BaseSelector getInstance() {↵
|
2 | return new ContainsSelector();↵ | | 2 | return new FilenameSelector();↵
|
3 | }↵ | | 3 | }↵
|
|
4 | /**↵ | | 4 | /**↵
|
5 | * Test the code that validates the selector.↵ | | 5 | * Test the code that validates the selector.↵
|
6 | */↵ | | 6 | */↵
|
7 | public void testValidate() {↵ | | 7 | public void testValidate() {↵
|
8 | ContainsSelector s = (ContainsSelector)getInstance();↵ | | 8 | FilenameSelector s = (FilenameSelector)getInstance();↵
|
9 | try {↵ | | 9 | try {↵
|
10 | s.isSelected(basedir,filenames[0],files[0]);↵ | | 10 | s.isSelected(basedir,filenames[0],files[0]);↵
|
11 | fail("ContainsSelector did not check for required field 'text'");↵ | | 11 | fail("FilenameSelector did not check for required fields");↵
|
12 | } catch (BuildException be1) {↵ | | 12 | } catch (BuildException be1) {↵
|
13 | assertEquals("The text attribute is required", be1.getMessage());↵ | | 13 | assertEquals("The name attribute is required", be1.getMessage());↵
|
14 | }↵ | | 14 | }↵
|
|
15 | s = (ContainsSelector)getInstance();↵ | | 15 | s = (FilenameSelector)getInstance();↵
|
16 | Parameter param = new Parameter();↵ | | 16 | Parameter param = new Parameter();↵
|
17 | param.setName("garbage in");↵ | | 17 | param.setName("garbage in");↵
|
18 | param.setValue("garbage out");↵ | | 18 | param.setValue("garbage out");↵
|
19 | Parameter[] params = {param};↵ | | 19 | Parameter[] params = {param};↵
|
20 | s.setParameters(params);↵ | | 20 | s.setParameters(params);↵
|
21 | try {↵ | | 21 | try {↵
|
22 | s.isSelected(basedir,filenames[0],files[0]);↵ | | 22 | s.isSelected(basedir,filenames[0],files[0]);↵
|
23 | fail("ContainsSelector did not check for valid parameter element");↵ | | 23 | fail("FilenameSelector did not check for valid parameter element");↵
|
24 | } catch (BuildException be2) {↵ | | 24 | } catch (BuildException be2) {↵
|
25 | assertEquals("Invalid parameter garbage in", be2.getMessage());↵ | | 25 | assertEquals("Invalid parameter garbage in", be2.getMessage());↵
|
26 | }↵ | | 26 | }↵
|
|
27 | | | 27 |
|