コード例 #1
0
  @Test
  public void testGetFiguresDirectory() throws IOException {
    final String properties =
        "figures.directory=where_it_is\n" + "sparagraph.full.default=willBeSkipped";
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(properties.getBytes());

    variables.load(inputStream);

    assertEquals("where_it_is", variables.getFiguresDirectory());
  }
コード例 #2
0
  @Test
  public void testGetWordVariables() throws IOException {
    final String properties =
        "word.schnick=juchee\n" + "word.schnack=blablabla\n" + "something.else=weDoNotSeeThis";
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(properties.getBytes());

    variables.load(inputStream);

    final Map<String, String> wordVariables = variables.getWordVariables();
    assertEquals(2, wordVariables.size());

    assertEquals("juchee", wordVariables.get("word.schnick"));
    assertEquals("blablabla", wordVariables.get("word.schnack"));
  }
コード例 #3
0
  @Test
  public void testLoad() throws IOException {
    final InputStream propertiesStream =
        TemplateVariablesTest.class.getResourceAsStream("pvir-template.properties");
    assertNotNull(propertiesStream);

    try {
      variables.load(propertiesStream);
      final Map<String, String> wordVariables = variables.getWordVariables();

      assertEquals(4, wordVariables.size());
    } finally {
      propertiesStream.close();
    }
  }
コード例 #4
0
  @Test
  public void testGetScale() throws IOException {
    final String properties =
        "figure.one.default=a_valid_default_figure\n"
            + "strange.key=somethingElse\n"
            + "figure.one.scale=0.45\n"
            + "figure.second=another_figure\n"
            + "figure.second.scale=0.56";
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(properties.getBytes());

    variables.load(inputStream);

    assertEquals(0.45, variables.getScale("figure.one"), 1e-8);
    assertEquals(0.56, variables.getScale("figure.second"), 1e-8);
  }
コード例 #5
0
  @Test
  public void testGetParagraphVariables() throws IOException {
    final String properties =
        "paragraph.full=this is a complete paragraph\n"
            + "strange.key=willBeSkipped\n"
            + "comment.schnack=me too";
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(properties.getBytes());

    variables.load(inputStream);

    final Map<String, String> paragraphVariables = variables.getParagraphVariables();
    assertEquals(2, paragraphVariables.size());

    assertEquals("this is a complete paragraph", paragraphVariables.get("paragraph.full"));
    assertEquals("me too", paragraphVariables.get("comment.schnack"));
  }
コード例 #6
0
  @Test
  public void testGetWordVariables_withDefaults() throws IOException {
    final String properties =
        "word.schnick=juchee\n"
            + "word.schnick.default=hurra\n"
            + "word.schnack.default=bla_default";
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(properties.getBytes());

    variables.load(inputStream);

    final Map<String, String> wordVariables = variables.getWordVariables();
    assertEquals(2, wordVariables.size());

    assertEquals("juchee", wordVariables.get("word.schnick"));
    assertEquals("bla_default", wordVariables.get("word.schnack"));
  }
コード例 #7
0
  @Test
  public void testGetFiguresVariables() throws IOException {
    final String properties =
        "figures.cool=some_valid_figure_files\n"
            + "strange.key=somethingElse\n"
            + "figures.more=another_set_of_figures";
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(properties.getBytes());

    variables.load(inputStream);

    final Map<String, String> figuresVariables = variables.getFiguresVariables();
    assertEquals(2, figuresVariables.size());

    assertEquals("some_valid_figure_files", figuresVariables.get("figures.cool"));
    assertEquals("another_set_of_figures", figuresVariables.get("figures.more"));
  }
コード例 #8
0
  @Test
  public void testGetFigureVariables() throws IOException {
    final String properties =
        "figure.one=a_valid_figure\n"
            + "strange.key=somethingElse\n"
            + "figure.second=another_figure";
    final ByteArrayInputStream inputStream = new ByteArrayInputStream(properties.getBytes());

    variables.load(inputStream);

    final Map<String, String> figureVariables = variables.getFigureVariables();
    assertEquals(2, figureVariables.size());

    assertEquals("a_valid_figure", figureVariables.get("figure.one"));
    assertEquals("another_figure", figureVariables.get("figure.second"));
  }