KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > execution > LazyInitConnectionTest


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.execution;
17
18 import scriptella.AbstractTestCase;
19 import scriptella.configuration.ConfigurationFactory;
20
21 import java.util.HashMap JavaDoc;
22 import java.util.Map JavaDoc;
23
24 /**
25  * Tests for lazy initialized connections.
26  *
27  * @author Fyodor Kupolov
28  * @version 1.0
29  */

30 public class LazyInitConnectionTest extends AbstractTestCase {
31     private Map JavaDoc<String JavaDoc,String JavaDoc> props;
32
33     protected ConfigurationFactory newConfigurationFactory() {
34         ConfigurationFactory cf = super.newConfigurationFactory();
35         cf.setExternalProperties(props);
36         return cf;
37     }
38
39     public void test() throws EtlExecutorException {
40         //script should execute normally because of lazy init
41
props=new HashMap JavaDoc<String JavaDoc, String JavaDoc>();
42         props.put("lazy", "true");
43         EtlExecutor exec = newEtlExecutor();
44         exec.execute();
45         //now ETL fails because of greedy mode
46
props.put("lazy", "false");
47         exec = newEtlExecutor();
48         try {
49             exec.execute();
50             fail("Script should fail in a greedy init mode.");
51         } catch (EtlExecutorException e) {
52             //OK
53
}
54
55     }
56 }
57
Free Books   Free Magazines  
Popular Tags