use of org.firebirdsql.gds.ng.wire.FbWireDatabase in project jaybird by FirebirdSQL.
the class TestV10Database method testExecuteImmediate_createDatabase.
// TODO Investigate why this doesn't work in wire protocol, but works in native
@Ignore("Test not working")
@Test
public void testExecuteImmediate_createDatabase() throws Exception {
try (WireDatabaseConnection gdsConnection = createConnection()) {
gdsConnection.socketConnect();
FbWireDatabase db = gdsConnection.identify();
assertEquals("Unexpected FbWireDatabase implementation", getExpectedDatabaseType(), db.getClass());
String createDb = String.format("CREATE DATABASE '%s' USER '%s' PASSWORD '%s'", getDatabasePath(), DB_USER, DB_PASSWORD);
db.executeImmediate(createDb, null);
assertTrue("Expected to be attached after create database", db.isAttached());
db.dropDatabase();
} finally {
new File(getDatabasePath()).delete();
}
}
use of org.firebirdsql.gds.ng.wire.FbWireDatabase in project jaybird by FirebirdSQL.
the class TestV10Database method testAttach_DoubleAttach.
@Test
public void testAttach_DoubleAttach() throws Exception {
expectedException.expect(SQLException.class);
expectedException.expectMessage(equalTo("Already attached to a database"));
FBManager fbManager = createFBManager();
defaultDatabaseSetUp(fbManager);
try (WireDatabaseConnection gdsConnection = createConnection()) {
gdsConnection.socketConnect();
try (FbWireDatabase db = gdsConnection.identify()) {
assertEquals("Unexpected FbWireDatabase implementation", getExpectedDatabaseType(), db.getClass());
db.attach();
// Second attach should throw exception
db.attach();
}
} finally {
defaultDatabaseTearDown(fbManager);
}
}
use of org.firebirdsql.gds.ng.wire.FbWireDatabase in project jaybird by FirebirdSQL.
the class TestV10Database method testDetach_NotAttached.
@Test
public void testDetach_NotAttached() throws Exception {
FBManager fbManager = createFBManager();
defaultDatabaseSetUp(fbManager);
try (WireDatabaseConnection gdsConnection = createConnection()) {
gdsConnection.socketConnect();
FbWireDatabase db = gdsConnection.identify();
assertEquals("Unexpected FbWireDatabase implementation", getExpectedDatabaseType(), db.getClass());
// Detach for connected but not attached should work
db.close();
assertFalse("Expected connection closed after detach", gdsConnection.isConnected());
} finally {
defaultDatabaseTearDown(fbManager);
}
}
use of org.firebirdsql.gds.ng.wire.FbWireDatabase in project jaybird by FirebirdSQL.
the class TestV10InputBlob method testDoubleOpen.
/**
* Tests double open 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)));
final int testId = 1;
final byte[] baseContent = generateBaseContent();
final int requiredSize = 256;
populateBlob(testId, baseContent, requiredSize);
try (FbWireDatabase db = createDatabaseConnection()) {
try {
long blobId = getBlobId(testId, db);
final FbBlob blob = db.createBlobForInput(transaction, null, blobId);
blob.open();
// Double open
blob.open();
} finally {
if (transaction != null)
transaction.commit();
}
}
}
use of org.firebirdsql.gds.ng.wire.FbWireDatabase in project jaybird by FirebirdSQL.
the class TestV10InputBlob method testBlobSeek_segmented.
/**
* Tests absolute seek on a segmented blob. Expectation: fails with an exception
*/
@Test
public void testBlobSeek_segmented() throws Exception {
final int testId = 1;
final byte[] baseContent = generateBaseContent();
// Use sufficiently large value so that multiple segments are used
final int requiredSize = 4 * Short.MAX_VALUE;
populateBlob(testId, baseContent, requiredSize);
try (FbWireDatabase db = createDatabaseConnection()) {
try {
long blobId = getBlobId(testId, db);
// NOTE: What matters is if the blob on the server is stream or segment
final FbBlob blob = db.createBlobForInput(transaction, null, blobId);
blob.open();
int offset = baseContent.length / 2;
expectedException.expect(SQLException.class);
expectedException.expect(allOf(errorCodeEquals(ISCConstants.isc_bad_segstr_type), message(startsWith(getFbMessage(ISCConstants.isc_bad_segstr_type)))));
blob.seek(offset, FbBlob.SeekMode.ABSOLUTE);
} finally {
if (transaction != null)
transaction.commit();
}
}
}
Aggregations