Clover Coverage Report - SQL Maven Plugin 1.5
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
24   89   6   4
0   47   0.25   6
6     1  
1    
 
  SqlSplitterTest       Line # 24 24 0% 6 30 0% 0.0
 
No Tests
 
1    package org.codehaus.mojo.sql;
2   
3    /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements. See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership. The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10    * with the License. You may obtain a copy of the License at
11    *
12    * http://www.apache.org/licenses/LICENSE-2.0
13    *
14    * Unless required by applicable law or agreed to in writing,
15    * software distributed under the License is distributed on an
16    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17    * KIND, either express or implied. See the License for the
18    * specific language governing permissions and limitations
19    * under the License.
20    */
21   
22    import junit.framework.TestCase;
23   
 
24    public class SqlSplitterTest extends TestCase
25    {
26   
 
27  0 toggle public void testContainsSqlString() throws Exception
28    {
29  0 containsNot( "" );
30  0 containsNot( " " );
31  0 containsNot( " \t " );
32   
33  0 contains( ";", 1 );
34  0 contains( "SELECT * from myTable;", 22 );
35   
36  0 contains( "SELECT * from myTable; -- with sl comment", 22 );
37  0 contains( "SELECT * from myTable; /* with part comment */", 22 );
38   
39  0 contains( "SELECT * from myTable /* with part comment inside*/ ; ", 54 );
40   
41  0 contains( "SELECT * from myTable /* with ; semicolon*/ ; ", 46 );
42   
43  0 contains( "INSERT INTO testTable (thevalue) VALUES ('value !'); -- comment at the end", 53 );
44   
45    // a " inside a ' quoted text
46  0 contains( "INSERT INTO testTable (thevalue) VALUES ('value \" !');", 55 );
47   
48    // a ' inside a " quoted text
49  0 contains( "INSERT INTO testTable (thevalue) VALUES (\"value ' !\");", 55 );
50   
51  0 contains( "INSERT INTO testTable (thevalue) VALUES (\"value -- \");", 55 );
52  0 contains( "INSERT INTO testTable (thevalue) VALUES ('value -- ');", 55 );
53   
54  0 containsNot( "SELECT * from myTable where value = ';' AND -- semicolon is quoted!" );
55   
56  0 contains( "INSERT INTO testTable (thevalue) VALUES (' text '' other ');", 60 );
57   
58    }
59   
 
60  0 toggle public void testMsSQLStrings() throws Exception
61    {
62  0 String del = "GO";
63   
64  0 containsNot( "SELECT COUNT(*) FROM Logs", del );
65  0 containsNot( "SELECT * FROM TPersons", del );
66  0 contains( "GO", del, 2 );
67    }
68   
69   
 
70  0 toggle private void contains( String sql, int expectedIndex ) throws Exception
71    {
72  0 contains( sql, ";", expectedIndex );
73    }
74   
 
75  0 toggle private void containsNot( String sql ) throws Exception
76    {
77  0 containsNot( sql, ";" );
78    }
79   
 
80  0 toggle private void contains( String sql, String delimiter, int expectedIndex ) throws Exception
81    {
82  0 assertEquals( sql, SqlSplitter.containsSqlEnd( sql, delimiter ), expectedIndex);
83    }
84   
 
85  0 toggle private void containsNot( String sql, String delimiter ) throws Exception
86    {
87  0 assertTrue( sql, SqlSplitter.containsSqlEnd( sql, delimiter ) == SqlSplitter.NO_END);
88    }
89    }