KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > DialectsTest


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;
17
18 import scriptella.execution.EtlExecutor;
19 import scriptella.execution.EtlExecutorException;
20 import scriptella.jdbc.QueryHelper;
21 import scriptella.spi.ParametersCallback;
22 import scriptella.spi.QueryCallback;
23
24 import java.sql.Connection JavaDoc;
25 import java.util.Arrays JavaDoc;
26 import java.util.HashSet JavaDoc;
27 import java.util.Set JavaDoc;
28
29
30 /**
31  * TODO: Add documentation
32  *
33  * @author Fyodor Kupolov
34  * @version 1.0
35  */

36 public class DialectsTest extends DBTestCase {
37     public void test() throws EtlExecutorException {
38         final Connection JavaDoc con = getConnection("dialectstest");
39         final EtlExecutor se = newEtlExecutor("DialectsTest.xml");
40         se.execute();
41
42         QueryHelper s = new QueryHelper("select * from test");
43         final Set JavaDoc expected = new HashSet JavaDoc(Arrays.asList(
44                 new Integer JavaDoc[]{1, 3, 4, 5, 6, 7, 9}));
45         final Set JavaDoc actual = new HashSet JavaDoc<Integer JavaDoc>();
46
47         s.execute(con,
48                 new QueryCallback() {
49                     public void processRow(final ParametersCallback row) {
50                         actual.add(row.getParameter("ID"));
51                     }
52                 });
53         assertEquals(expected, actual);
54     }
55
56     public void test2() throws EtlExecutorException {
57         final Connection JavaDoc con = getConnection("dialectstest2");
58         final EtlExecutor se = newEtlExecutor("DialectsTest2.xml");
59         se.execute();
60
61         QueryHelper s = new QueryHelper("select * from test2");
62         final Set JavaDoc expected = new HashSet JavaDoc(Arrays.asList(new Integer JavaDoc[]{1, 2}));
63         final Set JavaDoc actual = new HashSet JavaDoc<Integer JavaDoc>();
64
65         s.execute(con,
66                 new QueryCallback() {
67                     public void processRow(final ParametersCallback row) {
68                         actual.add(row.getParameter("ID"));
69                     }
70                 });
71         assertEquals(expected, actual);
72     }
73 }
74
Popular Tags