1 25 package testsuite.simple; 26 27 import testsuite.BaseTestCase; 28 29 34 public class EscapeProcessingTest extends BaseTestCase { 35 38 44 public EscapeProcessingTest(String name) { 45 super(name); 46 } 47 48 51 57 public void testEscapeProcessing() throws Exception { 58 String results = "select dayname (abs(now())), -- Today \n" 59 + " '1997-05-24', -- a date \n" 60 + " '10:30:29', -- a time \n" 61 + " '1997-05-24 10:30:29', -- a timestamp \n" 62 + " '{string data with { or } will not be altered' \n" 63 + "-- Also note that you can safely include { and } in comments"; 64 65 String exSql = "select {fn dayname ({fn abs({fn now()})})}, -- Today \n" 66 + " {d '1997-05-24'}, -- a date \n" 67 + " {t '10:30:29' }, -- a time \n" 68 + " {ts '1997-05-24 10:30:29.123'}, -- a timestamp \n" 69 + " '{string data with { or } will not be altered' \n" 70 + "-- Also note that you can safely include { and } in comments"; 71 72 String escapedSql = this.conn.nativeSQL(exSql); 73 74 assertTrue(results.equals(escapedSql)); 75 76 } 77 78 83 public static void main(String [] args) { 84 junit.textui.TestRunner.run(EscapeProcessingTest.class); 85 } 86 87 93 public void testConvertEscape() throws Exception { 94 assertEquals(conn.nativeSQL("{fn convert(abcd, SQL_INTEGER)}"), conn 95 .nativeSQL("{fn convert(abcd, INTEGER)}")); 96 } 97 } 98 | Popular Tags |