Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3ef5beb

Browse files
committed
Attached is a patch that fixes DatabaseMetaDataTest in the JDBC
driver's test suite. With previous patches applied, this reducesthe number of failures of the test suite from 6 to 4. The patchfixes the test case itself, rather than the driver.Details:1) The driver correctly provided DatabaseMetaData about the sortorder of NULLs. This was confirmed by Peter Eisentraut onpgsql-hackers. I fixed the test to accept/require the currentbehaviour, and made it dependent on the backend version. SeenullsAreSortedAtStart(), nullsAreSortedAtEnd(),nullsAreSortedHigh() and nullsAreSortedLow().2) DatabaseMetaData.supportsOrderByUnrelated() correctlyreturned true (an ORDER BY clause can contain columns that arenot in the SELECT clause), but the test case required false.Fixed that.3) Replaced deprecated assert() of junit.framework.TestCase byassertEquals(), assertTrue() and assertNotNull(). This isbecause assert will be a new keyword in Java 1.4.4) Replaced assert(message,false) by the more elegantfail(message).Regards,Ren? Pijlman <rene@lab.applinet.nl>
1 parentec0ad67 commit3ef5beb

File tree

1 file changed

+86
-78
lines changed

1 file changed

+86
-78
lines changed

‎src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java

Lines changed: 86 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* PS: Do you know how difficult it is to type on a train? ;-)
1111
*
12-
* $Id: DatabaseMetaDataTest.java,v 1.1 2001/02/13 16:39:05 peter Exp $
12+
* $Id: DatabaseMetaDataTest.java,v 1.2 2001/09/10 15:07:58 momjian Exp $
1313
*/
1414

1515
publicclassDatabaseMetaDataTestextendsTestCase {
@@ -29,11 +29,11 @@ public void testGetMetaData() {
2929
Connectioncon =JDBC2Tests.openDB();
3030

3131
DatabaseMetaDatadbmd =con.getMetaData();
32-
assert(dbmd!=null);
32+
assertNotNull(dbmd);
3333

3434
JDBC2Tests.closeDB(con);
3535
}catch(SQLExceptionex) {
36-
assert(ex.getMessage(),false);
36+
fail(ex.getMessage());
3737
}
3838
}
3939

@@ -45,32 +45,32 @@ public void testCapabilities() {
4545
Connectioncon =JDBC2Tests.openDB();
4646

4747
DatabaseMetaDatadbmd =con.getMetaData();
48-
assert(dbmd!=null);
48+
assertNotNull(dbmd);
4949

50-
assert(dbmd.allProceduresAreCallable()==true);
51-
assert(dbmd.allTablesAreSelectable()==true);// not true all the time
50+
assertTrue(dbmd.allProceduresAreCallable());
51+
assertTrue(dbmd.allTablesAreSelectable());// not true all the time
5252

5353
// This should always be false for postgresql (at least for 7.x)
54-
assert(!dbmd.isReadOnly());
54+
assertTrue(!dbmd.isReadOnly());
5555

5656
// does the backend support this yet? The protocol does...
57-
assert(!dbmd.supportsMultipleResultSets());
57+
assertTrue(!dbmd.supportsMultipleResultSets());
5858

5959
// yes, as multiple backends can have transactions open
60-
assert(dbmd.supportsMultipleTransactions());
60+
assertTrue(dbmd.supportsMultipleTransactions());
6161

62-
assert(dbmd.supportsMinimumSQLGrammar());
63-
assert(!dbmd.supportsCoreSQLGrammar());
64-
assert(!dbmd.supportsExtendedSQLGrammar());
65-
assert(!dbmd.supportsANSI92EntryLevelSQL());
66-
assert(!dbmd.supportsANSI92IntermediateSQL());
67-
assert(!dbmd.supportsANSI92FullSQL());
62+
assertTrue(dbmd.supportsMinimumSQLGrammar());
63+
assertTrue(!dbmd.supportsCoreSQLGrammar());
64+
assertTrue(!dbmd.supportsExtendedSQLGrammar());
65+
assertTrue(!dbmd.supportsANSI92EntryLevelSQL());
66+
assertTrue(!dbmd.supportsANSI92IntermediateSQL());
67+
assertTrue(!dbmd.supportsANSI92FullSQL());
6868

69-
assert(!dbmd.supportsIntegrityEnhancementFacility());
69+
assertTrue(!dbmd.supportsIntegrityEnhancementFacility());
7070

7171
JDBC2Tests.closeDB(con);
7272
}catch(SQLExceptionex) {
73-
assert(ex.getMessage(),false);
73+
fail(ex.getMessage());
7474
}
7575
}
7676

@@ -80,15 +80,15 @@ public void testJoins() {
8080
Connectioncon =JDBC2Tests.openDB();
8181

8282
DatabaseMetaDatadbmd =con.getMetaData();
83-
assert(dbmd!=null);
83+
assertNotNull(dbmd);
8484

85-
assert(dbmd.supportsOuterJoins());
86-
assert(dbmd.supportsFullOuterJoins());
87-
assert(dbmd.supportsLimitedOuterJoins());
85+
assertTrue(dbmd.supportsOuterJoins());
86+
assertTrue(dbmd.supportsFullOuterJoins());
87+
assertTrue(dbmd.supportsLimitedOuterJoins());
8888

8989
JDBC2Tests.closeDB(con);
9090
}catch(SQLExceptionex) {
91-
assert(ex.getMessage(),false);
91+
fail(ex.getMessage());
9292
}
9393
}
9494

@@ -97,14 +97,14 @@ public void testCursors() {
9797
Connectioncon =JDBC2Tests.openDB();
9898

9999
DatabaseMetaDatadbmd =con.getMetaData();
100-
assert(dbmd!=null);
100+
assertNotNull(dbmd);
101101

102-
assert(!dbmd.supportsPositionedDelete());
103-
assert(!dbmd.supportsPositionedUpdate());
102+
assertTrue(!dbmd.supportsPositionedDelete());
103+
assertTrue(!dbmd.supportsPositionedUpdate());
104104

105105
JDBC2Tests.closeDB(con);
106106
}catch(SQLExceptionex) {
107-
assert(ex.getMessage(),false);
107+
fail(ex.getMessage());
108108
}
109109
}
110110

@@ -113,21 +113,27 @@ public void testNulls() {
113113
Connectioncon =JDBC2Tests.openDB();
114114

115115
DatabaseMetaDatadbmd =con.getMetaData();
116-
assert(dbmd!=null);
116+
assertNotNull(dbmd);
117117

118-
// these need double checking
119-
assert(!dbmd.nullsAreSortedAtStart());
120-
assert(dbmd.nullsAreSortedAtEnd());
121-
assert(!dbmd.nullsAreSortedHigh());
122-
assert(!dbmd.nullsAreSortedLow());
118+
// We need to type cast the connection to get access to the
119+
// PostgreSQL-specific method haveMinimumServerVersion().
120+
// This is not available through the java.sql.Connection interface.
121+
assertTrue(coninstanceoforg.postgresql.Connection );
123122

124-
assert(dbmd.nullPlusNonNullIsNull());
123+
assertTrue(!dbmd.nullsAreSortedAtStart());
124+
assertTrue(dbmd.nullsAreSortedAtEnd() !=
125+
((org.postgresql.Connection)con).haveMinimumServerVersion("7.2"));
126+
assertTrue(dbmd.nullsAreSortedHigh() ==
127+
((org.postgresql.Connection)con).haveMinimumServerVersion("7.2"));
128+
assertTrue(!dbmd.nullsAreSortedLow());
125129

126-
assert(dbmd.supportsNonNullableColumns());
130+
assertTrue(dbmd.nullPlusNonNullIsNull());
131+
132+
assertTrue(dbmd.supportsNonNullableColumns());
127133

128134
JDBC2Tests.closeDB(con);
129135
}catch(SQLExceptionex) {
130-
assert(ex.getMessage(),false);
136+
fail(ex.getMessage());
131137
}
132138
}
133139

@@ -136,14 +142,14 @@ public void testLocalFiles() {
136142
Connectioncon =JDBC2Tests.openDB();
137143

138144
DatabaseMetaDatadbmd =con.getMetaData();
139-
assert(dbmd!=null);
145+
assertNotNull(dbmd);
140146

141-
assert(!dbmd.usesLocalFilePerTable());
142-
assert(!dbmd.usesLocalFiles());
147+
assertTrue(!dbmd.usesLocalFilePerTable());
148+
assertTrue(!dbmd.usesLocalFiles());
143149

144150
JDBC2Tests.closeDB(con);
145151
}catch(SQLExceptionex) {
146-
assert(ex.getMessage(),false);
152+
fail(ex.getMessage());
147153
}
148154
}
149155

@@ -152,23 +158,23 @@ public void testIdentifiers() {
152158
Connectioncon =JDBC2Tests.openDB();
153159

154160
DatabaseMetaDatadbmd =con.getMetaData();
155-
assert(dbmd!=null);
161+
assertNotNull(dbmd);
156162

157-
assert(!dbmd.supportsMixedCaseIdentifiers());// always false
158-
assert(dbmd.supportsMixedCaseQuotedIdentifiers());// always true
163+
assertTrue(!dbmd.supportsMixedCaseIdentifiers());// always false
164+
assertTrue(dbmd.supportsMixedCaseQuotedIdentifiers());// always true
159165

160-
assert(!dbmd.storesUpperCaseIdentifiers());// always false
161-
assert(dbmd.storesLowerCaseIdentifiers());// always true
162-
assert(!dbmd.storesUpperCaseQuotedIdentifiers());// always false
163-
assert(!dbmd.storesLowerCaseQuotedIdentifiers());// always false
164-
assert(!dbmd.storesMixedCaseQuotedIdentifiers());// always false
166+
assertTrue(!dbmd.storesUpperCaseIdentifiers());// always false
167+
assertTrue(dbmd.storesLowerCaseIdentifiers());// always true
168+
assertTrue(!dbmd.storesUpperCaseQuotedIdentifiers());// always false
169+
assertTrue(!dbmd.storesLowerCaseQuotedIdentifiers());// always false
170+
assertTrue(!dbmd.storesMixedCaseQuotedIdentifiers());// always false
165171

166-
assert(dbmd.getIdentifierQuoteString().equals("\""));
172+
assertTrue(dbmd.getIdentifierQuoteString().equals("\""));
167173

168174

169175
JDBC2Tests.closeDB(con);
170176
}catch(SQLExceptionex) {
171-
assert(ex.getMessage(),false);
177+
fail(ex.getMessage());
172178
}
173179
}
174180

@@ -177,17 +183,17 @@ public void testTables() {
177183
Connectioncon =JDBC2Tests.openDB();
178184

179185
DatabaseMetaDatadbmd =con.getMetaData();
180-
assert(dbmd!=null);
186+
assertNotNull(dbmd);
181187

182188
// we can add columns
183-
assert(dbmd.supportsAlterTableWithAddColumn());
189+
assertTrue(dbmd.supportsAlterTableWithAddColumn());
184190

185191
// we can't drop columns (yet)
186-
assert(!dbmd.supportsAlterTableWithDropColumn());
192+
assertTrue(!dbmd.supportsAlterTableWithDropColumn());
187193

188194
JDBC2Tests.closeDB(con);
189195
}catch(SQLExceptionex) {
190-
assert(ex.getMessage(),false);
196+
fail(ex.getMessage());
191197
}
192198
}
193199

@@ -196,23 +202,25 @@ public void testSelect() {
196202
Connectioncon =JDBC2Tests.openDB();
197203

198204
DatabaseMetaDatadbmd =con.getMetaData();
199-
assert(dbmd!=null);
205+
assertNotNull(dbmd);
200206

201207
// yes we can?: SELECT col a FROM a;
202-
assert(dbmd.supportsColumnAliasing());
208+
assertTrue(dbmd.supportsColumnAliasing());
203209

204210
// yes we can have expressions in ORDERBY
205-
assert(dbmd.supportsExpressionsInOrderBy());
211+
assertTrue(dbmd.supportsExpressionsInOrderBy());
206212

207-
assert(!dbmd.supportsOrderByUnrelated());
213+
// Yes, an ORDER BY clause can contain columns that are not in the
214+
// SELECT clause.
215+
assertTrue(dbmd.supportsOrderByUnrelated());
208216

209-
assert(dbmd.supportsGroupBy());
210-
assert(dbmd.supportsGroupByUnrelated());
211-
assert(dbmd.supportsGroupByBeyondSelect());// needs checking
217+
assertTrue(dbmd.supportsGroupBy());
218+
assertTrue(dbmd.supportsGroupByUnrelated());
219+
assertTrue(dbmd.supportsGroupByBeyondSelect());// needs checking
212220

213221
JDBC2Tests.closeDB(con);
214222
}catch(SQLExceptionex) {
215-
assert(ex.getMessage(),false);
223+
fail(ex.getMessage());
216224
}
217225
}
218226

@@ -221,53 +229,53 @@ public void testDBParams() {
221229
Connectioncon =JDBC2Tests.openDB();
222230

223231
DatabaseMetaDatadbmd =con.getMetaData();
224-
assert(dbmd!=null);
232+
assertNotNull(dbmd);
225233

226-
assert(dbmd.getURL().equals(JDBC2Tests.getURL()));
227-
assert(dbmd.getUserName().equals(JDBC2Tests.getUser()));
234+
assertTrue(dbmd.getURL().equals(JDBC2Tests.getURL()));
235+
assertTrue(dbmd.getUserName().equals(JDBC2Tests.getUser()));
228236

229237
JDBC2Tests.closeDB(con);
230238
}catch(SQLExceptionex) {
231-
assert(ex.getMessage(),false);
239+
fail(ex.getMessage());
232240
}
233241
}
234242

235243
publicvoidtestDbProductDetails() {
236244
try {
237245
Connectioncon =JDBC2Tests.openDB();
238-
assert(coninstanceoforg.postgresql.Connection);
246+
assertTrue(coninstanceoforg.postgresql.Connection);
239247
org.postgresql.Connectionpc = (org.postgresql.Connection)con;
240248

241249
DatabaseMetaDatadbmd =con.getMetaData();
242-
assert(dbmd!=null);
250+
assertNotNull(dbmd);
243251

244-
assert(dbmd.getDatabaseProductName().equals("PostgreSQL"));
245-
assert(dbmd.getDatabaseProductVersion().startsWith(Integer.toString(pc.this_driver.getMajorVersion())+"."+Integer.toString(pc.this_driver.getMinorVersion())));
246-
assert(dbmd.getDriverName().equals("PostgreSQL Native Driver"));
252+
assertTrue(dbmd.getDatabaseProductName().equals("PostgreSQL"));
253+
assertTrue(dbmd.getDatabaseProductVersion().startsWith(Integer.toString(pc.this_driver.getMajorVersion())+"."+Integer.toString(pc.this_driver.getMinorVersion())));
254+
assertTrue(dbmd.getDriverName().equals("PostgreSQL Native Driver"));
247255

248256
JDBC2Tests.closeDB(con);
249257
}catch(SQLExceptionex) {
250-
assert(ex.getMessage(),false);
258+
fail(ex.getMessage());
251259
}
252260
}
253261

254262
publicvoidtestDriverVersioning() {
255263
try {
256264
Connectioncon =JDBC2Tests.openDB();
257-
assert(coninstanceoforg.postgresql.Connection);
265+
assertTrue(coninstanceoforg.postgresql.Connection);
258266
org.postgresql.Connectionpc = (org.postgresql.Connection)con;
259267

260268
DatabaseMetaDatadbmd =con.getMetaData();
261-
assert(dbmd!=null);
269+
assertNotNull(dbmd);
262270

263-
assert(dbmd.getDriverVersion().equals(pc.this_driver.getVersion()));
264-
assert(dbmd.getDriverMajorVersion()==pc.this_driver.getMajorVersion());
265-
assert(dbmd.getDriverMinorVersion()==pc.this_driver.getMinorVersion());
271+
assertTrue(dbmd.getDriverVersion().equals(pc.this_driver.getVersion()));
272+
assertTrue(dbmd.getDriverMajorVersion()==pc.this_driver.getMajorVersion());
273+
assertTrue(dbmd.getDriverMinorVersion()==pc.this_driver.getMinorVersion());
266274

267275

268276
JDBC2Tests.closeDB(con);
269277
}catch(SQLExceptionex) {
270-
assert(ex.getMessage(),false);
278+
fail(ex.getMessage());
271279
}
272280
}
273-
}
281+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp