KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > tools > template > TemplateManagerTest


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
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 package scriptella.tools.template;
17
18 import scriptella.AbstractTestCase;
19
20 import java.io.IOException JavaDoc;
21 import java.io.StringWriter JavaDoc;
22 import java.io.Writer JavaDoc;
23 import java.util.HashMap JavaDoc;
24 import java.util.Map JavaDoc;
25
26 /**
27  * Tests for {@link TemplateManager}.
28  *
29  * @author Fyodor Kupolov
30  * @version 1.0
31  */

32 public class TemplateManagerTest extends AbstractTestCase {
33
34     public void test() throws IOException JavaDoc {
35         final Map JavaDoc<String JavaDoc,Writer JavaDoc> files = new HashMap JavaDoc<String JavaDoc, Writer JavaDoc>();
36         TemplateManager tm = new TemplateManager() {
37             protected Writer JavaDoc newFileWriter(String JavaDoc fileName) {
38                 files.put(fileName, new StringWriter JavaDoc());
39                 return files.get(fileName);
40             }
41
42             protected boolean checkFile(String JavaDoc name) {
43                 //etl.xml is absent but properties exist
44
if ("etl.xml".equals(name)) {
45                     return true;
46                 } else if ("etl.properties".equals(name)) {
47                     return false;
48                 }
49                 return true;
50             }
51         };
52         tm.create();
53         assertEquals(2, files.size());
54         assertTrue(files.containsKey("etl[1].xml"));
55         assertTrue(files.containsKey("etl[1].properties"));
56
57     }
58 }
59
Popular Tags