use of com.google.common.jimfs.Configuration in project buck by facebook.
the class StackedDownloaderTest method createDownloadersForEachEntryInTheMavenRepositoriesSection.
@Test
public void createDownloadersForEachEntryInTheMavenRepositoriesSection() throws IOException {
boolean isWindows = Platform.detect() == Platform.WINDOWS;
Configuration configuration = isWindows ? Configuration.windows() : Configuration.unix();
FileSystem vfs = Jimfs.newFileSystem(configuration);
Path m2Root = vfs.getPath(jimfAbsolutePath("/home/user/.m2/repository"));
Files.createDirectories(m2Root);
// Set up a config so we expect to see both a local and a remote maven repo.
Path projectRoot = vfs.getPath(jimfAbsolutePath("/opt/local/src"));
Files.createDirectories(projectRoot);
BuckConfig config = FakeBuckConfig.builder().setFilesystem(new ProjectFilesystem(projectRoot)).setSections("[maven_repositories]", "local = " + m2Root.toString(), "central = https://repo1.maven.org/maven2").build();
Downloader downloader = StackedDownloader.createFromConfig(config, Optional.empty());
List<Downloader> downloaders = unpackDownloaders(downloader);
boolean seenRemote = false;
boolean seenLocal = false;
for (Downloader seen : downloaders) {
if (seen instanceof RemoteMavenDownloader) {
seenRemote = true;
} else if (seen instanceof OnDiskMavenDownloader) {
seenLocal = true;
}
}
assertTrue(seenLocal);
assertTrue(seenRemote);
}
use of com.google.common.jimfs.Configuration in project buck by facebook.
the class FakeProjectFilesystem method createJavaOnlyFilesystem.
public static ProjectFilesystem createJavaOnlyFilesystem(String rootPath) {
boolean isWindows = Platform.detect() == Platform.WINDOWS;
Configuration configuration = isWindows ? Configuration.windows() : Configuration.unix();
rootPath = isWindows ? "C:" + rootPath : rootPath;
FileSystem vfs = Jimfs.newFileSystem(configuration);
Path root = vfs.getPath(rootPath);
try {
Files.createDirectories(root);
} catch (IOException e) {
throw new RuntimeException(e);
}
return new ProjectFilesystem(root) {
@Override
public Path resolve(Path path) {
// Avoid resolving paths from different Java FileSystems.
return super.resolve(path.toString());
}
};
}
use of com.google.common.jimfs.Configuration in project elasticsearch by elastic.
the class KeyStoreCommandTestCase method setupEnv.
void setupEnv(boolean posix) throws IOException {
final Configuration configuration;
if (posix) {
configuration = Configuration.unix().toBuilder().setAttributeViews("basic", "owner", "posix", "unix").build();
} else {
configuration = Configuration.unix();
}
FileSystem fs = Jimfs.newFileSystem(configuration);
fileSystems.add(fs);
// restored by restoreFileSystem in ESTestCase
PathUtilsForTesting.installMock(fs);
Path home = fs.getPath("/", "test-home");
Files.createDirectories(home.resolve("config"));
env = new Environment(Settings.builder().put("path.home", home).build());
}
Aggregations