/** Dump out all existing properties to message logging info channel. */
  @Override
  public void dumpProperties() {

    Iterator<String> keyIterator = config.getKeys();

    while (keyIterator.hasNext()) {
      String key = keyIterator.next();

      Object o = config.getProperty(key);
      if (o != null) {
        // Check for multiple setting of properties
        if (o instanceof ArrayList) {
          logger.debug(
              key
                  + " is set multiple times the value used will be the first! This maybe ok if deliberately overridden");
        }
        if (o instanceof String) {
          // Calling getString method ensures value has any
          // processing
          // done by commons config applied - ie string
          // interpolation, etc.
          logger.debug(key + " = " + LocalProperties.get(key));
        } else {
          // Handle non-string objects, eg ArrayList's
          logger.debug(key + " = " + o.toString());
        }
      }
    }
  }
  @Before
  public void setup() throws Exception, IOException, URISyntaxException {
    URL sourceUrl = this.getClass().getResource("/");

    sourceFolder = new File(sourceUrl.getFile());
    if (!sourceFolder.exists()) {
      throw new Exception("Cannot find sample data structure!");
    }

    destinationFolder = folder.getRoot();

    templateFolder = new File(sourceFolder, templateDir);
    if (!templateFolder.exists()) {
      throw new Exception("Cannot find template folder!");
    }

    config = ConfigUtil.load(new File(this.getClass().getResource("/").getFile()));
    Iterator<String> keys = config.getKeys();
    while (keys.hasNext()) {
      String key = keys.next();
      if (key.startsWith("template") && key.endsWith(".file")) {
        String old = (String) config.getProperty(key);
        config.setProperty(key, old.substring(0, old.length() - 4) + "." + templateExtension);
      }
    }
    Assert.assertEquals(".html", config.getString(ConfigUtil.Keys.OUTPUT_EXTENSION));
    db = DBUtil.createDataStore("memory", "documents" + System.currentTimeMillis());
  }
示例#3
0
 @Before
 public void setup() throws Exception, IOException, URISyntaxException {
   config = ConfigUtil.load(new File(this.getClass().getResource("/").getFile()));
   Iterator<String> keys = config.getKeys();
   while (keys.hasNext()) {
     String key = keys.next();
     if (key.startsWith("template") && key.endsWith(".file")) {
       String old = (String) config.getProperty(key);
       config.setProperty(key, old.substring(0, old.length() - 4) + ".ftl");
     }
   }
   config.setProperty(ConfigurationKeys.PAGINATE_INDEX, true);
   config.setProperty(ConfigurationKeys.POSTS_PER_PAGE, 1);
   db = DataBaseUtil.createDataStore("memory", "documents" + System.currentTimeMillis());
 }
  @Before
  public void setup() throws Exception {
    currentLocale = Locale.getDefault();
    Locale.setDefault(Locale.ENGLISH);

    ModelExtractorsDocumentTypeListener listener = new ModelExtractorsDocumentTypeListener();
    DocumentTypes.addListener(listener);

    URL sourceUrl = this.getClass().getResource("/");

    sourceFolder = new File(sourceUrl.getFile());
    if (!sourceFolder.exists()) {
      throw new Exception("Cannot find sample data structure!");
    }

    destinationFolder = folder.getRoot();

    templateFolder = new File(sourceFolder, templateDir);
    if (!templateFolder.exists()) {
      throw new Exception("Cannot find template folder!");
    }

    config = ConfigUtil.load(new File(this.getClass().getResource("/").getFile()));
    Iterator<String> keys = config.getKeys();
    while (keys.hasNext()) {
      String key = keys.next();
      if (key.startsWith("template") && key.endsWith(".file")) {
        String old = (String) config.getProperty(key);
        config.setProperty(key, old.substring(0, old.length() - 4) + "." + templateExtension);
      }
    }
    Assert.assertEquals(".html", config.getString(ConfigUtil.Keys.OUTPUT_EXTENSION));
    db = DBUtil.createDataStore("memory", "documents" + System.currentTimeMillis());

    crawler = new Crawler(db, sourceFolder, config);
    crawler.crawl(new File(sourceFolder.getPath() + File.separator + "content"));
    parser = new Parser(config, sourceFolder.getPath());
    renderer = new Renderer(db, destinationFolder, templateFolder, config);

    setupExpectedOutputStrings();
  }
 @Override
 public Iterator<String> getKeys() {
   return config.getKeys();
 }