use of com.ctrip.platform.dal.dao.task.DalRequestExecutor in project dal by ctripcorp.
the class DalRequestExecutorTest method testExecuteNullable.
@Test
public void testExecuteNullable() {
DalRequestExecutor test = new DalRequestExecutor();
TestDalRequest request = new TestDalRequest(null, new Integer[] { null });
DalHints hints = new DalHints();
try {
Integer result = test.execute(hints, request, true);
assertNull(result);
} catch (Exception e) {
fail();
}
try {
test.execute(hints, request, false);
fail();
} catch (Exception e) {
}
}
use of com.ctrip.platform.dal.dao.task.DalRequestExecutor in project dal by ctripcorp.
the class DalRequestExecutorTest method testExecuteNotCrossShard.
@Test
public void testExecuteNotCrossShard() {
DalRequestExecutor test = new DalRequestExecutor();
TestDalRequest request = new TestDalRequest(null, new Integer[] { 1 });
DalHints hints = new DalHints();
try {
Integer result = test.execute(hints, request);
assertEquals(1, result.intValue());
} catch (Exception e) {
fail();
}
}
use of com.ctrip.platform.dal.dao.task.DalRequestExecutor in project dal by ctripcorp.
the class DalRequestExecutorTest method testExecuteCrossShard.
@Test
public void testExecuteCrossShard() {
DalRequestExecutor test = new DalRequestExecutor();
TestDalRequest request = new TestDalRequest(null, new Integer[] { 1, 2 });
DalHints hints = new DalHints();
try {
Integer result = test.execute(hints, request);
assertEquals(3, result.intValue());
} catch (Exception e) {
fail();
}
}
use of com.ctrip.platform.dal.dao.task.DalRequestExecutor in project dal by ctripcorp.
the class DalRequestExecutorTest method testExecuteCallback.
@Test
public void testExecuteCallback() {
DalRequestExecutor test = new DalRequestExecutor();
TestDalRequest request = new TestDalRequest(null, new Integer[] { 1 });
DalHints hints = new DalHints();
DefaultResultCallback callback = new DefaultResultCallback();
try {
Integer result = test.execute(hints.callbackWith(callback), request, true);
assertNull(result);
assertEquals(1, ((Integer) hints.getAsyncResult().get()).intValue());
assertEquals(1, ((Integer) callback.getResult()).intValue());
} catch (Exception e) {
fail();
}
}
use of com.ctrip.platform.dal.dao.task.DalRequestExecutor in project dal by ctripcorp.
the class DalRequestExecutorTest method testExecuteFailByValidateAsync.
@Test
public void testExecuteFailByValidateAsync() {
DalRequestExecutor test = new DalRequestExecutor();
SQLException ex = new SQLException("Test");
TestDalRequest request = new TestDalRequest(ex, null);
DalHints hints = new DalHints().asyncExecution();
try {
assertNull(test.execute(hints, request));
Future<?> result = hints.getAsyncResult();
result.get();
fail();
} catch (SQLException | InterruptedException | ExecutionException e) {
assertEquals(ex, ((ExecutionException) e).getCause());
}
}
Aggregations