private static final ModuleIdentifier MODULE_C = ModuleIdentifier.fromString("c");
private static final ModuleIdentifier MODULE_D = ModuleIdentifier.fromString("d");
@Test
public void testExportDependencies() throws Exception {
final TestModuleLoader moduleLoader = new TestModuleLoader();
ModuleSpec.Builder builder = ModuleSpec.build(MODULE_A);
builder.addDependency(DependencySpec.createModuleDependencySpec(MODULE_B, true, false));
moduleLoader.addModuleSpec(builder.create());
builder = ModuleSpec.build(MODULE_B);
builder.addDependency(DependencySpec.createModuleDependencySpec(MODULE_C, true, false));
builder.addDependency(DependencySpec.createModuleDependencySpec(MODULE_D));
moduleLoader.addModuleSpec(builder.create());
builder = ModuleSpec.build(MODULE_C);
moduleLoader.addModuleSpec(builder.create());
builder = ModuleSpec.build(MODULE_D);
moduleLoader.addModuleSpec(builder.create());
Module module = moduleLoader.loadModule(MODULE_A);
final Set<ModuleIdentifier> dependencyExports = new HashSet<ModuleIdentifier>();
getExportedModuleDeps(module, dependencyExports);
assertEquals(2, dependencyExports.size());
assertTrue(dependencyExports.contains(MODULE_B));
assertTrue(dependencyExports.contains(MODULE_C));
dependencyExports.clear();
module = moduleLoader.loadModule(MODULE_B);
getExportedModuleDeps(module, dependencyExports);
assertEquals(1, dependencyExports.size());
assertTrue(dependencyExports.contains(MODULE_C));
dependencyExports.clear();
module = moduleLoader.loadModule(MODULE_C);
getExportedModuleDeps(module, dependencyExports);
assertEquals(0, dependencyExports.size());
dependencyExports.clear();
module = moduleLoader.loadModule(MODULE_D);
getExportedModuleDeps(module, dependencyExports);
assertEquals(0, dependencyExports.size());
}