01: package com.mockrunner.test.jdbc;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import com.mockrunner.base.BaseTestCase;
07: import com.mockrunner.jdbc.CallableStatementResultSetHandler;
08: import com.mockrunner.mock.jdbc.MockConnection;
09:
10: public class AbstractOutParameterResultSetHandlerTest extends
11: BaseTestCase {
12: private MockConnection connection;
13: private CallableStatementResultSetHandler callableStatementHandler;
14:
15: protected void setUp() throws Exception {
16: super .setUp();
17: connection = getJDBCMockObjectFactory().getMockConnection();
18: callableStatementHandler = connection
19: .getCallableStatementResultSetHandler();
20: }
21:
22: public void testGetOutParameter() {
23: Map outParameter = new HashMap();
24: outParameter.put("name", "value");
25: callableStatementHandler.prepareOutParameter("myc[a]ll",
26: outParameter);
27: assertNull(callableStatementHandler.getOutParameter("acall"));
28: assertNull(callableStatementHandler.getOutParameter("mycall"));
29: callableStatementHandler.setUseRegularExpressions(true);
30: assertEquals(outParameter, callableStatementHandler
31: .getOutParameter("mycall"));
32: }
33:
34: public void testGetOutParameterWithParameter() {
35: Map parameter = new HashMap();
36: parameter.put("name", "value");
37: callableStatementHandler.prepareOutParameter("myc[a]ll.*",
38: new HashMap(), parameter);
39: callableStatementHandler.setUseRegularExpressions(true);
40: assertNull(callableStatementHandler
41: .getOutParameter("mycall xyz"));
42: parameter = new HashMap();
43: parameter.put("name", "value");
44: parameter.put("name1", "value1");
45: assertEquals(new HashMap(), callableStatementHandler
46: .getOutParameter("mycall xyz", parameter));
47: callableStatementHandler.setExactMatchParameter(true);
48: assertNull(callableStatementHandler.getOutParameter(
49: "mycall xyz", parameter));
50: }
51:
52: public void testPreparedSQLOrdered() {
53: Map outParameterMap1 = new HashMap();
54: outParameterMap1.put("1", "1");
55: Map outParameterMap2 = new HashMap();
56: outParameterMap2.put("2", "2");
57: callableStatementHandler.prepareOutParameter("select",
58: outParameterMap1);
59: callableStatementHandler.prepareOutParameter("SelecT",
60: outParameterMap2);
61: callableStatementHandler.prepareOutParameter("SelecT",
62: outParameterMap1, new HashMap());
63: callableStatementHandler.prepareOutParameter("select",
64: outParameterMap2, new HashMap());
65: assertEquals(outParameterMap2, callableStatementHandler
66: .getOutParameter("select"));
67: assertEquals(outParameterMap1, callableStatementHandler
68: .getOutParameter("select", new HashMap()));
69: }
70: }
|