5454import static oracle .r2dbc .util .Awaits .awaitMany ;
5555import static oracle .r2dbc .util .Awaits .awaitNone ;
5656import static oracle .r2dbc .util .Awaits .awaitOne ;
57+ import static oracle .r2dbc .util .Awaits .awaitUpdate ;
5758import static oracle .r2dbc .util .Awaits .consumeOne ;
5859import static oracle .r2dbc .util .Awaits .tryAwaitExecution ;
5960import static oracle .r2dbc .util .Awaits .tryAwaitNone ;
6061import static org .junit .jupiter .api .Assertions .assertEquals ;
6162import static org .junit .jupiter .api .Assertions .assertFalse ;
6263import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
63- import static org .junit .jupiter .api .Assertions .assertSame ;
6464import static org .junit .jupiter .api .Assertions .assertThrows ;
6565import static org .junit .jupiter .api .Assertions .assertTrue ;
6666import static org .junit .jupiter .api .Assertions .fail ;
@@ -631,8 +631,8 @@ else if (index == 1) {
631631 }
632632
633633 /**
634- * Verifies that a warnings are emitted as {@code Message} segments with an
635- * {@link oracle.r2dbc.OracleR2dbcWarning}.
634+ * Verifies that a warnings are emitted as
635+ * {@link oracle.r2dbc.OracleR2dbcWarning} segments .
636636 */
637637 @ Test
638638 public void testOracleR2dbcWarning () {
@@ -642,7 +642,7 @@ public void testOracleR2dbcWarning() {
642642 // Expect a warning for forcing a view that references a non-existent
643643 // table
644644 String sql = "CREATE OR REPLACE FORCE VIEW testOracleR2dbcWarning AS" +
645- " SELECT x FROM thisdoesnotexist" ;
645+ " SELECT x FROM thisdoesnotexist" ;
646646 Statement warningStatement = connection .createStatement (sql );
647647
648648 // Collect the segments
@@ -684,4 +684,68 @@ public void testOracleR2dbcWarning() {
684684 }
685685 }
686686
687+ /**
688+ * Verifies that a warnings are not emitted as onError signals
689+ */
690+ @ Test
691+ public void testOracleR2dbcWarningIgnored () {
692+ Connection connection = awaitOne (sharedConnection ());
693+ try {
694+
695+ // Expect a warning for forcing a view that references a non-existent
696+ // table
697+ String sql =
698+ "CREATE OR REPLACE FORCE VIEW testOracleR2dbcWarningIgnored AS" +
699+ " SELECT x FROM thisdoesnotexist" ;
700+ Statement warningStatement = connection .createStatement (sql );
701+
702+ // Verify that an update count of 0 is returned.
703+ awaitUpdate (0 , warningStatement );
704+
705+ // Verify that no rows are returned
706+ awaitNone (
707+ awaitOne (warningStatement .execute ())
708+ .map (row -> "UNEXPECTED ROW" ));
709+
710+ // Verify that no rows are returned
711+ awaitNone (
712+ awaitOne (warningStatement .execute ())
713+ .map ((row , metadata ) -> "UNEXPECTED ROW WITH METADATA" ));
714+ }
715+ finally {
716+ tryAwaitExecution (
717+ connection .createStatement ("DROP VIEW testOracleR2dbcWarningIgnored" ));
718+ tryAwaitNone (connection .close ());
719+ }
720+ }
721+
722+ /**
723+ * Verifies that {@link Result#flatMap(Function)} may be used to convert
724+ * warnings into onError signals
725+ */
726+ @ Test
727+ public void testOracleR2dbcWarningNotIgnored () {
728+ Connection connection = awaitOne (sharedConnection ());
729+ try {
730+
731+ // Expect a warning for forcing a view that references a non-existent
732+ // table
733+ String sql =
734+ "CREATE OR REPLACE FORCE VIEW testOracleR2dbcWarningIgnored AS" +
735+ " SELECT x FROM thisdoesnotexist" ;
736+ Statement warningStatement = connection .createStatement (sql );
737+ awaitError (
738+ R2dbcException .class ,
739+ awaitOne (warningStatement .execute ())
740+ .flatMap (segment ->
741+ Mono .error (
742+ assertInstanceOf (OracleR2dbcWarning .class , segment ).exception ())));
743+ }
744+ finally {
745+ tryAwaitExecution (
746+ connection .createStatement ("DROP VIEW testOracleR2dbcWarningIgnored" ));
747+ tryAwaitNone (connection .close ());
748+ }
749+ }
750+
687751}
0 commit comments