KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > driver > spring > SpringDriverTest


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.driver.spring;
17
18 import org.springframework.beans.factory.BeanFactory;
19 import org.springframework.context.support.ClassPathXmlApplicationContext;
20 import scriptella.AbstractTestCase;
21 import scriptella.execution.EtlExecutor;
22 import scriptella.execution.EtlExecutorException;
23
24 import javax.sql.DataSource JavaDoc;
25 import java.sql.Connection JavaDoc;
26 import java.sql.SQLException JavaDoc;
27
28 /**
29  * Tests for {@link Driver}.
30  *
31  * @author Fyodor Kupolov
32  * @version 1.0
33  */

34 public class SpringDriverTest extends AbstractTestCase {
35     public void test() throws SQLException JavaDoc, ClassNotFoundException JavaDoc, EtlExecutorException {
36         BeanFactory bf = new ClassPathXmlApplicationContext("scriptella/driver/spring/springbeans.xml");
37         DataSource JavaDoc ds = (DataSource JavaDoc) bf.getBean("datasource"); //Test if bean factory contain correct data
38
Connection JavaDoc con = ds.getConnection();
39         con.createStatement().executeQuery("select * from AutoStart"); //A table should be created on startup
40
EtlExecutor exec = (EtlExecutor) bf.getBean("executor");
41         exec.execute();
42         con.createStatement().executeQuery("select * from SpringTable"); //A table should be created
43
con.createStatement().execute("SHUTDOWN");
44
45     }
46 }
47
Popular Tags