lowka commented on code in PR #6518: URL: https://github.com/apache/ignite-3/pull/6518#discussion_r2315276662
########## modules/jdbc/src/test/java/org/apache/ignite/internal/jdbc/JdbcResultSetBaseSelfTest.java: ########## @@ -0,0 +1,969 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.jdbc; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.any; +import static org.hamcrest.Matchers.containsString; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.InputStream; +import java.io.Reader; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.Time; +import java.sql.Timestamp; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; +import org.apache.ignite.sql.ColumnType; +import org.jetbrains.annotations.Nullable; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; + +/** + * Compatibility tests to ensure that both JDBC result set adapters behave identically for core java.sql.ResultSet methods (excluding + * metadata checks). + */ +public abstract class JdbcResultSetBaseSelfTest extends BaseIgniteAbstractTest { + + private static final Calendar CALENDAR = Calendar.getInstance(); + + protected abstract ResultSet createResultSet( + @Nullable ZoneId zoneId, + List<ColumnDefinition> cols, + List<List<Object>> rows + ) throws SQLException; + + protected final ResultSet createPositionedSingle(ColumnDefinition col, Object value) throws SQLException { + return createPositionedMulti(new ColumnDefinition[]{col}, new Object[]{value}); + } + + private ResultSet createPositionedMulti(@Nullable ZoneId zoneId, ColumnDefinition[] columns, Object[] values) throws SQLException { + if (columns.length != values.length) { + throw new IllegalArgumentException("cols, values must have the same length"); + } + + List<ColumnDefinition> cols = Arrays.asList(columns); + List<List<Object>> rows = new ArrayList<>(); + rows.add(Arrays.asList(values)); + + ResultSet rs = createResultSet(zoneId, cols, rows); + assertTrue(rs.next()); + return rs; + } + + private ResultSet createPositionedMulti(ColumnDefinition[] columns, Object[] values) throws SQLException { + return createPositionedMulti(null, columns, values); + } + + @Test + public void getNotSupportedTypes() throws SQLException { Review Comment: Moved those accessor methods to `getNotImplemented`. ########## modules/jdbc/src/test/java/org/apache/ignite/internal/jdbc/JdbcResultSetBaseSelfTest.java: ########## @@ -0,0 +1,969 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.jdbc; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.any; +import static org.hamcrest.Matchers.containsString; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.InputStream; +import java.io.Reader; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; +import java.sql.Time; +import java.sql.Timestamp; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; +import org.apache.ignite.sql.ColumnType; +import org.jetbrains.annotations.Nullable; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; + +/** + * Compatibility tests to ensure that both JDBC result set adapters behave identically for core java.sql.ResultSet methods (excluding + * metadata checks). + */ +public abstract class JdbcResultSetBaseSelfTest extends BaseIgniteAbstractTest { + + private static final Calendar CALENDAR = Calendar.getInstance(); + + protected abstract ResultSet createResultSet( + @Nullable ZoneId zoneId, + List<ColumnDefinition> cols, + List<List<Object>> rows + ) throws SQLException; + + protected final ResultSet createPositionedSingle(ColumnDefinition col, Object value) throws SQLException { + return createPositionedMulti(new ColumnDefinition[]{col}, new Object[]{value}); + } + + private ResultSet createPositionedMulti(@Nullable ZoneId zoneId, ColumnDefinition[] columns, Object[] values) throws SQLException { + if (columns.length != values.length) { + throw new IllegalArgumentException("cols, values must have the same length"); + } + + List<ColumnDefinition> cols = Arrays.asList(columns); + List<List<Object>> rows = new ArrayList<>(); + rows.add(Arrays.asList(values)); + + ResultSet rs = createResultSet(zoneId, cols, rows); + assertTrue(rs.next()); + return rs; + } + + private ResultSet createPositionedMulti(ColumnDefinition[] columns, Object[] values) throws SQLException { + return createPositionedMulti(null, columns, values); + } + + @Test + public void getNotSupportedTypes() throws SQLException { + try (ResultSet rs = createPositionedSingle(new ColumnDefinition("C", ColumnType.STRING, 3, 0, false), "ABC")) { + + expectNotSupported(() -> rs.getArray(1)); + expectNotSupported(() -> rs.getArray("C")); + + expectNotSupported(() -> rs.getAsciiStream(1)); + expectNotSupported(() -> rs.getAsciiStream("C")); + + expectNotSupported(() -> rs.getBinaryStream(1)); + expectNotSupported(() -> rs.getBinaryStream("C")); + + expectNotSupported(() -> rs.getBlob(1)); + expectNotSupported(() -> rs.getBlob("C")); + + expectNotSupported(() -> rs.getClob(1)); + expectNotSupported(() -> rs.getClob("C")); + + expectNotSupported(() -> rs.getCharacterStream(1)); + expectNotSupported(() -> rs.getCharacterStream("C")); + + expectNotSupported(() -> rs.getNCharacterStream(1)); + expectNotSupported(() -> rs.getNCharacterStream("C")); + + expectNotSupported(() -> rs.getNClob(1)); + expectNotSupported(() -> rs.getNClob("C")); + + expectNotSupported(() -> rs.getRef(1)); + expectNotSupported(() -> rs.getRef("C")); + + expectNotSupported(() -> rs.getRowId(1)); + expectNotSupported(() -> rs.getRowId("C")); + + expectNotSupported(() -> rs.getSQLXML(1)); + expectNotSupported(() -> rs.getSQLXML("C")); + + expectNotSupported(() -> rs.getObject(1, Map.of())); + expectNotSupported(() -> rs.getObject("C", Map.of())); + } + } + + @Test + public void updateMethodsAreNotSupported() throws Exception { + try (ResultSet rs = createPositionedSingle(new ColumnDefinition("C", ColumnType.STRING, 3, 0, false), "ABC")) { + + expectNotSupported(() -> rs.updateBoolean(1, true)); + expectNotSupported(() -> rs.updateBoolean("C", true)); + + expectNotSupported(() -> rs.updateByte(1, (byte) 0)); + expectNotSupported(() -> rs.updateByte("C", (byte) 0)); + + expectNotSupported(() -> rs.updateShort(1, (short) 0)); + expectNotSupported(() -> rs.updateShort("C", (short) 0)); + + expectNotSupported(() -> rs.updateInt(1, 0)); + expectNotSupported(() -> rs.updateInt("C", 0)); + + expectNotSupported(() -> rs.updateLong(1, 0)); + expectNotSupported(() -> rs.updateLong("C", 0)); + + expectNotSupported(() -> rs.updateFloat(1, (float) 0.0)); + expectNotSupported(() -> rs.updateFloat("C", (float) 0.0)); Review Comment: Thanks, fixed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org