Пример #1
0
  public void testParallelDifferentStores() throws Exception {
    List<XmlMetaStore> stores = new ArrayList<XmlMetaStore>();
    final List<Throwable> exceptions = new ArrayList<Throwable>();
    // Run the test against the XML metadata store.
    //
    try {
      for (int i = 0; i < 10; i++) {
        stores.add(new XmlMetaStore());
      }

      List<Thread> threads = new ArrayList<Thread>();
      for (final IMetaStore store : stores) {
        Thread thread =
            new Thread() {
              public void run() {
                try {
                  testFunctionality(store);
                } catch (Throwable e) {
                  exceptions.add(e);
                }
              }
            };
        threads.add(thread);
        thread.start();
      }

      for (Thread thread : threads) {
        thread.join();
      }
    } finally {
      for (XmlMetaStore store : stores) {
        FileUtil.cleanFolder(new File(store.getRootFolder()).getParentFile(), true);
      }
    }

    if (!exceptions.isEmpty()) {
      for (Throwable e : exceptions) {
        e.printStackTrace(System.err);
      }
      fail(exceptions.size() + " exceptions encountered during parallel store/retrieve");
    }
  }
Пример #2
0
 @Override
 protected void tearDown() throws Exception {
   super.tearDown();
   FileUtil.cleanFolder(new File(metaStore.getRootFolder()).getParentFile(), true);
 }