use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestFunctionsForJSON method testProcWithValidJSON.
private void testProcWithValidJSON(long[] expectedResult, Client client, String procName, Object... parameters) throws Exception {
ClientResponse cr = client.callProcedure(procName, parameters);
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
VoltTable result = cr.getResults()[0];
validateRowOfLongs(result, expectedResult);
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestFunctionsSuite method testMultiSignatureFunctionInStoredProcedure.
public void testMultiSignatureFunctionInStoredProcedure() throws Exception {
// ENG-10939
System.out.println("STARTING testMultiSignatureFunctionInStoredProcedure");
Client client = getClient();
ClientResponse cr = client.callProcedure("TEST_SUBSTRING_INPROC", 12, "string");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestFunctionsSuite method testPi.
public void testPi() throws Exception {
System.out.println("STARTING testPi");
Client client = getClient();
/*
* "CREATE TABLE P1 ( " +
"ID INTEGER DEFAULT 0 NOT NULL, " +
"DESC VARCHAR(300), " +
"NUM INTEGER, " +
"RATIO FLOAT, " +
"PAST TIMESTAMP DEFAULT NULL, " +
"PRIMARY KEY (ID) ); " +
*/
ClientResponse cr = null;
VoltTable vt = null;
double pi = 3.1415926535897932384;
cr = client.callProcedure("@AdHoc", "INSERT INTO P1 (ID) VALUES(1)");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
vt = client.callProcedure("@AdHoc", "SELECT PI() * ID FROM P1 WHERE ID = 1;").getResults()[0];
assertTrue(vt.advanceRow());
assertTrue(Math.abs(vt.getDouble(0) - pi) <= 1.0e-16);
cr = client.callProcedure("@AdHoc", "TRUNCATE TABLE P1");
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestFunctionsSuite method displayFunctionRun.
private FunctionTestCase[] displayFunctionRun(Client client, String fname, int rowCount, String expectedFormat) throws Exception {
ClientResponse cr;
VoltTable result;
FunctionTestCase[] resultSet = new FunctionTestCase[numTypeNames.length * rowCount];
int ii = 0;
String proc = "DISPLAY_" + fname;
cr = client.callProcedure(proc);
result = cr.getResults()[0];
assertEquals(rowCount, result.getRowCount());
while (result.advanceRow()) {
int jj = 0;
for (String numTypeName : numTypeNames) {
double value = getColumnValue(expectedFormat, result, jj);
resultSet[ii++] = new FunctionTestCase(proc + " " + numTypeName, value);
++jj;
}
}
return resultSet;
}
use of org.voltdb.client.ClientResponse in project voltdb by VoltDB.
the class TestMaterializedViewNonemptyTablesSuite method testCreateView.
/**
* Test to see if we can create a view. The view name is
* necessary because we drop the view after creation.
*
* @param client The Client object.
* @param sql The sql string. This should start "create view name ",
* where "name" is the view name.
* @param expectedDiagnostic The expected diagnostic string. This
* should be null if the creation is
* expected to succeed.
* @throws IOException
* @throws NoConnectionsException
* @throws ProcCallException
*/
private void testCreateView(Client client, String sql, String expectedDiagnostic) throws IOException, NoConnectionsException, ProcCallException {
ClientResponse cr = null;
assertTrue("SQL string should start with \"create view \"", sql.startsWith("create view "));
int pos = sql.indexOf(" ", 12);
String viewName = sql.substring(12, pos);
// Try to drop the view. Even if it doesn't
// exist, this should succeed.
dropView(client, viewName);
// Truncate all the tables.
truncateTables(client, TABLE_NAMES);
// This should always succeed.
try {
cr = client.callProcedure("@AdHoc", sql);
} catch (Exception ex) {
fail("Unexpected exception: \"" + ex.getMessage() + "\"");
}
assertEquals(ClientResponse.SUCCESS, cr.getStatus());
// Drop the view and populate the tables.
dropView(client, viewName);
populateTables(client);
// Try the view creation again. This may or may
// not succeed.
boolean expectedSuccess = (expectedDiagnostic == null);
try {
cr = client.callProcedure("@AdHoc", sql);
if (!expectedSuccess) {
fail("Unexpected SQL compilation success");
}
} catch (ProcCallException ex) {
cr = ex.getClientResponse();
if (expectedSuccess) {
fail(String.format("Unexpected SQL compilation failure:\n%s", cr.getStatusString()));
}
assertTrue(String.format("Did not find \"%s\" in diagnostic message \"%s\"", expectedDiagnostic, cr.getStatusString()), cr.getStatusString().contains(expectedDiagnostic));
}
// Drop the view..
dropView(client, viewName);
truncateTables(client, TABLE_NAMES);
// Try creating the view again. Sometimes after a
// population and then truncation things go awry.
// Again, this should always succeed.
cr = client.callProcedure("@AdHoc", sql);
assertEquals("View creation on empty tables should always succeed.", ClientResponse.SUCCESS, cr.getStatus());
dropView(client, viewName);
}
Aggregations