| 1 | 
    
            
    
     | 
    
      package org.codehaus.mojo.sql;     | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
           | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
           | 
  
            
  
    | 6 | 
    
            
    
     | 
    
           | 
  
            
  
    | 7 | 
    
            
    
     | 
    
           | 
  
            
  
    | 8 | 
    
            
    
     | 
    
           | 
  
            
  
    | 9 | 
    
            
    
     | 
    
           | 
  
            
  
    | 10 | 
    
            
    
     | 
    
           | 
  
            
  
    | 11 | 
    
            
    
     | 
    
           | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
            
  
    | 13 | 
    
            
    
     | 
    
           | 
  
            
  
    | 14 | 
    
            
    
     | 
    
           | 
  
            
  
    | 15 | 
    
            
    
     | 
    
           | 
  
            
  
    | 16 | 
    
            
    
     | 
    
           | 
  
            
  
    | 17 | 
    
            
    
     | 
    
           | 
  
            
  
    | 18 | 
    
            
    
     | 
    
           | 
  
            
  
    | 19 | 
    
            
    
     | 
    
           | 
  
            
  
    | 20 | 
    
            
    
     | 
    
           | 
  
            
  
    | 21 | 
    
            
    
     | 
    
           | 
  
            
  
    | 22 | 
    
            
    
     | 
    
      import junit.framework.TestCase;     | 
  
            
  
    | 23 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 30 (30) | 
           Complexity: 6 | 
           Complexity Density: 0.25 | 
                        
            
        | 
    
  
  
    | 24 | 
    
            
    
     | 
    
      public class SqlSplitterTest extends TestCase {     | 
  
            
  
    | 25 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 16 (16) | 
           Complexity: 1 | 
           Complexity Density: 0.06 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 26 | 
    
           0
    
     | 
    
           public void testContainsSqlString() throws Exception {...     | 
  
            
  
    | 27 | 
    
           0
    
     | 
    
              containsNot("");     | 
  
            
  
    | 28 | 
    
           0
    
     | 
    
              containsNot(" ");     | 
  
            
  
    | 29 | 
    
           0
    
     | 
    
              containsNot("  \t  ");     | 
  
            
  
    | 30 | 
    
            
    
     | 
    
           | 
  
            
  
    | 31 | 
    
           0
    
     | 
    
              contains(";", 1);     | 
  
            
  
    | 32 | 
    
           0
    
     | 
    
              contains("SELECT * from myTable;", 22);     | 
  
            
  
    | 33 | 
    
            
    
     | 
    
           | 
  
            
  
    | 34 | 
    
           0
    
     | 
    
              contains("SELECT * from myTable; -- with sl comment", 22);     | 
  
            
  
    | 35 | 
    
           0
    
     | 
    
              contains("SELECT * from myTable; /* with part comment */", 22);     | 
  
            
  
    | 36 | 
    
            
    
     | 
    
           | 
  
            
  
    | 37 | 
    
           0
    
     | 
    
              contains("SELECT * from myTable /* with part comment inside*/  ; ", 54);     | 
  
            
  
    | 38 | 
    
            
    
     | 
    
           | 
  
            
  
    | 39 | 
    
           0
    
     | 
    
              contains("SELECT * from myTable /* with ; semicolon*/  ; ", 46);     | 
  
            
  
    | 40 | 
    
            
    
     | 
    
           | 
  
            
  
    | 41 | 
    
           0
    
     | 
    
              contains("INSERT INTO testTable (thevalue) VALUES ('value  !'); -- comment at the end", 53);     | 
  
            
  
    | 42 | 
    
            
    
     | 
    
           | 
  
            
  
    | 43 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 44 | 
    
           0
    
     | 
    
              contains("INSERT INTO testTable (thevalue) VALUES ('value \"  !');", 55);     | 
  
            
  
    | 45 | 
    
            
    
     | 
    
           | 
  
            
  
    | 46 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 47 | 
    
           0
    
     | 
    
              contains("INSERT INTO testTable (thevalue) VALUES (\"value '  !\");", 55);     | 
  
            
  
    | 48 | 
    
            
    
     | 
    
           | 
  
            
  
    | 49 | 
    
           0
    
     | 
    
              contains("INSERT INTO testTable (thevalue) VALUES (\"value --  \");", 55);     | 
  
            
  
    | 50 | 
    
           0
    
     | 
    
              contains("INSERT INTO testTable (thevalue) VALUES ('value --  ');", 55);     | 
  
            
  
    | 51 | 
    
            
    
     | 
    
           | 
  
            
  
    | 52 | 
    
           0
    
     | 
    
              containsNot("SELECT * from myTable where value = ';' AND -- semicolon is quoted!");     | 
  
            
  
    | 53 | 
    
            
    
     | 
    
           | 
  
            
  
    | 54 | 
    
           0
    
     | 
    
              contains("INSERT INTO testTable (thevalue) VALUES (' text '' other ');", 60);     | 
  
            
  
    | 55 | 
    
            
    
     | 
    
           | 
  
            
  
    | 56 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 57 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 4 (4) | 
           Complexity: 1 | 
           Complexity Density: 0.25 | 
                            4
   -
 | 
                        
            
        | 
    
  
  
    | 58 | 
    
           0
    
     | 
    
           public void testMsSQLStrings() throws Exception {...     | 
  
            
  
    | 59 | 
    
           0
    
     | 
    
              String del = "GO";     | 
  
            
  
    | 60 | 
    
            
    
     | 
    
           | 
  
            
  
    | 61 | 
    
           0
    
     | 
    
              containsNot("SELECT COUNT(*) FROM Logs", del);     | 
  
            
  
    | 62 | 
    
           0
    
     | 
    
              containsNot("SELECT * FROM TPersons", del);     | 
  
            
  
    | 63 | 
    
           0
    
     | 
    
              contains("GO", del, 2);     | 
  
            
  
    | 64 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 65 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 66 | 
    
           0
    
     | 
    
           private void contains(String sql, int expectedIndex) throws Exception {...     | 
  
            
  
    | 67 | 
    
           0
    
     | 
    
              contains(sql, ";", expectedIndex);     | 
  
            
  
    | 68 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 69 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 70 | 
    
           0
    
     | 
    
           private void containsNot(String sql) throws Exception {...     | 
  
            
  
    | 71 | 
    
           0
    
     | 
    
              containsNot(sql, ";");     | 
  
            
  
    | 72 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 73 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 74 | 
    
           0
    
     | 
    
           private void contains(String sql, String delimiter, int expectedIndex) throws Exception {...     | 
  
            
  
    | 75 | 
    
           0
    
     | 
    
              assertEquals(sql, SqlSplitter.containsSqlEnd(sql, delimiter), expectedIndex);     | 
  
            
  
    | 76 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 77 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 78 | 
    
           0
    
     | 
    
           private void containsNot(String sql, String delimiter) throws Exception {...     | 
  
            
  
    | 79 | 
    
           0
    
     | 
    
              assertTrue(sql, SqlSplitter.containsSqlEnd(sql, delimiter) == SqlSplitter.NO_END);     | 
  
            
  
    | 80 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 81 | 
    
            
    
     | 
    
      }     |