Search in sources :

Example 16 with ApplicationAssemblerAdapter

use of org.qi4j.bootstrap.ApplicationAssemblerAdapter in project qi4j-sdk by Qi4j.

the class MixinVisibilityTest method testMixinInLowerLayerIsNotVisible.

// @Test( expected= MixinTypeNotAvailableException.class )
public void testMixinInLowerLayerIsNotVisible() throws Exception {
    Energy4Java boot = new Energy4Java();
    Assembler[][][] assemblers = new Assembler[][][] { { // Layer 1
    { new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module A");
            module.objects(ObjectA.class);
        }
    } } }, { // Layer 2
    { new Assembler() {

        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.setName("Module B");
            module.transients(B1Composite.class).visibleIn(Visibility.layer);
        }
    } } } };
    Application app = boot.newApplication(new ApplicationAssemblerAdapter(assemblers) {
    });
    app.activate();
    ObjectA object = app.findModule("Layer 1", "Module ").newObject(ObjectA.class);
    assertEquals("ok", object.test1());
    assertEquals("abc", object.test2());
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) Application(org.qi4j.api.structure.Application) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter)

Example 17 with ApplicationAssemblerAdapter

use of org.qi4j.bootstrap.ApplicationAssemblerAdapter 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)

Aggregations

ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)17 Assembler (org.qi4j.bootstrap.Assembler)17 Energy4Java (org.qi4j.bootstrap.Energy4Java)17 Application (org.qi4j.api.structure.Application)10 Test (org.junit.Test)9 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)8 Before (org.junit.Before)5 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)5 Module (org.qi4j.api.structure.Module)2 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)1 UnitOfWorkFactory (org.qi4j.api.unitofwork.UnitOfWorkFactory)1 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)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