source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/testcases/org/apache/tools/ant/types/selectors/TypeSelectorTest.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 2.8 KB
Line 
1/*
2 * Copyright 2003-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.apache.tools.ant.types.selectors;
19
20import org.apache.tools.ant.BuildException;
21import org.apache.tools.ant.Project;
22import org.apache.tools.ant.BuildFileTest;
23import org.apache.tools.ant.types.Parameter;
24import org.apache.tools.ant.util.JavaEnvUtils;
25
26import java.text.SimpleDateFormat;
27import java.text.ParsePosition;
28import java.util.Date;
29
30import junit.framework.TestCase;
31import junit.framework.AssertionFailedError;
32
33/**
34 * Tests Type Selectors.
35 *
36 */
37public class TypeSelectorTest extends BaseSelectorTest {
38
39 public TypeSelectorTest(String name) {
40 super(name);
41 }
42
43 /**
44 * Factory method from base class. This is overriden in child
45 * classes to return a specific Selector class.
46 */
47 public BaseSelector getInstance() {
48 return new TypeSelector();
49 }
50
51 /**
52 * Test the code that validates the selector.
53 */
54 public void testValidate() {
55 TypeSelector s = (TypeSelector)getInstance();
56 try {
57 s.isSelected(basedir,filenames[0],files[0]);
58 fail("TypeSelector did not check for required fields");
59 } catch (BuildException be1) {
60 assertEquals("The type attribute is required"
61 , be1.getMessage());
62 }
63 }
64
65 /**
66 * Tests to make sure that the selector is selecting files correctly.
67 */
68 public void testSelectionBehaviour() {
69 TypeSelector s;
70 String results;
71
72 TypeSelector.FileType directory = new
73 TypeSelector.FileType();
74 directory.setValue("dir");
75 TypeSelector.FileType file = new
76 TypeSelector.FileType();
77 file.setValue("file");
78
79 try {
80 makeBed();
81
82 s = (TypeSelector)getInstance();
83 s.setType(directory);
84 results = selectionString(s);
85 assertEquals("TFFFFFFFFFFT", results);
86
87 s = (TypeSelector)getInstance();
88 s.setType(file);
89 results = selectionString(s);
90 assertEquals("FTTTTTTTTTTF", results);
91
92
93 }
94 finally {
95 cleanupBed();
96 }
97
98 }
99
100}
Note: See TracBrowser for help on using the repository browser.