Search in sources :

Example 16 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestFailuresSuite method testViolateUniqueness.

public void testViolateUniqueness() throws IOException {
    System.out.println("STARTING testVU");
    Client client = getClient();
    VoltTable[] results = null;
    try {
        results = client.callProcedure("ViolateUniqueness", 1L, 1L, 1L).getResults();
        System.out.println("testVU client response received");
        assertEquals(results.length, 0);
    } catch (ProcCallException e) {
        try {
            results = client.callProcedure("InsertNewOrder", 2L, 2L, 2L).getResults();
        } catch (ProcCallException e1) {
            fail(e1.toString());
        } catch (IOException e1) {
            fail(e1.toString());
        }
        System.out.println("second client response received");
        assertEquals(1, results.length);
        assertEquals(1, results[0].asScalarLong());
        return;
    } catch (IOException e) {
        fail(e.toString());
        return;
    }
    fail("testViolateUniqueness should return while catching ProcCallException");
}
Also used : IOException(java.io.IOException) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) ProcCallException(org.voltdb.client.ProcCallException)

Example 17 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestFailuresSuite method testBadVarcharToAnyCompare.

// Subcase of ENG-800
public void testBadVarcharToAnyCompare() throws IOException {
    System.out.println("STARTING testBadVarcharToAnyCompare");
    Client client = getClient();
    boolean threw = false;
    try {
        client.callProcedure("BadVarcharCompare", 1).getResults();
    } catch (ProcCallException e) {
        if (!isHSQL()) {
            if ((e.getMessage().contains("SQL ERROR")) && (e.getMessage().contains("cannot be cast for comparison to type VARCHAR"))) {
                threw = true;
            } else {
                e.printStackTrace();
            }
        } else {
            threw = true;
        }
    }
    assertTrue(threw);
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 18 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestFailuresSuite method testBadDecimalToVarcharCompare.

// Subcase of ENG-800
public void testBadDecimalToVarcharCompare() throws IOException {
    System.out.println("STARTING testBadDecimalToVarcharCompare");
    Client client = getClient();
    boolean threw = false;
    try {
        client.callProcedure("BadDecimalToVarcharCompare", 1).getResults();
    } catch (ProcCallException e) {
        if (!isHSQL()) {
            if ((e.getMessage().contains("SQL ERROR")) && (e.getMessage().contains("VARCHAR cannot be cast for comparison to type DECIMAL"))) {
                threw = true;
            } else {
                e.printStackTrace();
            }
        } else {
            threw = true;
        }
    }
    assertTrue(threw);
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 19 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestFailuresSuite method testTooFewParamsOnSQLStmt.

public void testTooFewParamsOnSQLStmt() throws IOException {
    System.out.println("STARTING testTooFewParamsOnSQLStmt");
    Client client = getClient();
    try {
        client.callProcedure("TooFewParams", 1, 1);
        fail();
    } catch (ProcCallException e) {
    }
}
Also used : Client(org.voltdb.client.Client) ProcCallException(org.voltdb.client.ProcCallException)

Example 20 with ProcCallException

use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.

the class TestDecimalRoundingSuite method validateDecimalDefault.

private final void validateDecimalDefault(String tableName, boolean shouldFail, boolean roundEnabled, RoundingMode roundMode, String value) throws Exception {
    Client client = getClient();
    ClientResponse cr;
    boolean sawFail = false;
    VoltTable tbl = null;
    BigDecimal found = null;
    try {
        cr = client.callProcedure("@AdHoc", String.format("insert into %s (id) values ?;", tableName), 100);
        assertEquals(ClientResponse.SUCCESS, cr.getStatus());
        sawFail = false;
        cr = client.callProcedure("@AdHoc", String.format("select (dec) from %s;", tableName));
        assertEquals(ClientResponse.SUCCESS, cr.getStatus());
        tbl = cr.getResults()[0];
        assertTrue(tbl.advanceRow());
        found = tbl.getDecimalAsBigDecimal(0);
    } catch (ProcCallException ex) {
        sawFail = true;
    }
    assertEquals(shouldFail ? "Expected a failure here" : "Unexpected failure here", shouldFail, sawFail);
    if (shouldFail) {
        return;
    }
    BigDecimal expected = roundDecimalValue(value, roundEnabled, roundMode);
    assertEquals(String.format("Default decimal value failed: rounding is %s, mode is %s", roundEnabled ? "enabled" : "not enabled", roundMode), expected, found);
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) Client(org.voltdb.client.Client) VoltTable(org.voltdb.VoltTable) BigDecimal(java.math.BigDecimal) ProcCallException(org.voltdb.client.ProcCallException)

Aggregations

ProcCallException (org.voltdb.client.ProcCallException)239 Client (org.voltdb.client.Client)151 VoltTable (org.voltdb.VoltTable)120 ClientResponse (org.voltdb.client.ClientResponse)91 IOException (java.io.IOException)81 NoConnectionsException (org.voltdb.client.NoConnectionsException)55 Test (org.junit.Test)44 Configuration (org.voltdb.VoltDB.Configuration)41 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)36 File (java.io.File)21 InMemoryJarfile (org.voltdb.utils.InMemoryJarfile)19 VoltCompiler (org.voltdb.compiler.VoltCompiler)15 VoltDB (org.voltdb.VoltDB)10 VoltTableRow (org.voltdb.VoltTableRow)10 Timestamp (java.sql.Timestamp)5 TimestampType (org.voltdb.types.TimestampType)5 BigDecimal (java.math.BigDecimal)4 Date (java.util.Date)4 HashSet (java.util.HashSet)3 ClientResponseImpl (org.voltdb.ClientResponseImpl)3