KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > hajdbc > dialect > TestPostgreSQLDialect


1 /*
2  * HA-JDBC: High-Availability JDBC
3  * Copyright (c) 2004-2006 Paul Ferraro
4  *
5  * This library is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by the
7  * Free Software Foundation; either version 2.1 of the License, or (at your
8  * option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: ferraro@users.sourceforge.net
20  */

21 package net.sf.hajdbc.dialect;
22
23 import java.sql.SQLException JavaDoc;
24
25 import net.sf.hajdbc.Dialect;
26
27 import org.easymock.EasyMock;
28 import org.testng.annotations.Test;
29
30 /**
31  * @author Paul Ferraro
32  *
33  */

34 @Test
35 public class TestPostgreSQLDialect extends TestDefaultDialect
36 {
37     @Override JavaDoc
38     protected Dialect createDialect()
39     {
40         return new PostgreSQLDialect();
41     }
42
43     @Override JavaDoc
44     public void testGetLockTableSQL()
45     {
46         String JavaDoc schema = "schema";
47         String JavaDoc table = "table";
48         String JavaDoc quote = "'";
49         
50         try
51         {
52             EasyMock.expect(this.metaData.supportsSchemasInDataManipulation()).andReturn(true);
53             EasyMock.expect(this.metaData.getIdentifierQuoteString()).andReturn(quote).times(2);
54             
55             this.control.replay();
56             
57             String JavaDoc sql = this.dialect.getLockTableSQL(this.metaData, schema, table);
58             
59             this.control.verify();
60             
61             assert sql.equals("LOCK TABLE 'schema'.'table' IN EXCLUSIVE MODE") : sql;
62         }
63         catch (SQLException JavaDoc e)
64         {
65             assert false : e;
66         }
67     }
68
69     @Override JavaDoc
70     public void testGetTruncateTableSQL()
71     {
72         String JavaDoc schema = "schema";
73         String JavaDoc table = "table";
74         String JavaDoc quote = "'";
75         
76         try
77         {
78             EasyMock.expect(this.metaData.supportsSchemasInDataManipulation()).andReturn(true);
79             EasyMock.expect(this.metaData.getIdentifierQuoteString()).andReturn(quote).times(2);
80             
81             this.control.replay();
82             
83             String JavaDoc sql = this.dialect.getTruncateTableSQL(this.metaData, schema, table);
84             
85             this.control.verify();
86             
87             assert sql.equals("TRUNCATE TABLE 'schema'.'table'") : sql;
88         }
89         catch (SQLException JavaDoc e)
90         {
91             assert false : e;
92         }
93     }
94 }
95
Popular Tags