001 package com.mockrunner.jdbc; 002 003 import java.sql.CallableStatement; 004 import java.sql.PreparedStatement; 005 import java.sql.SQLException; 006 import java.util.ArrayList; 007 import java.util.Arrays; 008 import java.util.Iterator; 009 import java.util.List; 010 import java.util.Map; 011 import java.util.TreeMap; 012 013 import com.mockrunner.base.NestedApplicationException; 014 import com.mockrunner.base.VerifyFailedException; 015 import com.mockrunner.mock.jdbc.JDBCMockObjectFactory; 016 import com.mockrunner.mock.jdbc.MockCallableStatement; 017 import com.mockrunner.mock.jdbc.MockPreparedStatement; 018 import com.mockrunner.mock.jdbc.MockResultSet; 019 import com.mockrunner.mock.jdbc.MockSavepoint; 020 import com.mockrunner.mock.jdbc.MockStatement; 021 import com.mockrunner.util.common.StringUtil; 022 023 /** 024 * Module for JDBC tests. 025 */ 026 public class JDBCTestModule 027 { 028 private JDBCMockObjectFactory mockFactory; 029 private boolean caseSensitive = false; 030 private boolean exactMatch = false; 031 private boolean useRegularExpressions = false; 032 033 public JDBCTestModule(JDBCMockObjectFactory mockFactory) 034 { 035 this.mockFactory = mockFactory; 036 } 037 038 /** 039 * Set if specified SQL statements should be handled case sensitive. 040 * Defaults to to <code>false</code>, i.e. <i>INSERT</i> is the same 041 * as <i>insert</i>. 042 * Please note that this method controls SQL statement 043 * matching for this class, e.g. what statements the method 044 * {@link #getPreparedStatements(String)} returns or what statements 045 * are taken into account by the method {@link #verifySQLStatementExecuted(String)}. 046 * In contrast to {@link AbstractResultSetHandler#setCaseSensitive(boolean)} it does 047 * not control the prepared results that are returned when the tested application 048 * executes a matching statement. 049 * @param caseSensitive enable or disable case sensitivity 050 */ 051 public void setCaseSensitive(boolean caseSensitive) 052 { 053 this.caseSensitive = caseSensitive; 054 } 055 056 /** 057 * Set if specified SQL statements must match exactly. 058 * Defaults to <code>false</code>, i.e. the SQL statement used 059 * to create a <code>PreparedStatement</code> must contain 060 * the specified SQL statement, but does not have to match 061 * exactly. If the original statement is <i>insert into mytable values(?, ?, ?)</i> 062 * <code>verifyPreparedStatementPresent("insert into mytable")</code> 063 * will pass. 064 * Please note that this method controls SQL statement 065 * matching for this class, e.g. what statements the method 066 * {@link #getPreparedStatements(String)} returns or what statements 067 * are taken into account by the method {@link #verifySQLStatementExecuted(String)}. 068 * In contrast to {@link AbstractResultSetHandler#setExactMatch(boolean)} it does 069 * not control the prepared results that are returned when the tested application 070 * executes a matching statement. 071 * @param exactMatch enable or disable exact matching 072 */ 073 public void setExactMatch(boolean exactMatch) 074 { 075 this.exactMatch = exactMatch; 076 } 077 078 /** 079 * Set if regular expressions should be used when matching 080 * SQL statements. Irrelevant if <code>exactMatch</code> is 081 * <code>true</code>. Default is <code>false</code>, i.e. you 082 * cannot use regular expressions and matching is based 083 * on string comparison. 084 * Please note that this method controls SQL statement 085 * matching for the methods of this class, e.g. what statements the method 086 * {@link #getPreparedStatements(String)} returns or what statements 087 * are taken into account by the method {@link #verifySQLStatementExecuted(String)}. 088 * In contrast to {@link AbstractResultSetHandler#setUseRegularExpressions(boolean)} it does 089 * not control the prepared results that are returned when the tested application 090 * executes a matching statement. 091 * @param useRegularExpressions should regular expressions be used 092 */ 093 public void setUseRegularExpressions(boolean useRegularExpressions) 094 { 095 this.useRegularExpressions = useRegularExpressions; 096 } 097 098 /** 099 * Returns the {@link StatementResultSetHandler}. 100 * The {@link StatementResultSetHandler} 101 * contains methods that can be used to specify the 102 * {@link com.mockrunner.mock.jdbc.MockResultSet} objects 103 * and update counts that a {@link com.mockrunner.mock.jdbc.MockStatement} 104 * should return when executing an SQL statement. 105 * @return the {@link StatementResultSetHandler} 106 */ 107 public StatementResultSetHandler getStatementResultSetHandler() 108 { 109 return mockFactory.getMockConnection().getStatementResultSetHandler(); 110 } 111 112 /** 113 * Returns the {@link PreparedStatementResultSetHandler}. 114 * The {@link PreparedStatementResultSetHandler} 115 * contains methods that can be used to specify the 116 * {@link com.mockrunner.mock.jdbc.MockResultSet} objects 117 * and update counts that a {@link com.mockrunner.mock.jdbc.MockPreparedStatement} 118 * should return when executing an SQL statement. 119 * @return the {@link PreparedStatementResultSetHandler} 120 */ 121 public PreparedStatementResultSetHandler getPreparedStatementResultSetHandler() 122 { 123 return mockFactory.getMockConnection().getPreparedStatementResultSetHandler(); 124 } 125 126 /** 127 * Returns the {@link CallableStatementResultSetHandler}. 128 * The {@link CallableStatementResultSetHandler} 129 * contains methods that can be used to specify the 130 * {@link com.mockrunner.mock.jdbc.MockResultSet} objects 131 * and update counts that a {@link com.mockrunner.mock.jdbc.MockCallableStatement} 132 * should return when executing an SQL statement. 133 * @return the {@link CallableStatementResultSetHandler} 134 */ 135 public CallableStatementResultSetHandler getCallableStatementResultSetHandler() 136 { 137 return mockFactory.getMockConnection().getCallableStatementResultSetHandler(); 138 } 139 140 /** 141 * Returns a {@link com.mockrunner.mock.jdbc.MockStatement} by its index. 142 * @param index the index of the <code>Statement</code> 143 * @return the <code>Statement</code> or <code>null</code>, if there is no such 144 * <code>Statement</code> 145 */ 146 public MockStatement getStatement(int index) 147 { 148 List statements = getStatements(); 149 if(index < statements.size()) return (MockStatement)statements.get(index); 150 return null; 151 } 152 153 /** 154 * Returns all {@link com.mockrunner.mock.jdbc.MockStatement} objects. 155 * @return the <code>List</code> of <code>Statement</code> objects 156 */ 157 public List getStatements() 158 { 159 return mockFactory.getMockConnection().getStatementResultSetHandler().getStatements(); 160 } 161 162 /** 163 * Returns a <code>List</code> of all SQL statements that were executed 164 * by calling an <code>execute</code> method of a {@link com.mockrunner.mock.jdbc.MockStatement}, 165 * {@link com.mockrunner.mock.jdbc.MockPreparedStatement} or 166 * {@link com.mockrunner.mock.jdbc.MockCallableStatement}. 167 * @return the <code>List</code> of SQL statements 168 */ 169 public List getExecutedSQLStatements() 170 { 171 ArrayList list = new ArrayList(); 172 list.addAll(mockFactory.getMockConnection().getStatementResultSetHandler().getExecutedStatements()); 173 list.addAll(mockFactory.getMockConnection().getPreparedStatementResultSetHandler().getExecutedStatements()); 174 list.addAll(mockFactory.getMockConnection().getCallableStatementResultSetHandler().getExecutedStatements()); 175 return list; 176 } 177 178 /** 179 * @deprecated use {@link #getExecutedSQLStatementParameterMap} 180 */ 181 public Map getExecutedSQLStatementParameter() 182 { 183 return getExecutedSQLStatementParameterMap(); 184 } 185 186 /** 187 * Returns a <code>Map</code> of all parameters that were used when 188 * executing a {@link com.mockrunner.mock.jdbc.MockPreparedStatement} or 189 * {@link com.mockrunner.mock.jdbc.MockCallableStatement}. 190 * The keys are the corresponding SQL statements. The values are the 191 * {@link ParameterSets} objects. 192 * @return the <code>Map</code> of parameters 193 */ 194 public Map getExecutedSQLStatementParameterMap() 195 { 196 Map map = new TreeMap(); 197 map.putAll(mockFactory.getMockConnection().getPreparedStatementResultSetHandler().getExecutedStatementParameterMap()); 198 map.putAll(mockFactory.getMockConnection().getCallableStatementResultSetHandler().getExecutedStatementParameterMap()); 199 return map; 200 } 201 202 /** 203 * Returns the {@link ParameterSets} object for the specified SQL statement. 204 * If more than one {@link ParameterSets} object is found, the first one 205 * will be returned. 206 * @param sql the the SQL statement 207 * @return the {@link ParameterSets} object or <code>null</code> if no 208 * matching object is found 209 */ 210 public ParameterSets getExecutedSQLStatementParameterSets(String sql) 211 { 212 Map map = getExecutedSQLStatementParameterMap(); 213 SQLStatementMatcher matcher = new SQLStatementMatcher(caseSensitive, exactMatch, useRegularExpressions); 214 List list = matcher.getMatchingObjects(map, sql, false, false); 215 if(list != null && list.size() > 0) 216 { 217 return (ParameterSets)list.get(0); 218 } 219 return null; 220 } 221 222 /** 223 * Returns the <code>ResultSet</code> objects with the specified id. 224 * If there are more than one <code>ResultSet</code> objects with the 225 * specified id, the first one is returned. If there is no 226 * <code>ResultSet</code> with the specified id, this method 227 * returns <code>null</code>. 228 * Please also see {@link #getReturnedResultSets(String)}. 229 * @return the <code>ResultSet</code> with the specified id 230 */ 231 public MockResultSet getReturnedResultSet(String id) 232 { 233 List list = getReturnedResultSets(id); 234 if(list != null && list.size() > 0) 235 { 236 return (MockResultSet)list.get(0); 237 } 238 return null; 239 } 240 241 /** 242 * Returns a <code>List</code> of the <code>ResultSet</code> objects with 243 * the specified id. In contrast to {@link #getReturnedResultSets}, the 244 * returned <code>List</code> never contains <code>ResultSet[]</code> objects, 245 * only single result sets. If {@link #getReturnedResultSets} returns an 246 * array, every <code>ResultSet</code> is checked and added to the returned <code>List</code>, 247 * if the id matches. 248 * Please note that <code>ResultSet</code> objects are cloned when executing 249 * statements. The <code>ResultSet</code> objects in the <code>List</code> 250 * returned by this method are really the instances the statement returned 251 * and not the instances you have used when preparing them. 252 * @return the <code>List</code> of <code>ResultSet</code> objects 253 */ 254 public List getReturnedResultSets(String id) 255 { 256 List list = getReturnedResultSets(); 257 ArrayList resultList = new ArrayList(); 258 for(int ii = 0; ii < list.size(); ii++) 259 { 260 Object object = list.get(ii); 261 if(object instanceof MockResultSet) 262 { 263 addIfIdMatches((MockResultSet)object, id, resultList); 264 } 265 else if(object instanceof MockResultSet[]) 266 { 267 MockResultSet[] resultSets = (MockResultSet[])object; 268 for(int yy = 0; yy < resultSets.length; yy++) 269 { 270 addIfIdMatches(resultSets[yy], id, resultList); 271 } 272 } 273 } 274 return resultList; 275 } 276 277 private void addIfIdMatches(MockResultSet resultSet, String id, List resultList) 278 { 279 if(null == id) return; 280 if(id.equals(resultSet.getId())) 281 { 282 resultList.add(resultSet); 283 } 284 } 285 286 /** 287 * Returns a <code>List</code> of all <code>ResultSet</code> objects that were returned 288 * by calling an <code>executeQuery</code> method of a {@link com.mockrunner.mock.jdbc.MockStatement}, 289 * {@link com.mockrunner.mock.jdbc.MockPreparedStatement} or 290 * {@link com.mockrunner.mock.jdbc.MockCallableStatement}. 291 * Please note that the <code>List</code> may contain arrays of <code>ResultSet</code> objects, 292 * if a query returned multiple result sets. The <code>List</code> may 293 * contain <code>ResultSet</code> objects and <code>ResultSet[]</code> objects. 294 * If a query returned multiple result sets, the list will always contain 295 * the full array of <code>ResultSet</code> objects that were prepared, even 296 * if {@link com.mockrunner.mock.jdbc.MockStatement#getMoreResults()} was 297 * not called for all the result sets. 298 * Please note that <code>ResultSet</code> objects are cloned when executing 299 * statements. The <code>ResultSet</code> objects in the <code>List</code> 300 * returned by this method are really the instances the statement returned 301 * and not the instances you have used when preparing them. 302 * @return the <code>List</code> of <code>ResultSet</code> or <code>ResultSet[]</code> objects 303 */ 304 public List getReturnedResultSets() 305 { 306 ArrayList list = new ArrayList(); 307 list.addAll(mockFactory.getMockConnection().getStatementResultSetHandler().getReturnedResultSets()); 308 list.addAll(mockFactory.getMockConnection().getPreparedStatementResultSetHandler().getReturnedResultSets()); 309 list.addAll(mockFactory.getMockConnection().getCallableStatementResultSetHandler().getReturnedResultSets()); 310 return list; 311 } 312 313 /** 314 * Returns a {@link com.mockrunner.mock.jdbc.MockPreparedStatement} that was 315 * created using a {@link com.mockrunner.mock.jdbc.MockConnection} by its index. 316 * @param index the index of the <code>PreparedStatement</code> 317 * @return the <code>PreparedStatement</code> or <code>null</code>, if there is no such 318 * <code>PreparedStatement</code> 319 */ 320 public MockPreparedStatement getPreparedStatement(int index) 321 { 322 List statements = getPreparedStatements(); 323 if(index < statements.size()) return (MockPreparedStatement)statements.get(index); 324 return null; 325 } 326 327 /** 328 * Returns a {@link com.mockrunner.mock.jdbc.MockPreparedStatement} that was 329 * created using a {@link com.mockrunner.mock.jdbc.MockConnection} by its SQL statement. 330 * If there are more than one {@link com.mockrunner.mock.jdbc.MockPreparedStatement} 331 * objects with the specified SQL, the first one will be returned. 332 * Please note that you can modify the search parameters with 333 * {@link #setCaseSensitive}, {@link #setExactMatch} and {@link #setUseRegularExpressions}. 334 * @param sql the SQL statement used to create the <code>PreparedStatement</code> 335 * @return the <code>PreparedStatement</code> or <code>null</code>, if there is no macth 336 */ 337 public MockPreparedStatement getPreparedStatement(String sql) 338 { 339 List list = getPreparedStatements(sql); 340 if(null != list && list.size() > 0) 341 { 342 return (MockPreparedStatement)list.get(0); 343 } 344 return null; 345 } 346 347 /** 348 * Returns all {@link com.mockrunner.mock.jdbc.MockPreparedStatement} objects. 349 * @return the <code>List</code> of <code>PreparedStatement</code> objects 350 */ 351 public List getPreparedStatements() 352 { 353 return mockFactory.getMockConnection().getPreparedStatementResultSetHandler().getPreparedStatements(); 354 } 355 356 /** 357 * Returns all {@link com.mockrunner.mock.jdbc.MockPreparedStatement} objects with 358 * the specified SQL statement as a <code>List</code>. If there are no matches, an empty 359 * <code>List</code> will be returned. 360 * Please note that you can modify the search parameters with 361 * {@link #setCaseSensitive}, {@link #setExactMatch} and {@link #setUseRegularExpressions}. 362 * @param sql the SQL statement used to create the <code>PreparedStatement</code> 363 * @return the <code>List</code> of <code>PreparedStatement</code> objects 364 */ 365 public List getPreparedStatements(String sql) 366 { 367 Map sqlStatements = mockFactory.getMockConnection().getPreparedStatementResultSetHandler().getPreparedStatementMap(); 368 SQLStatementMatcher matcher = new SQLStatementMatcher(caseSensitive, exactMatch, useRegularExpressions); 369 return matcher.getMatchingObjects(sqlStatements, sql, true, false); 370 } 371 372 /** 373 * Returns a {@link com.mockrunner.mock.jdbc.MockCallableStatement} that was 374 * created using a {@link com.mockrunner.mock.jdbc.MockConnection} by its index. 375 * @param index the index of the <code>CallableStatement</code> 376 * @return the <code>CallableStatement</code> or <code>null</code>, if there is no such 377 * <code>CallableStatement</code> 378 */ 379 public MockCallableStatement getCallableStatement(int index) 380 { 381 List statements = getCallableStatements(); 382 if(index < statements.size()) return (MockCallableStatement)statements.get(index); 383 return null; 384 } 385 386 /** 387 * Returns a {@link com.mockrunner.mock.jdbc.MockCallableStatement} that was 388 * created using a {@link com.mockrunner.mock.jdbc.MockConnection} by its SQL statement. 389 * If there are more than one {@link com.mockrunner.mock.jdbc.MockCallableStatement} 390 * objects with the specified SQL, the first one will be returned. 391 * Please note that you can modify the search parameters with 392 * {@link #setCaseSensitive}, {@link #setExactMatch} and {@link #setUseRegularExpressions}. 393 * @param sql the SQL statement used to create the <code>CallableStatement</code> 394 * @return the <code>CallableStatement</code> or <code>null</code>, if there is no macth 395 */ 396 public MockCallableStatement getCallableStatement(String sql) 397 { 398 List list = getCallableStatements(sql); 399 if(null != list && list.size() > 0) 400 { 401 return (MockCallableStatement)list.get(0); 402 } 403 return null; 404 } 405 406 /** 407 * Returns all {@link com.mockrunner.mock.jdbc.MockCallableStatement} objects. 408 * @return the <code>List</code> of <code>CallableStatement</code> objects 409 */ 410 public List getCallableStatements() 411 { 412 return mockFactory.getMockConnection().getCallableStatementResultSetHandler().getCallableStatements(); 413 } 414 415 /** 416 * Returns all {@link com.mockrunner.mock.jdbc.MockCallableStatement} objects with 417 * the specified SQL statement as a <code>List</code>. 418 * If there are no matches, an empty <code>List</code> will be returned. 419 * Please note that you can modify the search parameters with 420 * {@link #setCaseSensitive}, {@link #setExactMatch} and {@link #setUseRegularExpressions}. 421 * @param sql the SQL statement used to create the <code>CallableStatement</code> 422 * @return the <code>List</code> of <code>CallableStatement</code> objects 423 */ 424 public List getCallableStatements(String sql) 425 { 426 Map sqlStatements = mockFactory.getMockConnection().getCallableStatementResultSetHandler().getCallableStatementMap(); 427 SQLStatementMatcher matcher = new SQLStatementMatcher(caseSensitive, exactMatch, useRegularExpressions); 428 return matcher.getMatchingObjects(sqlStatements, sql, true, false); 429 } 430 431 /** 432 * Returns a parameter that was added to a <code>PreparedStatement</code> 433 * using its <code>set</code> methods. Simple data types are returned as 434 * the corresponsing wrapper type. 435 * @param statement the <code>PreparedStatement</code> 436 * @param indexOfParameter the index used to set the parameter 437 * @return the corresponding object 438 */ 439 public Object getPreparedStatementParameter(PreparedStatement statement, int indexOfParameter) 440 { 441 if(null == statement) return null; 442 return ((MockPreparedStatement)statement).getParameter(indexOfParameter); 443 } 444 445 /** 446 * Returns a parameter that was added to a <code>PreparedStatement</code> 447 * using its <code>set</code> methods. Uses the first <code>PreparedStatement</code> 448 * with the specified SQL statement. Simple data types are returned as 449 * the corresponsing wrapper type. 450 * @param sql the SQL statement 451 * @param indexOfParameter the index used to set the object 452 * @return the corresponding object 453 */ 454 public Object getPreparedStatementParameter(String sql, int indexOfParameter) 455 { 456 return getPreparedStatementParameter(getPreparedStatement(sql), indexOfParameter); 457 } 458 459 /** 460 * Returns an object that was added to a <code>PreparedStatement</code> 461 * using its <code>set</code> methods. Simple data types are returned as 462 * the corresponsing wrapper type. 463 * @param indexOfStatement the index of the statement 464 * @param indexOfParameter the index used to set the object 465 * @return the corresponding object 466 */ 467 public Object getPreparedStatementParameter(int indexOfStatement, int indexOfParameter) 468 { 469 return getPreparedStatementParameter(getPreparedStatement(indexOfStatement), indexOfParameter); 470 } 471 472 /** 473 * Returns a parameter that was added to a <code>CallableStatement</code> 474 * using its <code>set</code> methods. Simple data types are returned as 475 * the corresponsing wrapper type. 476 * @param statement the <code>CallableStatement</code> 477 * @param indexOfParameter the index used to set the parameter 478 * @return the corresponding object 479 */ 480 public Object getCallableStatementParameter(CallableStatement statement, int indexOfParameter) 481 { 482 if(null == statement) return null; 483 return ((MockCallableStatement)statement).getParameter(indexOfParameter); 484 } 485 486 /** 487 * Returns a parameter that was added to a <code>CallableStatement</code> 488 * using its <code>set</code> methods. Uses the first <code>CallableStatement</code> 489 * with the specified SQL statement. Simple data types are returned as 490 * the corresponsing wrapper type. 491 * @param sql the SQL statement 492 * @param indexOfParameter the index used to set the object 493 * @return the corresponding object 494 */ 495 public Object getCallableStatementParameter(String sql, int indexOfParameter) 496 { 497 return getCallableStatementParameter(getCallableStatement(sql), indexOfParameter); 498 } 499 500 /** 501 * Returns an object that was added to a <code>CallableStatement</code> 502 * using its <code>set</code> methods. Simple data types are returned as 503 * the corresponsing wrapper type. 504 * @param indexOfStatement the index of the statement 505 * @param indexOfParameter the index used to set the object 506 * @return the corresponding object 507 */ 508 public Object getCallableStatementParameter(int indexOfStatement, int indexOfParameter) 509 { 510 return getCallableStatementParameter(getCallableStatement(indexOfStatement), indexOfParameter); 511 } 512 513 /** 514 * Returns a parameter that was added to a <code>CallableStatement</code> 515 * using its <code>set</code> methods. 516 * @param statement the <code>CallableStatement</code> 517 * @param nameOfParameter the name of the parameter 518 * @return the corresponding object 519 */ 520 public Object getCallableStatementParameter(CallableStatement statement, String nameOfParameter) 521 { 522 if(null == statement) return null; 523 return ((MockCallableStatement)statement).getParameter(nameOfParameter); 524 } 525 526 /** 527 * Returns a parameter that was added to a <code>CallableStatement</code> 528 * using its <code>set</code> methods. Uses the first <code>CallableStatement</code> 529 * with the specified SQL statement. 530 * @param sql the SQL statement 531 * @param nameOfParameter the name of the parameter 532 * @return the corresponding object 533 */ 534 public Object getCallableStatementParameter(String sql, String nameOfParameter) 535 { 536 return getCallableStatementParameter(getCallableStatement(sql), nameOfParameter); 537 } 538 539 /** 540 * Returns an object that was added to a <code>CallableStatement</code> 541 * using its <code>set</code> methods. 542 * @param indexOfStatement the index of the statement 543 * @param nameOfParameter the name of the parameter 544 * @return the corresponding object 545 */ 546 public Object getCallableStatementParameter(int indexOfStatement, String nameOfParameter) 547 { 548 return getCallableStatementParameter(getCallableStatement(indexOfStatement), nameOfParameter); 549 } 550 551 /** 552 * Returns a list of all <code>Savepoint</code> objects. 553 * @return the <code>List</code> of {@link com.mockrunner.mock.jdbc.MockSavepoint} objects 554 */ 555 public List getSavepoints() 556 { 557 return new ArrayList(mockFactory.getMockConnection().getSavepointMap().values()); 558 } 559 560 /** 561 * Returns the <code>Savepoint</code> with the specified index. 562 * The index is the number of the created <code>Savepoint</code> 563 * starting with 0 for the first <code>Savepoint</code>. 564 * @param index the index 565 * @return the {@link com.mockrunner.mock.jdbc.MockSavepoint} 566 */ 567 public MockSavepoint getSavepoint(int index) 568 { 569 List savepoints = getSavepoints(); 570 for(int ii = 0; ii < savepoints.size(); ii++) 571 { 572 MockSavepoint currentSavepoint = (MockSavepoint)savepoints.get(ii); 573 if(currentSavepoint.getNumber() == index) return currentSavepoint; 574 } 575 return null; 576 } 577 578 /** 579 * Returns the first <code>Savepoint</code> with the specified name. 580 * Unnamed <code>Savepoint</code> objects get the name <i>""</i>. 581 * @param name the name 582 * @return the {@link com.mockrunner.mock.jdbc.MockSavepoint} 583 */ 584 public MockSavepoint getSavepoint(String name) 585 { 586 List savepoints = getSavepoints(); 587 for(int ii = 0; ii < savepoints.size(); ii++) 588 { 589 MockSavepoint currentSavepoint = (MockSavepoint)savepoints.get(ii); 590 try 591 { 592 if(currentSavepoint.getSavepointName().equals(name)) return currentSavepoint; 593 } 594 catch(SQLException exc) 595 { 596 throw new NestedApplicationException(exc); 597 } 598 } 599 return null; 600 } 601 602 /** 603 * Verifies that an SQL statement was executed. 604 * @param sql the expected SQL string 605 * @throws VerifyFailedException if verification fails 606 */ 607 public void verifySQLStatementExecuted(String sql) 608 { 609 SQLStatementMatcher matcher = new SQLStatementMatcher(caseSensitive, exactMatch, useRegularExpressions); 610 if(!matcher.contains(getExecutedSQLStatements(), sql, false)) 611 { 612 throw new VerifyFailedException("Statement " + sql + " not executed."); 613 } 614 } 615 616 /** 617 * Verifies that an SQL statement was not executed. 618 * @param sql the SQL string 619 * @throws VerifyFailedException if verification fails 620 */ 621 public void verifySQLStatementNotExecuted(String sql) 622 { 623 SQLStatementMatcher matcher = new SQLStatementMatcher(caseSensitive, exactMatch, useRegularExpressions); 624 if(matcher.contains(getExecutedSQLStatements(), sql, false)) 625 { 626 throw new VerifyFailedException("Statement " + sql + " was executed."); 627 } 628 } 629 630 /** 631 * Verifies the number of parameters for the specified SQL statement. 632 * If more than one SQL statement is found, this method uses the 633 * first one. You can specify the index of the parameter set. If 634 * if a <code>PreparedStatement</code> or <code>CallableStatement</code> 635 * is executed N times, it has N parameter sets. Each parameter set 636 * can contain any number of parameters (possibly 0 parameters). 637 * Ordinary statements do not have parameter sets, of course. If 638 * the specified SQL has been executed by an ordinary statements, 639 * a <code>VerifyFailedException</code> is thrown stating the reason. 640 * @param sql the SQL string 641 * @param indexOfParameterSet the number of the parameter set 642 * @param number the expected number of parameters 643 * @throws VerifyFailedException if verification fails 644 */ 645 public void verifySQLStatementParameterNumber(String sql, int indexOfParameterSet, int number) 646 { 647 Map actualParameterMap = verifyAndGetParametersForSQL(sql, indexOfParameterSet); 648 if(actualParameterMap.size() != number) 649 { 650 throw new VerifyFailedException("Expected " + number + " parameter, actual " + actualParameterMap.size() + " parameter"); 651 } 652 } 653 654 /** 655 * Verifies the parameters for the specified SQL statement. 656 * If more than one SQL statement is found, this method uses the 657 * first one. The parameter map must match in size and the 658 * parameters must be equal (by comparing them with 659 * {com.mockrunner.jdbc.ParameterUtil#compareParameter}). 660 * You can specify the index of the parameter set. If 661 * if a <code>PreparedStatement</code> or <code>CallableStatement</code> 662 * is executed N times, it has N parameter sets. Each parameter set 663 * can contain any number of parameters (possibly 0 parameters). 664 * Ordinary statements do not have parameter sets, of course. If 665 * the specified SQL has been executed by an ordinary statements, 666 * a <code>VerifyFailedException</code> is thrown stating the reason. 667 * @param sql the SQL string 668 * @param indexOfParameterSet the number of the parameter set 669 * @param parameterMap the map of expected parameters 670 * @throws VerifyFailedException if verification fails 671 */ 672 public void verifySQLStatementParameter(String sql, int indexOfParameterSet, Map parameterMap) 673 { 674 verifySQLStatementParameterNumber(sql, indexOfParameterSet, parameterMap.size()); 675 Map actualParameterMap = verifyAndGetParametersForSQL(sql, indexOfParameterSet); 676 Iterator keys = parameterMap.keySet().iterator(); 677 while(keys.hasNext()) 678 { 679 Object nextKey = keys.next(); 680 Object nextExpectedParameter = parameterMap.get(nextKey); 681 Object nextActualParameter = actualParameterMap.get(nextKey); 682 if(null == nextActualParameter) 683 { 684 throw new VerifyFailedException("No parameter " + nextKey + " found."); 685 } 686 if(!ParameterUtil.compareParameter(nextExpectedParameter, nextActualParameter)) 687 { 688 throw new VerifyFailedException("Expected " + nextExpectedParameter + " for parameter " + nextKey + ", but was " + nextActualParameter); 689 } 690 } 691 } 692 693 /** 694 * Verifies the parameter for the specified SQL statement. 695 * If more than one SQL statement is found, this method uses the 696 * first one. 697 * You can specify the index of the parameter set. If 698 * if a <code>PreparedStatement</code> or <code>CallableStatement</code> 699 * is executed N times, it has N parameter sets. Each parameter set 700 * can contain any number of parameters (possibly 0 parameters). 701 * Ordinary statements do not have parameter sets, of course. If 702 * the specified SQL has been executed by an ordinary statements, 703 * a <code>VerifyFailedException</code> is thrown stating the reason. 704 * @param sql the SQL string 705 * @param indexOfParameterSet the number of the parameter set 706 * @param indexOfParameter the index of the parameter 707 * @param expectedParameter the expected parameter 708 * @throws VerifyFailedException if verification fails 709 */ 710 public void verifySQLStatementParameter(String sql, int indexOfParameterSet, int indexOfParameter, Object expectedParameter) 711 { 712 Map actualParameterMap = verifyAndGetParametersForSQL(sql, indexOfParameterSet); 713 Object actualParameter = actualParameterMap.get(new Integer(indexOfParameter)); 714 if(!ParameterUtil.compareParameter(expectedParameter, actualParameter)) 715 { 716 throw new VerifyFailedException("Expected " + expectedParameter + " for parameter " + indexOfParameter + ", but was " + actualParameter); 717 } 718 } 719 720 /** 721 * Verifies the parameter for the specified SQL statement. 722 * If more than one SQL statement is found, this method uses the 723 * first one. 724 * You can specify the index of the parameter set. If 725 * if a <code>PreparedStatement</code> or <code>CallableStatement</code> 726 * is executed N times, it has N parameter sets. Each parameter set 727 * can contain any number of parameters (possibly 0 parameters). 728 * Ordinary statements do not have parameter sets, of course. If 729 * the specified SQL has been executed by an ordinary statements, 730 * a <code>VerifyFailedException</code> is thrown stating the reason. 731 * @param sql the SQL string 732 * @param indexOfParameterSet the number of the parameter set 733 * @param nameOfParameter the name of the parameter 734 * @param expectedParameter the expected parameter 735 * @throws VerifyFailedException if verification fails 736 */ 737 public void verifySQLStatementParameter(String sql, int indexOfParameterSet, String nameOfParameter, Object expectedParameter) 738 { 739 Map actualParameterMap = verifyAndGetParametersForSQL(sql, indexOfParameterSet); 740 Object actualParameter = actualParameterMap.get(nameOfParameter); 741 if(!ParameterUtil.compareParameter(expectedParameter, actualParameter)) 742 { 743 throw new VerifyFailedException("Expected " + expectedParameter + " for parameter " + nameOfParameter + ", but was " + actualParameter); 744 } 745 } 746 747 private Map verifyAndGetParametersForSQL(String sql, int indexOfParameterSet) 748 { 749 verifySQLStatementExecuted(sql); 750 SQLStatementMatcher matcher = new SQLStatementMatcher(caseSensitive, exactMatch, useRegularExpressions); 751 List matchingParameterList = matcher.getMatchingObjects(getExecutedSQLStatementParameterMap(), sql, true, false); 752 if(null == matchingParameterList || matchingParameterList.size() == 0) 753 { 754 throw new VerifyFailedException("No parameter sets for SQL " + sql + " found. Maybe the SQL has been executed by a regular " + 755 "statement instead of a prepared statement or callable statement."); 756 } 757 ParameterSets actualParameterSets = (ParameterSets)matchingParameterList.get(0); 758 if(null == actualParameterSets || indexOfParameterSet >= actualParameterSets.getNumberParameterSets()) 759 { 760 throw new VerifyFailedException("Statement " + sql + " has no parameter set with index " + indexOfParameterSet + 761 ". Maybe it has been executed less than " + (indexOfParameterSet + 1) + " times."); 762 } 763 return actualParameterSets.getParameterSet(indexOfParameterSet); 764 } 765 766 /** 767 * Verifies that the connection is closed. 768 * @throws VerifyFailedException if verification fails 769 */ 770 public void verifyConnectionClosed() 771 { 772 try 773 { 774 if(!mockFactory.getMockConnection().isClosed()) 775 { 776 throw new VerifyFailedException("Connection not closed."); 777 } 778 } 779 catch(SQLException exc) 780 { 781 throw new NestedApplicationException(exc); 782 } 783 } 784 785 /** 786 * Verifies that all statements, all prepared statements and 787 * all callable statements are closed. 788 * @throws VerifyFailedException if verification fails 789 */ 790 public void verifyAllStatementsClosed() 791 { 792 List statements = getStatements(); 793 for(int ii = 0; ii < statements.size(); ii++) 794 { 795 MockStatement statement = (MockStatement)statements.get(ii); 796 if(!statement.isClosed()) 797 { 798 throw new VerifyFailedException("Statement with index " + ii + " not closed."); 799 } 800 } 801 statements = getPreparedStatements(); 802 for(int ii = 0; ii < statements.size(); ii++) 803 { 804 MockPreparedStatement statement = (MockPreparedStatement)statements.get(ii); 805 if(!statement.isClosed()) 806 { 807 throw new VerifyFailedException("Prepared statement with index " + ii + " (SQL " + statement.getSQL() + ") not closed."); 808 } 809 } 810 statements = getCallableStatements(); 811 for(int ii = 0; ii < statements.size(); ii++) 812 { 813 MockPreparedStatement statement = (MockCallableStatement)statements.get(ii); 814 if(!statement.isClosed()) 815 { 816 throw new VerifyFailedException("Callable statement with index " + ii + " (SQL " + statement.getSQL() + ") not closed."); 817 } 818 } 819 } 820 821 /** 822 * Verifies that the <code>ResultSet</code> with the 823 * specified id is closed. Only recognizes <code>ResultSet</code> 824 * objects that were actually returned when executing a statement 825 * and that were explicitly closed. Implicit closed <code>ResultSet</code> 826 * objects (when closing a statement) are not recognized. 827 * @throws VerifyFailedException if verification fails 828 */ 829 public void verifyResultSetClosed(String id) 830 { 831 MockResultSet resultSet = getReturnedResultSet(id); 832 if(null == resultSet) 833 { 834 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 835 } 836 if(!resultSet.isClosed()) 837 { 838 throw new VerifyFailedException("ResultSet with id " + id + " not closed."); 839 } 840 } 841 842 /** 843 * Verifies that the specified row of a <code>ResultSet</code> was 844 * inserted. 845 * @param resultSet the <code>ResultSet</code> 846 * @param number the number of the row 847 * @throws VerifyFailedException if verification fails 848 */ 849 public void verifyResultSetRowInserted(MockResultSet resultSet, int number) 850 { 851 if(!resultSet.rowInserted(number)) 852 { 853 throw new VerifyFailedException("Row number " + number + " of ResultSet " + resultSet.getId() + " not inserted."); 854 } 855 } 856 857 /** 858 * Verifies that the specified row of a <code>ResultSet</code> was 859 * inserted. 860 * @param id the id of the <code>ResultSet</code> 861 * @param number the number of the row 862 * @throws VerifyFailedException if verification fails 863 */ 864 public void verifyResultSetRowInserted(String id, int number) 865 { 866 MockResultSet resultSet = getReturnedResultSet(id); 867 if(null == resultSet) 868 { 869 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 870 } 871 verifyResultSetRowInserted(resultSet, number); 872 } 873 874 /** 875 * Verifies that the specified row of a <code>ResultSet</code> was 876 * not inserted. 877 * @param resultSet the <code>ResultSet</code> 878 * @param number the number of the row 879 * @throws VerifyFailedException if verification fails 880 */ 881 public void verifyResultSetRowNotInserted(MockResultSet resultSet, int number) 882 { 883 if(resultSet.rowInserted(number)) 884 { 885 throw new VerifyFailedException("Row number " + number + " of ResultSet " + resultSet.getId() + " was inserted."); 886 } 887 } 888 889 /** 890 * Verifies that the specified row of a <code>ResultSet</code> was 891 * not inserted. 892 * @param id the id of the <code>ResultSet</code> 893 * @param number the number of the row 894 * @throws VerifyFailedException if verification fails 895 */ 896 public void verifyResultSetRowNotInserted(String id, int number) 897 { 898 MockResultSet resultSet = getReturnedResultSet(id); 899 if(null == resultSet) 900 { 901 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 902 } 903 verifyResultSetRowNotInserted(resultSet, number); 904 } 905 906 /** 907 * Verifies that the specified row of a <code>ResultSet</code> was 908 * updated. 909 * @param resultSet the <code>ResultSet</code> 910 * @param number the number of the row 911 * @throws VerifyFailedException if verification fails 912 */ 913 public void verifyResultSetRowUpdated(MockResultSet resultSet, int number) 914 { 915 if(!resultSet.rowUpdated(number)) 916 { 917 throw new VerifyFailedException("Row number " + number + " of ResultSet " + resultSet.getId() + " not updated."); 918 } 919 } 920 921 /** 922 * Verifies that the specified row of a <code>ResultSet</code> was 923 * updated. 924 * @param id the id of the <code>ResultSet</code> 925 * @param number the number of the row 926 * @throws VerifyFailedException if verification fails 927 */ 928 public void verifyResultSetRowUpdated(String id, int number) 929 { 930 MockResultSet resultSet = getReturnedResultSet(id); 931 if(null == resultSet) 932 { 933 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 934 } 935 verifyResultSetRowUpdated(resultSet, number); 936 } 937 938 /** 939 * Verifies that the specified row of a <code>ResultSet</code> was 940 * not updated. 941 * @param resultSet the <code>ResultSet</code> 942 * @param number the number of the row 943 * @throws VerifyFailedException if verification fails 944 */ 945 public void verifyResultSetRowNotUpdated(MockResultSet resultSet, int number) 946 { 947 if(resultSet.rowUpdated(number)) 948 { 949 throw new VerifyFailedException("Row number " + number + " of ResultSet " + resultSet.getId() + " was updated."); 950 } 951 } 952 953 /** 954 * Verifies that the specified row of a <code>ResultSet</code> was 955 * not updated. 956 * @param id the id of the <code>ResultSet</code> 957 * @param number the number of the row 958 * @throws VerifyFailedException if verification fails 959 */ 960 public void verifyResultSetRowNotUpdated(String id, int number) 961 { 962 MockResultSet resultSet = getReturnedResultSet(id); 963 if(null == resultSet) 964 { 965 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 966 } 967 verifyResultSetRowNotUpdated(resultSet, number); 968 } 969 970 /** 971 * Verifies that the specified row of a <code>ResultSet</code> was 972 * deleted. 973 * @param resultSet the <code>ResultSet</code> 974 * @param number the number of the row 975 * @throws VerifyFailedException if verification fails 976 */ 977 public void verifyResultSetRowDeleted(MockResultSet resultSet, int number) 978 { 979 if(!resultSet.rowDeleted(number)) 980 { 981 throw new VerifyFailedException("Row number " + number + " of ResultSet " + resultSet.getId() + " not deleted."); 982 } 983 } 984 985 /** 986 * Verifies that the specified row of a <code>ResultSet</code> was 987 * deleted. 988 * @param id the id of the <code>ResultSet</code> 989 * @param number the number of the row 990 * @throws VerifyFailedException if verification fails 991 */ 992 public void verifyResultSetRowDeleted(String id, int number) 993 { 994 MockResultSet resultSet = getReturnedResultSet(id); 995 if(null == resultSet) 996 { 997 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 998 } 999 verifyResultSetRowDeleted(resultSet, number); 1000 } 1001 1002 /** 1003 * Verifies that the specified row of a <code>ResultSet</code> was 1004 * not deleted. 1005 * @param resultSet the <code>ResultSet</code> 1006 * @param number the number of the row 1007 * @throws VerifyFailedException if verification fails 1008 */ 1009 public void verifyResultSetRowNotDeleted(MockResultSet resultSet, int number) 1010 { 1011 if(resultSet.rowDeleted(number)) 1012 { 1013 throw new VerifyFailedException("Row number " + number + " of ResultSet " + resultSet.getId() + " was deleted."); 1014 } 1015 } 1016 1017 /** 1018 * Verifies that the specified row of a <code>ResultSet</code> was 1019 * not deleted. 1020 * @param id the id of the <code>ResultSet</code> 1021 * @param number the number of the row 1022 * @throws VerifyFailedException if verification fails 1023 */ 1024 public void verifyResultSetRowNotDeleted(String id, int number) 1025 { 1026 MockResultSet resultSet = getReturnedResultSet(id); 1027 if(null == resultSet) 1028 { 1029 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 1030 } 1031 verifyResultSetRowNotDeleted(resultSet, number); 1032 } 1033 1034 /** 1035 * Verifies that all <code>ResultSet</code> objects are closed. 1036 * Only recognizes <code>ResultSet</code> objects that were actually 1037 * returned when executing a statement and that were explicitly closed. 1038 * Implicit closed <code>ResultSet</code> objects (when closing a statement) 1039 * are not recognized. 1040 * @throws VerifyFailedException if verification fails 1041 */ 1042 public void verifyAllResultSetsClosed() 1043 { 1044 List allResultSets = getReturnedResultSets(); 1045 for(int ii = 0; ii < allResultSets.size(); ii++) 1046 { 1047 Object object = allResultSets.get(ii); 1048 if(object instanceof MockResultSet) 1049 { 1050 throwExceptionIfNotClosed((MockResultSet)object); 1051 } 1052 else if(object instanceof MockResultSet[]) 1053 { 1054 MockResultSet[] resultSets = (MockResultSet[])object; 1055 for(int yy = 0; yy < resultSets.length; yy++) 1056 { 1057 throwExceptionIfNotClosed(resultSets[yy]); 1058 } 1059 } 1060 } 1061 } 1062 1063 private void throwExceptionIfNotClosed(MockResultSet resultSet) 1064 { 1065 if(!resultSet.isClosed()) 1066 { 1067 throw new VerifyFailedException("ResultSet with id " + resultSet.getId() + " not closed."); 1068 } 1069 } 1070 1071 /** 1072 * Verifies that the changes were commited, i.e. the <code>commit</code> 1073 * method of <code>Connection</code> was at least called once. 1074 * Makes only sense, if the <code>Connection</code> is not in 1075 * autocommit mode. Automatic commits are not recognized. 1076 * @throws VerifyFailedException if verification fails 1077 */ 1078 public void verifyCommitted() 1079 { 1080 int number = mockFactory.getMockConnection().getNumberCommits(); 1081 if(number <= 0) 1082 { 1083 throw new VerifyFailedException("Connection received no commits."); 1084 } 1085 } 1086 1087 /** 1088 * Verifies that the changes were not commited. 1089 * Makes only sense, if the <code>Connection</code> is not in 1090 * autocommit mode. Automatic commits are not recognized. 1091 * @throws VerifyFailedException if verification fails 1092 */ 1093 public void verifyNotCommitted() 1094 { 1095 int number = mockFactory.getMockConnection().getNumberCommits(); 1096 if(number > 0) 1097 { 1098 throw new VerifyFailedException("Connection was committed"); 1099 } 1100 } 1101 1102 /** 1103 * Verifies that the changes were rolled back, i.e. the <code>rollback</code> 1104 * method of <code>Connection</code> was at least called once. 1105 * Makes only sense, if the <code>Connection</code> is not in 1106 * autocommit mode. 1107 * @throws VerifyFailedException if verification fails 1108 */ 1109 public void verifyRolledBack() 1110 { 1111 int number = mockFactory.getMockConnection().getNumberRollbacks(); 1112 if(number <= 0) 1113 { 1114 throw new VerifyFailedException("Connection received no rollbacks."); 1115 } 1116 } 1117 1118 /** 1119 * Verifies that the changes were not rolled back. 1120 * Makes only sense, if the <code>Connection</code> is not in 1121 * autocommit mode. 1122 * @throws VerifyFailedException if verification fails 1123 */ 1124 public void verifyNotRolledBack() 1125 { 1126 int number = mockFactory.getMockConnection().getNumberRollbacks(); 1127 if(number > 0) 1128 { 1129 throw new VerifyFailedException("Connection was rolled back."); 1130 } 1131 } 1132 1133 /** 1134 * Verifies the number of <code>commit</code> calls. 1135 * Makes only sense, if the <code>Connection</code> is not in 1136 * autocommit mode. 1137 * @param number the expected number of commits 1138 * @throws VerifyFailedException if verification fails 1139 */ 1140 public void verifyNumberCommits(int number) 1141 { 1142 int actualNumber = mockFactory.getMockConnection().getNumberCommits(); 1143 if(actualNumber != number) 1144 { 1145 throw new VerifyFailedException("Connection received " + actualNumber + " commits, expected " + number); 1146 } 1147 } 1148 1149 /** 1150 * Verifies the number of <code>rollback</code> calls. 1151 * Makes only sense, if the <code>Connection</code> is not in 1152 * autocommit mode. 1153 * @param number the expected number of rollbacks 1154 * @throws VerifyFailedException if verification fails 1155 */ 1156 public void verifyNumberRollbacks(int number) 1157 { 1158 int actualNumber = mockFactory.getMockConnection().getNumberRollbacks(); 1159 if(actualNumber != number) 1160 { 1161 throw new VerifyFailedException("Connection received " + actualNumber + " rollbacks, expected " + number); 1162 } 1163 } 1164 1165 /** 1166 * Verifies the number of statements. 1167 * @param number the expected number 1168 * @throws VerifyFailedException if verification fails 1169 */ 1170 public void verifyNumberStatements(int number) 1171 { 1172 verifyNumberStatements(number, getStatements()); 1173 } 1174 1175 /** 1176 * Verifies the number of prepared statements. 1177 * @param number the expected number 1178 * @throws VerifyFailedException if verification fails 1179 */ 1180 public void verifyNumberPreparedStatements(int number) 1181 { 1182 verifyNumberStatements(number, getPreparedStatements()); 1183 } 1184 1185 /** 1186 * Verifies the number of prepared statements with the specified 1187 * SQL. 1188 * @param number the expected number 1189 * @param sql the SQL 1190 * @throws VerifyFailedException if verification fails 1191 */ 1192 public void verifyNumberPreparedStatements(int number, String sql) 1193 { 1194 verifyNumberStatements(number, getPreparedStatements(sql)); 1195 } 1196 1197 /** 1198 * Verifies the number of callable statements. 1199 * @param number the expected number 1200 * @throws VerifyFailedException if verification fails 1201 */ 1202 public void verifyNumberCallableStatements(int number) 1203 { 1204 verifyNumberStatements(number, getCallableStatements()); 1205 } 1206 1207 /** 1208 * Verifies the number of callable statements with the specified 1209 * SQL. 1210 * @param number the expected number 1211 * @param sql the SQL 1212 * @throws VerifyFailedException if verification fails 1213 */ 1214 public void verifyNumberCallableStatements(int number, String sql) 1215 { 1216 verifyNumberStatements(number, getCallableStatements(sql)); 1217 } 1218 1219 private void verifyNumberStatements(int number, List statements) 1220 { 1221 if(null == statements || statements.size() == 0) 1222 { 1223 if(number == 0) return; 1224 throw new VerifyFailedException("Expected " + number + " statements, received 0 statements"); 1225 } 1226 if(statements.size() != number) 1227 { 1228 throw new VerifyFailedException("Expected " + number + " statements, received " + statements.size()+ " statements"); 1229 } 1230 } 1231 1232 /** 1233 * Verifies that a statement is closed. 1234 * @param index the index of the statement 1235 * @throws VerifyFailedException if verification fails 1236 */ 1237 public void verifyStatementClosed(int index) 1238 { 1239 MockStatement statement = getStatement(index); 1240 if(null == statement) 1241 { 1242 throw new VerifyFailedException("No statement with index " + index + " present."); 1243 } 1244 if(!statement.isClosed()) 1245 { 1246 throw new VerifyFailedException("Statement with index " + index + " not closed."); 1247 } 1248 } 1249 1250 /** 1251 * Verifies that a prepared statement is closed. 1252 * @param index the index of the prepared statement 1253 * @throws VerifyFailedException if verification fails 1254 */ 1255 public void verifyPreparedStatementClosed(int index) 1256 { 1257 MockPreparedStatement statement = getPreparedStatement(index); 1258 if(null == statement) 1259 { 1260 throw new VerifyFailedException("No prepared statement with index " + index + " present."); 1261 } 1262 if(!statement.isClosed()) 1263 { 1264 throw new VerifyFailedException("Prepared statement with index " + index + " not closed."); 1265 } 1266 } 1267 1268 /** 1269 * Verifies that a prepared statement is closed. 1270 * @param sql the SQL statement 1271 * @throws VerifyFailedException if verification fails 1272 */ 1273 public void verifyPreparedStatementClosed(String sql) 1274 { 1275 MockPreparedStatement statement = getPreparedStatement(sql); 1276 if(null == statement) 1277 { 1278 throw new VerifyFailedException("No prepared statement with SQL " + sql + " present."); 1279 } 1280 if(!statement.isClosed()) 1281 { 1282 throw new VerifyFailedException("Prepared statement with SQL " + sql + " not closed."); 1283 } 1284 } 1285 1286 /** 1287 * Verifies that a callable statement is closed. 1288 * @param index the index of the callable statement 1289 * @throws VerifyFailedException if verification fails 1290 */ 1291 public void verifyCallableStatementClosed(int index) 1292 { 1293 MockCallableStatement statement = getCallableStatement(index); 1294 if(null == statement) 1295 { 1296 throw new VerifyFailedException("No callable statement with index " + index + " present."); 1297 } 1298 if(!statement.isClosed()) 1299 { 1300 throw new VerifyFailedException("Callable statement with index " + index + " not closed."); 1301 } 1302 } 1303 1304 /** 1305 * Verifies that a callable statement is closed. 1306 * @param sql the SQL statement 1307 * @throws VerifyFailedException if verification fails 1308 */ 1309 public void verifyCallableStatementClosed(String sql) 1310 { 1311 MockCallableStatement statement = getCallableStatement(sql); 1312 if(null == statement) 1313 { 1314 throw new VerifyFailedException("No callable statement with SQL " + sql + " present."); 1315 } 1316 if(!statement.isClosed()) 1317 { 1318 throw new VerifyFailedException("Callable statement with SQL " + sql + " not closed."); 1319 } 1320 } 1321 1322 /** 1323 * Verifies that a row of a <code>ResultSet</code> is equal to the 1324 * entries in the specified <code>List</code>. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isRowEqual}. 1325 * You can verify the data of returned <code>ResultSet</code> objects if 1326 * the tested JDBC code makes updates. 1327 * @param resultSet the <code>ResultSet</code> 1328 * @param number the number of the row 1329 * @param rowData the row data 1330 * @throws VerifyFailedException if verification fails 1331 */ 1332 public void verifyResultSetRow(MockResultSet resultSet, int number, List rowData) 1333 { 1334 if(null == resultSet.getRow(number)) 1335 { 1336 throw new VerifyFailedException("ResultSet " + resultSet.getId() + " has no row " + number); 1337 } 1338 if(!resultSet.isRowEqual(number, rowData)) 1339 { 1340 StringBuffer buffer = new StringBuffer("Actual row data:\n"); 1341 StringUtil.appendObjectsAsString(buffer, resultSet.getRow(number)); 1342 buffer.append("\n"); 1343 buffer.append("Expected row data:\n"); 1344 StringUtil.appendObjectsAsString(buffer, rowData); 1345 throw new VerifyFailedException("Mismatch in row data.\n" + buffer.toString()); 1346 } 1347 } 1348 1349 /** 1350 * Verifies that a row of a <code>ResultSet</code> is equal to the 1351 * entries in the specified array. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isRowEqual}. 1352 * You can verify the data of returned <code>ResultSet</code> objects if 1353 * the tested JDBC code makes updates. 1354 * @param resultSet the <code>ResultSet</code> 1355 * @param number the number of the row 1356 * @param rowData the row data 1357 * @throws VerifyFailedException if verification fails 1358 */ 1359 public void verifyResultSetRow(MockResultSet resultSet, int number, Object[] rowData) 1360 { 1361 List dataList = Arrays.asList(rowData); 1362 verifyResultSetRow(resultSet, number, dataList); 1363 } 1364 1365 /** 1366 * Verifies that a row of a <code>ResultSet</code> is equal to the 1367 * entries in the specified <code>List</code>. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isRowEqual}. 1368 * You can verify the data of returned <code>ResultSet</code> objects if 1369 * the tested JDBC code makes updates. 1370 * @param id the id of the <code>ResultSet</code> 1371 * @param number the number of the row 1372 * @param rowData the row data 1373 * @throws VerifyFailedException if verification fails 1374 */ 1375 public void verifyResultSetRow(String id, int number, List rowData) 1376 { 1377 MockResultSet resultSet = getReturnedResultSet(id); 1378 if(null == resultSet) 1379 { 1380 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 1381 } 1382 verifyResultSetRow(resultSet, number, rowData); 1383 } 1384 1385 /** 1386 * Verifies that a row of a <code>ResultSet</code> is equal to the 1387 * entries in the specified array. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isRowEqual}. 1388 * You can verify the data of returned <code>ResultSet</code> objects if 1389 * the tested JDBC code makes updates. 1390 * @param id the id of the <code>ResultSet</code> 1391 * @param number the number of the row 1392 * @param rowData the row data 1393 * @throws VerifyFailedException if verification fails 1394 */ 1395 public void verifyResultSetRow(String id, int number, Object[] rowData) 1396 { 1397 List dataList = Arrays.asList(rowData); 1398 verifyResultSetRow(id, number, dataList); 1399 } 1400 1401 /** 1402 * Verifies that a column of a <code>ResultSet</code> is equal to the 1403 * entries in the specified <code>List</code>. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isColumnEqual(int, List)}. 1404 * You can verify the data of returned <code>ResultSet</code> objects if 1405 * the tested JDBC code makes updates. 1406 * @param resultSet the <code>ResultSet</code> 1407 * @param number the number of the column 1408 * @param columnData the column data 1409 * @throws VerifyFailedException if verification fails 1410 */ 1411 public void verifyResultSetColumn(MockResultSet resultSet, int number, List columnData) 1412 { 1413 if(null == resultSet.getColumn(number)) 1414 { 1415 throw new VerifyFailedException("ResultSet " + resultSet.getId() + " has no column " + number); 1416 } 1417 if(!resultSet.isColumnEqual(number, columnData)) 1418 { 1419 StringBuffer buffer = new StringBuffer("Actual column data:\n"); 1420 StringUtil.appendObjectsAsString(buffer, resultSet.getColumn(number)); 1421 buffer.append("\n"); 1422 buffer.append("Expected column data:\n"); 1423 StringUtil.appendObjectsAsString(buffer, columnData); 1424 throw new VerifyFailedException("Mismatch in column data.\n" + buffer.toString()); 1425 } 1426 } 1427 1428 /** 1429 * Verifies that a column of a <code>ResultSet</code> is equal to the 1430 * entries in the specified array. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isColumnEqual(int, List)}. 1431 * You can verify the data of returned <code>ResultSet</code> objects if 1432 * the tested JDBC code makes updates. 1433 * @param resultSet the <code>ResultSet</code> 1434 * @param number the number of the column 1435 * @param columnData the column data 1436 * @throws VerifyFailedException if verification fails 1437 */ 1438 public void verifyResultSetColumn(MockResultSet resultSet, int number, Object[] columnData) 1439 { 1440 List dataList = Arrays.asList(columnData); 1441 verifyResultSetColumn(resultSet, number, dataList); 1442 } 1443 1444 /** 1445 * Verifies that a column of a <code>ResultSet</code> is equal to the 1446 * entries in the specified <code>List</code>. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isColumnEqual(int, List)}. 1447 * You can verify the data of returned <code>ResultSet</code> objects if 1448 * the tested JDBC code makes updates. 1449 * @param id the id of the <code>ResultSet</code> 1450 * @param number the number of the column 1451 * @param columnData the column data 1452 * @throws VerifyFailedException if verification fails 1453 */ 1454 public void verifyResultSetColumn(String id, int number, List columnData) 1455 { 1456 MockResultSet resultSet = getReturnedResultSet(id); 1457 if(null == resultSet) 1458 { 1459 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 1460 } 1461 verifyResultSetColumn(resultSet, number, columnData); 1462 } 1463 1464 /** 1465 * Verifies that a column of a <code>ResultSet</code> is equal to the 1466 * entries in the specified array. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isColumnEqual(int, List)}. 1467 * You can verify the data of returned <code>ResultSet</code> objects if 1468 * the tested JDBC code makes updates. 1469 * @param id the id of the <code>ResultSet</code> 1470 * @param number the number of the column 1471 * @param columnData the column data 1472 * @throws VerifyFailedException if verification fails 1473 */ 1474 public void verifyResultSetColumn(String id, int number, Object[] columnData) 1475 { 1476 List dataList = Arrays.asList(columnData); 1477 verifyResultSetColumn(id, number, dataList); 1478 } 1479 1480 /** 1481 * Verifies that a column of a <code>ResultSet</code> is equal to the 1482 * entries in the specified <code>List</code>. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isColumnEqual(String, List)}. 1483 * You can verify the data of returned <code>ResultSet</code> objects if 1484 * the tested JDBC code makes updates. 1485 * @param resultSet the <code>ResultSet</code> 1486 * @param name the name of the column 1487 * @param columnData the column data 1488 * @throws VerifyFailedException if verification fails 1489 */ 1490 public void verifyResultSetColumn(MockResultSet resultSet, String name, List columnData) 1491 { 1492 if(null == resultSet.getColumn(name)) 1493 { 1494 throw new VerifyFailedException("ResultSet " + resultSet.getId() + " has no column " + name); 1495 } 1496 if(!resultSet.isColumnEqual(name, columnData)) 1497 { 1498 StringBuffer buffer = new StringBuffer("Actual column data:\n"); 1499 StringUtil.appendObjectsAsString(buffer, resultSet.getColumn(name)); 1500 buffer.append("\n"); 1501 buffer.append("Expected column data:\n"); 1502 StringUtil.appendObjectsAsString(buffer, columnData); 1503 throw new VerifyFailedException("Mismatch in column data.\n" + buffer.toString()); 1504 } 1505 } 1506 1507 /** 1508 * Verifies that a column of a <code>ResultSet</code> is equal to the 1509 * entries in the specified array. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isColumnEqual(String, List)}. 1510 * You can verify the data of returned <code>ResultSet</code> objects if 1511 * the tested JDBC code makes updates. 1512 * @param resultSet the <code>ResultSet</code> 1513 * @param name the name of the column 1514 * @param columnData the column data 1515 * @throws VerifyFailedException if verification fails 1516 */ 1517 public void verifyResultSetColumn(MockResultSet resultSet, String name, Object[] columnData) 1518 { 1519 List dataList = Arrays.asList(columnData); 1520 verifyResultSetColumn(resultSet, name, dataList); 1521 } 1522 1523 /** 1524 * Verifies that a column of a <code>ResultSet</code> is equal to the 1525 * entries in the specified <code>List</code>. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isColumnEqual(String, List)}. 1526 * You can verify the data of returned <code>ResultSet</code> objects if 1527 * the tested JDBC code makes updates. 1528 * @param id the id of the <code>ResultSet</code> 1529 * @param name the name of the column 1530 * @param columnData the column data 1531 * @throws VerifyFailedException if verification fails 1532 */ 1533 public void verifyResultSetColumn(String id, String name, List columnData) 1534 { 1535 MockResultSet resultSet = getReturnedResultSet(id); 1536 if(null == resultSet) 1537 { 1538 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 1539 } 1540 verifyResultSetColumn(resultSet, name, columnData); 1541 } 1542 1543 /** 1544 * Verifies that a column of a <code>ResultSet</code> is equal to the 1545 * entries in the specified array. Uses {@link com.mockrunner.mock.jdbc.MockResultSet#isColumnEqual(String, List)}. 1546 * You can verify the data of returned <code>ResultSet</code> objects if 1547 * the tested JDBC code makes updates. 1548 * @param id the id of the <code>ResultSet</code> 1549 * @param name the name of the column 1550 * @param columnData the column data 1551 * @throws VerifyFailedException if verification fails 1552 */ 1553 public void verifyResultSetColumn(String id, String name, Object[] columnData) 1554 { 1555 List dataList = Arrays.asList(columnData); 1556 verifyResultSetColumn(id, name, dataList); 1557 } 1558 1559 /** 1560 * Verifies that a <code>ResultSet</code> is equal to another one. 1561 * Compares all the rows with {@link com.mockrunner.mock.jdbc.MockResultSet#isEqual}. 1562 * @param source the source <code>ResultSet</code> 1563 * @param target the target <code>ResultSet</code> 1564 * @throws VerifyFailedException if verification fails 1565 */ 1566 public void verifyResultSetEquals(MockResultSet source, MockResultSet target) 1567 { 1568 if(!source.isEqual(target)) 1569 { 1570 StringBuffer buffer = new StringBuffer("Source data:\n"); 1571 buffer.append(source.toString()); 1572 buffer.append("\n"); 1573 buffer.append("Target data:\n"); 1574 buffer.append(target.toString()); 1575 throw new VerifyFailedException("Mismatch in ResultSet data.\n" + buffer.toString()); 1576 } 1577 } 1578 1579 /** 1580 * Verifies that a <code>ResultSet</code> is equal to another one. 1581 * Compares all the rows with {@link com.mockrunner.jdbc.ParameterUtil#compareParameter}. 1582 * @param id the id of the source <code>ResultSet</code> 1583 * @param target the target <code>ResultSet</code> 1584 * @throws VerifyFailedException if verification fails 1585 */ 1586 public void verifyResultSetEquals(String id, MockResultSet target) 1587 { 1588 MockResultSet resultSet = getReturnedResultSet(id); 1589 if(null == resultSet) 1590 { 1591 throw new VerifyFailedException("ResultSet with id " + id + " not present."); 1592 } 1593 verifyResultSetEquals(resultSet, target); 1594 } 1595 1596 /** 1597 * Verifies that a <code>PreparedStatement</code> with the specified 1598 * SQL statement is present. 1599 * @param sql the SQL statement 1600 * @throws VerifyFailedException if verification fails 1601 */ 1602 public void verifyPreparedStatementPresent(String sql) 1603 { 1604 if(null == getPreparedStatement(sql)) 1605 { 1606 throw new VerifyFailedException("Prepared statement with SQL " + sql + " present."); 1607 } 1608 } 1609 1610 /** 1611 * Verifies that a <code>PreparedStatement</code> with the specified 1612 * SQL statement is not present. 1613 * @param sql the SQL statement 1614 * @throws VerifyFailedException if verification fails 1615 */ 1616 public void verifyPreparedStatementNotPresent(String sql) 1617 { 1618 if(null != getPreparedStatement(sql) ) 1619 { 1620 throw new VerifyFailedException("Prepared statement with SQL " + sql + " not present."); 1621 } 1622 } 1623 1624 /** 1625 * Verifies that a <code>CallableStatement</code> with the specified 1626 * SQL statement is present. 1627 * @param sql the SQL statement 1628 * @throws VerifyFailedException if verification fails 1629 */ 1630 public void verifyCallableStatementPresent(String sql) 1631 { 1632 if(null == getCallableStatement(sql)) 1633 { 1634 throw new VerifyFailedException("Callable statement with SQL " + sql + " present."); 1635 } 1636 } 1637 1638 /** 1639 * Verifies that a <code>CallableStatement</code> with the specified 1640 * SQL statement is not present. 1641 * @param sql the SQL statement 1642 * @throws VerifyFailedException if verification fails 1643 */ 1644 public void verifyCallableStatementNotPresent(String sql) 1645 { 1646 if(null != getCallableStatement(sql)) 1647 { 1648 throw new VerifyFailedException("Callable statement with SQL " + sql + " not present."); 1649 } 1650 } 1651 1652 /** 1653 * Verifies that a parameter was added to a <code>PreparedStatement</code> with 1654 * the specified index. 1655 * @param statement the <code>PreparedStatement</code> 1656 * @param indexOfParameter the index used to set the object 1657 * @throws VerifyFailedException if verification fails 1658 */ 1659 public void verifyPreparedStatementParameterPresent(PreparedStatement statement, int indexOfParameter) 1660 { 1661 if(!containsPreparedStatementParameter(statement, indexOfParameter)) 1662 { 1663 throw new VerifyFailedException("Prepared statement parameter with index " + indexOfParameter + " not present."); 1664 } 1665 } 1666 1667 /** 1668 * Verifies that a parameter was added to a <code>PreparedStatement</code> with 1669 * the specified index. Uses the first <code>PreparedStatement</code> with 1670 * the specified SQL. 1671 * @param sql the SQL statement of the <code>PreparedStatement</code> 1672 * @param indexOfParameter the index used to set the object 1673 * @throws VerifyFailedException if verification fails 1674 */ 1675 public void verifyPreparedStatementParameterPresent(String sql, int indexOfParameter) 1676 { 1677 if(!containsPreparedStatementParameter(sql, indexOfParameter)) 1678 { 1679 throw new VerifyFailedException("Prepared statement parameter with index " + indexOfParameter + " not present."); 1680 } 1681 } 1682 1683 /** 1684 * Verifies that a parameter was added to a <code>PreparedStatement</code> with 1685 * the specified index. 1686 * @param indexOfStatement the index of the statement 1687 * @param indexOfParameter the index used to set the object 1688 * @throws VerifyFailedException if verification fails 1689 */ 1690 public void verifyPreparedStatementParameterPresent(int indexOfStatement, int indexOfParameter) 1691 { 1692 if(!containsPreparedStatementParameter(indexOfStatement, indexOfParameter)) 1693 { 1694 throw new VerifyFailedException("Prepared statement parameter with index " + indexOfParameter + " not present."); 1695 } 1696 } 1697 1698 /** 1699 * Verifies that a parameter with the specified index is not present. 1700 * @param statement the <code>PreparedStatement</code> 1701 * @param indexOfParameter the index used to set the object 1702 * @throws VerifyFailedException if verification fails 1703 */ 1704 public void verifyPreparedStatementParameterNotPresent(PreparedStatement statement, int indexOfParameter) 1705 { 1706 if(containsPreparedStatementParameter(statement, indexOfParameter)) 1707 { 1708 throw new VerifyFailedException("Prepared statement parameter with index " + indexOfParameter + " present."); 1709 } 1710 } 1711 1712 /** 1713 * Verifies that a parameter with the specified index is not present. 1714 * Uses the first <code>PreparedStatement</code> with the specified SQL. 1715 * @param sql the SQL statement of the <code>PreparedStatement</code> 1716 * @param indexOfParameter the index used to set the object 1717 * @throws VerifyFailedException if verification fails 1718 */ 1719 public void verifyPreparedStatementParameterNotPresent(String sql, int indexOfParameter) 1720 { 1721 if(containsPreparedStatementParameter(sql, indexOfParameter)) 1722 { 1723 throw new VerifyFailedException("Prepared statement parameter with index " + indexOfParameter + " present."); 1724 } 1725 } 1726 1727 /** 1728 * Verifies that a parameter with the specified index is not present. 1729 * @param indexOfStatement the index of the statement 1730 * @param indexOfParameter the index used to set the object 1731 * @throws VerifyFailedException if verification fails 1732 */ 1733 public void verifyPreparedStatementParameterNotPresent(int indexOfStatement, int indexOfParameter) 1734 { 1735 if(containsPreparedStatementParameter(indexOfStatement, indexOfParameter)) 1736 { 1737 throw new VerifyFailedException("Prepared statement parameter with index " + indexOfParameter + " present."); 1738 } 1739 } 1740 1741 private boolean containsPreparedStatementParameter(int indexOfStatement, int indexOfParameter) 1742 { 1743 MockPreparedStatement statement = getPreparedStatement(indexOfStatement); 1744 if(null == statement) return false; 1745 return containsPreparedStatementParameter(statement, indexOfParameter); 1746 } 1747 1748 private boolean containsPreparedStatementParameter(String sql, int indexOfParameter) 1749 { 1750 MockPreparedStatement statement = getPreparedStatement(sql); 1751 if(null == statement) return false; 1752 return containsPreparedStatementParameter(statement, indexOfParameter); 1753 } 1754 1755 private boolean containsPreparedStatementParameter(PreparedStatement statement, int indexOfParameter) 1756 { 1757 return ((MockPreparedStatement)statement).getParameterMap().containsKey(new Integer(indexOfParameter)); 1758 } 1759 1760 /** 1761 * Verifies that a parameter was added to a <code>CallableStatement</code> with 1762 * the specified index. 1763 * @param statement the <code>CallableStatement</code> 1764 * @param indexOfParameter the index used to set the object 1765 * @throws VerifyFailedException if verification fails 1766 */ 1767 public void verifyCallableStatementParameterPresent(CallableStatement statement, int indexOfParameter) 1768 { 1769 if(!containsCallableStatementParameter(statement, indexOfParameter)) 1770 { 1771 throw new VerifyFailedException("Callable statement parameter with index " + indexOfParameter + " not present."); 1772 } 1773 } 1774 1775 /** 1776 * Verifies that a parameter was added to a <code>CallableStatement</code> with 1777 * the specified index. Uses the first <code>CallableStatement</code> with 1778 * the specified SQL. 1779 * @param sql the SQL statement of the <code>CallableStatement</code> 1780 * @param indexOfParameter the index used to set the object 1781 * @throws VerifyFailedException if verification fails 1782 */ 1783 public void verifyCallableStatementParameterPresent(String sql, int indexOfParameter) 1784 { 1785 if(!containsCallableStatementParameter(sql, indexOfParameter)) 1786 { 1787 throw new VerifyFailedException("Callable statement parameter with index " + indexOfParameter + " not present."); 1788 } 1789 } 1790 1791 /** 1792 * Verifies that a parameter was added to a <code>CallableStatement</code> with 1793 * the specified index. 1794 * @param indexOfStatement the index of the statement 1795 * @param indexOfParameter the index used to set the object 1796 * @throws VerifyFailedException if verification fails 1797 */ 1798 public void verifyCallableStatementParameterPresent(int indexOfStatement, int indexOfParameter) 1799 { 1800 if(!containsCallableStatementParameter(indexOfStatement, indexOfParameter)) 1801 { 1802 throw new VerifyFailedException("Callable statement parameter with index " + indexOfParameter + " not present."); 1803 } 1804 } 1805 1806 /** 1807 * Verifies that a parameter with the specified index is not present. 1808 * @param statement the <code>CallableStatement</code> 1809 * @param indexOfParameter the index used to set the object 1810 * @throws VerifyFailedException if verification fails 1811 */ 1812 public void verifyCallableStatementParameterNotPresent(CallableStatement statement, int indexOfParameter) 1813 { 1814 if(containsCallableStatementParameter(statement, indexOfParameter)) 1815 { 1816 throw new VerifyFailedException("Callable statement parameter with index " + indexOfParameter + " present."); 1817 } 1818 } 1819 1820 /** 1821 * Verifies that a parameter with the specified index is not present. 1822 * Uses the first <code>CallableStatement</code> with the specified SQL. 1823 * @param sql the SQL statement of the <code>CallableStatement</code> 1824 * @param indexOfParameter the index used to set the object 1825 * @throws VerifyFailedException if verification fails 1826 */ 1827 public void verifyCallableStatementParameterNotPresent(String sql, int indexOfParameter) 1828 { 1829 if(containsCallableStatementParameter(sql, indexOfParameter)) 1830 { 1831 throw new VerifyFailedException("Callable statement parameter with index " + indexOfParameter + " present."); 1832 } 1833 } 1834 1835 /** 1836 * Verifies that a parameter with the specified index is not present. 1837 * @param indexOfStatement the index of the statement 1838 * @param indexOfParameter the index used to set the object 1839 * @throws VerifyFailedException if verification fails 1840 */ 1841 public void verifyCallableStatementParameterNotPresent(int indexOfStatement, int indexOfParameter) 1842 { 1843 if(containsCallableStatementParameter(indexOfStatement, indexOfParameter)) 1844 { 1845 throw new VerifyFailedException("Callable statement parameter with index " + indexOfParameter + " present."); 1846 } 1847 } 1848 1849 /** 1850 * Verifies that a parameter was added to a <code>CallableStatement</code> with 1851 * the specified index. 1852 * @param statement the <code>CallableStatement</code> 1853 * @param nameOfParameter the name of the parameter 1854 * @throws VerifyFailedException if verification fails 1855 */ 1856 public void verifyCallableStatementParameterPresent(CallableStatement statement, String nameOfParameter) 1857 { 1858 if(!containsCallableStatementParameter(statement, nameOfParameter)) 1859 { 1860 throw new VerifyFailedException("Callable statement parameter with index " + nameOfParameter + " not present."); 1861 } 1862 } 1863 1864 /** 1865 * Verifies that a parameter was added to a <code>CallableStatement</code> with 1866 * the specified index. Uses the first <code>CallableStatement</code> with 1867 * the specified SQL. 1868 * @param sql the SQL statement of the <code>CallableStatement</code> 1869 * @param nameOfParameter the name of the parameter 1870 * @throws VerifyFailedException if verification fails 1871 */ 1872 public void verifyCallableStatementParameterPresent(String sql, String nameOfParameter) 1873 { 1874 if(!containsCallableStatementParameter(sql, nameOfParameter)) 1875 { 1876 throw new VerifyFailedException("Callable statement parameter with index " + nameOfParameter + " not present."); 1877 } 1878 } 1879 1880 /** 1881 * Verifies that a parameter was added to a <code>CallableStatement</code> with 1882 * the specified index. 1883 * @param indexOfStatement the index of the statement 1884 * @param nameOfParameter the name of the parameter 1885 * @throws VerifyFailedException if verification fails 1886 */ 1887 public void verifyCallableStatementParameterPresent(int indexOfStatement, String nameOfParameter) 1888 { 1889 if(!containsCallableStatementParameter(indexOfStatement, nameOfParameter)) 1890 { 1891 throw new VerifyFailedException("Callable statement parameter with index " + nameOfParameter + " not present."); 1892 } 1893 } 1894 1895 /** 1896 * Verifies that a parameter with the specified index is not present. 1897 * @param statement the <code>CallableStatement</code> 1898 * @param nameOfParameter the name of the parameter 1899 * @throws VerifyFailedException if verification fails 1900 */ 1901 public void verifyCallableStatementParameterNotPresent(CallableStatement statement, String nameOfParameter) 1902 { 1903 if(containsCallableStatementParameter(statement, nameOfParameter)) 1904 { 1905 throw new VerifyFailedException("Callable statement parameter with index " + nameOfParameter + " present."); 1906 } 1907 } 1908 1909 /** 1910 * Verifies that a parameter with the specified index is not present. 1911 * Uses the first <code>CallableStatement</code> with the specified SQL. 1912 * @param sql the SQL statement of the <code>CallableStatement</code> 1913 * @param nameOfParameter the name of the parameter 1914 * @throws VerifyFailedException if verification fails 1915 */ 1916 public void verifyCallableStatementParameterNotPresent(String sql, String nameOfParameter) 1917 { 1918 if(containsCallableStatementParameter(sql, nameOfParameter)) 1919 { 1920 throw new VerifyFailedException("Callable statement parameter with index " + nameOfParameter + " present."); 1921 } 1922 } 1923 1924 /** 1925 * Verifies that a parameter with the specified index is not present. 1926 * @param indexOfStatement the index of the statement 1927 * @param nameOfParameter the name of the parameter 1928 * @throws VerifyFailedException if verification fails 1929 */ 1930 public void verifyCallableStatementParameterNotPresent(int indexOfStatement, String nameOfParameter) 1931 { 1932 if(containsCallableStatementParameter(indexOfStatement, nameOfParameter)) 1933 { 1934 throw new VerifyFailedException("Callable statement parameter with index " + nameOfParameter + " present."); 1935 } 1936 } 1937 1938 private boolean containsCallableStatementParameter(int indexOfStatement, int indexOfParameter) 1939 { 1940 MockCallableStatement statement = getCallableStatement(indexOfStatement); 1941 if(null == statement) return false; 1942 return containsCallableStatementParameter(statement, indexOfParameter); 1943 } 1944 1945 private boolean containsCallableStatementParameter(String sql, int indexOfParameter) 1946 { 1947 MockCallableStatement statement = getCallableStatement(sql); 1948 if(null == statement) return false; 1949 return containsCallableStatementParameter(statement, indexOfParameter); 1950 } 1951 1952 private boolean containsCallableStatementParameter(CallableStatement statement, int indexOfParameter) 1953 { 1954 return ((MockCallableStatement)statement).getParameterMap().containsKey(new Integer(indexOfParameter)); 1955 } 1956 1957 private boolean containsCallableStatementParameter(int indexOfStatement, String nameOfParameter) 1958 { 1959 MockCallableStatement statement = getCallableStatement(indexOfStatement); 1960 if(null == statement) return false; 1961 return containsCallableStatementParameter(statement, nameOfParameter); 1962 } 1963 1964 private boolean containsCallableStatementParameter(String sql, String nameOfParameter) 1965 { 1966 MockCallableStatement statement = getCallableStatement(sql); 1967 if(null == statement) return false; 1968 return containsCallableStatementParameter(statement, nameOfParameter); 1969 } 1970 1971 private boolean containsCallableStatementParameter(CallableStatement statement, String nameOfParameter) 1972 { 1973 return ((MockCallableStatement)statement).getParameterMap().containsKey(nameOfParameter); 1974 } 1975 1976 /** 1977 * Verifies that a parameter from the specified <code>PreparedStatement</code> is equal 1978 * to the specified object. Please use the corresponding wrapper type for 1979 * primitive data types. 1980 * @param statement the <code>PreparedStatement</code> 1981 * @param indexOfParameter the index used to set the object 1982 * @param object the expected object 1983 * @throws VerifyFailedException if verification fails 1984 */ 1985 public void verifyPreparedStatementParameter(PreparedStatement statement, int indexOfParameter, Object object) 1986 { 1987 verifyPreparedStatementParameterPresent(statement, indexOfParameter); 1988 Object actualObject = getPreparedStatementParameter(statement, indexOfParameter); 1989 if(!ParameterUtil.compareParameter(actualObject, object)) 1990 { 1991 throw new VerifyFailedException("Prepared statement parameter with index " + indexOfParameter + " has the value " + 1992 String.valueOf(actualObject) + ", expected " + String.valueOf(object)); 1993 } 1994 } 1995 1996 /** 1997 * Verifies that a parameter from the <code>PreparedStatement</code> with the 1998 * specified SQL statement is equal to the specified object. 1999 * Uses the first <code>PreparedStatement</code> with the specified SQL. 2000 * Please use the corresponding wrapper type for primitive data types. 2001 * @param sql the SQL statement of the <code>PreparedStatement</code> 2002 * @param indexOfParameter the index used to set the object 2003 * @param object the expected object 2004 * @throws VerifyFailedException if verification fails 2005 */ 2006 public void verifyPreparedStatementParameter(String sql, int indexOfParameter, Object object) 2007 { 2008 verifyPreparedStatementParameterPresent(sql, indexOfParameter); 2009 Object actualObject = getPreparedStatementParameter(sql, indexOfParameter); 2010 if(!ParameterUtil.compareParameter(actualObject, object)) 2011 { 2012 throw new VerifyFailedException("Prepared statement parameter with index " + indexOfParameter + " has the value " + 2013 String.valueOf(actualObject) + ", expected " + String.valueOf(object)); 2014 } 2015 } 2016 2017 /** 2018 * Verifies that a parameter from the <code>PreparedStatement</code> with the 2019 * specified SQL statement is equal to the specified object. 2020 * Please use the corresponding wrapper type for primitive data types. 2021 * @param indexOfStatement the index of the statement 2022 * @param indexOfParameter the index used to set the object 2023 * @param object the expected object 2024 * @throws VerifyFailedException if verification fails 2025 */ 2026 public void verifyPreparedStatementParameter(int indexOfStatement, int indexOfParameter, Object object) 2027 { 2028 verifyPreparedStatementParameterPresent(indexOfStatement, indexOfParameter); 2029 Object actualObject = getPreparedStatementParameter(indexOfStatement, indexOfParameter); 2030 if(!ParameterUtil.compareParameter(actualObject, object)) 2031 { 2032 throw new VerifyFailedException("Prepared statement parameter with index " + indexOfParameter + " has the value " + 2033 String.valueOf(actualObject) + ", expected " + String.valueOf(object)); 2034 } 2035 } 2036 2037 /** 2038 * Verifies that a parameter from the specified <code>CallableStatement</code> is equal 2039 * to the specified object. Please use the corresponding wrapper type 2040 * for primitive data types. 2041 * @param statement the <code>CallableStatement</code> 2042 * @param indexOfParameter the index used to set the object 2043 * @param object the expected object 2044 * @throws VerifyFailedException if verification fails 2045 */ 2046 public void verifyCallableStatementParameter(CallableStatement statement, int indexOfParameter, Object object) 2047 { 2048 verifyCallableStatementParameterPresent(statement, indexOfParameter); 2049 Object actualObject = getCallableStatementParameter(statement, indexOfParameter); 2050 if(!ParameterUtil.compareParameter(actualObject, object)) 2051 { 2052 throw new VerifyFailedException("Callable statement parameter with index " + indexOfParameter + " has the value " + 2053 String.valueOf(actualObject) + ", expected " + String.valueOf(object)); 2054 } 2055 } 2056 2057 /** 2058 * Verifies that a parameter from the <code>CallableStatement</code> with the 2059 * specified SQL statement is equal to the specified object. 2060 * Uses the first <code>CallableStatement</code> with the specified SQL. 2061 * Please use the corresponding wrapper type for primitive data types. 2062 * @param sql the SQL statement of the <code>CallableStatement</code> 2063 * @param indexOfParameter the index used to set the object 2064 * @param object the expected object 2065 * @throws VerifyFailedException if verification fails 2066 */ 2067 public void verifyCallableStatementParameter(String sql, int indexOfParameter, Object object) 2068 { 2069 verifyCallableStatementParameterPresent(sql, indexOfParameter); 2070 Object actualObject = getCallableStatementParameter(sql, indexOfParameter); 2071 if(!ParameterUtil.compareParameter(actualObject, object)) 2072 { 2073 throw new VerifyFailedException("Callable statement parameter with index " + indexOfParameter + " has the value " + 2074 String.valueOf(actualObject) + ", expected " + String.valueOf(object)); 2075 } 2076 } 2077 2078 /** 2079 * Verifies that a parameter from the <code>CallableStatement</code> with the 2080 * specified SQL statement is equal to the specified object. 2081 * Please use the corresponding wrapper type for primitive data types. 2082 * @param indexOfStatement the index of the statement 2083 * @param indexOfParameter the index used to set the object 2084 * @param object the expected object 2085 * @throws VerifyFailedException if verification fails 2086 */ 2087 public void verifyCallableStatementParameter(int indexOfStatement, int indexOfParameter, Object object) 2088 { 2089 verifyCallableStatementParameterPresent(indexOfStatement, indexOfParameter); 2090 Object actualObject = getCallableStatementParameter(indexOfStatement, indexOfParameter); 2091 if(!ParameterUtil.compareParameter(actualObject, object)) 2092 { 2093 throw new VerifyFailedException("Callable statement parameter with index " + indexOfParameter + " has the value " + 2094 String.valueOf(actualObject) + ", expected " + String.valueOf(object)); 2095 } 2096 } 2097 2098 /** 2099 * Verifies that a parameter from the specified <code>CallableStatement</code> is equal 2100 * to the specified object. Please use the corresponding wrapper type 2101 * for primitive data types. 2102 * @param statement the <code>CallableStatement</code> 2103 * @param nameOfParameter the name of the parameter 2104 * @param object the expected object 2105 * @throws VerifyFailedException if verification fails 2106 */ 2107 public void verifyCallableStatementParameter(CallableStatement statement, String nameOfParameter, Object object) 2108 { 2109 verifyCallableStatementParameterPresent(statement, nameOfParameter); 2110 Object actualObject = getCallableStatementParameter(statement, nameOfParameter); 2111 if(!ParameterUtil.compareParameter(actualObject, object)) 2112 { 2113 throw new VerifyFailedException("Callable statement parameter with name " + nameOfParameter + " has the value " + 2114 String.valueOf(actualObject) + ", expected " + String.valueOf(object)); 2115 } 2116 } 2117 2118 /** 2119 * Verifies that a parameter from the <code>CallableStatement</code> with the 2120 * specified SQL statement is equal to the specified object. 2121 * Uses the first <code>CallableStatement</code> with the specified SQL. 2122 * Please use the corresponding wrapper type for primitive data types. 2123 * @param sql the SQL statement of the <code>CallableStatement</code> 2124 * @param nameOfParameter the name of the parameter 2125 * @param object the expected object 2126 * @throws VerifyFailedException if verification fails 2127 */ 2128 public void verifyCallableStatementParameter(String sql, String nameOfParameter, Object object) 2129 { 2130 verifyCallableStatementParameterPresent(sql, nameOfParameter); 2131 Object actualObject = getCallableStatementParameter(sql, nameOfParameter); 2132 if(!ParameterUtil.compareParameter(actualObject, object)) 2133 { 2134 throw new VerifyFailedException("Callable statement parameter with name " + nameOfParameter + " has the value " + 2135 String.valueOf(actualObject) + ", expected " + String.valueOf(object)); 2136 } 2137 } 2138 2139 /** 2140 * Verifies that a parameter from the <code>CallableStatement</code> with the 2141 * specified SQL statement is equal to the specified object. 2142 * Please use the corresponding wrapper type for primitive data types. 2143 * @param indexOfStatement the index of the statement 2144 * @param nameOfParameter the name of the parameter 2145 * @param object the expected object 2146 * @throws VerifyFailedException if verification fails 2147 */ 2148 public void verifyCallableStatementParameter(int indexOfStatement, String nameOfParameter, Object object) 2149 { 2150 verifyCallableStatementParameterPresent(indexOfStatement, nameOfParameter); 2151 Object actualObject = getCallableStatementParameter(indexOfStatement, nameOfParameter); 2152 if(!ParameterUtil.compareParameter(actualObject, object)) 2153 { 2154 throw new VerifyFailedException("Callable statement parameter with name " + nameOfParameter + " has the value " + 2155 String.valueOf(actualObject) + ", expected " + String.valueOf(object)); 2156 } 2157 } 2158 2159 /** 2160 * Verifies that an out parameter was registered on the specified 2161 * <code>CallableStatement</code>. 2162 * @param statement the <code>CallableStatement</code> 2163 * @param indexOfParameter the index of the parameter 2164 * @throws VerifyFailedException if verification fails 2165 */ 2166 public void verifyCallableStatementOutParameterRegistered(CallableStatement statement, int indexOfParameter) 2167 { 2168 if(!((MockCallableStatement)statement).isOutParameterRegistered(indexOfParameter)) 2169 { 2170 throw new VerifyFailedException("Out parameter with index " + indexOfParameter + 2171 " not registered in callable statement "); 2172 } 2173 } 2174 2175 /** 2176 * Verifies that an out parameter was registered on the 2177 * <code>CallableStatement</code> with the specified SQL. 2178 * @param sql the SQL statement 2179 * @param indexOfParameter the index of the parameter 2180 * @throws VerifyFailedException if verification fails 2181 */ 2182 public void verifyCallableStatementOutParameterRegistered(String sql, int indexOfParameter) 2183 { 2184 MockCallableStatement statement = getCallableStatement(sql); 2185 if(null == statement) 2186 { 2187 throw new VerifyFailedException("No callable statement " + sql + " present"); 2188 } 2189 if(!statement.isOutParameterRegistered(indexOfParameter)) 2190 { 2191 throw new VerifyFailedException("Out parameter with index " + indexOfParameter + 2192 " not registered in callable statement " + sql); 2193 } 2194 } 2195 2196 /** 2197 * Verifies that an out parameter was registered on the 2198 * <code>CallableStatement</code> with the specified index. 2199 * @param indexOfStatement the index of the <code>CallableStatement</code> 2200 * @param indexOfParameter the index of the parameter 2201 * @throws VerifyFailedException if verification fails 2202 */ 2203 public void verifyCallableStatementOutParameterRegistered(int indexOfStatement, int indexOfParameter) 2204 { 2205 MockCallableStatement statement = getCallableStatement(indexOfStatement); 2206 if(null == statement) 2207 { 2208 throw new VerifyFailedException("No callable statement with index " + indexOfStatement + " present"); 2209 } 2210 if(!statement.isOutParameterRegistered(indexOfParameter)) 2211 { 2212 throw new VerifyFailedException("Out parameter with index " + indexOfParameter + 2213 " not registered in callable statement with index " + indexOfStatement); 2214 } 2215 } 2216 2217 /** 2218 * Verifies that an out parameter was registered on the specified 2219 * <code>CallableStatement</code>. 2220 * @param statement the <code>CallableStatement</code> 2221 * @param nameOfParameter the name of the parameter 2222 * @throws VerifyFailedException if verification fails 2223 */ 2224 public void verifyCallableStatementOutParameterRegistered(CallableStatement statement, String nameOfParameter) 2225 { 2226 if(!((MockCallableStatement)statement).isOutParameterRegistered(nameOfParameter)) 2227 { 2228 throw new VerifyFailedException("Out parameter with name " + nameOfParameter + 2229 " not registered in callable statement "); 2230 } 2231 } 2232 2233 /** 2234 * Verifies that an out parameter was registered on the 2235 * <code>CallableStatement</code> with the specified SQL. 2236 * @param sql the SQL statement 2237 * @param nameOfParameter the name of the parameter 2238 * @throws VerifyFailedException if verification fails 2239 */ 2240 public void verifyCallableStatementOutParameterRegistered(String sql, String nameOfParameter) 2241 { 2242 MockCallableStatement statement = getCallableStatement(sql); 2243 if(null == statement) 2244 { 2245 throw new VerifyFailedException("No callable statement " + sql + " present"); 2246 } 2247 if(!statement.isOutParameterRegistered(nameOfParameter)) 2248 { 2249 throw new VerifyFailedException("Out parameter with name " + nameOfParameter + 2250 " not registered in callable statement " + sql); 2251 } 2252 } 2253 2254 /** 2255 * Verifies that an out parameter was registered on the 2256 * <code>CallableStatement</code> with the specified index. 2257 * @param indexOfStatement the index of the <code>CallableStatement</code> 2258 * @param nameOfParameter the name of the parameter 2259 * @throws VerifyFailedException if verification fails 2260 */ 2261 public void verifyCallableStatementOutParameterRegistered(int indexOfStatement, String nameOfParameter) 2262 { 2263 MockCallableStatement statement = getCallableStatement(indexOfStatement); 2264 if(null == statement) 2265 { 2266 throw new VerifyFailedException("No callable statement with index " + indexOfStatement + " present"); 2267 } 2268 if(!statement.isOutParameterRegistered(nameOfParameter)) 2269 { 2270 throw new VerifyFailedException("Out parameter with name " + nameOfParameter + 2271 " not registered in callable statement with index " + indexOfStatement); 2272 } 2273 } 2274 2275 /** 2276 * Verifies that a <code>Savepoint</code> with the specified index 2277 * is present. The index is the number of the created <code>Savepoint</code> 2278 * starting with 0 for the first <code>Savepoint</code>. 2279 * @param index the index of the <code>Savepoint</code> 2280 */ 2281 public void verifySavepointPresent(int index) 2282 { 2283 MockSavepoint savepoint = getSavepoint(index); 2284 if(null == savepoint) 2285 { 2286 throw new VerifyFailedException("No savepoint with index " + index + " present."); 2287 } 2288 } 2289 2290 /** 2291 * Verifies that a <code>Savepoint</code> with the specified name 2292 * is present. 2293 * @param name the name of the <code>Savepoint</code> 2294 */ 2295 public void verifySavepointPresent(String name) 2296 { 2297 MockSavepoint savepoint = getSavepoint(name); 2298 if(null == savepoint) 2299 { 2300 throw new VerifyFailedException("No savepoint with name " + name + " present."); 2301 } 2302 } 2303 2304 /** 2305 * Verifies that the <code>Savepoint</code> with the specified index 2306 * is released. The index is the number of the created <code>Savepoint</code> 2307 * starting with 0 for the first <code>Savepoint</code>. 2308 * @param index the index of the <code>Savepoint</code> 2309 */ 2310 public void verifySavepointReleased(int index) 2311 { 2312 verifySavepointPresent(index); 2313 if(!getSavepoint(index).isReleased()) 2314 { 2315 throw new VerifyFailedException("Savepoint with index " + index + " not released."); 2316 } 2317 } 2318 2319 /** 2320 * Verifies that the <code>Savepoint</code> with the specified name 2321 * is released. 2322 * @param name the name of the <code>Savepoint</code> 2323 */ 2324 public void verifySavepointReleased(String name) 2325 { 2326 verifySavepointPresent(name); 2327 if(!getSavepoint(name).isReleased()) 2328 { 2329 throw new VerifyFailedException("Savepoint with name " + name + " not released."); 2330 } 2331 } 2332 2333 /** 2334 * Verifies that the <code>Savepoint</code> with the specified index 2335 * is not released. The index is the number of the created <code>Savepoint</code> 2336 * starting with 0 for the first <code>Savepoint</code>. 2337 * @param index the index of the <code>Savepoint</code> 2338 */ 2339 public void verifySavepointNotReleased(int index) 2340 { 2341 verifySavepointPresent(index); 2342 if(getSavepoint(index).isReleased()) 2343 { 2344 throw new VerifyFailedException("Savepoint with index " + index + " is released."); 2345 } 2346 } 2347 2348 /** 2349 * Verifies that the <code>Savepoint</code> with the specified name 2350 * is not released. 2351 * @param name the name of the <code>Savepoint</code> 2352 */ 2353 public void verifySavepointNotReleased(String name) 2354 { 2355 verifySavepointPresent(name); 2356 if(getSavepoint(name).isReleased()) 2357 { 2358 throw new VerifyFailedException("Savepoint with name " + name + " is released."); 2359 } 2360 } 2361 2362 /** 2363 * Verifies that the <code>Savepoint</code> with the specified index 2364 * is rolled back. The index is the number of the created <code>Savepoint</code> 2365 * starting with 0 for the first <code>Savepoint</code>. 2366 * @param index the index of the <code>Savepoint</code> 2367 */ 2368 public void verifySavepointRolledBack(int index) 2369 { 2370 verifySavepointPresent(index); 2371 if(!getSavepoint(index).isRolledBack()) 2372 { 2373 throw new VerifyFailedException("Savepoint with index " + index + " not rolled back."); 2374 } 2375 } 2376 2377 /** 2378 * Verifies that the <code>Savepoint</code> with the specified name 2379 * is rolled back. 2380 * @param name the name of the <code>Savepoint</code> 2381 */ 2382 public void verifySavepointRolledBack(String name) 2383 { 2384 verifySavepointPresent(name); 2385 if(!getSavepoint(name).isRolledBack()) 2386 { 2387 throw new VerifyFailedException("Savepoint with name " + name + " not rolled back."); 2388 } 2389 } 2390 2391 /** 2392 * Verifies that the <code>Savepoint</code> with the specified index 2393 * is not rolled back. The index is the number of the created <code>Savepoint</code> 2394 * starting with 0 for the first <code>Savepoint</code>. 2395 * @param index the index of the <code>Savepoint</code> 2396 */ 2397 public void verifySavepointNotRolledBack(int index) 2398 { 2399 verifySavepointPresent(index); 2400 if(getSavepoint(index).isRolledBack()) 2401 { 2402 throw new VerifyFailedException("Savepoint with index " + index + " is rolled back."); 2403 } 2404 } 2405 2406 /** 2407 * Verifies that the <code>Savepoint</code> with the specified name 2408 * is not rolled back. 2409 * @param name the name of the <code>Savepoint</code> 2410 */ 2411 public void verifySavepointNotRolledBack(String name) 2412 { 2413 verifySavepointPresent(name); 2414 if(getSavepoint(name).isRolledBack()) 2415 { 2416 throw new VerifyFailedException("Savepoint with name " + name + " is rolled back."); 2417 } 2418 } 2419 2420 /** 2421 * @deprecated use {@link #verifySavepointRolledBack(int)} 2422 */ 2423 public void verifySavepointRollbacked(int index) 2424 { 2425 verifySavepointRolledBack(index); 2426 } 2427 2428 /** 2429 * @deprecated use {@link #verifySavepointRolledBack(String)} 2430 */ 2431 public void verifySavepointRollbacked(String name) 2432 { 2433 verifySavepointRolledBack(name); 2434 } 2435 2436 /** 2437 * @deprecated use {@link #verifySavepointNotRolledBack(int)} 2438 */ 2439 public void verifySavepointNotRollbacked(int index) 2440 { 2441 verifySavepointNotRolledBack(index); 2442 } 2443 2444 /** 2445 * @deprecated use {@link #verifySavepointNotRolledBack(String)} 2446 */ 2447 public void verifySavepointNotRollbacked(String name) 2448 { 2449 verifySavepointNotRolledBack(name); 2450 } 2451 }