Search in sources :

Example 1 with ClientModuleFactory

use of io.crnk.client.module.ClientModuleFactory in project crnk-framework by crnk-project.

the class ValidationClientModuleFactoryTest method test.

@Test
public void test() {
    ServiceLoader<ClientModuleFactory> loader = ServiceLoader.load(ClientModuleFactory.class);
    Iterator<ClientModuleFactory> iterator = loader.iterator();
    Set<Class> moduleClasses = new HashSet<>();
    while (iterator.hasNext()) {
        ClientModuleFactory moduleFactory = iterator.next();
        Module module = moduleFactory.create();
        moduleClasses.add(module.getClass());
    }
    Assert.assertEquals(2, moduleClasses.size());
    Assert.assertTrue(moduleClasses.contains(ValidationModule.class));
    Assert.assertTrue(moduleClasses.contains(MetaModule.class));
}
Also used : ClientModuleFactory(io.crnk.client.module.ClientModuleFactory) Module(io.crnk.core.module.Module) MetaModule(io.crnk.meta.MetaModule) ValidationModule(io.crnk.validation.ValidationModule) ValidationModule(io.crnk.validation.ValidationModule) MetaModule(io.crnk.meta.MetaModule) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with ClientModuleFactory

use of io.crnk.client.module.ClientModuleFactory in project crnk-framework by crnk-project.

the class CrnkClient method findModules.

/**
 * Finds and registers modules on the classpath trough the use of java.util.ServiceLoader.
 * Each module can register itself for lookup by registering a ClientModuleFactory.
 */
public void findModules() {
    ServiceLoader<ClientModuleFactory> loader = ServiceLoader.load(ClientModuleFactory.class);
    Iterator<ClientModuleFactory> iterator = loader.iterator();
    while (iterator.hasNext()) {
        ClientModuleFactory factory = iterator.next();
        Module module = factory.create();
        addModule(module);
    }
}
Also used : ClientModuleFactory(io.crnk.client.module.ClientModuleFactory) Module(io.crnk.core.module.Module) JacksonModule(io.crnk.core.engine.internal.jackson.JacksonModule) ClientModule(io.crnk.client.module.ClientModule)

Example 3 with ClientModuleFactory

use of io.crnk.client.module.ClientModuleFactory in project crnk-framework by crnk-project.

the class JpaClientModuleFactoryTest method test.

@Test
public void test() {
    ServiceLoader<ClientModuleFactory> loader = ServiceLoader.load(ClientModuleFactory.class);
    Iterator<ClientModuleFactory> iterator = loader.iterator();
    Set<Class> moduleClasses = new HashSet<>();
    while (iterator.hasNext()) {
        ClientModuleFactory moduleFactory = iterator.next();
        Module module = moduleFactory.create();
        moduleClasses.add(module.getClass());
    }
    Assert.assertEquals(2, moduleClasses.size());
    Assert.assertTrue(moduleClasses.contains(JpaModule.class));
    Assert.assertTrue(moduleClasses.contains(MetaModule.class));
}
Also used : ClientModuleFactory(io.crnk.client.module.ClientModuleFactory) JpaModule(io.crnk.jpa.JpaModule) Module(io.crnk.core.module.Module) MetaModule(io.crnk.meta.MetaModule) MetaModule(io.crnk.meta.MetaModule) HashSet(java.util.HashSet) JpaModule(io.crnk.jpa.JpaModule) Test(org.junit.Test)

Example 4 with ClientModuleFactory

use of io.crnk.client.module.ClientModuleFactory in project crnk-framework by crnk-project.

the class SecurityClientModuleFactoryTest method test.

@Test
public void test() {
    ServiceLoader<ClientModuleFactory> loader = ServiceLoader.load(ClientModuleFactory.class);
    Iterator<ClientModuleFactory> iterator = loader.iterator();
    Assert.assertTrue(iterator.hasNext());
    ClientModuleFactory moduleFactory = iterator.next();
    Assert.assertFalse(iterator.hasNext());
    Module module = moduleFactory.create();
    Assert.assertTrue(module instanceof SecurityModule);
}
Also used : ClientModuleFactory(io.crnk.client.module.ClientModuleFactory) Module(io.crnk.core.module.Module) Test(org.junit.Test)

Example 5 with ClientModuleFactory

use of io.crnk.client.module.ClientModuleFactory in project crnk-framework by crnk-project.

the class MetaClientModuleFactoryTest method test.

@Test
public void test() {
    ServiceLoader<ClientModuleFactory> loader = ServiceLoader.load(ClientModuleFactory.class);
    Iterator<ClientModuleFactory> iterator = loader.iterator();
    Assert.assertTrue(iterator.hasNext());
    ClientModuleFactory moduleFactory = iterator.next();
    Assert.assertFalse(iterator.hasNext());
    Module module = moduleFactory.create();
    Assert.assertTrue(module instanceof MetaModule);
}
Also used : ClientModuleFactory(io.crnk.client.module.ClientModuleFactory) Module(io.crnk.core.module.Module) Test(org.junit.Test)

Aggregations

ClientModuleFactory (io.crnk.client.module.ClientModuleFactory)5 Module (io.crnk.core.module.Module)5 Test (org.junit.Test)4 MetaModule (io.crnk.meta.MetaModule)2 HashSet (java.util.HashSet)2 ClientModule (io.crnk.client.module.ClientModule)1 JacksonModule (io.crnk.core.engine.internal.jackson.JacksonModule)1 JpaModule (io.crnk.jpa.JpaModule)1 ValidationModule (io.crnk.validation.ValidationModule)1