Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
422c2e38
Commit
422c2e38
authored
22 years ago
by
Dave Cramer
Browse files
Options
Downloads
Patches
Plain Diff
testing for insertRow
parent
164e1bc9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
+71
-70
71 additions, 70 deletions
.../jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
with
71 additions
and
70 deletions
src/interfaces/jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java
+
71
−
70
View file @
422c2e38
...
@@ -23,47 +23,48 @@ public class UpdateableResultTest extends TestCase
...
@@ -23,47 +23,48 @@ public class UpdateableResultTest extends TestCase
public
void
testUpdateable
()
public
void
testUpdateable
()
{
{
try
try
{
{
Connection
con
=
TestUtil
.
openDB
();
Connection
con
=
TestUtil
.
openDB
();
TestUtil
.
createTable
(
con
,
"updateable"
,
"id int primary key, name text, notselected text"
);
TestUtil
.
createTable
(
con
,
"updateable"
,
"id int primary key, name text, notselected text"
);
TestUtil
.
createTable
(
con
,
"second"
,
"id1 int primary key, name1 text"
);
TestUtil
.
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')"
);
assertTrue
(!
retVal
);
retVal
=
st1
.
execute
(
"insert into second (id1, name1) values (1, 'jake')"
);
// put some dummy data into second
assertTrue
(
!
retVal
);
Statement
st2
=
con
.
createStatement
();
st1
.
close
();
st2
.
execute
(
"insert into second values (1,'anyvalue' )"
);
st2
.
close
();
Statement
st
=
con
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_UPDATABLE
);
Statement
st
=
con
.
createStatement
(
ResultSet
.
TYPE_SCROLL_INSENSITIVE
,
ResultSet
.
CONCUR_UPDATABLE
);
ResultSet
rs
=
st
.
executeQuery
(
"select id, name, notselected from updateable"
);
ResultSet
rs
=
st
.
executeQuery
(
"select * from updateable"
);
assertNotNull
(
rs
);
rs
.
moveToInsertRow
();
rs
.
updateInt
(
1
,
1
);
rs
.
updateString
(
2
,
"jake"
);
rs
.
updateString
(
3
,
"avalue"
);
rs
.
insertRow
();
rs
.
first
();
assertNotNull
(
rs
);
rs
.
updateInt
(
"id"
,
2
);
rs
.
updateString
(
"name"
,
"dave"
);
rs
.
updateRow
();
while
(
rs
.
next
())
assertTrue
(
rs
.
getInt
(
"id"
)
==
2
);
{
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave"
));
rs
.
updateInt
(
"id"
,
2
);
assertTrue
(
rs
.
getString
(
"notselected"
).
equals
(
"avalue"
)
);
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
.
deleteRow
();
rs
.
moveToInsertRow
();
rs
.
moveToInsertRow
();
rs
.
updateInt
(
"id"
,
3
);
rs
.
updateInt
(
"id"
,
3
);
rs
.
updateString
(
"name"
,
"paul"
);
rs
.
updateString
(
"name"
,
"paul"
);
rs
.
insertRow
();
rs
.
insertRow
();
rs
.
refreshRow
();
rs
.
refreshRow
();
assertTrue
(
rs
.
getInt
(
"id"
)
==
3
);
assertTrue
(
rs
.
getInt
(
"id"
)
==
3
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"paul"
));
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"paul"
));
assertTrue
(
rs
.
getString
(
"notselected"
)
==
null
);
assertTrue
(
rs
.
getString
(
"notselected"
)
==
null
);
}
rs
.
close
();
rs
.
close
();
rs
=
st
.
executeQuery
(
"select id1, id, name, name1 from updateable, second"
);
rs
=
st
.
executeQuery
(
"select id1, id, name, name1 from updateable, second"
);
try
try
...
@@ -82,53 +83,53 @@ public class UpdateableResultTest extends TestCase
...
@@ -82,53 +83,53 @@ public class UpdateableResultTest extends TestCase
try
try
{
{
rs
=
st
.
executeQuery
(
"select oid,* from updateable"
);
rs
=
st
.
executeQuery
(
"select oid,* from updateable"
);
if
(
rs
.
first
()
)
if
(
rs
.
first
()
)
{
{
rs
.
updateInt
(
"id"
,
3
);
rs
.
updateInt
(
"id"
,
3
);
rs
.
updateString
(
"name"
,
"dave3"
);
rs
.
updateString
(
"name"
,
"dave3"
);
rs
.
updateRow
();
rs
.
updateRow
();
assertTrue
(
rs
.
getInt
(
"id"
)
==
3
);
assertTrue
(
rs
.
getInt
(
"id"
)
==
3
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave3"
));
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave3"
));
rs
.
moveToInsertRow
();
rs
.
moveToInsertRow
();
rs
.
updateInt
(
"id"
,
4
);
rs
.
updateInt
(
"id"
,
4
);
rs
.
updateString
(
"name"
,
"dave4"
);
rs
.
updateString
(
"name"
,
"dave4"
);
rs
.
insertRow
();
rs
.
insertRow
();
rs
.
updateInt
(
"id"
,
5
);
rs
.
updateInt
(
"id"
,
5
);
rs
.
updateString
(
"name"
,
"dave5"
);
rs
.
updateString
(
"name"
,
"dave5"
);
rs
.
insertRow
();
rs
.
insertRow
();
rs
.
moveToCurrentRow
();
rs
.
moveToCurrentRow
();
assertTrue
(
rs
.
getInt
(
"id"
)
==
3
);
assertTrue
(
rs
.
getInt
(
"id"
)
==
3
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave3"
));
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave3"
));
assertTrue
(
rs
.
next
()
);
assertTrue
(
rs
.
next
()
);
assertTrue
(
rs
.
getInt
(
"id"
)
==
4
);
assertTrue
(
rs
.
getInt
(
"id"
)
==
4
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave4"
));
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave4"
));
assertTrue
(
rs
.
next
()
);
assertTrue
(
rs
.
next
()
);
assertTrue
(
rs
.
getInt
(
"id"
)
==
5
);
assertTrue
(
rs
.
getInt
(
"id"
)
==
5
);
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave5"
));
assertTrue
(
rs
.
getString
(
"name"
).
equals
(
"dave5"
));
}
}
}
}
catch
(
SQLException
ex
)
catch
(
SQLException
ex
)
{
{
fail
(
ex
.
getMessage
());
fail
(
ex
.
getMessage
());
}
}
st
.
close
();
st
.
close
();
TestUtil
.
dropTable
(
con
,
"updateable"
);
TestUtil
.
dropTable
(
con
,
"updateable"
);
TestUtil
.
closeDB
(
con
);
TestUtil
.
closeDB
(
con
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
fail
(
ex
.
getMessage
());
fail
(
ex
.
getMessage
());
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment