Search in sources :

Example 1 with SerialException

use of javax.sql.rowset.serial.SerialException in project jdk8u_jdk by JetBrains.

the class SerialExceptionTests method test05.

/*
     * Serialize a SerialException and make sure you can read it back properly
     */
@Test
public void test05() throws Exception {
    SerialException e = new SerialException(reason);
    SerialException ex1 = createSerializedException(e);
    assertTrue(ex1.getMessage().equals(reason) && ex1.getSQLState() == null && ex1.getCause() == null && ex1.getErrorCode() == 0);
    ;
}
Also used : SerialException(javax.sql.rowset.serial.SerialException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 2 with SerialException

use of javax.sql.rowset.serial.SerialException in project jdk8u_jdk by JetBrains.

the class SerialJavaObjectTests method test02.

/*
     * Validate that an getFields()s returns the same Field[] for the object
     * used to create the SerialJavaObject
     */
@Test
public void test02() throws Exception {
    SerialException e = new SerialException();
    SerialJavaObject sjo = new SerialJavaObject(e);
    Field[] f = e.getClass().getFields();
    assertTrue(Arrays.equals(f, sjo.getFields()));
    assertFalse(Arrays.equals("hello".getClass().getFields(), sjo.getFields()));
}
Also used : Field(java.lang.reflect.Field) SerialException(javax.sql.rowset.serial.SerialException) SerialJavaObject(javax.sql.rowset.serial.SerialJavaObject) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Example 3 with SerialException

use of javax.sql.rowset.serial.SerialException in project teiid by teiid.

the class TestClobValue method testReferencePersistenceError.

@SuppressWarnings("serial")
@Test
public void testReferencePersistenceError() throws Exception {
    // $NON-NLS-1$
    String testString = "this is test clob";
    SerialClob clob = new SerialClob(testString.toCharArray()) {

        @Override
        public Reader getCharacterStream() throws SerialException {
            throw new SerialException();
        }
    };
    ClobType cv = new ClobType(clob);
    cv.setReferenceStreamId(null);
    // now force to serialize
    ClobType read = UnitTestUtil.helpSerialize(cv);
    assertTrue(read.length() > 0);
    assertNotNull(read.getReferenceStreamId());
    assertNull(read.getReference());
}
Also used : SerialException(javax.sql.rowset.serial.SerialException) SerialClob(javax.sql.rowset.serial.SerialClob) Test(org.junit.Test)

Example 4 with SerialException

use of javax.sql.rowset.serial.SerialException in project open-kilda by telstra.

the class SamlConversionUtil method toUpdateSamlConfigEntity.

/**
 * To update saml config entity.
 *
 * @param samlConfigEntity the saml config entity
 * @param roleEntities the role entities
 * @param file the metadata file
 * @param name the provider name
 * @param url the metadata url
 * @param entityId the entityId
 * @param status the provider status
 * @param userCreation the userCreation
 * @param attribute the attribute
 * @return the requireManagerUpdateStatus
 */
public static boolean toUpdateSamlConfigEntity(SamlConfigEntity samlConfigEntity, Set<RoleEntity> roleEntities, MultipartFile file, String name, String url, String entityId, boolean status, boolean userCreation, String attribute) {
    Blob blob = null;
    boolean requireManagerUpdate = false;
    try {
        if (file != null) {
            byte[] bytes = file.getBytes();
            try {
                blob = new SerialBlob(bytes);
            } catch (SerialException e) {
                LOGGER.error("Error occurred while updating saml provider" + e);
            } catch (SQLException e) {
                LOGGER.error("Error occurred while updating saml provider" + e);
            }
            samlConfigEntity.setMetadata(blob);
            samlConfigEntity.setType(IConstants.ProviderType.FILE);
            requireManagerUpdate = true;
            samlConfigEntity.setUrl(null);
        } else if (url != null) {
            samlConfigEntity.setUrl(url);
            samlConfigEntity.setType(IConstants.ProviderType.URL);
            requireManagerUpdate = true;
            samlConfigEntity.setMetadata(null);
        }
        samlConfigEntity.setEntityId(entityId);
        if (userCreation) {
            samlConfigEntity.setUserCreation(true);
            if (!samlConfigEntity.getRoles().isEmpty()) {
                samlConfigEntity.getRoles().clear();
            }
            samlConfigEntity.getRoles().addAll(roleEntities);
        } else {
            samlConfigEntity.setRoles(null);
        }
        samlConfigEntity.setName(name);
        samlConfigEntity.setUserCreation(userCreation);
        samlConfigEntity.setAttribute(attribute);
        samlConfigEntity.setStatus(status);
    } catch (RequestValidationException e) {
        throw new RequestValidationException(e.getMessage());
    } catch (FileNotFoundException e) {
        LOGGER.error("Error occurred while updating saml provider" + e);
    } catch (IOException e) {
        LOGGER.error("Error occurred while updating saml provider" + e);
    }
    return requireManagerUpdate;
}
Also used : SerialBlob(javax.sql.rowset.serial.SerialBlob) Blob(java.sql.Blob) SerialException(javax.sql.rowset.serial.SerialException) SQLException(java.sql.SQLException) FileNotFoundException(java.io.FileNotFoundException) SerialBlob(javax.sql.rowset.serial.SerialBlob) IOException(java.io.IOException) RequestValidationException(org.usermanagement.exception.RequestValidationException)

Example 5 with SerialException

use of javax.sql.rowset.serial.SerialException in project jdk8u_jdk by JetBrains.

the class SerialExceptionTests method test03.

/*
     * Validate that the ordering of the returned Exceptions is correct using
     * for-each loop
     */
@Test
public void test03() {
    SerialException ex = new SerialException("Exception 1");
    ex.initCause(t1);
    SerialException ex1 = new SerialException("Exception 2");
    SerialException ex2 = new SerialException("Exception 3");
    ex2.initCause(t2);
    ex.setNextException(ex1);
    ex.setNextException(ex2);
    int num = 0;
    for (Throwable e : ex) {
        assertTrue(msgs[num++].equals(e.getMessage()));
    }
}
Also used : SerialException(javax.sql.rowset.serial.SerialException) Test(org.testng.annotations.Test) BaseTest(util.BaseTest)

Aggregations

SerialException (javax.sql.rowset.serial.SerialException)10 Test (org.testng.annotations.Test)6 BaseTest (util.BaseTest)6 SQLException (java.sql.SQLException)4 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 Blob (java.sql.Blob)2 SerialBlob (javax.sql.rowset.serial.SerialBlob)2 SerialClob (javax.sql.rowset.serial.SerialClob)2 BootException (com.github.mgramin.sqlboot.exceptions.BootException)1 SqlQuery (com.github.mgramin.sqlboot.sql.SqlQuery)1 SelectStatementParser (com.github.mgramin.sqlboot.sql.parser.SelectStatementParser)1 TemplateGenerator (com.github.mgramin.sqlboot.template.generator.TemplateGenerator)1 Field (java.lang.reflect.Field)1 Connection (java.sql.Connection)1 SimpleEntry (java.util.AbstractMap.SimpleEntry)1 Arrays.stream (java.util.Arrays.stream)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1