SQLFormatterTest.java from BIRT at Krugle
Show SQLFormatterTest.java syntax highlighted
package org.eclipse.birt.report.data.oda.jdbc;
import junit.framework.TestCase;
/**
* Test case for SQLFormatter
*
*/
public class SQLFormatterTest extends TestCase
{
public void testSQLFormatter( )
{
String[] testStr = {
"select * from tableA where tableA.a = \"aaa\"",
"/*This is a query*/ \rselect * from tableA",
"select * from tableA \r\n--This is a query",
"/*This is a query,/n and this query has comments*/\n"
+ "select * from table -- get the table's resultset\n"
+ "where table.a =\"one\"--query condition",
"/*This is a query, and this query has comments*/\n"
+ "\"/*I am not a comment in quote*/\"\n"
+ "\"--I am also not a comment in quote*/\"\n"
+ "select * from table",
"select *,'/*This is query /n a*/' from table",
"/*This is a query/\n select * from table",
"-This is a query- select * from table",
"select * from multi-lang",
"select amount/100.0 from table",
"select amount/**//100.0 from table"
};
assertTrue( SQLFormatter.formatQueryText( testStr[0] )
.equals( testStr[0] ) );
assertTrue( SQLFormatter.formatQueryText( testStr[1] )
.equals( " \rselect * from tableA" ) );
assertTrue( SQLFormatter.formatQueryText( testStr[2] )
.equals( "select * from tableA \r " ) );
assertTrue( SQLFormatter.formatQueryText( testStr[3] )
.equals( " select * from table where table.a =\"one\"" ) );
assertTrue( SQLFormatter.formatQueryText( testStr[4] )
.equals( " \"/*I am not a comment in quote*/\" \"--I am also not a comment in quote*/\" select * from table" ) );
assertTrue( SQLFormatter.formatQueryText( testStr[5] )
.equals( testStr[5] ) );
assertTrue( SQLFormatter.formatQueryText( testStr[6] )
.equals( testStr[6] ) );
assertTrue( SQLFormatter.formatQueryText( testStr[7] )
.equals( testStr[7] ) );
assertTrue( SQLFormatter.formatQueryText( testStr[8] )
.equals( testStr[8] ) );
assertTrue( SQLFormatter.formatQueryText( testStr[9] )
.equals( testStr[9] ) );
assertTrue( SQLFormatter.formatQueryText( testStr[10] )
.equals( "select amount/100.0 from table" ) );
}
}
See more files for this project here