Java Code Examples for com.google.common.jimfs.Jimfs#newFileSystem()

The following examples show how to use com.google.common.jimfs.Jimfs#newFileSystem() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZipPackagerTest.java    From powsybl-core with Mozilla Public License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
    workingDir = fileSystem.getPath("/wd");
    Path f1 = workingDir.resolve("f1");
    Path f2 = workingDir.resolve("f2");
    Path f3 = workingDir.resolve("f3.gz");
    try {
        Files.createDirectories(workingDir);
        try (BufferedWriter f1Writer = Files.newBufferedWriter(f1, StandardCharsets.UTF_8);
             BufferedWriter f2Writer = Files.newBufferedWriter(f2, StandardCharsets.UTF_8);
             OutputStream f3Writer = new GZIPOutputStream(Files.newOutputStream(f3))) {
            f1Writer.write("foo");
            f2Writer.write("bar");
            f3Writer.write(Strings.toByteArray("hello"));
        }
    } catch (IOException e) {
        fail();
    }
}
 
Example 2
Source File: ComputationExceptionBuilderTest.java    From powsybl-core with Mozilla Public License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
    workingDir = fileSystem.getPath("/wd");
    f1 = workingDir.resolve("f1.out");
    f2 = workingDir.resolve("f2.err");
    try {
        Files.createDirectories(workingDir);
        try (BufferedWriter writer = Files.newBufferedWriter(f1, StandardCharsets.UTF_8);
             BufferedWriter w2 = Files.newBufferedWriter(f2, StandardCharsets.UTF_8);) {
            writer.write("foo");
            w2.write("bar");
        }
    } catch (IOException e) {
        fail();
    }
}
 
Example 3
Source File: FileUtilsTest.java    From startup-os with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
  fileSystem = Jimfs.newFileSystem(fileSystemConfig);
  CommonComponent commonComponent =
      DaggerCommonComponent.builder()
          .commonModule(
              new CommonModule() {
                @Provides
                @Singleton
                @Override
                public FileSystem provideDefaultFileSystem() {
                  return fileSystem;
                }
              })
          .build();
  fileUtils = commonComponent.getFileUtils();
}
 
Example 4
Source File: DistributedSecurityAnalysisTest.java    From powsybl-core with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * Checks config class read from config file.
 */
@Test
public void testConfigFromFile() throws IOException {
    try (FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix())) {
        InMemoryPlatformConfig platformConfig = new InMemoryPlatformConfig(fileSystem);

        ExternalSecurityAnalysisConfig config = ExternalSecurityAnalysisConfig.load(platformConfig);
        assertFalse(config.isDebug());
        assertEquals("itools", config.getItoolsCommand());

        MapModuleConfig moduleConfig = platformConfig.createModuleConfig("external-security-analysis-config");
        moduleConfig.setStringProperty("debug", "true");
        moduleConfig.setStringProperty("itools-command", "/path/to/itools");
        config = ExternalSecurityAnalysisConfig.load(platformConfig);
        assertTrue(config.isDebug());
        assertEquals("/path/to/itools", config.getItoolsCommand());
    }
}
 
Example 5
Source File: XmlPlatformConfigTest.java    From powsybl-core with Mozilla Public License 2.0 5 votes vote down vote up
@Test
public void properties2XmlConvertionTest() throws IOException, XMLStreamException {
    try (FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix())) {
        Path cfgDir = Files.createDirectory(fileSystem.getPath("config"));
        Properties prop1 = new Properties();
        prop1.setProperty("a", "hello");
        prop1.setProperty("b", "bye");
        try (Writer w = Files.newBufferedWriter(cfgDir.resolve("mod1.properties"), StandardCharsets.UTF_8)) {
            prop1.store(w, null);
        }
        Properties prop2 = new Properties();
        prop2.setProperty("c", "thanks");
        try (Writer w = Files.newBufferedWriter(cfgDir.resolve("mod2.properties"), StandardCharsets.UTF_8)) {
            prop2.store(w, null);
        }
        PlatformConfig propsConfig = new PlatformConfig(new PropertiesModuleConfigRepository(cfgDir), cfgDir);
        assertEquals("hello", propsConfig.getModuleConfig("mod1").getStringProperty("a"));
        assertEquals("bye", propsConfig.getModuleConfig("mod1").getStringProperty("b"));
        assertEquals("thanks", propsConfig.getModuleConfig("mod2").getStringProperty("c"));
        Path xmlConfigFile = cfgDir.resolve("config.xml");
        PropertiesModuleConfigRepository.writeXml(cfgDir, xmlConfigFile);

        PlatformConfig xmlConfig = new PlatformConfig(new XmlModuleConfigRepository(xmlConfigFile), cfgDir);
        assertEquals("hello", xmlConfig.getModuleConfig("mod1").getStringProperty("a"));
        assertEquals("bye", xmlConfig.getModuleConfig("mod1").getStringProperty("b"));
        assertEquals("thanks", xmlConfig.getModuleConfig("mod2").getStringProperty("c"));
    }
}
 
Example 6
Source File: FilePermissionSampleTest.java    From cloud-search-samples with Apache License 2.0 5 votes vote down vote up
@Before
public void createFileSystem() {
  Configuration filesystemConfig = Configuration.unix().toBuilder()
      .setAttributeViews("basic", "owner", "posix", "unix", "acl")
      .setWorkingDirectory("/home/user")
      .setBlockSize(4096)
      .build();
  fileSystem = Jimfs.newFileSystem(filesystemConfig);
}
 
Example 7
Source File: ConversionTester.java    From powsybl-core with Mozilla Public License 2.0 5 votes vote down vote up
public void validateBusBalances(Network network) throws IOException {
    try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
        ValidationConfig config = loadFlowValidationConfig(validateBusBalancesThreshold);
        Path working = Files.createDirectories(fs.getPath("lf-validation"));

        computeMissingFlows(network, config.getLoadFlowParameters());
        assertTrue(ValidationType.BUSES.check(network, config, working));
    }
}
 
Example 8
Source File: ComponentDefaultConfigTest.java    From powsybl-core with Mozilla Public License 2.0 5 votes vote down vote up
@Before
public void setUp() throws IOException {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
    InMemoryPlatformConfig platformConfig = new InMemoryPlatformConfig(fileSystem);
    moduleConfig = platformConfig.createModuleConfig("componentDefaultConfig");
    config = new ComponentDefaultConfig.Impl(moduleConfig);
}
 
Example 9
Source File: CandidateComputationsTest.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
    platformConfig = new InMemoryPlatformConfig(fileSystem);
}
 
Example 10
Source File: FileAsyncResponseTransformerTest.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void setup() {
    testFs = Jimfs.newFileSystem();
}
 
Example 11
Source File: GroovyDynamicModelSupplierTest.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void setup() throws IOException {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());

    Files.copy(getClass().getResourceAsStream("/dynamicModels.groovy"), fileSystem.getPath("/dynamicModels.groovy"));
}
 
Example 12
Source File: NetworkLoadSaveGroovyScriptExtensionTest.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
    Network network = EurostagTutorialExample1Factory.create();
    NetworkXml.write(network, fileSystem.getPath("/work/n.xiidm"));
}
 
Example 13
Source File: ClassicPlatformConfigProviderTest.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void setUp() throws IOException {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
}
 
Example 14
Source File: DynamicSimulationParametersTest.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
    platformConfig = new InMemoryPlatformConfig(fileSystem);
}
 
Example 15
Source File: BfgTest.java    From BUILD_file_generator with Apache License 2.0 4 votes vote down vote up
private static FileSystem createDefaultFileSystem() {
  return Jimfs.newFileSystem(Configuration.forCurrentPlatform().toBuilder().build());
}
 
Example 16
Source File: SimulationParametersConfigTest.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
    platformConfig = new InMemoryPlatformConfig(fileSystem);
}
 
Example 17
Source File: LoadFlowResultsCompletionPostProcessorTest.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
    platformConfig = new InMemoryPlatformConfig(fileSystem);
    super.setUp();
}
 
Example 18
Source File: ExportTest.java    From powsybl-core with Mozilla Public License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    fileSystem = Jimfs.newFileSystem(Configuration.unix());
    exportFolder = Files.createDirectory(fileSystem.getPath(exportFolderName));
}
 
Example 19
Source File: ConccTestMockFileLoader.java    From Concurnas with MIT License 4 votes vote down vote up
public ConccTestMockFileLoader() {
	fs = Jimfs.newFileSystem(Configuration.unix());
}
 
Example 20
Source File: ResourceLocatorTest.java    From flink-statefun with Apache License 2.0 4 votes vote down vote up
public ResourceLocatorTest(Configuration filesystemConfiguration) {
  this.fileSystem = Jimfs.newFileSystem(filesystemConfiguration);
}