Search in sources :

Example 16 with Module

use of org.qi4j.api.structure.Module in project qi4j-sdk by Qi4j.

the class ModuleTest method givenFixture1WhenFindFromAnotherModuleThenCompositeTypeIsReturned.

@Test
public void givenFixture1WhenFindFromAnotherModuleThenCompositeTypeIsReturned() throws ClassNotFoundException, AssemblyException {
    Application app = givenFixture1();
    Module module = app.findModule("Layer 1", "Module 1").newTransient(TestComposite1.class).getModule();
    module.classLoader().loadClass(TestComposite2.class.getName());
}
Also used : Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 17 with Module

use of org.qi4j.api.structure.Module in project qi4j-sdk by Qi4j.

the class TypeToCompositeLookupTest method transientsAmbiguousDeclaration.

@Test
public void transientsAmbiguousDeclaration() throws ActivationException, AssemblyException {
    Module module = new SingletonAssembler() {

        @Override
        public void assemble(ModuleAssembly module) throws AssemblyException {
            module.transients(SomeOtherFoo.class, BasicFoo.class);
        }
    }.module();
    assertEquals(CATHEDRAL, module.newTransientBuilder(SomeOtherFoo.class).newInstance().bar());
    assertEquals(BAZAR, module.newTransientBuilder(BasicFoo.class).newInstance().bar());
    try {
        module.newTransientBuilder(Foo.class);
        fail("Ambiguous type exception not detected for Transients");
    } catch (AmbiguousTypeException expected) {
    }
}
Also used : ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) SingletonAssembler(org.qi4j.bootstrap.SingletonAssembler) Module(org.qi4j.api.structure.Module) AmbiguousTypeException(org.qi4j.api.composite.AmbiguousTypeException) Test(org.junit.Test)

Example 18 with Module

use of org.qi4j.api.structure.Module in project qi4j-sdk by Qi4j.

the class ModuleTest method givenFixture1WhenGetNameThenConfiguredNameIsReturned.

@Test
public void givenFixture1WhenGetNameThenConfiguredNameIsReturned() throws AssemblyException {
    Application app = givenFixture1();
    Module module = app.findModule("Layer 1", "Module 1").newTransient(TestComposite1.class).getModule();
    assertThat("module name is correct", module.name(), equalTo("Module 1"));
}
Also used : Module(org.qi4j.api.structure.Module) Application(org.qi4j.api.structure.Application) Test(org.junit.Test)

Example 19 with Module

use of org.qi4j.api.structure.Module 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 20 with Module

use of org.qi4j.api.structure.Module 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)

Aggregations

Module (org.qi4j.api.structure.Module)41 Test (org.junit.Test)28 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)18 Application (org.qi4j.api.structure.Application)17 AssemblyException (org.qi4j.bootstrap.AssemblyException)16 SingletonAssembler (org.qi4j.bootstrap.SingletonAssembler)15 ArrayList (java.util.ArrayList)6 Energy4Java (org.qi4j.bootstrap.Energy4Java)6 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)5 UnitOfWorkFactory (org.qi4j.api.unitofwork.UnitOfWorkFactory)5 AmbiguousTypeException (org.qi4j.api.composite.AmbiguousTypeException)4 EntityDescriptor (org.qi4j.api.entity.EntityDescriptor)4 EntityTypeNotFoundException (org.qi4j.api.unitofwork.EntityTypeNotFoundException)4 Assembler (org.qi4j.bootstrap.Assembler)4 HashMap (java.util.HashMap)3 List (java.util.List)3 JSONException (org.json.JSONException)3 JSONObject (org.json.JSONObject)3 JSONTokener (org.json.JSONTokener)3 AssociationDescriptor (org.qi4j.api.association.AssociationDescriptor)3