예제 #1
0
  /*	@Test
  public void searchContentTest() throws IOException {
  	System.out.println("Search");
  	textbuddy.searchContent("textfile.txt");

  }*/
  public boolean testIfFilesAreTheSame(File file1, File file2) {
    BufferedReader file1Reader = null;
    BufferedReader file2Reader = null;
    boolean equals = true;
    ;
    try {
      file1Reader = new BufferedReader(new FileReader(file1));
      file2Reader = new BufferedReader(new FileReader(file2));
      String linefromfile1;
      String linefromfile2;
      while (((linefromfile1 = file1Reader.readLine()) != null)
          && ((linefromfile2 = file2Reader.readLine()) != null)) {
        if (!linefromfile1.equals(linefromfile2)) {
          equals = false;
          break;
        }
      }

    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        file1Reader.close();
        file2Reader.close();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    return equals;
  }
예제 #2
0
  // @Test
  public void validateDoubfulRanks() {

    try {
      BufferedReader bufferedReader =
          new BufferedReader(
              new FileReader(new File("/home/alext/Downloads/NCBI/taxdump/nodes.dmp")));
      String line;
      while ((line = bufferedReader.readLine()) != null) {
        String[] split = line.split("\t\\|\t");
        if (split[2].equals("forma")) {
          System.out.println(line);
          // break;
        }
      }
      bufferedReader.close();
    } catch (FileNotFoundException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    } catch (IOException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
  }
예제 #3
0
 public List<String> linesThat(Matcher<? super String> matcher) {
   try {
     BufferedReader reader = new BufferedReader(new FileReader(this));
     try {
       List<String> lines = new ArrayList<String>();
       String line;
       while ((line = reader.readLine()) != null) {
         if (matcher.matches(line)) {
           lines.add(line);
         }
       }
       return lines;
     } finally {
       reader.close();
     }
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
예제 #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);
  }