Search in sources :

Example 11 with FBManager

use of org.firebirdsql.management.FBManager in project jaybird by FirebirdSQL.

the class TestJnaDatabase method testBasicDetach.

@Test
public void testBasicDetach() throws Exception {
    FBManager fbManager = createFBManager();
    defaultDatabaseSetUp(fbManager);
    try {
        JnaDatabase db = factory.connect(connectionInfo);
        try {
            db.attach();
            db.close();
            assertFalse("Expected database not attached", db.isAttached());
        } finally {
            safelyClose(db);
        }
    } finally {
        defaultDatabaseTearDown(fbManager);
    }
}
Also used : FBManager(org.firebirdsql.management.FBManager) Test(org.junit.Test)

Example 12 with FBManager

use of org.firebirdsql.management.FBManager in project jaybird by FirebirdSQL.

the class TestJnaDatabase method doubleAttach.

@Test
public void doubleAttach() throws Exception {
    expectedException.expect(SQLException.class);
    expectedException.expectMessage(equalTo("Already attached to a database"));
    FBManager fbManager = createFBManager();
    defaultDatabaseSetUp(fbManager);
    try (JnaDatabase db = factory.connect(connectionInfo)) {
        db.attach();
        // Second attach should throw exception
        db.attach();
    } finally {
        defaultDatabaseTearDown(fbManager);
    }
}
Also used : FBManager(org.firebirdsql.management.FBManager) Test(org.junit.Test)

Example 13 with FBManager

use of org.firebirdsql.management.FBManager in project jaybird by FirebirdSQL.

the class TestJnaDatabase method testDetach_openTransactions.

@Test
public void testDetach_openTransactions() throws Exception {
    FBManager fbManager = createFBManager();
    defaultDatabaseSetUp(fbManager);
    try {
        JnaDatabase db = factory.connect(connectionInfo);
        FbTransaction transaction = null;
        try {
            db.attach();
            // Starting an active transaction
            transaction = getTransaction(db);
            expectedException.expect(allOf(errorCodeEquals(ISCConstants.isc_open_trans), message(startsWith(getFbMessage(ISCConstants.isc_open_trans, "1")))));
            db.close();
        } finally {
            if (transaction != null && transaction.getState() == TransactionState.ACTIVE) {
                transaction.commit();
            }
            safelyClose(db);
        }
    } finally {
        defaultDatabaseTearDown(fbManager);
    }
}
Also used : FBManager(org.firebirdsql.management.FBManager) FbTransaction(org.firebirdsql.gds.ng.FbTransaction) Test(org.junit.Test)

Example 14 with FBManager

use of org.firebirdsql.management.FBManager in project jaybird by FirebirdSQL.

the class TestJaybirdBlobBackupProblem method setUp.

@Before
public void setUp() throws Exception {
    GDSType gdsType = FBTestProperties.getGdsType();
    dbFactory = FBTestProperties.getFbDatabaseFactory();
    try {
        fbManager = new FBManager(gdsType);
        fbManager.setServer("localhost");
        fbManager.setPort(5066);
        fbManager.start();
        File dbFolder = temporaryFolder.newFolder("db");
        mAbsoluteBackupPath = new File(dbFolder, "testES01344.fbk").getAbsolutePath();
        mAbsoluteDatabasePath = new File(dbFolder, "testES01344.fdb").getAbsolutePath();
        fbManager.createDatabase(mAbsoluteDatabasePath, "SYSDBA", "masterkey");
    } catch (Exception e) {
        log.warn("exception in setup: ", e);
    }
}
Also used : FBManager(org.firebirdsql.management.FBManager) GDSType(org.firebirdsql.gds.impl.GDSType) File(java.io.File)

Example 15 with FBManager

use of org.firebirdsql.management.FBManager in project jaybird by FirebirdSQL.

the class TestSpecialEmbeddedServerUrls method testFBManagerWithRelativeDatabaseFile.

@Test
public void testFBManagerWithRelativeDatabaseFile() throws Exception {
    FBManager testFBManager = new FBManager(gdsType);
    testFBManager.setDropOnStop(true);
    try {
        testFBManager.start();
        testFBManager.createDatabase(mRelativeDatabasePath, "SYSDBA", "masterkey");
    } finally {
        testFBManager.stop();
    }
}
Also used : FBManager(org.firebirdsql.management.FBManager)

Aggregations

FBManager (org.firebirdsql.management.FBManager)26 Test (org.junit.Test)17 FbWireDatabase (org.firebirdsql.gds.ng.wire.FbWireDatabase)9 WireDatabaseConnection (org.firebirdsql.gds.ng.wire.WireDatabaseConnection)9 AbstractFbWireDatabase (org.firebirdsql.gds.ng.wire.AbstractFbWireDatabase)8 Connection (java.sql.Connection)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 SQLException (java.sql.SQLException)2 Properties (java.util.Properties)2 FBTestProperties (org.firebirdsql.common.FBTestProperties)2 ServiceRequestBuffer (org.firebirdsql.gds.ServiceRequestBuffer)2 FbConnectionProperties (org.firebirdsql.gds.ng.FbConnectionProperties)2 FBDriver (org.firebirdsql.jdbc.FBDriver)2 GDSType (org.firebirdsql.gds.impl.GDSType)1 FbTransaction (org.firebirdsql.gds.ng.FbTransaction)1 AbstractFbWireService (org.firebirdsql.gds.ng.wire.AbstractFbWireService)1 FbWireService (org.firebirdsql.gds.ng.wire.FbWireService)1 WireServiceConnection (org.firebirdsql.gds.ng.wire.WireServiceConnection)1