KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > ConditionsTest


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.JdbcUtils;
21
22 import java.sql.Connection JavaDoc;
23 import java.sql.PreparedStatement JavaDoc;
24 import java.sql.ResultSet JavaDoc;
25 import java.sql.SQLException JavaDoc;
26 import java.util.ArrayList JavaDoc;
27 import java.util.HashSet JavaDoc;
28 import java.util.List JavaDoc;
29 import java.util.Set JavaDoc;
30
31
32 /**
33  * TODO: Add documentation
34  *
35  * @author Fyodor Kupolov
36  * @version 1.0
37  */

38 public class ConditionsTest extends DBTestCase {
39     public void test() throws EtlExecutorException, SQLException JavaDoc {
40         final Connection JavaDoc con = getConnection("conditionstest");
41         final EtlExecutor se = newEtlExecutor();
42         se.execute();
43
44         PreparedStatement JavaDoc ps = null;
45         ResultSet JavaDoc rs = null;
46
47         try {
48             ps = con.prepareStatement("select * from Test");
49             rs = ps.executeQuery();
50
51             Set JavaDoc<Integer JavaDoc> expected = new HashSet JavaDoc<Integer JavaDoc>();
52             expected.add(1);
53             expected.add(3);
54             expected.add(4);
55
56             List JavaDoc<Integer JavaDoc> actual = new ArrayList JavaDoc<Integer JavaDoc>();
57
58             //resultset must contains only 1,3 and 4
59
while (rs.next()) {
60                 actual.add(rs.getInt(1));
61             }
62
63             assertEquals("Set must be " + expected, 3, actual.size());
64             assertTrue("Set must be " + expected, expected.containsAll(actual));
65         } finally {
66             JdbcUtils.closeSilent(rs);
67             JdbcUtils.closeSilent(ps);
68         }
69     }
70 }
71
Popular Tags