use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestSQLTypesSuite method testMaxValidStringSize.
//
// Test that the max supported varchar can be inserted.
//
public void testMaxValidStringSize() throws IOException, ProcCallException {
final Client client = getClient();
boolean caught = false;
final Object[] params = new Object[COLS + 2];
params[0] = "NO_NULLS";
// array to build the Big String.
final char[] blob = new char[VoltType.MAX_VALUE_LENGTH];
for (int i = 0; i < blob.length; i++) {
blob[i] = 'a';
}
// this string *is* fastserializable.
for (int stringcount = 0; stringcount < 4; ++stringcount) {
int curr_string = 0;
params[1] = pkey.incrementAndGet();
for (int k = 0; k < COLS; ++k) {
if ((m_types[k] == VoltType.STRING) && (stringcount == curr_string)) {
params[k + 2] = new String(blob);
} else {
params[k + 2] = m_midValues[k];
}
if (m_types[k] == VoltType.STRING)
curr_string++;
}
try {
caught = false;
client.callProcedure("Insert", params);
} catch (final ProcCallException e) {
caught = true;
}
// the last (1048576) string should be fine here.
if (stringcount != 3) {
assertTrue(caught);
} else {
assertFalse(caught);
}
}
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestSQLTypesSuite method testMissingAttributeInsert_With_Defaults.
public void testMissingAttributeInsert_With_Defaults() throws NoConnectionsException, ProcCallException, IOException {
Client client = this.getClient();
Object[] params = new Object[COLS + 2];
params[0] = "WITH_DEFAULTS";
params[1] = pkey.incrementAndGet();
for (int i = 0; i < COLS; i++) {
params[i + 2] = m_defaultValues[i];
assert (params[i + 2] != null);
}
try {
client.callProcedure("Insert", params);
} catch (ProcCallException e) {
e.printStackTrace();
fail();
} catch (NoConnectionsException e) {
e.printStackTrace();
fail();
}
VoltTable[] result = client.callProcedure("Select", "WITH_DEFAULTS", pkey.get()).getResults();
VoltTableRow row = result[0].fetchRow(0);
for (int i = 0; i < COLS; ++i) {
Object obj = row.get(i + 1, m_types[i]);
if (m_types[i] == VoltType.GEOGRAPHY || m_types[i] == VoltType.GEOGRAPHY_POINT) {
// Default values are not supported for these types (yet?)
assertNull(obj);
} else {
assertTrue("Expected to be equal: (" + obj + ", " + params[i + 2] + ")", comparisonHelper(obj, params[i + 2], m_types[i]));
}
}
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestSecuritySuite method testDefaultProcPermissions.
// Tests permissions applied to auto-generated default CRUD procedures.
public void testDefaultProcPermissions() throws Exception {
Client client;
boolean exceptionThrown;
// userWithDefaultProcPerm is allowed to invoke default CRUD procs
m_username = "userWithDefaultProcPerm";
client = getClient();
exceptionThrown = false;
try {
client.callProcedure("NEW_ORDER.insert", 100, 100, 100);
} catch (ProcCallException e) {
e.printStackTrace();
exceptionThrown = true;
}
assertFalse(exceptionThrown);
// userWithoutDefaultProcPerm is not allowed to invoke default CRUD procs
m_username = "userWithoutDefaultProcPerm";
client = getClient();
exceptionThrown = false;
try {
client.callProcedure("NEW_ORDER.insert", 101, 101, 101);
} catch (ProcCallException e) {
e.printStackTrace();
exceptionThrown = true;
}
assertTrue(exceptionThrown);
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestSecuritySuite method testDefaultUser.
public void testDefaultUser() throws Exception {
m_username = "userWithDefaultUserPerm";
m_password = "password";
Client client = getClient();
// adhoc
VoltTable modCount = client.callProcedure("@AdHoc", "INSERT INTO NEW_ORDER VALUES (4, 4, 4);").getResults()[0];
assertTrue(modCount.getRowCount() == 1);
assertTrue(modCount.asScalarLong() == 1);
// read-only adhoc
modCount = client.callProcedure("@AdHoc", "SELECT COUNT(*) FROM NEW_ORDER;").getResults()[0];
assertTrue(modCount.getRowCount() == 1);
assertTrue(modCount.asScalarLong() == 1);
// user proc
assertEquals(ClientResponse.SUCCESS, client.callProcedure("DoNothing3", 1).getStatus());
// sysproc
try {
client.callProcedure("@Quiesce").getStatus();
fail("Should not allow RW sysproc");
} catch (ProcCallException e) {
}
}
use of org.voltdb.client.ProcCallException in project voltdb by VoltDB.
the class TestSecuritySuite method testSysprocAndAdhocPermissions.
public void testSysprocAndAdhocPermissions() throws Exception {
Client client;
boolean exceptionThrown;
VoltTable modCount;
VoltTable[] results;
// user1 can't run anything
m_username = "user1";
client = getClient();
exceptionThrown = false;
try {
modCount = client.callProcedure("@AdHoc", "INSERT INTO NEW_ORDER VALUES (2, 2, 2);").getResults()[0];
} catch (ProcCallException e) {
e.printStackTrace();
exceptionThrown = true;
}
assertTrue(exceptionThrown);
exceptionThrown = false;
try {
results = client.callProcedure("@Quiesce").getResults();
} catch (ProcCallException e) {
e.printStackTrace();
exceptionThrown = true;
}
assertTrue(exceptionThrown);
// user2 can run adhoc due to his group
m_username = "user2";
client = getClient();
modCount = client.callProcedure("@AdHoc", "INSERT INTO NEW_ORDER VALUES (4, 4, 4);").getResults()[0];
assertTrue(modCount.getRowCount() == 1);
assertTrue(modCount.asScalarLong() == 1);
// user3 can only run adhoc due to his group
m_username = "user3";
client = getClient();
modCount = client.callProcedure("@AdHoc", "INSERT INTO NEW_ORDER VALUES (5, 5, 5);").getResults()[0];
assertTrue(modCount.getRowCount() == 1);
assertTrue(modCount.asScalarLong() == 1);
exceptionThrown = false;
try {
results = client.callProcedure("@Quiesce").getResults();
} catch (ProcCallException e) {
e.printStackTrace();
exceptionThrown = true;
}
assertTrue(exceptionThrown);
// user4 can do anything due to his group
m_username = "user4";
client = getClient();
modCount = client.callProcedure("@AdHoc", "INSERT INTO NEW_ORDER VALUES (6, 6, 6);").getResults()[0];
assertTrue(modCount.getRowCount() == 1);
assertTrue(modCount.asScalarLong() == 1);
results = client.callProcedure("@Quiesce").getResults();
// one aggregate table returned
assertTrue(results.length == 1);
}
Aggregations