KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > OnErrorTest


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.LinkedHashMap JavaDoc;
26 import java.util.Map JavaDoc;
27
28 /**
29  * Tests support of onerror elements.
30  *
31  * @author Fyodor Kupolov
32  * @version 1.0
33  */

34 public class OnErrorTest extends DBTestCase {
35     public void test() throws EtlExecutorException {
36         final Connection JavaDoc con = getConnection("onerrortest");
37         EtlExecutor se = newEtlExecutor();
38         se.execute();
39         QueryHelper q = new QueryHelper("select * from test");
40         final Map JavaDoc<Integer JavaDoc, String JavaDoc> expected = new LinkedHashMap JavaDoc<Integer JavaDoc, String JavaDoc>();
41         expected.put(1, "Updated1");
42         expected.put(2, "Updated2");
43         expected.put(3, "Updated3");
44         expected.put(4, "444");
45         expected.put(5, "555");
46         q.execute(con, new QueryCallback() {
47             public void processRow(final ParametersCallback parameters) {
48                 Integer JavaDoc id = (Integer JavaDoc) parameters.getParameter("id");
49                 assertEquals(expected.get(id), parameters.getParameter("value"));
50                 expected.remove(id);
51             }
52         });
53         assertTrue(expected.isEmpty());
54
55     }
56 }
57
Popular Tags