use of spoon.reflect.declaration.CtModule in project spoon by INRIA.
the class TestModule method testGetModuleAfterChangingItsName.
@Test
public void testGetModuleAfterChangingItsName() {
// contract: a module should be always available through ModuleFactory even after its name changed
final Launcher launcher = new Launcher();
CtModule module = launcher.getFactory().Module().getOrCreate("myModule");
module.setSimpleName("newName");
CtModule moduleNewName = launcher.getFactory().Module().getOrCreate("newName");
assertSame(module, moduleNewName);
}
use of spoon.reflect.declaration.CtModule in project spoon by INRIA.
the class TestModule method testMultipleModulesAndParents.
@Ignore
@Test
public void testMultipleModulesAndParents() {
// contract: Spoon is able to build a model with multiple modules
final Launcher launcher = new Launcher();
launcher.getEnvironment().setComplianceLevel(9);
// launcher.addModulePath("./src/test/resources/spoon/test/module/code-multiple-modules/foo");
// launcher.addModulePath("./src/test/resources/spoon/test/module/code-multiple-modules/bar");
launcher.addInputResource(MODULE_RESOURCES_PATH + "/code-multiple-modules");
launcher.run();
assertEquals(3, launcher.getModel().getAllModules().size());
CtType barclass = launcher.getFactory().Type().get("packbar.BarClass");
assertNotNull(barclass);
assertTrue(barclass.getParent() instanceof CtPackage);
CtPackage packBar = (CtPackage) barclass.getParent();
assertTrue(packBar.getParent() instanceof CtModule);
}
use of spoon.reflect.declaration.CtModule in project spoon by INRIA.
the class TestModule method testModuleInfoWithComments.
@Test
public void testModuleInfoWithComments() {
// contract: documentation on module-info elements should be managed
final Launcher launcher = new Launcher();
launcher.getEnvironment().setNoClasspath(true);
launcher.getEnvironment().setComplianceLevel(9);
launcher.getEnvironment().setCommentEnabled(true);
launcher.addInputResource(MODULE_RESOURCES_PATH + "/module_with_comments/module-info.java");
launcher.buildModel();
assertEquals(2, launcher.getModel().getAllModules().size());
CtModule module = launcher.getFactory().Module().getModule("module_with_comments");
assertNotNull(module);
assertTrue(module.isOpenModule());
List<CtComment> comments = module.getComments();
assertEquals(1, comments.size());
CtComment comment = comments.get(0);
assertEquals("This is the main module of the application", comment.getContent());
assertEquals(CtComment.CommentType.JAVADOC, comment.getCommentType());
assertEquals(3, module.getModuleDirectives().size());
CtModuleRequirement moduleRequirement = module.getRequiredModules().get(0);
comments = moduleRequirement.getComments();
assertEquals(1, comments.size());
comment = comments.get(0);
assertEquals("this is needed for logging stuff", comment.getContent());
assertEquals(CtComment.CommentType.INLINE, comment.getCommentType());
CtProvidedService providedService = module.getProvidedServices().get(0);
comments = providedService.getComments();
assertEquals(1, comments.size());
comment = comments.get(0);
assertEquals("A specific implementation", comment.getContent());
assertEquals(CtComment.CommentType.JAVADOC, comment.getCommentType());
CtUsedService usedService = module.getUsedServices().get(0);
comments = usedService.getComments();
assertEquals(1, comments.size());
comment = comments.get(0);
assertEquals("A simple implementation", comment.getContent());
assertEquals(CtComment.CommentType.BLOCK, comment.getCommentType());
}
Aggregations