private static void delete(File directory) {
   for (File file : directory.listFiles()) {
     if (file.isDirectory()) {
       delete(file);
     } else {
       assertTrue(file.delete());
     }
   }
   assertTrue(directory.delete());
 }
コード例 #2
0
  @Test
  public void testLoadData() {

    final Set<TestBean> theLoadedBeans = new HashSet<TestBean>();

    this.myDataLoader.loadData(
        new DataConsumer() {

          public void consume(Map<String, Object> aRecord) {

            theLoadedBeans.add(
                new TestBean(
                    (String) aRecord.get(FIRST_NAME_PROP_NAME),
                    (String) aRecord.get(LAST_NAME_PROP_NAME),
                    (String) aRecord.get(FAVORITE_COLOR)));
          }
        });

    assertEquals(theLoadedBeans.size(), this.myExpectedBeans.size());
    assertTrue(
        this.myExpectedBeans.containsAll(theLoadedBeans),
        format("%1$s does not match %2$s", theLoadedBeans, this.myExpectedBeans));
  }