Search in sources :

Example 26 with FbWireDatabase

use of org.firebirdsql.gds.ng.wire.FbWireDatabase in project jaybird by FirebirdSQL.

the class TestV10OutputBlob method testIsEof_afterClose.

/**
 * Test if blob is eof after close.
 */
@Test
public void testIsEof_afterClose() throws Exception {
    try (FbWireDatabase db = createDatabaseConnection()) {
        final FbTransaction transaction = getTransaction(db);
        try {
            FbBlob blob = db.createBlobForOutput(transaction, null);
            assumeTrue("Output blob before open should be eof", blob.isEof());
            blob.open();
            blob.close();
            assertTrue("Output blob after close should be eof", blob.isEof());
        } finally {
            transaction.commit();
        }
    }
}
Also used : FbWireDatabase(org.firebirdsql.gds.ng.wire.FbWireDatabase) FbTransaction(org.firebirdsql.gds.ng.FbTransaction) FbBlob(org.firebirdsql.gds.ng.FbBlob) Test(org.junit.Test)

Example 27 with FbWireDatabase

use of org.firebirdsql.gds.ng.wire.FbWireDatabase in project jaybird by FirebirdSQL.

the class TestV10OutputBlob method testDoubleOpen.

/**
 * Test double open is not allowed.
 */
@Test
public void testDoubleOpen() throws Exception {
    expectedException.expect(SQLNonTransientException.class);
    expectedException.expect(allOf(errorCodeEquals(ISCConstants.isc_no_segstr_close), fbMessageStartsWith(ISCConstants.isc_no_segstr_close)));
    try (FbWireDatabase db = createDatabaseConnection()) {
        final FbTransaction transaction = getTransaction(db);
        try {
            final FbBlob blob = db.createBlobForOutput(transaction, null);
            blob.open();
            blob.open();
        } finally {
            transaction.commit();
        }
    }
}
Also used : FbWireDatabase(org.firebirdsql.gds.ng.wire.FbWireDatabase) FbTransaction(org.firebirdsql.gds.ng.FbTransaction) FbBlob(org.firebirdsql.gds.ng.FbBlob) Test(org.junit.Test)

Aggregations

FbWireDatabase (org.firebirdsql.gds.ng.wire.FbWireDatabase)27 Test (org.junit.Test)23 WireDatabaseConnection (org.firebirdsql.gds.ng.wire.WireDatabaseConnection)13 FbBlob (org.firebirdsql.gds.ng.FbBlob)11 AbstractFbWireDatabase (org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase)11 FBManager (org.firebirdsql.management.FBManager)9 FbTransaction (org.firebirdsql.gds.ng.FbTransaction)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 SQLException (java.sql.SQLException)2 IOException (java.io.IOException)1 SQLNonTransientException (java.sql.SQLNonTransientException)1 BlobParameterBuffer (org.firebirdsql.gds.BlobParameterBuffer)1 DatatypeCoder (org.firebirdsql.gds.ng.DatatypeCoder)1 FbExceptionBuilder (org.firebirdsql.gds.ng.FbExceptionBuilder)1 FbStatement (org.firebirdsql.gds.ng.FbStatement)1 StatementState (org.firebirdsql.gds.ng.StatementState)1 FieldValue (org.firebirdsql.gds.ng.fields.FieldValue)1 SimpleStatementListener (org.firebirdsql.gds.ng.wire.SimpleStatementListener)1 Ignore (org.junit.Ignore)1