01: /*
02: * Copyright 2006-2007 The Scriptella Project Team.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.ant;
17:
18: import org.apache.tools.ant.BuildException;
19: import scriptella.AbstractTestCase;
20: import scriptella.tools.template.DataMigrator;
21: import scriptella.tools.template.TemplateManager;
22:
23: import java.io.IOException;
24: import java.util.HashMap;
25: import java.util.Map;
26:
27: /**
28: * Tests for {@link scriptella.tools.ant.EtlTemplateTask}.
29: *
30: * @author Fyodor Kupolov
31: * @version 1.0
32: */
33: public class EtlTemplateTaskTest extends AbstractTestCase {
34: private Map<String, ?> props;
35:
36: public void test() {
37: EtlTemplateTask t = new EtlTemplateTask() {
38: @Override
39: //Verify that data migrator template is used
40: protected void create(TemplateManager tm,
41: Map<String, ?> properties) throws IOException {
42: assertTrue(tm instanceof DataMigrator);
43: props = properties;
44: }
45:
46: @Override
47: //Return mock properties to isolate from Ant
48: protected Map<String, ?> getProperties() {
49: Map<String, Object> m = new HashMap<String, Object>();
50: m.put("a", "AA");
51: m.put("b", "BB");
52: return m;
53: }
54: };
55: try {
56: t.execute();
57: fail("Required attribute exception expected");
58: } catch (BuildException e) {
59: //OK
60: }
61: t.setName(DataMigrator.class.getSimpleName());
62: t.execute();
63: assertTrue(props != null && "AA".equals(props.get("a"))
64: && props.size() == 2);
65: }
66:
67: }
|