org.apache.velocity.runtime.log.JdkLogChute Java Examples

The following examples show how to use org.apache.velocity.runtime.log.JdkLogChute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NoVelocityLoggingTest.java    From RetroFacebook with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #2
Source File: NoVelocityLoggingTest.java    From RetroFacebook with Apache License 2.0 5 votes vote down vote up
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));
}
 
Example #3
Source File: NoVelocityLoggingTest.java    From SimpleWeibo with Apache License 2.0 5 votes vote down vote up
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));
}