下面列出了怎么用java.sql.SQLIntegrityConstraintViolationException的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException("Exception 1", t1);
SQLIntegrityConstraintViolationException ex1 =
new SQLIntegrityConstraintViolationException("Exception 2");
SQLIntegrityConstraintViolationException ex2 =
new SQLIntegrityConstraintViolationException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException("Exception 1", t1);
SQLIntegrityConstraintViolationException ex1 =
new SQLIntegrityConstraintViolationException("Exception 2");
SQLIntegrityConstraintViolationException ex2 =
new SQLIntegrityConstraintViolationException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException("Exception 1", t1);
SQLIntegrityConstraintViolationException ex1 =
new SQLIntegrityConstraintViolationException("Exception 2");
SQLIntegrityConstraintViolationException ex2 =
new SQLIntegrityConstraintViolationException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException("Exception 1", t1);
SQLIntegrityConstraintViolationException ex1 =
new SQLIntegrityConstraintViolationException("Exception 2");
SQLIntegrityConstraintViolationException ex2 =
new SQLIntegrityConstraintViolationException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException("Exception 1", t1);
SQLIntegrityConstraintViolationException ex1 =
new SQLIntegrityConstraintViolationException("Exception 2");
SQLIntegrityConstraintViolationException ex2 =
new SQLIntegrityConstraintViolationException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using for-each loop
*/
@Test
public void test11() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException("Exception 1", t1);
SQLIntegrityConstraintViolationException ex1 =
new SQLIntegrityConstraintViolationException("Exception 2");
SQLIntegrityConstraintViolationException ex2 =
new SQLIntegrityConstraintViolationException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/**
* Validate that the ordering of the returned Exceptions is correct
* using traditional while loop
*/
@Test
public void test12() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException("Exception 1", t1);
SQLIntegrityConstraintViolationException ex1 =
new SQLIntegrityConstraintViolationException("Exception 2");
SQLIntegrityConstraintViolationException ex2 =
new SQLIntegrityConstraintViolationException("Exception 3", t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
SQLException sqe = ex;
while (sqe != null) {
assertTrue(msgs[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextException();
}
}
@Test
public void whenAlreadyExists() throws Exception {
// given
FixtureScript fs = new DocFragment_tearDown();
fixtureScripts.runFixtureScript(fs, null);
transactionService.nextTransaction();
final DocFragmentData random = fakeDataService.enums().anyOf(DocFragmentData.class);
random.createWith(repository);
transactionService.nextTransaction();
// then
expectedExceptions.expectCause(causedBy(SQLIntegrityConstraintViolationException.class));
// when
random.createWith(repository);
transactionService.nextTransaction();
}
@Test(expectedExceptions = SQLIntegrityConstraintViolationException.class)
public void testUpgradeVersion4WithNonUniqueConfigNameAndTypeAdded() throws Exception {
super.createOrUpgradeSchema(4);
super.addConnectorB();
// try loading duplicate config names in version 4 and it should throw an
// exception
super.loadNonUniqueConfigNameTypeInVersion4();
}
/**
* Create SQLIntegrityConstraintViolationException and setting all objects to null
*/
@Test
public void test() {
SQLIntegrityConstraintViolationException e =
new SQLIntegrityConstraintViolationException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException with no-arg constructor
*/
@Test
public void test1() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with no-arg constructor
*/
@Test
public void test1() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
public void setActivityCompletionTime(ActivityInstance ai) throws SQLException {
Long elapsedTime = getActivityElapsedTime0(ai.getId());
try {
setElapsedTime0(OwnerType.ACTIVITY_INSTANCE, ai.getId(), elapsedTime);
} catch (SQLIntegrityConstraintViolationException ex) {
// activity timing captured previously
}
}
/**
* Create SQLIntegrityConstraintViolationException with message, and SQLState
*/
@Test
public void test3() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException and setting all objects to null
*/
@Test
public void test() {
SQLIntegrityConstraintViolationException e =
new SQLIntegrityConstraintViolationException(null,
null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException with message, and Throwable
*/
@Test
public void test7() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with null Throwable
*/
@Test
public void test8() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException((Throwable)null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException with message
*/
@Test
public void test2() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLIntegrityConstraintViolationException and make sure
* you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLIntegrityConstraintViolationException e =
new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
SQLIntegrityConstraintViolationException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException with no-arg constructor
*/
@Test
public void test1() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with no-arg constructor
*/
@Test
public void test1() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
@Test(expectedExceptions = SQLIntegrityConstraintViolationException.class)
public void testUpgradeVersion4WithNonUniqueJobNameFailure() throws Exception {
super.createOrUpgradeSchema(4);
// try loading duplicate job names in version 4 and it should throw an
// exception
super.loadNonUniqueJobsInVersion4();
}
/**
* Create SQLIntegrityConstraintViolationException with message, SQLState, and error code
*/
@Test
public void test4() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
/**
* Create SQLIntegrityConstraintViolationException with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with message, and Throwable
*/
@Test
public void test7() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(reason, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Create SQLIntegrityConstraintViolationException with Throwable
*/
@Test
public void test9() {
SQLIntegrityConstraintViolationException ex =
new SQLIntegrityConstraintViolationException(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
/**
* Serialize a SQLIntegrityConstraintViolationException and make sure
* you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLIntegrityConstraintViolationException e =
new SQLIntegrityConstraintViolationException(reason, state, errorCode, t);
SQLIntegrityConstraintViolationException ex1 =
createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}