private void showEncoding(TestContext context, String charSetString, Handler<String> encodingHandler) { client = createClient(vertx, new JsonObject() .put("charset", charSetString) ); client.getConnection(sqlConnectionAsyncResult -> { ensureSuccess(context, sqlConnectionAsyncResult); conn = sqlConnectionAsyncResult.result(); conn.query(getEncodingStatement(), showEncodingAr -> { ensureSuccess(context, showEncodingAr); String encoding = getEncodingValueFromResults(showEncodingAr.result().getResults()); conn.close(connCloseAr -> { ensureSuccess(context, connCloseAr); conn = null; client.close(clientCloseAr -> { ensureSuccess(context, clientCloseAr); client = null; encodingHandler.handle(encoding); }); }); }); }); }
@Test public void testCharset(TestContext context) { Async async = context.async(); showEncoding(context, "iso-8859-1", encoding1 -> { showEncoding(context, "utf-8", encoding2 -> { context.assertNotEquals(encoding1, encoding2); async.complete(); }); }); }
@Test public void testQueryTimeout(TestContext context) { Async async = context.async(); client = createClient(vertx, new JsonObject() .put("queryTimeout", Long.parseLong(System.getProperty("db.queryTimeout", "1"))) ); client.getConnection(sqlConnectionAsyncResult -> { conn = sqlConnectionAsyncResult.result(); conn.query("SELECT " + sleepCommand(2), ar -> { if (ar.failed()) { context.assertTrue(ar.cause() instanceof TimeoutException); async.complete(); } else { context.fail("Should fail due to a connection timeout exception"); } }); }); }
@Ignore("Not implemented in driver yet, see https://github.com/mauricio/postgresql-async/issues/6") @Test public void testConnectionTimeout(TestContext context) { Async async = context.async(); client = createClient(vertx, new JsonObject() .put("connectTimeout", Long.parseLong(System.getProperty("db.connectTimeout", "1"))) ); client.getConnection(sqlConnectionAsyncResult -> { if (sqlConnectionAsyncResult.failed()) { context.assertTrue(sqlConnectionAsyncResult.cause() instanceof ConnectionTimeoutedException); async.complete(); } else { context.fail("Should fail due to a connection timeout exception"); } }); }
@Test public void testQueryTimeout(TestContext context) { Async async = context.async(); client = createClient(vertx, new JsonObject() .put("queryTimeout", Long.parseLong(System.getProperty("db.queryTimeout", "1"))) ); client.getConnection(sqlConnectionAsyncResult -> { conn = sqlConnectionAsyncResult.result(); conn.query("SELECT " + sleepCommand(2), ar -> { if (ar.failed()) { context.assertTrue(ar.cause() instanceof TimeoutException); async.complete(); } else { context.fail("Should fail due to a connection timeout exception"); } }); }); }
@Ignore("Not implemented in driver yet, see https://github.com/mauricio/postgresql-async/issues/6") @Test public void testConnectionTimeout(TestContext context) { Async async = context.async(); client = createClient(vertx, new JsonObject() .put("connectTimeout", Long.parseLong(System.getProperty("db.connectTimeout", "1"))) ); client.getConnection(sqlConnectionAsyncResult -> { if (sqlConnectionAsyncResult.failed()) { context.assertTrue(sqlConnectionAsyncResult.cause() instanceof ConnectionTimeoutedException); async.complete(); } else { context.fail("Should fail due to a connection timeout exception"); } }); }
private void showEncoding(TestContext context, String charSetString, Handler<String> encodingHandler) { client = createClient(vertx, new JsonObject() .put("charset", charSetString) ); client.getConnection(sqlConnectionAsyncResult -> { ensureSuccess(context, sqlConnectionAsyncResult); conn = sqlConnectionAsyncResult.result(); conn.query(getEncodingStatement(), showEncodingAr -> { ensureSuccess(context, showEncodingAr); String encoding = getEncodingValueFromResults(showEncodingAr.result().getResults()); conn.close(connCloseAr -> { ensureSuccess(context, connCloseAr); conn = null; client.close(clientCloseAr -> { ensureSuccess(context, clientCloseAr); client = null; encodingHandler.handle(encoding); }); }); }); }); }
@Test public void testQueryTimeout(TestContext context) { Async async = context.async(); client = createClient(vertx, new JsonObject() .put("queryTimeout", Long.parseLong(System.getProperty("db.queryTimeout", "1"))) ); client.getConnection(sqlConnectionAsyncResult -> { conn = sqlConnectionAsyncResult.result(); conn.query("SELECT " + sleepCommand(2), ar -> { if (ar.failed()) { context.assertTrue(ar.cause() instanceof TimeoutException); async.complete(); } else { context.fail("Should fail due to a connection timeout exception"); } }); }); }
@Test public void testCharset(TestContext context) { Async async = context.async(); showEncoding(context, "iso-8859-1", encoding1 -> { showEncoding(context, "utf-8", encoding2 -> { context.assertNotEquals(encoding1, encoding2); async.complete(); }); }); }
@Ignore("Not implemented in driver yet, see https://github.com/mauricio/postgresql-async/issues/6") @Test public void testConnectionTimeout(TestContext context) { Async async = context.async(); client = createClient(vertx, new JsonObject() .put("connectTimeout", Long.parseLong(System.getProperty("db.connectTimeout", "1"))) ); client.getConnection(sqlConnectionAsyncResult -> { if (sqlConnectionAsyncResult.failed()) { context.assertTrue(sqlConnectionAsyncResult.cause() instanceof ConnectionTimeoutedException); async.complete(); } else { context.fail("Should fail due to a connection timeout exception"); } }); }
private void showEncoding(TestContext context, String charSetString, Handler<String> encodingHandler) { client = createClient(vertx, new JsonObject() .put("charset", charSetString) ); client.getConnection(sqlConnectionAsyncResult -> { ensureSuccess(context, sqlConnectionAsyncResult); conn = sqlConnectionAsyncResult.result(); conn.query(getEncodingStatement(), showEncodingAr -> { ensureSuccess(context, showEncodingAr); String encoding = getEncodingValueFromResults(showEncodingAr.result().getResults()); conn.close(connCloseAr -> { ensureSuccess(context, connCloseAr); conn = null; client.close(clientCloseAr -> { ensureSuccess(context, clientCloseAr); client = null; encodingHandler.handle(encoding); }); }); }); }); }
@Test public void testCharset(TestContext context) { Async async = context.async(); showEncoding(context, "iso-8859-1", encoding1 -> { showEncoding(context, "utf-8", encoding2 -> { context.assertNotEquals(encoding1, encoding2); async.complete(); }); }); }