List of usage examples for java.nio.file Path toUri
URI toUri();
From source file:com.seleritycorp.common.base.http.client.FileHttpClientTest.java
@Test public void testExecuteGetDirectory() throws Exception { Path tmpFile = this.createTempDirectory(); replayAll();/*from ww w. j av a 2 s.c o m*/ HttpClient httpClient = createFileHttpClient(); HttpGet method = new HttpGet(tmpFile.toUri()); org.apache.http.HttpResponse response = httpClient.execute(method); HttpEntity entity = response.getEntity(); verifyAll(); assertThat(response.getStatusLine().getProtocolVersion().getProtocol()).isEqualTo("FILE"); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(400); assertThat(response.getStatusLine().getReasonPhrase()).isEqualTo("Bad Request"); assertThat(entity).isNull(); }
From source file:schemacrawler.tools.integration.spring.SchemaCrawlerSpringCommandLine.java
@Override public void execute() throws Exception { final Path contextFile = Paths.get(springOptions.getContextFileName()).normalize().toAbsolutePath(); final ApplicationContext appContext; if (exists(contextFile)) { final String contextFilePath = contextFile.toUri().toString(); LOGGER.log(Level.INFO, "Loading context from file, " + contextFilePath); appContext = new FileSystemXmlApplicationContext(contextFilePath); } else {/*w w w .j a v a 2 s .c o m*/ LOGGER.log(Level.INFO, "Loading context from classpath, " + springOptions.getContextFileName()); appContext = new ClassPathXmlApplicationContext(springOptions.getContextFileName()); } try { final DataSource dataSource = (DataSource) appContext.getBean(springOptions.getDataSourceName()); try (Connection connection = dataSource.getConnection();) { final Executable executable = (Executable) appContext.getBean(springOptions.getExecutableName()); executable.execute(connection); } } finally { ((AbstractXmlApplicationContext) appContext).close(); } }
From source file:org.ow2.proactive_grid_cloud_portal.dataspace.util.VFSZipperZIPTest.java
private void testZip(Path pathToZip) throws IOException { List<FileObject> files = FileSystem.findFiles(fileSystemManager.resolveFile(pathToZip.toUri()), null, null); VFSZipper.ZIP.zip(fileSystemManager.resolveFile(pathToZip.toUri()), files, Files.newOutputStream(archivePath)); }
From source file:org.ow2.proactive_grid_cloud_portal.dataspace.util.VFSZipperZIPTest.java
private void testUnzip(Path resultPath) throws IOException { VFSZipper.ZIP.unzip(Files.newInputStream(archivePath), fileSystemManager.resolveFile(resultPath.toUri())); assertUnzippedFileHierarchy(outputPath); }
From source file:org.cirdles.webServices.calamari.PrawnFileHandlerService.java
private Path zip(Path target) throws IOException { Path zipFilePath = target.resolveSibling("reports.zip"); try (FileSystem zipFileFileSystem = FileSystems.newFileSystem(URI.create("jar:" + zipFilePath.toUri()), ZIP_FILE_ENV)) {//from w ww. j a v a2 s . c o m Files.list(target).forEach(entry -> { try { Files.copy(entry, zipFileFileSystem.getPath("/" + entry.getFileName())); } catch (IOException ex) { throw new RuntimeException(ex); } }); } return zipFilePath; }
From source file:de.tiqsolutions.hdfs.HadoopFileSystemPath.java
@Override public Path resolve(Path other) { return new HadoopFileSystemPath(fileSystem, base.resolve(other.toUri())); }
From source file:de.tiqsolutions.hdfs.HadoopFileSystemPath.java
@Override public Path relativize(Path other) { return new HadoopFileSystemPath(fileSystem, base.relativize(other.toUri())); }
From source file:com.seleritycorp.common.base.http.client.FileHttpClientTest.java
@Test public void testExecutePostFails() throws Exception { Path tmpFile = this.createTempFile(); this.writeFile(tmpFile, "foo\nbar"); replayAll();/*w w w . j av a2 s.c o m*/ HttpClient httpClient = createFileHttpClient(); HttpPost method = new HttpPost(tmpFile.toUri()); org.apache.http.HttpResponse response = httpClient.execute(method); HttpEntity entity = response.getEntity(); verifyAll(); assertThat(response.getStatusLine().getProtocolVersion().getProtocol()).isEqualTo("FILE"); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(400); assertThat(response.getStatusLine().getReasonPhrase()).isEqualTo("Bad Request"); assertThat(entity).isNull(); }
From source file:com.seleritycorp.common.base.http.client.FileHttpClientTest.java
@Test public void testExecuteGetOk() throws Exception { Path tmpFile = this.createTempFile(); this.writeFile(tmpFile, "foo\nbar"); replayAll();//from w w w . ja v a 2s . c o m HttpClient httpClient = createFileHttpClient(); HttpGet method = new HttpGet(tmpFile.toUri()); org.apache.http.HttpResponse response = httpClient.execute(method); HttpEntity entity = response.getEntity(); verifyAll(); assertThat(response.getStatusLine().getProtocolVersion().getProtocol()).isEqualTo("FILE"); assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200); assertThat(response.getStatusLine().getReasonPhrase()).isEqualTo("OK"); assertThat(entity).isNotNull(); assertThat(entity.getContentEncoding()).isNull(); assertThat(entity.getContentType()).isNull(); String body = EntityUtils.toString(entity, StandardCharsets.UTF_8); assertThat(body).isEqualTo("foo\nbar"); }
From source file:at.ac.tuwien.infosys.repository.LocalComponentRepository.java
protected List<Resource> createResources(List<Path> resources) { List<Resource> result = new ArrayList<Resource>(); for (Path path : resources) { Resource resource = new Resource(); resource.setName(path.getFileName().toString()); try {// w ww. j a v a 2 s . c o m resource.setUri(path.toUri().toURL()); } catch (MalformedURLException e) { e.printStackTrace(); } result.add(resource); } return result; }