Search in sources :

Example 1 with Configuration

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);
}
Also used : Path(java.nio.file.Path) Configuration(com.google.common.jimfs.Configuration) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) FileSystem(java.nio.file.FileSystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 2 with Configuration

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());
        }
    };
}
Also used : Path(java.nio.file.Path) Configuration(com.google.common.jimfs.Configuration) FileSystem(java.nio.file.FileSystem) IOException(java.io.IOException) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Example 3 with Configuration

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());
}
Also used : Path(java.nio.file.Path) Configuration(com.google.common.jimfs.Configuration) FileSystem(java.nio.file.FileSystem) Environment(org.elasticsearch.env.Environment)

Aggregations

Configuration (com.google.common.jimfs.Configuration)3 FileSystem (java.nio.file.FileSystem)3 Path (java.nio.file.Path)3 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 BuckConfig (com.facebook.buck.cli.BuckConfig)1 FakeBuckConfig (com.facebook.buck.cli.FakeBuckConfig)1 IOException (java.io.IOException)1 Environment (org.elasticsearch.env.Environment)1 Test (org.junit.Test)1