@@ -161,4 +161,32 @@ public String apply(DriverPropertyInfo input) {
161161 });
162162 assertThat (driverPropertyNames ).containsExactlyElementsIn (validConnectionPropertyNames );
163163 }
164+
165+ @ Test
166+ public void testLenient () throws SQLException {
167+ // With lenient=true the driver should accept unknown properties and only generate a warning.
168+ try (Connection connection =
169+ DriverManager .getConnection (
170+ String .format (
171+ "jdbc:cloudspanner://localhost:%d/projects/p/instances/i/databases/d?usePlainText=true;credentials=%s;lenient=true;foo=bar" ,
172+ server .getPort (), TEST_KEY_PATH ))) {
173+ assertThat (connection .isClosed ()).isFalse ();
174+ assertThat ((Throwable ) connection .getWarnings ()).isNotNull ();
175+ assertThat (connection .getWarnings ().getMessage ()).contains ("foo" );
176+ }
177+
178+ // Without lenient the driver should throw an exception for unknown properties.
179+ try (Connection connection =
180+ DriverManager .getConnection (
181+ String .format (
182+ "jdbc:cloudspanner://localhost:%d/projects/p/instances/i/databases/d?usePlainText=true;credentials=%s;foo=bar" ,
183+ server .getPort (), TEST_KEY_PATH ))) {
184+ fail ("missing expected exception" );
185+ } catch (SQLException e ) {
186+ assertThat ((Throwable ) e ).isInstanceOf (JdbcSqlException .class );
187+ JdbcSqlException jdbc = (JdbcSqlException ) e ;
188+ assertThat (jdbc .getMessage ()).contains ("foo" );
189+ assertThat (jdbc .getCode ()).isEqualTo (Code .INVALID_ARGUMENT );
190+ }
191+ }
164192}
0 commit comments