use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project controller by opendaylight.
the class JMXGeneratorTest method generateMBEsTest.
@Test
public void generateMBEsTest() throws Exception {
// default value for module factory file is true
map.put(JMXGenerator.MODULE_FACTORY_FILE_BOOLEAN, "randomValue");
jmxGenerator.setAdditionalConfig(map);
Collection<File> files = jmxGenerator.generateSources(context, outputBaseDir, Collections.singleton(threadsJavaModule), m -> Optional.empty());
assertEquals(expectedModuleFileNames, toFileNames(files));
for (File file : files) {
final String name = file.getName();
if (!name.endsWith("java")) {
continue;
}
MbeASTVisitor visitor = new MbeASTVisitor(EXPECTED_PACKAGE_PREFIX + ".threads.java", name);
verifyFile(file, visitor);
switch(name) {
case "AbstractDynamicThreadPoolModule.java":
assertAbstractDynamicThreadPoolModule(visitor);
break;
case "AsyncEventBusModuleMXBean.java":
assertEquals("Incorrenct number of generated methods", 4, visitor.methods.size());
break;
case "AbstractNamingThreadFactoryModuleFactory.java":
assertAbstractNamingThreadFactoryModuleFactory(visitor);
break;
case "AsyncEventBusModule.java":
assertContains(visitor.extnds, EXPECTED_PACKAGE_PREFIX + ".threads.java.AbstractAsyncEventBusModule");
visitor.assertFields(0);
assertEquals("Incorrenct number of generated methods", 2, visitor.methods.size());
visitor.assertConstructors(2);
visitor.assertMethodDescriptions(0);
visitor.assertMethodJavadocs(0);
break;
case "EventBusModuleFactory.java":
assertContains(visitor.extnds, EXPECTED_PACKAGE_PREFIX + ".threads.java.AbstractEventBusModuleFactory");
visitor.assertFields(0);
assertEquals("Incorrenct number of generated methods", 0, visitor.methods.size());
visitor.assertConstructors(0);
visitor.assertMethodDescriptions(0);
visitor.assertMethodJavadocs(0);
break;
}
}
verifyXmlFiles(Collections2.filter(files, input -> input.getName().endsWith("xml")));
// verify ModuleFactory file
File moduleFactoryFile = JMXGenerator.concatFolders(generatedResourcesDir, "META-INF", "services", ModuleFactory.class.getName());
assertTrue(moduleFactoryFile.exists());
Set<String> lines = ImmutableSet.copyOf(Files.readLines(moduleFactoryFile, StandardCharsets.UTF_8));
Set<String> expectedLines = ImmutableSet.of(EXPECTED_PACKAGE_PREFIX + ".threads.java.EventBusModuleFactory", EXPECTED_PACKAGE_PREFIX + ".threads.java.AsyncEventBusModuleFactory", EXPECTED_PACKAGE_PREFIX + ".threads.java.DynamicThreadPoolModuleFactory", EXPECTED_PACKAGE_PREFIX + ".threads.java.NamingThreadFactoryModuleFactory", EXPECTED_PACKAGE_PREFIX + ".threads.java.ThreadPoolRegistryImplModuleFactory");
assertEquals(expectedLines, lines);
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project sonar-java by SonarSource.
the class XmlFileSensorTest method test_issues_creation.
@Test
public void test_issues_creation() throws Exception {
SensorContextTester context = SensorContextTester.create(new File("src/test/files/maven/").getAbsoluteFile());
DefaultFileSystem fs = context.fileSystem();
final File file = new File("src/test/files/maven/pom.xml");
DefaultInputFile inputFile = new TestInputFileBuilder("", "pom.xml").setModuleBaseDir(fs.baseDirPath()).setPublish(false).build();
fs.add(inputFile);
SonarComponents sonarComponents = createSonarComponentsMock(fs, file);
XmlFileSensor sensor = new XmlFileSensor(sonarComponents, fs);
assertThat(inputFile.isPublished()).isFalse();
sensor.execute(context);
assertThat(inputFile.isPublished()).isTrue();
verify(sonarComponents, times(1)).reportIssue(Mockito.argThat(argument -> file.getAbsolutePath().equals(argument.getFile().getAbsolutePath())));
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project j2objc by google.
the class Options method getPathArgument.
private List<String> getPathArgument(String argument, boolean expandAarFiles, boolean expandWildcard) {
List<String> entries = new ArrayList<>();
for (String entry : Splitter.on(File.pathSeparatorChar).split(argument)) {
if (entry.startsWith("~/")) {
// Expand bash/csh tildes, which don't get expanded by the shell
// first if in the middle of a path string.
entry = System.getProperty("user.home") + entry.substring(1);
}
File f = new File(entry);
if (f.getName().equals("*") && expandWildcard) {
File parent = f.getParentFile() == null ? new File(".") : f.getParentFile();
FileFilter jarFilter = file -> file.getName().endsWith(".jar");
File[] files = parent.listFiles(jarFilter);
if (files != null) {
for (File jar : files) {
entries.add(jar.toString());
}
}
continue;
}
if (entry.endsWith(".aar") && expandAarFiles) {
// Extract classes.jar from Android library AAR file.
f = fileUtil().extractClassesJarFromAarFile(f);
}
if (f.exists()) {
entries.add(f.toString());
}
}
return entries;
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project knime-core by knime.
the class NodeViewManagerTest method testGetNodeViewPageUrl.
/**
* Tests {@link NodeViewManager#getNodeViewPageUrl(NativeNodeContainer)}.
*
* @throws URISyntaxException
* @throws IOException
*/
@Test
public void testGetNodeViewPageUrl() throws URISyntaxException, IOException {
var staticPage = Page.builder(BUNDLE_ID, "files", "page.html").addResourceFile("resource.html").build();
var dynamicPage = Page.builder(() -> "page content", "page.html").addResourceFromString(() -> "resource content", "resource.html").build();
NativeNodeContainer nnc = createNodeWithNodeView(m_wfm, m -> createNodeView(staticPage));
NativeNodeContainer nnc2 = createNodeWithNodeView(m_wfm, m -> createNodeView(staticPage));
NativeNodeContainer nnc3 = createNodeWithNodeView(m_wfm, m -> createNodeView(dynamicPage));
var nodeViewManager = NodeViewManager.getInstance();
String url = nodeViewManager.getNodeViewPageUrl(nnc).orElse("");
String url2 = nodeViewManager.getNodeViewPageUrl(nnc2).orElse(null);
String url3 = nodeViewManager.getNodeViewPageUrl(nnc3).orElse(null);
String url4 = nodeViewManager.getNodeViewPageUrl(nnc3).orElse(null);
assertThat("file url of static pages not expected to change", url, is(url2));
assertThat("file url of dynamic pages expected to change between node instances", url, is(not(url3)));
assertThat("file url of dynamic pages not expected for same node instance (without node state change)", url3, is(url4));
assertThat("resource files are expected to be written, too", new File(new URI(url.replace("page.html", "resource.html"))).exists(), is(true));
assertThat(new File(new URI(url)).exists(), is(true));
assertThat(new File(new URI(url3)).exists(), is(true));
String pageContent = Files.readLines(new File(new URI(url3)), StandardCharsets.UTF_8).get(0);
assertThat(pageContent, is("page content"));
// impose node state changes
m_wfm.executeAllAndWaitUntilDone();
var dynamicPage2 = Page.builder(() -> "new page content", "page.html").addResourceFromString(() -> "resource content", "resource.html").build();
nnc = createNodeWithNodeView(m_wfm, m -> createNodeView(dynamicPage2));
String url5 = nodeViewManager.getNodeViewPageUrl(nnc).orElse(null);
pageContent = Files.readLines(new File(new URI(url5)), StandardCharsets.UTF_8).get(0);
assertThat(pageContent, is("new page content"));
runOnExecutor(() -> assertThat(nodeViewManager.getNodeViewPageUrl(nnc2).isEmpty(), is(true)));
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Files in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method getResultFiles.
@ApiOperation("Get result files of the submission.")
@GetMapping("/api/v1/analysis-management/submissions/{submissionId}/results")
public List<ResultFileDTO> getResultFiles(Principal principal, @PathVariable("submissionId") Long submissionId, @RequestParam(value = "path", required = false, defaultValue = "") String path, @RequestParam(value = "real-name", required = false) String realName) throws PermissionDeniedException, IOException {
IUser user = userService.getByUsername(principal.getName());
ResultFileSearch resultFileSearch = new ResultFileSearch();
resultFileSearch.setPath(path);
resultFileSearch.setRealName(realName);
List<? extends ArachneFileMeta> resultFileList = submissionService.getResultFiles(user, submissionId, resultFileSearch);
String resultFilesPath = contentStorageHelper.getResultFilesDir(Submission.class, submissionId, null);
return resultFileList.stream().map(rf -> {
ResultFileDTO rfDto = conversionService.convert(rf, ResultFileDTO.class);
rfDto.setSubmissionId(submissionId);
rfDto.setRelativePath(contentStorageHelper.getRelativePath(resultFilesPath, rfDto.getPath()));
return rfDto;
}).collect(Collectors.toList());
}
Aggregations