@Override public void installApplication(Path ipaOrAppPath) throws IosDeviceException { try { if (Files.isDirectory(ipaOrAppPath)) { await(simctl.install(ipaOrAppPath.toString())); } else { Path tmpDir = Files.createTempDirectory("app"); try { unzipFile(ipaOrAppPath, tmpDir); Path appPath = tmpDir .resolve("Payload") .resolve(MoreFiles.getNameWithoutExtension(ipaOrAppPath) + ".app"); await(simctl.install(appPath.toString())); } finally { MoreFiles.deleteRecursively(tmpDir, RecursiveDeleteOption.ALLOW_INSECURE); } } } catch (IOException e) { throw new IosDeviceException(this, e); } }
@After public void cleanUp() throws Exception { appContext.stopLogging(); DataStore.closeConnection(dbconn); try { MoreFiles .deleteRecursively(Paths.get(DataStore.getDbDir(testDbName)), RecursiveDeleteOption.ALLOW_INSECURE); } catch (IOException e) { // DONT make test failure. System.err.println("test db clean-up failure, remove manually later :P"); e.printStackTrace(); } }
private void stopService() { try { brokerService.stop(); MoreFiles.deleteRecursively(tempDir.toPath(), RecursiveDeleteOption.ALLOW_INSECURE); brokerService = null; } catch (Exception e) { throw new IllegalStateException("Could not stop broker", e); } }
@Override public void clearCrashLogs() throws IosDeviceException { try { Path tempDir = Files.createTempDirectory("artifacts"); try { idevice.crashreport(tempDir.toString()); } finally { MoreFiles.deleteRecursively(tempDir, RecursiveDeleteOption.ALLOW_INSECURE); } } catch (IOException e) { throw new IosDeviceException(this, e); } }
/** * Delete all the contents of a path recursively. * * <p>First we try to delete securely. In case the FileSystem doesn't support it, * delete it insecurely. */ public static void deleteRecursively(Path path) throws IOException { try { MoreFiles.deleteRecursively(path); } catch (InsecureRecursiveDeleteException ignore) { logger.warning(String.format("Secure delete not supported. Deleting '%s' insecurely.", path)); MoreFiles.deleteRecursively(path, RecursiveDeleteOption.ALLOW_INSECURE); } }
@Test public void reindexFromScratch() throws Exception { setUpChange(); MoreFiles.deleteRecursively(sitePaths.index_dir, RecursiveDeleteOption.ALLOW_INSECURE); Files.createDirectory(sitePaths.index_dir); assertServerStartupFails(); runGerrit("reindex", "-d", sitePaths.site_path.toString(), "--show-stack-trace"); assertReady(ChangeSchemaDefinitions.INSTANCE.getLatest().getVersion()); try (ServerContext ctx = startServer()) { GerritApi gApi = ctx.getInjector().getInstance(GerritApi.class); // Query change index assertThat(gApi.changes().query("message:Test").get().stream().map(c -> c.changeId)) .containsExactly(changeId); // Query account index assertThat(gApi.accounts().query("admin").get().stream().map(a -> a._accountId)) .containsExactly(adminId.get()); // Query group index assertThat( gApi.groups() .query("Group") .withOption(MEMBERS) .get() .stream() .flatMap(g -> g.members.stream()) .map(a -> a._accountId)) .containsExactly(adminId.get()); } }