use of org.testng.annotations.Parameters in project elasticsearch-jdbc by jprante.
the class StandardSourceTests method testSimpleSQL.
@Test
@Parameters({ "sql1" })
public void testSimpleSQL(String sql) throws Exception {
PreparedStatement statement = source.prepareQuery(sql);
ResultSet results = source.executeQuery(statement);
for (int i = 0; i < 5; i++) {
assertTrue(results.next());
}
source.close(results);
source.close(statement);
}
use of org.testng.annotations.Parameters in project elasticsearch-jdbc by jprante.
the class StandardSourceTests method testSimpleNullInteger.
@Test
@Parameters({ "sql3" })
public void testSimpleNullInteger(String sql) throws Exception {
List<Object> params = new LinkedList<Object>();
Sink sink = new MockSink() {
@Override
public void index(IndexableObject object, boolean create) throws IOException {
if (object == null || object.source() == null) {
throw new IllegalArgumentException("object missing");
}
Values o = (Values) object.source().get("amount");
if (o == null) {
// hsqldb is uppercase
o = (Values) object.source().get("AMOUNT");
}
if (!o.isNull()) {
throw new IllegalArgumentException("amount not null??? " + o.getClass().getName());
}
}
};
PreparedStatement statement = source.prepareQuery(sql);
source.bind(statement, params);
ResultSet results = source.executeQuery(statement);
StringKeyValueStreamListener listener = new StringKeyValueStreamListener().output(sink);
long rows = 0L;
source.beforeRows(results, listener);
if (source.nextRow(results, listener)) {
// only one row
rows++;
}
source.afterRows(results, listener);
assertEquals(rows, 1);
source.close(results);
source.close(statement);
}
use of org.testng.annotations.Parameters in project adbcj by mheath.
the class ConnectSpecialCaseTest method testConnectBadCredentials.
@Parameters({ "url", "user", "password" })
@Test(timeOut = 60000)
public void testConnectBadCredentials(String url, String user, String password) throws InterruptedException {
final boolean[] callbacks = { false };
final CountDownLatch latch = new CountDownLatch(1);
ConnectionManager connectionManager = ConnectionManagerProvider.createConnectionManager(url, user, "__BADPASSWORD__");
try {
DbFuture<Connection> connectFuture = connectionManager.connect().addListener(new DbListener<Connection>() {
public void onCompletion(DbFuture<Connection> future) throws Exception {
callbacks[0] = true;
latch.countDown();
}
});
try {
connectFuture.get();
fail("Connect should have failed because of bad credentials");
} catch (DbException e) {
assertTrue(connectFuture.isDone(), "Connect future should be marked done even though it failed");
assertTrue(!connectFuture.isCancelled(), "Connect future should not be marked as cancelled");
}
assertTrue(latch.await(1, TimeUnit.SECONDS), "Callback was not invoked in time");
assertTrue(callbacks[0], "Connect future callback was not invoked with connect failure");
} finally {
connectionManager.close(true);
}
}
use of org.testng.annotations.Parameters in project OpenAM by OpenRock.
the class IdRepoTest method getAssignableServices.
// Duplicate of getIdentityServices?
// @Parameters ({"realm", "uid"})
// @Test(groups = {"cli-idrepo", "get-identity-svcs"},
// dependsOnMethods = {"createIdentity"})
// public void getServices(String realm, String uid)
// throws CLIException {
// String[] param = {realm, uid};
// entering("getServices", param);
// String[] args = {
// "get-identity-svcs",
// CLIConstants.PREFIX_ARGUMENT_LONG +
// IdentityCommand.ARGUMENT_ID_TYPE,
// "User",
// CLIConstants.PREFIX_ARGUMENT_LONG +
// IdentityCommand.ARGUMENT_ID_NAME,
// uid,
// CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME,
// realm};
//
// CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
// cmdManager.addToRequestQueue(req);
// cmdManager.serviceRequestQueue();
// exiting("getServices");
// }
@Parameters({ "realm", "uid" })
@Test(groups = { "cli-idrepo", "list-identity-assignable-svcs" }, dependsOnMethods = { "createIdentity" })
public void getAssignableServices(String realm, String uid) throws CLIException {
String[] param = { realm, uid };
entering("getAssignableServices", param);
String[] args = { "list-identity-assignable-svcs", CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_TYPE, "User", CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_NAME, uid, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm };
CLIRequest req = new CLIRequest(null, args, getAdminSSOToken());
cmdManager.addToRequestQueue(req);
cmdManager.serviceRequestQueue();
exiting("getAssignableServices");
}
use of org.testng.annotations.Parameters in project OpenAM by OpenRock.
the class IdRepoTest method assignServices.
@Parameters({ "realm", "uid" })
@Test(groups = { "cli-idrepo", "add-svc-identity" }, dependsOnMethods = { "createIdentity" })
public void assignServices(String realm, String uid) throws CLIException, IdRepoException, SSOException {
String[] param = { realm, uid };
entering("assignServices", param);
String[] args = { "add-svc-identity", CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_TYPE, "User", CLIConstants.PREFIX_ARGUMENT_LONG + IdentityCommand.ARGUMENT_ID_NAME, uid, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.REALM_NAME, realm, CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.SERVICE_NAME, "iPlanetAMSessionService", CLIConstants.PREFIX_ARGUMENT_LONG + IArgument.ATTRIBUTE_VALUES, "iplanet-am-session-quota-limit=10" };
SSOToken adminSSOToken = getAdminSSOToken();
CLIRequest req = new CLIRequest(null, args, adminSSOToken);
cmdManager.addToRequestQueue(req);
cmdManager.serviceRequestQueue();
AMIdentity amid = new AMIdentity(adminSSOToken, uid, IdType.USER, realm, null);
Set services = amid.getAssignedServices();
assert services.contains("iPlanetAMSessionService");
exiting("assignServices");
}
Aggregations