Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
1ffd044a
Commit
1ffd044a
authored
May 30, 2002
by
Dave Cramer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added imported/exported key testDatabaseMetaDataTest.java
parent
970ff81e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
7 deletions
+101
-7
src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
.../jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
+75
-6
src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java
src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java
+26
-1
No files found.
src/interfaces/jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java
View file @
1ffd044a
...
...
@@ -9,7 +9,7 @@ import java.sql.*;
*
* PS: Do you know how difficult it is to type on a train? ;-)
*
* $Id: DatabaseMetaDataTest.java,v 1.
5 2002/04/16 15:25:17
davec Exp $
* $Id: DatabaseMetaDataTest.java,v 1.
6 2002/05/30 16:26:55
davec Exp $
*/
public
class
DatabaseMetaDataTest
extends
TestCase
...
...
@@ -228,6 +228,75 @@ public class DatabaseMetaDataTest extends TestCase
}
}
public
void
testForeignKeys
()
{
try
{
Connection
con1
=
JDBC2Tests
.
openDB
();
JDBC2Tests
.
createTable
(
con1
,
"people"
,
"id int4 primary key, name text"
);
JDBC2Tests
.
createTable
(
con1
,
"policy"
,
"id int4 primary key, name text"
);
JDBC2Tests
.
createTable
(
con1
,
"users"
,
"id int4 primary key, people_id int4, policy_id int4,"
+
"CONSTRAINT people FOREIGN KEY (people_id) references people(id),"
+
"constraint policy FOREIGN KEY (policy_id) references policy(id)"
);
DatabaseMetaData
dbmd
=
con
.
getMetaData
();
assertNotNull
(
dbmd
);
ResultSet
rs
=
dbmd
.
getImportedKeys
(
null
,
""
,
"users"
);
int
j
=
0
;
for
(;
rs
.
next
();
j
++
)
{
String
pkTableName
=
rs
.
getString
(
"PKTABLE_NAME"
);
assertTrue
(
pkTableName
.
equals
(
"people"
)
||
pkTableName
.
equals
(
"policy"
)
);
String
pkColumnName
=
rs
.
getString
(
"PKCOLUMN_NAME"
);
assertTrue
(
pkColumnName
.
equals
(
"id"
)
);
String
fkTableName
=
rs
.
getString
(
"FKTABLE_NAME"
);
assertTrue
(
fkTableName
.
equals
(
"users"
)
);
String
fkColumnName
=
rs
.
getString
(
"FKCOLUMN_NAME"
);
assertTrue
(
fkColumnName
.
equals
(
"people_id"
)
||
fkColumnName
.
equals
(
"policy_id"
)
)
;
String
fkName
=
rs
.
getString
(
"FK_NAME"
);
assertTrue
(
fkName
.
equals
(
"people"
)
||
fkName
.
equals
(
"policy"
)
);
String
pkName
=
rs
.
getString
(
"PK_NAME"
);
}
assertTrue
(
j
==
2
);
rs
=
dbmd
.
getExportedKeys
(
null
,
""
,
"people"
);
// this is hacky, but it will serve the purpose
assertTrue
(
rs
.
next
()
);
for
(
int
i
=
0
;
i
<
14
;
i
++
)
{
assertTrue
(
rs
.
getString
(
"PKTABLE_NAME"
).
equals
(
"people"
)
);
assertTrue
(
rs
.
getString
(
"PKCOLUMN_NAME"
).
equals
(
"id"
)
);
assertTrue
(
rs
.
getString
(
"FKTABLE_NAME"
).
equals
(
"users"
)
);
assertTrue
(
rs
.
getString
(
"FKCOLUMN_NAME"
).
equals
(
"people_id"
)
);
assertTrue
(
rs
.
getString
(
"FK_NAME"
).
equals
(
"people"
)
);
}
JDBC2Tests
.
dropTable
(
con1
,
"users"
);
JDBC2Tests
.
dropTable
(
con1
,
"people"
);
JDBC2Tests
.
dropTable
(
con1
,
"policy"
);
}
catch
(
SQLException
ex
)
{
fail
(
ex
.
getMessage
());
}
}
public
void
testTables
()
{
try
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/MiscTest.java
View file @
1ffd044a
...
...
@@ -5,7 +5,7 @@ import junit.framework.TestCase;
import
java.sql.*
;
/*
* $Id: MiscTest.java,v 1.
4 2001/11/19 22:33:39 momjian
Exp $
* $Id: MiscTest.java,v 1.
5 2002/05/30 16:26:55 davec
Exp $
*
* Some simple tests based on problems reported by users. Hopefully these will
* help prevent previous problems from re-occuring ;-)
...
...
@@ -51,4 +51,29 @@ public class MiscTest extends TestCase
fail
(
ex
.
getMessage
());
}
}
public
void
xtestLocking
()
{
System
.
out
.
println
(
"testing lock"
);
try
{
Connection
con
=
JDBC2Tests
.
openDB
();
Connection
con2
=
JDBC2Tests
.
openDB
();
JDBC2Tests
.
createTable
(
con
,
"test_lock"
,
"name text"
);
Statement
st
=
con
.
createStatement
();
Statement
st2
=
con2
.
createStatement
();
con
.
setAutoCommit
(
false
);
st
.
execute
(
"lock table test_lock"
);
st2
.
executeUpdate
(
"insert into test_lock ( name ) values ('hello')"
);
con
.
commit
();
JDBC2Tests
.
dropTable
(
con
,
"test_lock"
);
con
.
close
();
}
catch
(
Exception
ex
)
{
fail
(
ex
.
getMessage
()
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment