本文整理匯總了Java中com.google.common.jimfs.Jimfs.newFileSystem方法的典型用法代碼示例。如果您正苦於以下問題:Java Jimfs.newFileSystem方法的具體用法?Java Jimfs.newFileSystem怎麽用?Java Jimfs.newFileSystem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.jimfs.Jimfs
的用法示例。
在下文中一共展示了Jimfs.newFileSystem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: givesInformativeParseErrors
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Test
public void givesInformativeParseErrors() throws Exception {
final FileSystem fs = Jimfs.newFileSystem();
EvenMoreFiles.writeFile(
fs.getPath(System.getProperty("user.home"), ".buckaroo", "buckaroo-recipes", "recipes", "org", "example.json"),
"{ \"content\": \"this is an invalid recipe\" }");
final RecipeSource recipeSource = LazyCookbookRecipeSource.of(
fs.getPath(System.getProperty("user.home"), ".buckaroo", "buckaroo-recipes"));
final SettableFuture<Throwable> futureError = SettableFuture.create();
recipeSource.fetch(RecipeIdentifier.of(Identifier.of("org"), Identifier.of("example")))
.result()
.subscribe(x -> {
}, error -> {
futureError.set(error);
});
final Throwable exception = futureError.get(5000L, TimeUnit.MILLISECONDS);
assertTrue(exception instanceof RecipeFetchException);
}
示例2: fetchFailsWhenThereIsNoProjectFile
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Test
public void fetchFailsWhenThereIsNoProjectFile() throws Exception {
final FileSystem fs = Jimfs.newFileSystem();
final RecipeSource recipeSource = GitProviderRecipeSource.of(fs, GitHubGitProvider.of());
final Single<Recipe> task = recipeSource.fetch(
RecipeIdentifier.of("github", "njlr", "test-lib-no-project"))
.result();
final SettableFuture<Throwable> futureException = SettableFuture.create();
task.subscribe(
result -> {
}, error -> {
futureException.set(error);
});
final Throwable exception = futureException.get(90, TimeUnit.SECONDS);
assertTrue(exception instanceof RecipeFetchException);
}
示例3: testEqual_links
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
public void testEqual_links() throws IOException {
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
Path fooPath = fs.getPath("foo");
MoreFiles.asCharSink(fooPath, UTF_8).write("foo");
Path fooSymlink = fs.getPath("symlink");
Files.createSymbolicLink(fooSymlink, fooPath);
Path fooHardlink = fs.getPath("hardlink");
Files.createLink(fooHardlink, fooPath);
assertThat(MoreFiles.equal(fooPath, fooSymlink)).isTrue();
assertThat(MoreFiles.equal(fooPath, fooHardlink)).isTrue();
assertThat(MoreFiles.equal(fooSymlink, fooHardlink)).isTrue();
}
}
示例4: testByteSource_size_ofSymlinkToRegularFile_nofollowLinks
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
public void testByteSource_size_ofSymlinkToRegularFile_nofollowLinks() throws IOException {
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
Path file = fs.getPath("file");
Files.write(file, new byte[10]);
Path link = fs.getPath("link");
Files.createSymbolicLink(link, file);
ByteSource source = MoreFiles.asByteSource(link, NOFOLLOW_LINKS);
assertThat(source.sizeIfKnown()).isAbsent();
try {
source.size();
fail();
} catch (IOException expected) {
}
}
}
示例5: findWithFakeImageDirs
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
private static DevDiskImages findWithFakeImageDirs(
Predicate<Path> readablePredicate, String... imageDirNames) throws IOException {
FileSystem fileSystem =
Jimfs.newFileSystem(Configuration.unix().toBuilder().setAttributeViews("posix").build());
Path rootImagesDir = fileSystem.getPath("path", "to", "images");
Files.createDirectories(rootImagesDir);
for (String imageDirName : imageDirNames) {
Path imageDir = rootImagesDir.resolve(imageDirName);
Files.createDirectory(imageDir);
Files.createFile(imageDir.resolve("DiskImage." + DevDiskImages.IMAGE_EXTENSION));
Files.createFile(imageDir.resolve("DiskImage." + DevDiskImages.SIGNATURE_EXTENSION));
}
return DevDiskImages.forTesting(rootImagesDir, readablePredicate);
}
示例6: setUp
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Before
public void setUp() throws IOException {
FileSystem fileSystem =
Jimfs.newFileSystem(Configuration.forCurrentPlatform().toBuilder().build());
srcMain = fileSystem.getPath("/src/main/");
Files.createDirectories(srcMain);
srcTest = fileSystem.getPath("/src/test/");
Files.createDirectories(srcTest);
}
示例7: setUp
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
fileSystem = Jimfs.newFileSystem(Configuration.unix());
Files.createDirectories(fileSystem.getPath("/tmp"));
Files.createFile(fileSystem.getPath("/test"));
platformConfig = new InMemoryPlatformConfig(fileSystem);
MapModuleConfig moduleConfig = platformConfig.createModuleConfig("local-app-file-system");
moduleConfig.setStringProperty("drive-name", "local");
moduleConfig.setPathProperty("root-dir", fileSystem.getPath("/work"));
moduleConfig.setStringProperty("max-additional-drive-count", "2");
moduleConfig.setStringProperty("drive-name-1", "local1");
moduleConfig.setStringProperty("remotely-accessible-1", "true");
moduleConfig.setPathProperty("root-dir-1", fileSystem.getPath("/work"));
}
示例8: setUp
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Before
public void setUp() throws IOException {
fileSystem = Jimfs.newFileSystem(Configuration.unix());
tmpDir = Files.createDirectory(fileSystem.getPath("/tmp"));
contingency = new ContingencyImpl("contingency", Collections.emptyList());
}
示例9: installDirectlyFromGitHub2
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Test
public void installDirectlyFromGitHub2() throws Exception {
final FileSystem fs = Jimfs.newFileSystem();
// Workaround: JimFs does not implement .toFile;
// We clone and fail buckaroo-recipes if it does not exist, so we create it.
MoreFiles.createParentDirectories(fs.getPath(
System.getProperty("user.home"),
".buckaroo",
"buckaroo-recipes",
".git"));
final ImmutableList<PartialDependency> partialDependencies = ImmutableList.of(
PartialDependency.of(
Identifier.of("github"),
Identifier.of("njlr"),
Identifier.of("test-lib-d"),
AnySemanticVersion.of()));
InitTasks.initWorkingDirectory(fs).toList().blockingGet();
InstallTasks.installDependencyInWorkingDirectory(fs, partialDependencies).toList().blockingGet();
assertTrue(Files.exists(fs.getPath("BUCKAROO_DEPS")));
final Path dependencyFolder = fs.getPath(
"buckaroo", "github", "njlr", "test-lib-d");
assertTrue(Files.exists(dependencyFolder.resolve("BUCK")));
assertTrue(Files.exists(dependencyFolder.resolve("BUCKAROO_DEPS")));
}
示例10: projectWithTarget
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Test
public void projectWithTarget() throws Exception {
final FileSystem fs = Jimfs.newFileSystem();
final Recipe recipe = Recipe.of(
"example",
new URI("https://github.com/org/example"),
ImmutableMap.of(
SemanticVersion.of(1),
RecipeVersion.of(
GitCommit.of("https://github.com/org/example/commit", "c7355d5"),
"some-custom-target")));
EvenMoreFiles.writeFile(fs.getPath(System.getProperty("user.home"),
".buckaroo", "buckaroo-recipes", "recipes", "org", "example.json"),
Serializers.serialize(recipe));
final Project project = Project.of(
"Example",
DependencyGroup.of(ImmutableMap.of(
RecipeIdentifier.of("org", "example"), AnySemanticVersion.of())));
EvenMoreFiles.writeFile(
fs.getPath("buckaroo.json"),
Serializers.serialize(project));
final Observable<Event> task = ResolveTasks.resolveDependenciesInWorkingDirectory(fs);
task.toList().blockingGet();
final DependencyLocks expected = DependencyLocks.of(DependencyLock.of(
RecipeIdentifier.of("org", "example"),
ResolvedDependency.of(
recipe.versions.get(SemanticVersion.of(1)).source,
recipe.versions.get(SemanticVersion.of(1)).target,
recipe.versions.get(SemanticVersion.of(1)).buckResource,
ImmutableList.of())));
final Either<JsonParseException, DependencyLocks> actual = Serializers.parseDependencyLocks(
EvenMoreFiles.read(fs.getPath("buckaroo.lock.json")));
assertEquals(right(expected), actual);
}
示例11: newTestFileSystem
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
/**
* Creates a new file system for testing that supports the given features in addition to
* supporting symbolic links. The file system is created initially having the following file
* structure:
*
* <pre>
* /
* work/
* dir/
* a
* b/
* g
* h -> ../a
* i/
* j/
* k
* l/
* c
* d -> b/i
* e/
* f -> /dontdelete
* dontdelete/
* a
* b/
* c
* symlinktodir -> work/dir
* </pre>
*/
static FileSystem newTestFileSystem(Feature... supportedFeatures) throws IOException {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix().toBuilder()
.setSupportedFeatures(ObjectArrays.concat(SYMBOLIC_LINKS, supportedFeatures))
.build());
Files.createDirectories(fs.getPath("dir/b/i/j/l"));
Files.createFile(fs.getPath("dir/a"));
Files.createFile(fs.getPath("dir/c"));
Files.createSymbolicLink(fs.getPath("dir/d"), fs.getPath("b/i"));
Files.createDirectory(fs.getPath("dir/e"));
Files.createSymbolicLink(fs.getPath("dir/f"), fs.getPath("/dontdelete"));
Files.createFile(fs.getPath("dir/b/g"));
Files.createSymbolicLink(fs.getPath("dir/b/h"), fs.getPath("../a"));
Files.createFile(fs.getPath("dir/b/i/j/k"));
Files.createDirectory(fs.getPath("/dontdelete"));
Files.createFile(fs.getPath("/dontdelete/a"));
Files.createDirectory(fs.getPath("/dontdelete/b"));
Files.createFile(fs.getPath("/dontdelete/c"));
Files.createSymbolicLink(fs.getPath("/symlinktodir"), fs.getPath("work/dir"));
return fs;
}
示例12: setUp
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Before
public void setUp() throws IOException {
fileSystem = Jimfs.newFileSystem(Configuration.unix());
}
示例13: setUp
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Before
public void setUp() throws IOException {
fileSystem = Jimfs.newFileSystem(Configuration.unix());
tmpDir = Files.createDirectory(fileSystem.getPath("tmp"));
}
示例14: simpleProject
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Test
public void simpleProject() throws Exception {
final FileSystem fs = Jimfs.newFileSystem();
final Recipe recipe = Recipe.of(
"example",
new URI("https://github.com/org/example"),
ImmutableMap.of(
SemanticVersion.of(1),
RecipeVersion.of(
GitCommit.of("https://github.com/org/example/commit", "c7355d5"))));
EvenMoreFiles.writeFile(fs.getPath(System.getProperty("user.home"),
".buckaroo", "buckaroo-recipes", "recipes", "org", "example.json"),
Serializers.serialize(recipe));
final Project project = Project.of(
"Example",
DependencyGroup.of(ImmutableMap.of(
RecipeIdentifier.of("org", "example"), AnySemanticVersion.of())));
EvenMoreFiles.writeFile(
fs.getPath("buckaroo.json"),
Serializers.serialize(project));
final Observable<Event> task = ResolveTasks.resolveDependenciesInWorkingDirectory(fs);
task.toList().blockingGet();
final DependencyLocks expected = DependencyLocks.of(DependencyLock.of(
RecipeIdentifier.of("org", "example"),
ResolvedDependency.of(
recipe.versions.get(SemanticVersion.of(1)).source,
recipe.versions.get(SemanticVersion.of(1)).target,
recipe.versions.get(SemanticVersion.of(1)).buckResource,
ImmutableList.of())));
assertEquals(
right(expected),
Serializers.parseDependencyLocks(EvenMoreFiles.read(fs.getPath("buckaroo.lock.json"))));
}
示例15: setUp
import com.google.common.jimfs.Jimfs; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
fileSystem = Jimfs.newFileSystem(Configuration.unix());
}