Permalink
1 comment
on commit
sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix: use SQLWarning(String reason) constructor for correct DriverMana… (
#751) * fix: use SQLWarning(String reason) constructor for correct DriverManager logging Previously, the default constructor was used which only logs "SQLWarning: ", but no information about the warning.
- Loading branch information
Showing
with
38 additions
and 8 deletions.
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (c) 2016, PostgreSQL Global Development Group | ||
* See the LICENSE file in the project root for more information. | ||
*/ | ||
|
||
package org.postgresql.util; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.postgresql.test.TestUtil; | ||
|
||
import org.junit.Test; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.OutputStreamWriter; | ||
import java.io.PrintWriter; | ||
import java.sql.Connection; | ||
import java.sql.DriverManager; | ||
import java.sql.Statement; | ||
|
||
|
||
public class PSQLWarningTest { | ||
|
||
@Test | ||
public void testPSQLLogsToDriverManagerMessage() throws Exception { | ||
Connection con = TestUtil.openDB(); | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
DriverManager.setLogWriter(new PrintWriter(new OutputStreamWriter(baos, "ASCII"))); | ||
|
||
Statement stmt = con.createStatement(); | ||
stmt.execute("DO language plpgsql $$ BEGIN RAISE NOTICE 'test notice'; END $$;"); | ||
assertTrue(baos.toString().contains("NOTICE: test notice")); | ||
|
||
stmt.close(); | ||
con.close(); | ||
} | ||
} |
This comment has been minimized.
74a426b
So this is failing in travis allegedly with core dumps according to the message. I created another PR #799 just to test this but it doesn't fail. Anyone have any ideas ?