Search in sources :

Example 36 with CloudSpannerConnection

use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.

the class CloudSpannerStatementTest method testInsert.

@Test
public void testInsert() throws SQLException {
    CloudSpannerConnection connection = createConnection();
    CloudSpannerStatement statement = connection.createStatement();
    boolean isResultSet = statement.execute(INSERT_SQL);
    Assert.assertFalse(isResultSet);
    int count = statement.getUpdateCount();
    Assert.assertEquals(1, count);
    boolean moreResults = statement.getMoreResults();
    Assert.assertFalse(moreResults);
    Assert.assertEquals(-1, statement.getUpdateCount());
    int count2 = statement.executeUpdate(INSERT_SQL);
    Assert.assertEquals(1, count2);
}
Also used : CloudSpannerConnection(nl.topicus.jdbc.CloudSpannerConnection) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Example 37 with CloudSpannerConnection

use of nl.topicus.jdbc.CloudSpannerConnection in project spanner-jdbc by olavloite.

the class AbstractTablePartWorkerTest method createWorker.

private AbstractTablePartWorker createWorker(String sql, ParameterStore parameters) throws JSQLParserException {
    CloudSpannerConnection connection = mock(CloudSpannerConnection.class);
    Select select = (Select) CCJSqlParserUtil.parse(sql);
    DMLOperation operation = DMLOperation.INSERT;
    AbstractTablePartWorker worker = mock(AbstractTablePartWorker.class, withSettings().useConstructor(connection, select, parameters, true, operation).defaultAnswer(CALLS_REAL_METHODS));
    return worker;
}
Also used : DMLOperation(nl.topicus.jdbc.statement.AbstractTablePartWorker.DMLOperation) Select(net.sf.jsqlparser.statement.select.Select) CloudSpannerConnection(nl.topicus.jdbc.CloudSpannerConnection)

Aggregations

CloudSpannerConnection (nl.topicus.jdbc.CloudSpannerConnection)37 Test (org.junit.Test)22 UnitTest (nl.topicus.jdbc.test.category.UnitTest)17 ResultSet (java.sql.ResultSet)11 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 IntegrationTest (nl.topicus.jdbc.test.category.IntegrationTest)5 SQLException (java.sql.SQLException)4 Returns (org.mockito.internal.stubbing.answers.Returns)4 TableKeyMetaData (nl.topicus.jdbc.MetaDataStore.TableKeyMetaData)3 CloudSpannerResultSet (nl.topicus.jdbc.resultset.CloudSpannerResultSet)3 Select (net.sf.jsqlparser.statement.select.Select)2 CloudSpannerDataSourceTest (nl.topicus.jdbc.CloudSpannerDataSourceTest)2 CloudSpannerDatabaseMetaData (nl.topicus.jdbc.CloudSpannerDatabaseMetaData)2 CloudSpannerXADataSource (nl.topicus.jdbc.CloudSpannerXADataSource)2 CloudSpannerSQLException (nl.topicus.jdbc.exception.CloudSpannerSQLException)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Code (com.google.rpc.Code)1 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1 PropertyVetoException (java.beans.PropertyVetoException)1