68 lines
1.8 KiB
Java
68 lines
1.8 KiB
Java
package dev.asdf00.confindibus;
|
|
|
|
import dev.asdf00.confindibus.testclasses.*;
|
|
import org.junit.Assert;
|
|
import org.junit.Test;
|
|
|
|
import static com.sun.tools.javac.Main.compile;
|
|
|
|
public class ProcessorTest {
|
|
@Test
|
|
public void testSimpleConfig() {
|
|
Assert.assertEquals(0, compileWithProc(SimpleTestConfig.class));
|
|
}
|
|
|
|
@Test
|
|
public void testBrokenConfig() {
|
|
Assert.assertEquals(1, compileWithProc(BrokenConfig.class));
|
|
}
|
|
|
|
@Test
|
|
public void testBrokenSection1() {
|
|
Assert.assertEquals(1, compileWithProc(BrokenSection1.class));
|
|
}
|
|
|
|
@Test
|
|
public void testBrokenSection2() {
|
|
Assert.assertEquals(1, compileWithProc(BrokenSection2.class));
|
|
}
|
|
|
|
@Test
|
|
public void testBrokenValue1() {
|
|
Assert.assertEquals(1, compileWithProc(BrokenValue1.class));
|
|
}
|
|
|
|
@Test
|
|
public void testBrokenValue2() {
|
|
Assert.assertEquals(1, compileWithProc(BrokenValue2.class));
|
|
}
|
|
|
|
@Test
|
|
public void testBrokenValue3() {
|
|
Assert.assertEquals(1, compileWithProc(BrokenValue3.class));
|
|
}
|
|
|
|
@Test
|
|
public void testBrokenValue4() {
|
|
Assert.assertEquals(1, compileWithProc(BrokenValue4.class));
|
|
}
|
|
|
|
|
|
// =================================================================================================================
|
|
private int compileWithProc(Class<?>... classes) {
|
|
int fixedArgCnt = 3;
|
|
String[] args = new String[classes.length + fixedArgCnt];
|
|
args[0] = "-proc:only";
|
|
args[1] = "-processor";
|
|
args[2] = "dev.asdf00.confindibus.processor.ConfigProcessor";
|
|
for (int i = fixedArgCnt; i < args.length; i++) {
|
|
args[i] = testClass(classes[i - fixedArgCnt]);
|
|
}
|
|
return compile(args);
|
|
}
|
|
|
|
private String testClass(Class cls) {
|
|
return "test/" + cls.getName().replace('.', '/') + ".java";
|
|
}
|
|
}
|