-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c8fbee
commit 81dbac2
Showing
8 changed files
with
262 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/test/java/net/snowflake/client/core/SQLInputOutputTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package net.snowflake.client.core; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
import static org.mockito.Mockito.any; | ||
import static org.mockito.Mockito.mockStatic; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import net.snowflake.client.core.json.Converters; | ||
import net.snowflake.client.jdbc.BaseJDBCTest; | ||
import net.snowflake.common.core.SqlState; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.mockito.MockedStatic; | ||
import org.mockito.MockedStatic.Verification; | ||
import org.mockito.Mockito; | ||
|
||
import java.sql.SQLData; | ||
import java.sql.SQLException; | ||
|
||
public class SQLInputOutputTest { | ||
|
||
@Test | ||
public void testBaseSQLUnSupportedException() { | ||
BaseSqlInput sqlInput = new ArrowSqlInput(null,null,null,null); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readCharacterStream); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readAsciiStream); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readBinaryStream); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readRef); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readBlob); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readClob); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readArray); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readURL); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readNClob); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readNString); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readSQLXML); | ||
expectSnowflakeLoggedFeatureNotSupportedException(sqlInput::readRowId); | ||
} | ||
|
||
@Test | ||
public void testJsonSqlOutPutUnSupportedTest() { | ||
JsonSqlOutput sqloutput = new JsonSqlOutput(mock(SQLData.class),mock(SFBaseSession.class)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeRef(null)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeBlob(null)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeClob(null)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeStruct(null)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeArray(null)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeURL(null)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeNString(null)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeNClob(null)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeRowId(null)); | ||
expectSnowflakeLoggedFeatureNotSupportedException(()->sqloutput.writeSQLXML(null)); | ||
} | ||
|
||
private interface MethodRaisesSQLException { | ||
void run() throws SQLException; | ||
} | ||
private void expectSnowflakeLoggedFeatureNotSupportedException(MethodRaisesSQLException f) { | ||
try { | ||
f.run(); | ||
fail("must raise exception"); | ||
} catch (SQLException ex) { | ||
assertEquals(SqlState.FEATURE_NOT_SUPPORTED, "0A000"); | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/java/net/snowflake/client/jdbc/SnowflakeColumnMetadataTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.snowflake.client.jdbc; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.mockito.Mockito.mock; | ||
|
||
|
||
public class SnowflakeColumnMetadataTest { | ||
|
||
@Test | ||
public void testSnowflakeColumnMetaData() { | ||
SnowflakeColumnMetadata metadata = new SnowflakeColumnMetadata("mock",1,true,2,3,4,"fake",true,null,null,null,null,true); | ||
List<FieldMetadata> list = mock(List.class); | ||
metadata.setName("test"); | ||
metadata.setType(10); | ||
metadata.setNullable(false); | ||
metadata.setLength(12); | ||
metadata.setPrecision(13); | ||
metadata.setScale(14); | ||
metadata.setTypeName("type"); | ||
metadata.setFixed(false); | ||
metadata.setFields(list); | ||
metadata.setAutoIncrement(false); | ||
|
||
assertEquals(metadata.getName(),"test"); | ||
assertEquals(metadata.getType(),10); | ||
assertFalse(metadata.isNullable()); | ||
assertEquals(metadata.getLength(),12); | ||
assertEquals(metadata.getPrecision(),13); | ||
assertEquals(metadata.getScale(),14); | ||
assertEquals(metadata.getTypeName(),"type"); | ||
assertFalse(metadata.isFixed()); | ||
assertEquals(metadata.getFields(),list); | ||
assertFalse(metadata.isAutoIncrement()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters