use of spoon.test.api.testclasses.Bar in project spoon by INRIA.
the class APITest method testAddProcessorMethodInSpoonAPI.
@Test
public void testAddProcessorMethodInSpoonAPI() throws Exception {
final SpoonAPI launcher = new Launcher();
launcher.addInputResource("./src/test/java/spoon/test/api/testclasses");
launcher.setSourceOutputDirectory("./target/spooned");
final AwesomeProcessor processor = new AwesomeProcessor();
launcher.addProcessor(processor);
launcher.run();
assertEquals(1, processor.getElements().size());
final CtClass<Bar> actual = processor.getElements().get(0);
assertEquals(2, actual.getMethods().size());
assertNotNull(actual.getMethodsByName("prepareMojito").get(0));
assertNotNull(actual.getMethodsByName("makeMojito").get(0));
}
use of spoon.test.api.testclasses.Bar in project spoon by INRIA.
the class APITest method testInvalidateCacheOfCompiler.
@Test
public void testInvalidateCacheOfCompiler() throws Exception {
final Launcher spoon = new Launcher();
spoon.addInputResource("./src/test/java/spoon/test/api/testclasses/Bar.java");
spoon.setSourceOutputDirectory("./target/api");
spoon.getEnvironment().setNoClasspath(true);
spoon.run();
assertTrue(spoon.getModelBuilder().compile());
final CtClass<Bar> aClass = spoon.getFactory().Class().get(Bar.class);
final CtMethod aMethod = spoon.getFactory().Core().createMethod();
aMethod.setSimpleName("foo");
aMethod.setType(spoon.getFactory().Type().BOOLEAN_PRIMITIVE);
aMethod.setBody(spoon.getFactory().Core().createBlock());
aClass.addMethod(aMethod);
assertFalse(spoon.getModelBuilder().compile());
aClass.removeMethod(aMethod);
assertTrue(spoon.getModelBuilder().compile());
}