示例#1
0
 public void run() {
   try {
     String line = in.readLine();
     while (line != null) {
       buf.append(line);
       buf.append('\n');
       line = in.readLine();
     }
   } catch (IOException ioe) {
     System.err.println("can't read output from process");
   }
 }
 private static boolean isAaptPresent() throws Exception {
   boolean result = true;
   try {
     Process proc = Runtime.getRuntime().exec("aapt");
     BufferedReader br = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
     String line = null;
     while ((line = br.readLine()) != null) {}
   } catch (Exception ex) {
     result = false;
   }
   return result;
 }
示例#3
0
  @Test
  public void testMachine() throws Exception {
    if (!isUnix()) return;

    Process p = Runtime.getRuntime().exec(new String[] {"uname", "-m"});
    BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));

    String uname = r.readLine().trim();
    String m = uname;
    assertTrue(m.length() > 0);

    if (m.matches("i\\d86")) m = "i386";
    else if (m.matches("i86pc")) m = "x86";

    if (m.equals("i386") && Platform.is64Bits()) m = "x86_64";

    assertEquals(
        "uname = " + uname + ", Platform.getMachine = " + Platform.getMachine(),
        m,
        Platform.getMachine());
  }
示例#4
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);
  }