Search in sources :

Example 11 with Parameters

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);
}
Also used : ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 12 with Parameters

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);
}
Also used : Sink(org.xbib.elasticsearch.jdbc.strategy.Sink) MockSink(org.xbib.elasticsearch.jdbc.strategy.mock.MockSink) MockSink(org.xbib.elasticsearch.jdbc.strategy.mock.MockSink) StringKeyValueStreamListener(org.xbib.elasticsearch.common.util.StringKeyValueStreamListener) Values(org.xbib.elasticsearch.common.util.Values) ResultSet(java.sql.ResultSet) IndexableObject(org.xbib.elasticsearch.common.util.IndexableObject) PreparedStatement(java.sql.PreparedStatement) IndexableObject(org.xbib.elasticsearch.common.util.IndexableObject) LinkedList(java.util.LinkedList) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 13 with Parameters

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);
    }
}
Also used : ConnectionManager(org.adbcj.ConnectionManager) Connection(org.adbcj.Connection) CountDownLatch(java.util.concurrent.CountDownLatch) DbException(org.adbcj.DbException) DbException(org.adbcj.DbException) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 14 with Parameters

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");
}
Also used : CLIRequest(com.sun.identity.cli.CLIRequest) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Example 15 with Parameters

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");
}
Also used : SSOToken(com.iplanet.sso.SSOToken) HashSet(java.util.HashSet) Set(java.util.Set) AMIdentity(com.sun.identity.idm.AMIdentity) CLIRequest(com.sun.identity.cli.CLIRequest) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) AfterTest(org.testng.annotations.AfterTest)

Aggregations

Parameters (org.testng.annotations.Parameters)628 Test (org.testng.annotations.Test)610 BaseTest (org.xdi.oxauth.BaseTest)511 Response (javax.ws.rs.core.Response)271 Builder (javax.ws.rs.client.Invocation.Builder)270 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)270 ResponseType (org.xdi.oxauth.model.common.ResponseType)259 JSONException (org.codehaus.jettison.json.JSONException)238 OxAuthCryptoProvider (org.xdi.oxauth.model.crypto.OxAuthCryptoProvider)196 JSONObject (org.codehaus.jettison.json.JSONObject)191 URISyntaxException (java.net.URISyntaxException)119 RegisterResponse (org.xdi.oxauth.client.RegisterResponse)110 RegisterRequest (org.xdi.oxauth.client.RegisterRequest)96 JwtAuthorizationRequest (org.xdi.oxauth.client.model.authorize.JwtAuthorizationRequest)92 AuthorizationRequest (org.xdi.oxauth.client.AuthorizationRequest)86 URI (java.net.URI)85 Jwt (org.xdi.oxauth.model.jwt.Jwt)81 Claim (org.xdi.oxauth.client.model.authorize.Claim)80 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)73 REGISTRATION_CLIENT_URI (org.xdi.oxauth.model.register.RegisterResponseParam.REGISTRATION_CLIENT_URI)73