mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-30 21:08:30 +08:00
add tests for enabling note logging
This commit is contained in:
parent
d92743ec29
commit
f52c728f15
@ -66,8 +66,8 @@ public abstract class AbstractProcessorTest {
|
||||
options.addAll(getAPTOptions());
|
||||
options.addAll(classes);
|
||||
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream err = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream out = getStdOut();
|
||||
ByteArrayOutputStream err = getStdErr();
|
||||
int compilationResult = compiler.run(null, out, err, options.toArray(new String[options.size()]));
|
||||
|
||||
// Processor.elementCache.clear();
|
||||
@ -77,6 +77,14 @@ public abstract class AbstractProcessorTest {
|
||||
}
|
||||
}
|
||||
|
||||
protected ByteArrayOutputStream getStdOut() {
|
||||
return new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
protected ByteArrayOutputStream getStdErr() {
|
||||
return new ByteArrayOutputStream();
|
||||
}
|
||||
|
||||
protected Collection<String> getAPTOptions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
63
querydsl-apt/src/test/java/com/querydsl/apt/NoteTest.java
Normal file
63
querydsl-apt/src/test/java/com/querydsl/apt/NoteTest.java
Normal file
@ -0,0 +1,63 @@
|
||||
package com.querydsl.apt;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class NoteTest extends AbstractProcessorTest {
|
||||
|
||||
private Collection<String> aptOptions;
|
||||
|
||||
private ByteArrayOutputStream err = new ByteArrayOutputStream();
|
||||
|
||||
private static final String packagePath = "src/test/java/com/querydsl/apt/";
|
||||
|
||||
public void process() throws IOException {
|
||||
List<String> classes = getFiles(packagePath);
|
||||
process(QuerydslAnnotationProcessor.class, classes, "includedClasses");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<String> getAPTOptions() {
|
||||
return aptOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ByteArrayOutputStream getStdErr() {
|
||||
return err;
|
||||
}
|
||||
|
||||
protected boolean isStdErrEmpty() {
|
||||
return getStdErr().toByteArray().length == 0;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void processDefault() throws IOException {
|
||||
aptOptions = Collections.emptyList();
|
||||
process();
|
||||
assertTrue(isStdErrEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void processEnabled() throws IOException {
|
||||
aptOptions = Arrays.asList("-Aquerydsl.logInfo=true");
|
||||
process();
|
||||
assertFalse(isStdErrEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void processDisabled() throws IOException {
|
||||
aptOptions = Arrays.asList("-Aquerydsl.logInfo=false");
|
||||
process();
|
||||
assertTrue(isStdErrEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user