Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: PgSQLXML setCharacterStream() results in null value (#1608)
* fix: PgSQLXML setCharacterStream() results in null value fixes Issue #731
- Loading branch information
1 parent
e64b0a2
commit 1e37026
Showing
3 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
pgjdbc/src/test/java/org/postgresql/jdbc/PgSQLXMLTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2019, PostgreSQL Global Development Group | ||
* See the LICENSE file in the project root for more information. | ||
*/ | ||
|
||
package org.postgresql.jdbc; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.postgresql.test.TestUtil; | ||
import org.postgresql.test.jdbc2.BaseTest4; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.Writer; | ||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.sql.SQLXML; | ||
import java.sql.Statement; | ||
|
||
public class PgSQLXMLTest extends BaseTest4 { | ||
|
||
@Override | ||
@Before | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
TestUtil.createTempTable(con, "xmltab","x xml"); | ||
} | ||
|
||
@Test | ||
public void setCharacterStream() throws Exception { | ||
String exmplar = "<x>value</x>"; | ||
SQLXML pgSQLXML = con.createSQLXML(); | ||
Writer writer = pgSQLXML.setCharacterStream(); | ||
writer.write(exmplar); | ||
PreparedStatement preparedStatement = con.prepareStatement("insert into xmltab values (?)"); | ||
preparedStatement.setSQLXML(1,pgSQLXML); | ||
preparedStatement.execute(); | ||
|
||
Statement statement = con.createStatement(); | ||
ResultSet rs = statement.executeQuery("select * from xmltab"); | ||
assertTrue(rs.next()); | ||
SQLXML result = rs.getSQLXML(1); | ||
assertNotNull(result); | ||
assertEquals(exmplar, result.getString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters