Package java.sql

Examples of java.sql.SQLIntegrityConstraintViolationException


     * @test java.sql.SQLIntegrityConstraintViolationException(String,
     *       Throwable)
     */
    public void test_Constructor_LStringLThrowable() {
        Throwable cause = new Exception("MYTHROWABLE");
        SQLIntegrityConstraintViolationException sQLIntegrityConstraintViolationException = new SQLIntegrityConstraintViolationException(
                "MYTESTSTRING", cause);
        assertNotNull(sQLIntegrityConstraintViolationException);
        assertEquals(
                "The reason of SQLIntegrityConstraintViolationException set and get should be equivalent",
                "MYTESTSTRING", sQLIntegrityConstraintViolationException
                        .getMessage());
        assertNull(
                "The SQLState of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getSQLState());
        assertEquals(
                "The error code of SQLIntegrityConstraintViolationException should be 0",
                sQLIntegrityConstraintViolationException.getErrorCode(), 0);
        assertEquals(
                "The cause of SQLIntegrityConstraintViolationException set and get should be equivalent",
                cause, sQLIntegrityConstraintViolationException.getCause());
    }
View Full Code Here


    /**
     * @test java.sql.SQLIntegrityConstraintViolationException(String,
     *       Throwable)
     */
    public void test_Constructor_LStringLThrowable_1() {
        SQLIntegrityConstraintViolationException sQLIntegrityConstraintViolationException = new SQLIntegrityConstraintViolationException(
                "MYTESTSTRING", (Throwable) null);
        assertNotNull(sQLIntegrityConstraintViolationException);
        assertEquals(
                "The reason of SQLIntegrityConstraintViolationException set and get should be equivalent",
                "MYTESTSTRING", sQLIntegrityConstraintViolationException
                        .getMessage());
        assertNull(
                "The SQLState of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getSQLState());
        assertEquals(
                "The error code of SQLIntegrityConstraintViolationException should be 0",
                sQLIntegrityConstraintViolationException.getErrorCode(), 0);
        assertNull(
                "The cause of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getCause());
    }
View Full Code Here

     * @test java.sql.SQLIntegrityConstraintViolationException(String,
     *       Throwable)
     */
    public void test_Constructor_LStringLThrowable_2() {
        Throwable cause = new Exception("MYTHROWABLE");
        SQLIntegrityConstraintViolationException sQLIntegrityConstraintViolationException = new SQLIntegrityConstraintViolationException(
                null, cause);
        assertNotNull(sQLIntegrityConstraintViolationException);
        assertNull(
                "The reason of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getMessage());
        assertNull(
                "The SQLState of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getSQLState());
        assertEquals(
                "The error code of SQLIntegrityConstraintViolationException should be 0",
                sQLIntegrityConstraintViolationException.getErrorCode(), 0);
    }
View Full Code Here

    /**
     * @test java.sql.SQLIntegrityConstraintViolationException(String,
     *       Throwable)
     */
    public void test_Constructor_LStringLThrowable_3() {
        SQLIntegrityConstraintViolationException sQLIntegrityConstraintViolationException = new SQLIntegrityConstraintViolationException(
                (String) null, (Throwable) null);
        assertNotNull(sQLIntegrityConstraintViolationException);
        assertNull(
                "The SQLState of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getSQLState());
        assertNull(
                "The reason of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getMessage());
        assertEquals(
                "The error code of SQLIntegrityConstraintViolationException should be 0",
                sQLIntegrityConstraintViolationException.getErrorCode(), 0);
        assertNull(
                "The cause of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getCause());
    }
View Full Code Here

     * @test java.sql.SQLIntegrityConstraintViolationException(String, String,
     *       Throwable)
     */
    public void test_Constructor_LStringLStringLThrowable() {
        Throwable cause = new Exception("MYTHROWABLE");
        SQLIntegrityConstraintViolationException sQLIntegrityConstraintViolationException = new SQLIntegrityConstraintViolationException(
                "MYTESTSTRING1", "MYTESTSTRING2", cause);
        assertNotNull(sQLIntegrityConstraintViolationException);
        assertEquals(
                "The SQLState of SQLIntegrityConstraintViolationException set and get should be equivalent",
                "MYTESTSTRING2", sQLIntegrityConstraintViolationException
                        .getSQLState());
        assertEquals(
                "The reason of SQLIntegrityConstraintViolationException set and get should be equivalent",
                "MYTESTSTRING1", sQLIntegrityConstraintViolationException
                        .getMessage());
        assertEquals(
                "The error code of SQLIntegrityConstraintViolationException should be 0",
                sQLIntegrityConstraintViolationException.getErrorCode(), 0);
        assertEquals(
                "The cause of SQLIntegrityConstraintViolationException set and get should be equivalent",
                cause, sQLIntegrityConstraintViolationException.getCause());
    }
View Full Code Here

    /**
     * @test java.sql.SQLIntegrityConstraintViolationException(String, String,
     *       Throwable)
     */
    public void test_Constructor_LStringLStringLThrowable_1() {
        SQLIntegrityConstraintViolationException sQLIntegrityConstraintViolationException = new SQLIntegrityConstraintViolationException(
                "MYTESTSTRING1", "MYTESTSTRING2", null);
        assertNotNull(sQLIntegrityConstraintViolationException);
        assertEquals(
                "The SQLState of SQLIntegrityConstraintViolationException set and get should be equivalent",
                "MYTESTSTRING2", sQLIntegrityConstraintViolationException
                        .getSQLState());
        assertEquals(
                "The reason of SQLIntegrityConstraintViolationException set and get should be equivalent",
                "MYTESTSTRING1", sQLIntegrityConstraintViolationException
                        .getMessage());
        assertEquals(
                "The error code of SQLIntegrityConstraintViolationException should be 0",
                sQLIntegrityConstraintViolationException.getErrorCode(), 0);
        assertNull(
                "The cause of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getCause());
    }
View Full Code Here

     * @test java.sql.SQLIntegrityConstraintViolationException(String, String,
     *       Throwable)
     */
    public void test_Constructor_LStringLStringLThrowable_2() {
        Throwable cause = new Exception("MYTHROWABLE");
        SQLIntegrityConstraintViolationException sQLIntegrityConstraintViolationException = new SQLIntegrityConstraintViolationException(
                "MYTESTSTRING", null, cause);
        assertNotNull(sQLIntegrityConstraintViolationException);
        assertNull(
                "The SQLState of SQLIntegrityConstraintViolationException should be null",
                sQLIntegrityConstraintViolationException.getSQLState());
        assertEquals(
                "The reason of SQLIntegrityConstraintViolationException set and get should be equivalent",
                "MYTESTSTRING", sQLIntegrityConstraintViolationException
                        .getMessage());
        assertEquals(
                "The error code of SQLIntegrityConstraintViolationException should be 0",
                sQLIntegrityConstraintViolationException.getErrorCode(), 0);
        assertEquals(
                "The cause of SQLIntegrityConstraintViolationException set and get should be equivalent",
                cause, sQLIntegrityConstraintViolationException.getCause());
    }
View Full Code Here

  public static SQLException newSQLFeatureNotSupportedException(String reason, String SQLState, int vendorCode) {
    return new SQLFeatureNotSupportedException(reason, SQLState, vendorCode);
  }

  public static SQLException newSQLIntegrityConstraintViolationException(String reason, String SQLState, int vendorCode) {
    return new SQLIntegrityConstraintViolationException(reason, SQLState, vendorCode);
  }
View Full Code Here

                        code, cause);
            }
        } else if (sqlstate.startsWith("22")) {
            return new SQLDataException(msg, sqlstate, code, cause);
        } else if (sqlstate.startsWith("23")) {
            return new SQLIntegrityConstraintViolationException(msg, sqlstate,
                    code, cause);
        } else if (sqlstate.startsWith("28")) {
            return new SQLInvalidAuthorizationSpecException(msg, sqlstate,
                    code, cause);
        } else if (sqlstate.startsWith("42") || sqlstate.startsWith("37")
View Full Code Here

    }
   
    @Test
    public void uniqueConstraintOrIndexViolation() throws Exception {
        final String msg = "initial gumph: unique constraint or index violation; further details";
        final SQLIntegrityConstraintViolationException ex = new SQLIntegrityConstraintViolationException(msg);
        String recognize = exceptionRecognizer.recognize(ex);
        assertThat(recognize, is("Data already exists<br/><br/>" + msg));
    }
View Full Code Here

TOP

Related Classes of java.sql.SQLIntegrityConstraintViolationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.