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));
}
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);
}
}
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));
}
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);
}
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);
}
Aggregations