Example #1
0
 @Test
 public void testLoadForAnotherFile() {
   String s = n.getArg("square").getDataType();
   String m = n.getArg("blue").getName();
   assertEquals("TestLoad", n.getProgramName());
   assertEquals("TestLoadProgram", n.getProgramDescription());
   assertEquals("integer", s);
   assertEquals("blue", m);
 }
Example #2
0
 @Test
 public void testGetArgName() {
   String s = q.getArg("one").getName();
   assertEquals("one", s);
 }
Example #3
0
 @Test
 public void testLoadGetProgramDescription() {
   assertEquals("Test Program", q.getProgramDescription());
 }
Example #4
0
 @Test
 public void testLoadGetProgramName() {
   assertEquals("Test", q.getProgramName());
 }
Example #5
0
  @Test
  public void testSave() {
    List<String> values = new ArrayList<String>();
    values.add("one");
    values.add("two");
    values.add("three");

    String[] mutex = new String[] {"testArg", "testArg2"};

    p.setProgramName("Test");
    p.setProgramDescription("Test Program");
    p.addArg("one", Arg.DataType.STRING, "");
    p.getArg("one").setRestrictedValues(values);
    p.addArg("two", Arg.DataType.INTEGER, "This is a test.");
    p.addNamedArg("testArg", Arg.DataType.STRING, "", "test1", 't');
    p.addNamedArg("testArg2", Arg.DataType.STRING, "", "three");
    p.getArg("testArg2").setRestrictedValues(values);
    p.addNamedArg("testArg3", Arg.DataType.STRING, "NamedDescrip", "one", 'c');
    p.getArg("testArg3").setRestrictedValues(values);
    p.addMutualExclusion(mutex);
    p.setNamedArgToRequired("testArg3");

    x.save(p, "./build/tmp/testSave.xml");
    // read in xml file as string and test against known string
    String actualXMLOutput = "";
    String expectedXLMOutput =
        "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><arguments>    <programname>Test</programname>    <programdescription>Test Program</programdescription>    <mutualexclusion>testArg, testArg2</mutualexclusion><positional>    <position>1</position>    <name>one</name>    <type>string</type>    <restrictedvalues>one, two, three</restrictedvalues></positional><positional>    <position>2</position>    <name>two</name>    <type>integer</type>    <description>This is a test.</description></positional><named>    <name>testArg</name>    <type>string</type>    <shortname>t</shortname>    <default>test1</default></named><named>    <name>testArg2</name>    <type>string</type>    <restrictedvalues>one, two, three</restrictedvalues>    <default>three</default></named><named>    <name>testArg3</name>    <type>string</type>    <restrictedvalues>one, two, three</restrictedvalues>    <description>NamedDescrip</description>    <shortname>c</shortname>    <required>true</required>    <default>one</default></named></arguments>";
    String currentLine = null;
    try {
      FileReader r = new FileReader("./build/tmp/testSave.xml");
      BufferedReader b = new BufferedReader(r);
      while ((currentLine = b.readLine()) != null) actualXMLOutput += currentLine;
      b.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
    assertEquals(expectedXLMOutput, actualXMLOutput);
  }
Example #6
0
 @Test
 public void testRequiredArgs() {
   assertEquals("testArg3", q.getRequiredNamedArgs());
 }
Example #7
0
  @Test
  public void testMutualExclusion() {
    List<String[]> testList = q.getMutualExclusion();

    assertEquals("[testArg, testArg2]", Arrays.toString(testList.get(0)));
  }
Example #8
0
 @Test
 public void testGetRestrictedValues() {
   assertEquals("[one, two, three]", q.getArg("one").getRestrictedValues());
   assertEquals("[one, two, three]", q.getArg("testArg3").getRestrictedValues());
 }
Example #9
0
 @Test
 public void testGetArgDataType() {
   String s = q.getArg("one").getDataType();
   assertEquals("string", s);
 }