@Test
 public void testGetResultSet() {
   MockResultSet result = new MockResultSet("id");
   statementHandler.prepareResultSet("select column from table", result);
   statementHandler.prepareResultSet("select .*", result);
   assertSame(result, statementHandler.getResultSet("select column from table"));
   assertNull(statementHandler.getResultSet("select xyz from table"));
   statementHandler.setUseRegularExpressions(true);
   assertSame(result, statementHandler.getResultSet("select column from table"));
   assertSame(result, statementHandler.getResultSet("SELECT xyz from table"));
   statementHandler.setCaseSensitive(true);
   assertNull(statementHandler.getResultSet("SELECT xyz from table"));
   MockResultSet result0 = new MockResultSet("id0");
   MockResultSet result1 = new MockResultSet("id1");
   MockResultSet[] results = new MockResultSet[] {result0, result1};
   statementHandler.clearResultSets();
   statementHandler.prepareResultSets("select abc", results);
   assertSame(result0, statementHandler.getResultSet("select abc"));
 }
 @Test
 public void testMakeStatCumulWithoutExistingData() throws Exception {
   MockConnection connexion = factory.getMockConnection();
   StatementResultSetHandler statementHandler = connexion.getStatementResultSetHandler();
   statementHandler.setExactMatch(true);
   MockResultSet result = statementHandler.createResultSet();
   result.addColumn("dateStat", new Object[] {"2011-04-17"});
   result.addColumn("fileDir", new Object[] {"/var/data/silverpeas/kmelia36"});
   result.addColumn("sizeDir", new Object[] {543L});
   statementHandler.prepareResultSet("SELECT * FROM SB_Stat_SizeDir", result);
   MockResultSet cumulResult = statementHandler.createResultSet();
   statementHandler.prepareResultSet(
       "SELECT dateStat,fileDir,sizeDir FROM SB_Stat_SizeDirCumul "
           + "WHERE dateStat='2011-04-01' AND fileDir='/var/data/silverpeas/kmelia36'",
       cumulResult);
   SilverStatisticsManagerDAO.makeStatCumul(connexion, typeofStat, config);
   module.verifyAllStatementsClosed();
   List<?> statements = module.getExecutedSQLStatements();
   assertNotNull(statements);
   assertThat(statements.size(), is(3));
   List<?> preparedStatements = module.getPreparedStatements();
   assertNotNull(preparedStatements);
   assertThat(preparedStatements, hasSize(2));
   MockPreparedStatement pstmt = module.getPreparedStatement(0);
   assertThat(
       pstmt.getSQL(),
       is(
           "UPDATE SB_Stat_SizeDirCumul SET sizeDir=?  WHERE "
               + "dateStat='2011-04-01' AND fileDir='/var/data/silverpeas/kmelia36'"));
   Map parameters = pstmt.getParameterMap();
   assertThat(parameters.size(), is(0));
   pstmt = module.getPreparedStatement(1);
   assertThat(
       pstmt.getSQL(),
       is("INSERT INTO SB_Stat_SizeDirCumul(dateStat,fileDir,sizeDir) " + "VALUES(?,?,?)"));
   parameters = pstmt.getParameterMap();
   assertThat(parameters.size(), is(3));
   assertThat((String) parameters.get(1), is("2011-04-01"));
   assertThat((String) parameters.get(2), is("/var/data/silverpeas/kmelia36"));
   assertThat((Long) parameters.get(3), is(543L));
 }
 @Test
 public void testHasMultipleResultSets() {
   MockResultSet result0 = new MockResultSet("id0");
   MockResultSet result1 = new MockResultSet("id1");
   statementHandler.prepareResultSets(
       "select column from table", new MockResultSet[] {result0, result1});
   statementHandler.prepareResultSets("select column from abc", new MockResultSet[] {result1});
   statementHandler.prepareResultSet("select .*", result0);
   assertTrue(statementHandler.hasMultipleResultSets("select column from table"));
   assertTrue(statementHandler.hasMultipleResultSets("select column from abc"));
   assertFalse(statementHandler.hasMultipleResultSets("select .*"));
   assertFalse(statementHandler.hasMultipleResultSets("do nothing"));
 }
 @Test
 public void testGetResultSets() {
   MockResultSet result0 = new MockResultSet("id0");
   MockResultSet result1 = new MockResultSet("id1");
   MockResultSet[] results = new MockResultSet[] {result0, result1};
   statementHandler.prepareResultSets("select column from table", results);
   statementHandler.prepareResultSet("select .*", result0);
   MockResultSet[] returnedResults = statementHandler.getResultSets("select column from table");
   assertNotSame(returnedResults, results);
   assertEquals(2, returnedResults.length);
   assertSame(result0, returnedResults[0]);
   assertSame(result1, returnedResults[1]);
   assertNull(statementHandler.getResultSet("select xyz from table"));
   returnedResults = statementHandler.getResultSets("select .*");
   assertEquals(1, returnedResults.length);
   assertSame(result0, returnedResults[0]);
 }
 @Test
 public void testClearMethods() {
   statementHandler.prepareResultSet("select", new MockResultSet("id"));
   statementHandler.prepareUpdateCount("select", 3);
   statementHandler.prepareThrowsSQLException("select");
   statementHandler.prepareReturnsResultSet("select", true);
   statementHandler.prepareGeneratedKeys("select", new MockResultSet("id"));
   statementHandler.clearResultSets();
   statementHandler.clearUpdateCounts();
   statementHandler.clearThrowsSQLException();
   statementHandler.clearReturnsResultSet();
   statementHandler.clearGeneratedKeys();
   assertNull(statementHandler.getResultSet("select"));
   assertNull(statementHandler.getUpdateCount("select"));
   assertFalse(statementHandler.getThrowsSQLException("select"));
   assertNull(statementHandler.getReturnsResultSet("select"));
   assertNull(statementHandler.getGeneratedKeys("select"));
 }
 @Test
 public void testPreparedSQLOrdered() {
   MockResultSet result1 = new MockResultSet("id1");
   MockResultSet result2 = new MockResultSet("id2");
   statementHandler.prepareResultSet("select", result1);
   statementHandler.prepareResultSet("SelecT", result2);
   statementHandler.prepareUpdateCount("SelecT", 3);
   statementHandler.prepareUpdateCount("select2", 2);
   statementHandler.prepareReturnsResultSet("select", false);
   statementHandler.prepareReturnsResultSet("selecT", true);
   statementHandler.prepareGeneratedKeys("seLECT", result1);
   statementHandler.prepareGeneratedKeys("select", result2);
   assertSame(result2, statementHandler.getResultSet("select"));
   assertSame(result2, statementHandler.getResultSets("select")[0]);
   assertEquals(new Integer(3), statementHandler.getUpdateCount("SELECT"));
   assertEquals(new Integer(3), statementHandler.getUpdateCounts("selecT")[0]);
   assertTrue(statementHandler.getReturnsResultSet("select").booleanValue());
   assertSame(result1, statementHandler.getGeneratedKeys("select"));
 }