本文整理汇总了Java中com.google.common.jimfs.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于com.google.common.jimfs包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadPaths
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@BeforeAll
static void loadPaths() throws IOException, RunnerException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
String[] paths;
fileSystem = FileTestHelper.createMockFileSystem(Configuration.unix());
fileSystemField = ConversionEntry.class.getDeclaredField("fileSystem");
fileSystemField.setAccessible(true);
defaultFileSystem = (FileSystem) fileSystemField.get(null);
fileSystemField.set(null, fileSystem);
paths = FileTestHelper.getAllQrdaFiles(fileSystem, "-latest.xml").map(Path::toString).toArray(String[]::new);
Options opt = new OptionsBuilder()
.mode(Mode.Throughput)
.mode(Mode.AverageTime)
.include(".*" + ParameterizedBenchmark.class.getSimpleName() + ".*")
.param("fileName", paths)
.forks(1)
.build();
List<RunResult> results = new ArrayList<>(new Runner(opt).run());
benchResults = results.stream()
.map(RunResult::getAggregatedResult)
.collect(Collectors.toList());
}
示例2: setUp
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
fileSystem = Jimfs.newFileSystem(Configuration.unix());
Path rootDir = fileSystem.getPath("/cases");
Files.createDirectories(rootDir);
path1 = rootDir.resolve("n.tst");
path2 = rootDir.resolve("n2.tst");
Files.createFile(path1);
Files.createFile(path2);
ComputationManager computationManager = Mockito.mock(ComputationManager.class);
Network network = Mockito.mock(Network.class);
List<LocalFileScanner> fileExtensions
= Collections.singletonList(new LocalCaseScanner(new ImportConfig(),
new ImportersLoaderList(Collections.singletonList(new TestImporter(network)),
Collections.emptyList())));
storage = new LocalAppStorage(rootDir, "mem", fileExtensions, Collections.emptyList(), computationManager);
}
示例3: testConfig
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@Test
public void testConfig() throws IOException {
TableFormatterConfig config = new TableFormatterConfig();
testConfig(config, Locale.getDefault(), ';', "inv", true, true);
try (FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix())) {
InMemoryPlatformConfig platformConfig = new InMemoryPlatformConfig(fileSystem);
MapModuleConfig moduleConfig = platformConfig.createModuleConfig("table-formatter");
moduleConfig.setStringProperty("language", "en-US");
moduleConfig.setStringProperty("separator", "\t");
moduleConfig.setStringProperty("invalid-string", "NaN");
moduleConfig.setStringProperty("print-header", "false");
moduleConfig.setStringProperty("print-title", "false");
config = TableFormatterConfig.load(platformConfig);
testConfig(config, Locale.US, '\t', "NaN", false, false);
}
}
示例4: test
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@Test
public void test() throws IOException {
try (FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix())) {
InMemoryPlatformConfig platformConfig = new InMemoryPlatformConfig(fileSystem);
MapModuleConfig moduleConfig = platformConfig.createModuleConfig("load-flow-action-simulator");
moduleConfig.setClassProperty("load-flow-factory", LoadFlowFactoryMock.class);
moduleConfig.setStringProperty("max-iterations", "15");
moduleConfig.setStringProperty("ignore-pre-contingency-violations", "true");
LoadFlowActionSimulatorConfig config = LoadFlowActionSimulatorConfig.load(platformConfig);
assertEquals(LoadFlowFactoryMock.class, config.getLoadFlowFactoryClass());
config.setLoadFlowFactoryClass(AnotherLoadFlowFactoryMock.class);
assertEquals(AnotherLoadFlowFactoryMock.class, config.getLoadFlowFactoryClass());
assertEquals(15, config.getMaxIterations());
config.setMaxIterations(10);
assertEquals(10, config.getMaxIterations());
assertTrue(config.isIgnorePreContingencyViolations());
config.setIgnorePreContingencyViolations(false);
assertFalse(config.isIgnorePreContingencyViolations());
}
}
示例5: testByteSource_size_ofDirectory
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
public void testByteSource_size_ofDirectory() throws IOException {
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
Path dir = fs.getPath("dir");
Files.createDirectory(dir);
ByteSource source = MoreFiles.asByteSource(dir);
assertThat(source.sizeIfKnown()).isAbsent();
try {
source.size();
fail();
} catch (IOException expected) {
}
}
}
示例6: testByteSource_size_ofSymlinkToDirectory
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
public void testByteSource_size_ofSymlinkToDirectory() throws IOException {
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
Path dir = fs.getPath("dir");
Files.createDirectory(dir);
Path link = fs.getPath("link");
Files.createSymbolicLink(link, dir);
ByteSource source = MoreFiles.asByteSource(link);
assertThat(source.sizeIfKnown()).isAbsent();
try {
source.size();
fail();
} catch (IOException expected) {
}
}
}
示例7: testByteSource_size_ofSymlinkToRegularFile_nofollowLinks
import com.google.common.jimfs.Configuration; //导入依赖的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) {
}
}
}
示例8: testEqual
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
public void testEqual() throws IOException {
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
Path fooPath = fs.getPath("foo");
Path barPath = fs.getPath("bar");
MoreFiles.asCharSink(fooPath, UTF_8).write("foo");
MoreFiles.asCharSink(barPath, UTF_8).write("barbar");
assertThat(MoreFiles.equal(fooPath, barPath)).isFalse();
assertThat(MoreFiles.equal(fooPath, fooPath)).isTrue();
assertThat(MoreFiles.asByteSource(fooPath).contentEquals(MoreFiles.asByteSource(fooPath)))
.isTrue();
Path fooCopy = Files.copy(fooPath, fs.getPath("fooCopy"));
assertThat(Files.isSameFile(fooPath, fooCopy)).isFalse();
assertThat(MoreFiles.equal(fooPath, fooCopy)).isTrue();
MoreFiles.asCharSink(fooCopy, UTF_8).write("boo");
assertThat(MoreFiles.asByteSource(fooPath).size())
.isEqualTo(MoreFiles.asByteSource(fooCopy).size());
assertThat(MoreFiles.equal(fooPath, fooCopy)).isFalse();
// should also assert that a Path that erroneously reports a size 0 can still be compared,
// not sure how to do that with the Path API
}
}
示例9: testEqual_links
import com.google.common.jimfs.Configuration; //导入依赖的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();
}
}
示例10: testFileIgnoreDetection
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@Test
public void testFileIgnoreDetection() throws IOException {
try (FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix())) {
Files.createDirectory(fileSystem.getPath("/data"));
Files.createDirectory(fileSystem.getPath("/data/ok"));
Files.createDirectory(fileSystem.getPath("/data/bad"));
// Create ok file
Files.createFile(fileSystem.getPath("/data/ok/toto"));
// Create ignore file
Files.createFile(fileSystem.getPath("/data/bad/.photatoignore"));
Assert.assertFalse(FileHelper.folderContainsIgnoreFile(fileSystem.getPath("/data/ok")));
Assert.assertTrue(FileHelper.folderContainsIgnoreFile(fileSystem.getPath("/data/bad")));
}
}
示例11: testEurostagDDB
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@Test
public void testEurostagDDB() throws IOException {
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
Path folder1 = Files.createDirectory(fs.getPath("/folder1"));
Path folder2 = Files.createDirectory(fs.getPath("/folder2"));
Path folder3 = Files.createDirectory(fs.getPath("/folder3"));
Path generator1 = Files.createFile(folder1.resolve("generator1.tg"));
Path generator2 = Files.createFile(folder1.resolve("generator2.tg"));
Files.createFile(folder2.resolve("generator3.tg.bck"));
Path link = Files.createSymbolicLink(folder2.resolve("folder3"), folder3);
Path generator4 = Files.createFile(link.resolve("generator4.tg"));
Path dataFile = Files.createFile(folder3.resolve("generator.data"));
Files.createSymbolicLink(folder3.resolve("generator5.tg"), dataFile);
EurostagDDB eurostagDDB = new EurostagDDB(Arrays.asList(folder1, folder2));
assertEquals(generator1, eurostagDDB.findGenerator("generator1"));
assertEquals(generator2, eurostagDDB.findGenerator("generator2"));
assertNull(eurostagDDB.findGenerator("generator3"));
assertEquals(generator4, eurostagDDB.findGenerator("generator4"));
assertEquals(dataFile, eurostagDDB.findGenerator("generator5"));
}
}
示例12: testLinkFiles
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@Test
public void testLinkFiles() throws IOException {
try (FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
Path folder = Files.createDirectory(fs.getPath("/tmp"));
Path dataFile = Files.createFile(folder.resolve("generator.data"));
Files.createSymbolicLink(folder.resolve("generator1.tg"), dataFile);
Files.createSymbolicLink(folder.resolve("generator2.tg"), dataFile);
Files.createSymbolicLink(folder.resolve("generator3.tg"), dataFile);
Path generator4 = Files.createFile(folder.resolve("generator4.tg"));
EurostagDDB eurostagDDB = new EurostagDDB(Collections.singletonList(folder));
assertEquals(dataFile, eurostagDDB.findGenerator("generator1"));
assertEquals(dataFile, eurostagDDB.findGenerator("generator2"));
assertEquals(dataFile, eurostagDDB.findGenerator("generator3"));
assertEquals(generator4, eurostagDDB.findGenerator("generator4"));
}
}
示例13: testToTask
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@Test
public void testToTask() throws Exception {
Network network = PhaseShifterTestCaseFactory.create();
PhaseTapChanger tapChanger = network.getTwoWindingsTransformer("PS1").getPhaseTapChanger();
assertEquals(1, tapChanger.getTapPosition());
TapChangeAction action = new TapChangeAction("PS1", 2);
ModificationTask task = action.toTask();
try (FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix())) {
Path localDir = fileSystem.getPath("/tmp");
ComputationManager computationManager = new LocalComputationManager(localDir);
task.modify(network, computationManager);
assertEquals(2, tapChanger.getTapPosition());
try {
action.toTask(null);
fail();
} catch (UnsupportedOperationException exc) {
}
}
}
示例14: testMarkdownFiles
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@Test
public void testMarkdownFiles() throws IOException {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path input = fs.getPath("/root/input");
Files.createDirectories(input);
Path inputMd = input.resolve("example1.md");
Files.write(inputMd, "# Example heading 1".getBytes(StandardCharsets.UTF_8));
Path inputMd2 = input.resolve("example2.md");
Files.write(inputMd2, "# Example heading 2".getBytes(StandardCharsets.UTF_8));
Path nonMd = input.resolve(".gitignore");
Files.write(nonMd, "Should be ignored for navigation".getBytes(StandardCharsets.UTF_8));
NavigationNode node = new BuildNavigationStructure(input).build();
Assert.assertTrue(node instanceof Directory);
Assert.assertEquals(2, node.getChildren().size());
Assert.assertTrue(node.getChildren().get(0) instanceof MarkdownPage);
Assert.assertTrue(node.getChildren().get(1) instanceof MarkdownPage);
}
开发者ID:mattsheppard,项目名称:markdown-static-site-generator,代码行数:23,代码来源:BuildNavigationStructureTest.java
示例15: testNonUrlSafeFileNames
import com.google.common.jimfs.Configuration; //导入依赖的package包/类
@Test
public void testNonUrlSafeFileNames() throws IOException {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path input = fs.getPath("/root/input");
Files.createDirectories(input);
Path inputMd = input.resolve("example number one.md");
Files.write(inputMd, "# Spaces example".getBytes(StandardCharsets.UTF_8));
Path inputMd2 = input.resolve("example漏斗回.md");
Files.write(inputMd2, "# Chinese example".getBytes(StandardCharsets.UTF_8));
NavigationNode node = new BuildNavigationStructure(input).build();
// Primarily we're checking that nothing blows up
Assert.assertTrue(node instanceof Directory);
Assert.assertEquals(2, node.getChildren().size());
Assert.assertTrue(node.getChildren().get(0) instanceof MarkdownPage);
Assert.assertTrue(node.getChildren().get(1) instanceof MarkdownPage);
}
开发者ID:mattsheppard,项目名称:markdown-static-site-generator,代码行数:21,代码来源:BuildNavigationStructureTest.java