use of org.firebirdsql.gds.ng.wire.WireDatabaseConnection in project jaybird by FirebirdSQL.
the class TestV10Database method testBasicCreateAndDrop.
/**
* Tests creating and subsequently dropping a database
*/
@Test
public void testBasicCreateAndDrop() throws Exception {
IConnectionProperties connectionProperties = getConnectionInfo();
connectionProperties.getExtraDatabaseParameters().addArgument(ISCConstants.isc_dpb_sql_dialect, 3);
File dbFile = new File(connectionProperties.getAttachObjectName());
try (WireDatabaseConnection gdsConnection = new WireDatabaseConnection(connectionProperties, EncodingFactory.getPlatformDefault(), getProtocolCollection())) {
gdsConnection.socketConnect();
FbWireDatabase db = gdsConnection.identify();
assertEquals("Unexpected FbWireDatabase implementation", getExpectedDatabaseType(), db.getClass());
db.createDatabase();
assertTrue("Database should be attached after create", db.isAttached());
assertTrue("Connection should be connected after create", gdsConnection.isConnected());
assertTrue("Expected database file to exist (NOTE: only works on localhost)", dbFile.exists() || !FBTestProperties.DB_SERVER_URL.equalsIgnoreCase("localhost"));
db.dropDatabase();
assertFalse(gdsConnection.isConnected());
assertFalse(dbFile.exists());
} finally {
if (dbFile.exists()) {
dbFile.delete();
}
}
}
use of org.firebirdsql.gds.ng.wire.WireDatabaseConnection 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.WireDatabaseConnection 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.WireDatabaseConnection 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.WireDatabaseConnection in project jaybird by FirebirdSQL.
the class TestV10Statement method createDatabase.
@Override
protected final FbDatabase createDatabase() throws SQLException {
WireDatabaseConnection gdsConnection = new WireDatabaseConnection(connectionInfo, EncodingFactory.getPlatformDefault(), getProtocolCollection());
gdsConnection.socketConnect();
return gdsConnection.identify();
}
Aggregations