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
5598cbf6
Commit
5598cbf6
authored
Jun 13, 2002
by
Dave Cramer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for newly implemented updateable result sets
parent
603c46d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
142 additions
and
3 deletions
+142
-3
src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java
src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java
+7
-3
src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
.../jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
+135
-0
No files found.
src/interfaces/jdbc/org/postgresql/test/JDBC2Tests.java
View file @
5598cbf6
...
@@ -16,7 +16,8 @@ public class JDBC2Tests extends TestSuite
...
@@ -16,7 +16,8 @@ public class JDBC2Tests extends TestSuite
*/
*/
public
static
String
getURL
()
public
static
String
getURL
()
{
{
return
System
.
getProperty
(
"database"
);
//return System.getProperty("database");
return
"test"
;
}
}
/*
/*
...
@@ -24,7 +25,8 @@ public class JDBC2Tests extends TestSuite
...
@@ -24,7 +25,8 @@ public class JDBC2Tests extends TestSuite
*/
*/
public
static
String
getUser
()
public
static
String
getUser
()
{
{
return
System
.
getProperty
(
"username"
);
return
"davec"
;
//return System.getProperty("username");
}
}
/*
/*
...
@@ -32,7 +34,8 @@ public class JDBC2Tests extends TestSuite
...
@@ -32,7 +34,8 @@ public class JDBC2Tests extends TestSuite
*/
*/
public
static
String
getPassword
()
public
static
String
getPassword
()
{
{
return
System
.
getProperty
(
"password"
);
return
null
;
//return System.getProperty("password");
}
}
/*
/*
...
@@ -226,6 +229,7 @@ public class JDBC2Tests extends TestSuite
...
@@ -226,6 +229,7 @@ public class JDBC2Tests extends TestSuite
// Fastpath/LargeObject
// Fastpath/LargeObject
suite
.
addTestSuite
(
BlobTest
.
class
);
suite
.
addTestSuite
(
BlobTest
.
class
);
suite
.
addTestSuite
(
UpdateableResultTest
.
class
);
// That's all folks
// That's all folks
return
suite
;
return
suite
;
...
...
src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
0 → 100644
View file @
5598cbf6
package
org.postgresql.test.jdbc2
;
import
java.sql.*
;
import
junit.framework.TestCase
;
import
org.postgresql.test.JDBC2Tests
;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2001</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
*/
public
class
UpdateableResultTest
extends
TestCase
{
public
UpdateableResultTest
(
String
name
)
{
super
(
name
);
}
public
void
testUpdateable
()
{
try
{
Connection
con
=
JDBC2Tests
.
openDB
();
JDBC2Tests
.
createTable
(
con
,
"updateable"
,
"id int primary key, name text, notselected text"
);
JDBC2Tests
.
createTable
(
con
,
"second"
,
"id1 int primary key, name1 text"
);
Statement
st1
=
con
.
createStatement
();
boolean
retVal
=
st1
.
execute
(
"insert into updateable ( id, name, notselected ) values (1, 'jake', 'avalue')"
);
assert
(
retVal
==
false
);
retVal
=
st1
.
execute
(
"insert into second (id1, name1) values (1, 'jake')"
);
assertTrue
(
!
retVal
);
st1
.
close
();
Statement
st
=
con
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_UPDATABLE
);
ResultSet
rs
=
st
.
executeQuery
(
"select id, name, notselected from updateable"
);
assertNotNull
(
rs
);
while
(
rs
.
next
())
{
rs
.
updateInt
(
"id"
,
2
);
rs
.
updateString
(
"name"
,
"dave"
);
rs
.
updateRow
();
assertTrue
(
rs
.
getInt
(
"id"
)
==
2
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave"
));
assertTrue
(
rs
.
getString
(
"notselected"
).
equals
(
"avalue"
)
);
rs
.
deleteRow
();
rs
.
moveToInsertRow
();
rs
.
updateInt
(
"id"
,
3
);
rs
.
updateString
(
"name"
,
"paul"
);
rs
.
insertRow
();
assertTrue
(
rs
.
getInt
(
"id"
)
==
3
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"paul"
));
assertTrue
(
rs
.
getString
(
"notselected"
)
==
null
);
}
rs
.
close
();
rs
=
st
.
executeQuery
(
"select id1, id, name, name1 from updateable, second"
);
try
{
while
(
rs
.
next
()
)
{
rs
.
updateInt
(
"id"
,
2
);
rs
.
updateString
(
"name"
,
"dave"
);
rs
.
updateRow
();
}
assertTrue
(
"should not get here, update should fail"
,
false
);
}
catch
(
SQLException
ex
){}
try
{
rs
=
st
.
executeQuery
(
"select oid,* from updateable"
);
if
(
rs
.
first
()
)
{
rs
.
updateInt
(
"id"
,
3
);
rs
.
updateString
(
"name"
,
"dave3"
);
rs
.
updateRow
();
assertTrue
(
rs
.
getInt
(
"id"
)
==
3
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave3"
));
rs
.
moveToInsertRow
();
rs
.
updateInt
(
"id"
,
4
);
rs
.
updateString
(
"name"
,
"dave4"
);
rs
.
insertRow
();
rs
.
updateInt
(
"id"
,
5
);
rs
.
updateString
(
"name"
,
"dave5"
);
rs
.
insertRow
();
rs
.
moveToCurrentRow
();
assertTrue
(
rs
.
getInt
(
"id"
)
==
3
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave3"
));
assertTrue
(
rs
.
next
()
);
assertTrue
(
rs
.
getInt
(
"id"
)
==
4
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave4"
));
assertTrue
(
rs
.
next
()
);
assertTrue
(
rs
.
getInt
(
"id"
)
==
5
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave5"
));
}
}
catch
(
SQLException
ex
)
{
fail
(
ex
.
getMessage
());
}
st
.
close
();
JDBC2Tests
.
dropTable
(
con
,
"updateable"
);
JDBC2Tests
.
closeDB
(
con
);
}
catch
(
Exception
ex
)
{
fail
(
ex
.
getMessage
());
}
}
}
\ No newline at end of file
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