Search in sources :

Example 1 with SimpleTemplate

use of spoon.test.template.testclasses.SimpleTemplate in project spoon by INRIA.

the class TemplateTest method testSimpleTemplate.

@Test
public void testSimpleTemplate() {
    Launcher spoon = new Launcher();
    spoon.addTemplateResource(new FileSystemFile("./src/test/java/spoon/test/template/testclasses/SimpleTemplate.java"));
    spoon.buildModel();
    Factory factory = spoon.getFactory();
    CtClass<?> testSimpleTpl = factory.Class().create("TestSimpleTpl");
    new SimpleTemplate("Hello world").apply(testSimpleTpl);
    Set<CtMethod<?>> listMethods = testSimpleTpl.getMethods();
    assertEquals(0, testSimpleTpl.getMethodsByName("apply").size());
    assertEquals(1, listMethods.size());
}
Also used : SimpleTemplate(spoon.test.template.testclasses.SimpleTemplate) Launcher(spoon.Launcher) Factory(spoon.reflect.factory.Factory) FileSystemFile(spoon.support.compiler.FileSystemFile) CtMethod(spoon.reflect.declaration.CtMethod) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Launcher (spoon.Launcher)1 CtMethod (spoon.reflect.declaration.CtMethod)1 Factory (spoon.reflect.factory.Factory)1 FileSystemFile (spoon.support.compiler.FileSystemFile)1 SimpleTemplate (spoon.test.template.testclasses.SimpleTemplate)1