Search in sources :

Example 1 with UnitOfWorkFactory

use of org.qi4j.api.unitofwork.UnitOfWorkFactory in project qi4j-sdk by Qi4j.

the class Qi95IssueTest method canCreateAndQueryWithInMemoryRdfWithJdbm.

@Test
public void canCreateAndQueryWithInMemoryRdfWithJdbm() throws Exception {
    Application application = createApplication(inMemoryRdf, jdbmStore, domain);
    try {
        application.activate();
        Module domain = application.findModule("Domain", "Domain");
        UnitOfWorkFactory unitOfWorkFactory = domain;
        createABunchOfStuffAndDoQueries(unitOfWorkFactory, domain);
    } finally {
        application.passivate();
    }
}
Also used : UnitOfWorkFactory(org.qi4j.api.unitofwork.UnitOfWorkFactory) Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 2 with UnitOfWorkFactory

use of org.qi4j.api.unitofwork.UnitOfWorkFactory in project qi4j-sdk by Qi4j.

the class Qi95IssueTest method canCreateAndQueryWithNativeRdfWithInMemoryStore.

@Test
public void canCreateAndQueryWithNativeRdfWithInMemoryStore() throws Exception {
    Application application = createApplication(nativeRdf, inMemoryStore, domain);
    try {
        application.activate();
        Module domain = application.findModule("Domain", "Domain");
        UnitOfWorkFactory unitOfWorkFactory = domain;
        createABunchOfStuffAndDoQueries(unitOfWorkFactory, domain);
    } finally {
        application.passivate();
    }
}
Also used : UnitOfWorkFactory(org.qi4j.api.unitofwork.UnitOfWorkFactory) Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 3 with UnitOfWorkFactory

use of org.qi4j.api.unitofwork.UnitOfWorkFactory in project qi4j-sdk by Qi4j.

the class PostgreSQLEntityStorePerformanceTest method cleanUp.

@Override
protected void cleanUp() throws Exception {
    try {
        super.cleanUp();
    } finally {
        Energy4Java qi4j = new Energy4Java();
        Assembler[][][] assemblers = new Assembler[][][] { { { createAssembler() } } };
        Application application = qi4j.newApplication(new ApplicationAssemblerAdapter(assemblers) {
        });
        application.activate();
        Module moduleInstance = application.findModule("Layer 1", "config");
        UnitOfWorkFactory uowf = moduleInstance;
        UnitOfWork uow = uowf.newUnitOfWork();
        try {
            SQLConfiguration config = uow.get(SQLConfiguration.class, PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY);
            // TODO fix AbstractEntityStorePerformanceTest to extend from AbstractQi4jTest
            // SQLUtil.getConnection( this.serviceLocator );
            Connection connection = null;
            String schemaName = config.schemaName().get();
            if (schemaName == null) {
                schemaName = SQLs.DEFAULT_SCHEMA_NAME;
            }
            Statement stmt = null;
            try {
                stmt = connection.createStatement();
                stmt.execute(String.format("DELETE FROM %s." + SQLs.TABLE_NAME, schemaName));
                connection.commit();
            } finally {
                SQLUtil.closeQuietly(stmt);
            }
        } finally {
            uow.discard();
        }
    }
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Statement(java.sql.Statement) Connection(java.sql.Connection) Energy4Java(org.qi4j.bootstrap.Energy4Java) UnitOfWorkFactory(org.qi4j.api.unitofwork.UnitOfWorkFactory) SQLConfiguration(org.qi4j.library.sql.common.SQLConfiguration) DBCPDataSourceServiceAssembler(org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler) PostgreSQLEntityStoreAssembler(org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler) Assembler(org.qi4j.bootstrap.Assembler) DataSourceAssembler(org.qi4j.library.sql.assembly.DataSourceAssembler) Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter)

Example 4 with UnitOfWorkFactory

use of org.qi4j.api.unitofwork.UnitOfWorkFactory in project qi4j-sdk by Qi4j.

the class Qi95IssueTest method canCreateAndQueryWithNativeRdfAndJdbm.

@Test
public void canCreateAndQueryWithNativeRdfAndJdbm() throws Exception {
    Application application = createApplication(nativeRdf, jdbmStore, domain);
    try {
        application.activate();
        Module domain = application.findModule("Domain", "Domain");
        UnitOfWorkFactory unitOfWorkFactory = domain;
        createABunchOfStuffAndDoQueries(unitOfWorkFactory, domain);
    } finally {
        application.passivate();
    }
}
Also used : UnitOfWorkFactory(org.qi4j.api.unitofwork.UnitOfWorkFactory) Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 5 with UnitOfWorkFactory

use of org.qi4j.api.unitofwork.UnitOfWorkFactory in project qi4j-sdk by Qi4j.

the class Qi95IssueTest method canCreateAndQueryWithAllInMemory.

@Test
public void canCreateAndQueryWithAllInMemory() throws Exception {
    Application application = createApplication(inMemoryRdf, inMemoryStore, domain);
    try {
        application.activate();
        Module domain = application.findModule("Domain", "Domain");
        UnitOfWorkFactory unitOfWorkFactory = domain;
        createABunchOfStuffAndDoQueries(unitOfWorkFactory, domain);
    } finally {
        application.passivate();
    }
}
Also used : UnitOfWorkFactory(org.qi4j.api.unitofwork.UnitOfWorkFactory) Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Aggregations

Application (org.qi4j.api.structure.Application)5 Module (org.qi4j.api.structure.Module)5 UnitOfWorkFactory (org.qi4j.api.unitofwork.UnitOfWorkFactory)5 Test (org.junit.Test)4 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)1 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)1 Assembler (org.qi4j.bootstrap.Assembler)1 Energy4Java (org.qi4j.bootstrap.Energy4Java)1 PostgreSQLEntityStoreAssembler (org.qi4j.entitystore.sql.assembly.PostgreSQLEntityStoreAssembler)1 DataSourceAssembler (org.qi4j.library.sql.assembly.DataSourceAssembler)1 SQLConfiguration (org.qi4j.library.sql.common.SQLConfiguration)1 DBCPDataSourceServiceAssembler (org.qi4j.library.sql.dbcp.DBCPDataSourceServiceAssembler)1