54
54
import static oracle .r2dbc .util .Awaits .awaitMany ;
55
55
import static oracle .r2dbc .util .Awaits .awaitNone ;
56
56
import static oracle .r2dbc .util .Awaits .awaitOne ;
57
+ import static oracle .r2dbc .util .Awaits .awaitUpdate ;
57
58
import static oracle .r2dbc .util .Awaits .consumeOne ;
58
59
import static oracle .r2dbc .util .Awaits .tryAwaitExecution ;
59
60
import static oracle .r2dbc .util .Awaits .tryAwaitNone ;
60
61
import static org .junit .jupiter .api .Assertions .assertEquals ;
61
62
import static org .junit .jupiter .api .Assertions .assertFalse ;
62
63
import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
63
- import static org .junit .jupiter .api .Assertions .assertSame ;
64
64
import static org .junit .jupiter .api .Assertions .assertThrows ;
65
65
import static org .junit .jupiter .api .Assertions .assertTrue ;
66
66
import static org .junit .jupiter .api .Assertions .fail ;
@@ -631,8 +631,8 @@ else if (index == 1) {
631
631
}
632
632
633
633
/**
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 .
636
636
*/
637
637
@ Test
638
638
public void testOracleR2dbcWarning () {
@@ -642,7 +642,7 @@ public void testOracleR2dbcWarning() {
642
642
// Expect a warning for forcing a view that references a non-existent
643
643
// table
644
644
String sql = "CREATE OR REPLACE FORCE VIEW testOracleR2dbcWarning AS" +
645
- " SELECT x FROM thisdoesnotexist" ;
645
+ " SELECT x FROM thisdoesnotexist" ;
646
646
Statement warningStatement = connection .createStatement (sql );
647
647
648
648
// Collect the segments
@@ -684,4 +684,68 @@ public void testOracleR2dbcWarning() {
684
684
}
685
685
}
686
686
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
+
687
751
}
0 commit comments