private void doTestDontLog(File log) throws IOException { // Set things up so that if Velocity is successfully logging then we will see its log output // in the temporary file we have created. This depends on Velocity falling back on JDK logging, // so this test won't do anything useful if its classpath contains Log4J or Commons Logging or // any of the other exotic logging systems that Velocity will pounce on if it sees them. FileHandler fileHandler = new FileHandler(log.getPath()); fileHandler.setFormatter(new SimpleFormatter()); Logger logger = Logger.getLogger(JdkLogChute.DEFAULT_LOG_NAME); logger.addHandler(fileHandler); logger.setLevel(Level.ALL); LogManager logManager = LogManager.getLogManager(); logManager.addLogger(logger); // Now do a random compilation that implies using RetroFacebookProcessor. JavaFileObject javaFileObject = JavaFileObjects.forSourceLines( "foo.bar.Baz", "package foo.bar;", "", "import retrofacebook.RetroFacebook;", "", "@RetroFacebook", "public abstract class Baz {", " public abstract int buh();", "", " public static Baz create(int buh) {", " return new RetroFacebook_Baz(buh);", " }", "}"); assert_().about(javaSource()) .that(javaFileObject) .processedWith(new RetroFacebookProcessor()) .compilesWithoutError(); // The log file should be empty. fileHandler.close(); assertEquals("", Files.toString(log, StandardCharsets.UTF_8)); }
private void doTestDontLog(File log) throws IOException { // Set things up so that if Velocity is successfully logging then we will see its log output // in the temporary file we have created. This depends on Velocity falling back on JDK logging, // so this test won't do anything useful if its classpath contains Log4J or Commons Logging or // any of the other exotic logging systems that Velocity will pounce on if it sees them. FileHandler fileHandler = new FileHandler(log.getPath()); fileHandler.setFormatter(new SimpleFormatter()); Logger logger = Logger.getLogger(JdkLogChute.DEFAULT_LOG_NAME); logger.addHandler(fileHandler); logger.setLevel(Level.ALL); LogManager logManager = LogManager.getLogManager(); logManager.addLogger(logger); // Now do a random compilation that implies using AutoCursorProcessor. JavaFileObject javaFileObject = JavaFileObjects.forSourceLines( "foo.bar.Baz", "package foo.bar;", "", "import auto.cursor.AutoCursor;", "", "@AutoCursor", "public abstract class Baz {", " public abstract int buh();", "", " public static Baz create(int buh) {", " return new AutoCursor_Baz(buh);", " }", "}"); assert_().about(javaSource()) .that(javaFileObject) .processedWith(new AutoCursorProcessor()) .compilesWithoutError(); // The log file should be empty. fileHandler.close(); assertEquals("", Files.toString(log, StandardCharsets.UTF_8)); }
private void doTestDontLog(File log) throws IOException { // Set things up so that if Velocity is successfully logging then we will see its log output // in the temporary file we have created. This depends on Velocity falling back on JDK logging, // so this test won't do anything useful if its classpath contains Log4J or Commons Logging or // any of the other exotic logging systems that Velocity will pounce on if it sees them. FileHandler fileHandler = new FileHandler(log.getPath()); fileHandler.setFormatter(new SimpleFormatter()); Logger logger = Logger.getLogger(JdkLogChute.DEFAULT_LOG_NAME); logger.addHandler(fileHandler); logger.setLevel(Level.ALL); LogManager logManager = LogManager.getLogManager(); logManager.addLogger(logger); // Now do a random compilation that implies using RetrofitProcessor. JavaFileObject javaFileObject = JavaFileObjects.forSourceLines( "foo.bar.Baz", "package foo.bar;", "", "import retrofit.http.Retrofit;", "import retrofit.http.Retrofit.GET;", "import rx.Observable;", "", "@Retrofit", "public abstract class Baz {", " @GET(\"/\")", " public abstract Observable<Integer> buh();", "", " public static Baz create() {", " return new Retrofit_Baz();", " }", "}"); assert_().about(javaSource()) .that(javaFileObject) .processedWith(new RetrofitProcessor()) .compilesWithoutError(); // The log file should be empty. fileHandler.close(); assertEquals("", Files.toString(log, StandardCharsets.UTF_8)); }
private void doTestDontLog(File log) throws IOException { // Set things up so that if Velocity is successfully logging then we will see its log output // in the temporary file we have created. This depends on Velocity falling back on JDK logging, // so this test won't do anything useful if its classpath contains Log4J or Commons Logging or // any of the other exotic logging systems that Velocity will pounce on if it sees them. FileHandler fileHandler = new FileHandler(log.getPath()); fileHandler.setFormatter(new SimpleFormatter()); Logger logger = Logger.getLogger(JdkLogChute.DEFAULT_LOG_NAME); logger.addHandler(fileHandler); logger.setLevel(Level.ALL); LogManager logManager = LogManager.getLogManager(); logManager.addLogger(logger); // Now do a random compilation that implies using RetroWeiboProcessor. JavaFileObject javaFileObject = JavaFileObjects.forSourceLines( "foo.bar.Baz", "package foo.bar;", "", "import retroweibo.RetroWeibo;", "", "@RetroWeibo", "public abstract class Baz {", " public abstract int buh();", "", " public static Baz create(int buh) {", " return new RetroWeibo_Baz(buh);", " }", "}"); assert_().about(javaSource()) .that(javaFileObject) .processedWith(new RetroWeiboProcessor()) .compilesWithoutError(); // The log file should be empty. fileHandler.close(); assertEquals("", Files.toString(log, StandardCharsets.UTF_8)); }
private void doTestDontLog(File log) throws IOException { // Set things up so that if Velocity is successfully logging then we will see its log output // in the temporary file we have created. This depends on Velocity falling back on JDK logging, // so this test won't do anything useful if its classpath contains Log4J or Commons Logging or // any of the other exotic logging systems that Velocity will pounce on if it sees them. FileHandler fileHandler = new FileHandler(log.getPath()); fileHandler.setFormatter(new SimpleFormatter()); Logger logger = Logger.getLogger(JdkLogChute.DEFAULT_LOG_NAME); logger.addHandler(fileHandler); logger.setLevel(Level.ALL); LogManager logManager = LogManager.getLogManager(); logManager.addLogger(logger); // Now do a random compilation that implies using AutoJsonProcessor. JavaFileObject javaFileObject = JavaFileObjects.forSourceLines( "foo.bar.Baz", "package foo.bar;", "", "import auto.json.AutoJson;", "", "@AutoJson", "public abstract class Baz {", " public abstract int buh();", "", " public static Baz create(int buh) {", " return new AutoJson_Baz(buh);", " }", "}"); assert_().about(javaSource()) .that(javaFileObject) .processedWith(new AutoJsonProcessor()) .compilesWithoutError(); // The log file should be empty. fileHandler.close(); assertEquals("", Files.toString(log, StandardCharsets.UTF_8)); }