本文整理了Java中org.mule.runtime.core.api.util.FileUtils.newFile()
方法的一些代码示例,展示了FileUtils.newFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.newFile()
方法的具体详情如下:
包路径:org.mule.runtime.core.api.util.FileUtils
类名称:FileUtils
方法名:newFile
[英]Workaround for JDK bug 4117557. More in-context information at MULE-1112
Factory methods correspond to constructors of the java.io.File class
. No physical file created in this method.
[中]JDK错误4117557的解决方法。更多上下文信息,请访问MULE-1112
工厂方法对应于java.io.File class
的构造函数。没有在此方法中创建物理文件。
代码示例来源:origin: mulesoft/mule
/**
* Initialises the directory for the deployment properties in case it does not exist.
*
* @param deploymentPropertiesPath the path to persist the deployment properties.
*/
private static void initDeploymentPropertiesDirectory(String deploymentPropertiesPath) {
File deploymentPropertiesDirectory = newFile(deploymentPropertiesPath);
if (!deploymentPropertiesDirectory.exists()) {
createDeploymentPropertiesDirectory(deploymentPropertiesDirectory);
}
}
代码示例来源:origin: mulesoft/mule
public File getLog(String appName) {
File log = newFile(format("%s/logs/mule-app-%s.log", osSpecificController.getMuleHome(), appName));
if (log.exists() && log.isFile()) {
return log;
}
throw new MuleControllerException(format("There is no app log available at %s/logs/mule-app-%s",
osSpecificController.getMuleHome(), appName));
}
代码示例来源:origin: mulesoft/mule
@BeforeClass
public static void setUpPatches() {
File libFolder = newFile(workingDirectory.getRoot(), "lib/patches");
libFolder.mkdirs();
newFile(libFolder, FIRST_PATCH).mkdir();
newFile(libFolder, "library.jar").mkdir();
newFile(libFolder, SECOND_PATCH).mkdir();
File servicesFolder = newFile(workingDirectory.getRoot(), "services");
servicesFolder.mkdir();
newFile(servicesFolder, "myService.zip").mkdir();
}
代码示例来源:origin: mulesoft/mule
public void generateSchemaTestResource(ExtensionModel model, File generatedResourcesDirectory) {
String xsdFileName = model.getXmlDslModel().getXsdFileName();
try {
ExtensionSchemaGenerator schemaGenerator = getSchemaGenerator();
Set<ExtensionModel> models = new HashSet<>(extensionManager.getExtensions());
models.add(MuleExtensionModelProvider.getExtensionModel());
String schema = schemaGenerator.generate(model, DslResolvingContext.getDefault(models));
File xsd = FileUtils.newFile(generatedResourcesDirectory, xsdFileName);
FileUtils.copyStreamToFile(new ByteArrayInputStream(schema.getBytes()), xsd);
} catch (IOException e) {
throw new RuntimeException(format("Error generating test xsd resource [%s]: " + e.getMessage(), xsdFileName, e));
}
}
代码示例来源:origin: mulesoft/mule
/**
* Used to obtain base directory used in tests. Uses the build directory; "target" in the current working directory.
*/
private File getBuidDirectory() {
return FileUtils.newFile(getUserDir(), "target");
}
代码示例来源:origin: mulesoft/mule
@Test
public void testDeleteTreeWithIgnoredDirectories() throws Exception {
final String testDir = TEST_DIRECTORY + File.separator + "Test-deleting";
File outputDir = FileUtils.newFile(testDir);
if (!outputDir.exists()) {
outputDir.mkdirs();
}
File toBeDeleted1 = FileUtils.newFile(outputDir, "toBeDeleted1/");
toBeDeleted1.mkdirs();
File toBeDeleted2 = FileUtils.newFile(outputDir, "toBeDeleted2/");
toBeDeleted2.mkdirs();
File keepMeIntact = FileUtils.newFile(outputDir, "keepMeIntact/");
keepMeIntact.mkdirs();
FileUtils.deleteTree(outputDir, new String[] {"keepMeIntact"});
assertTrue("Shouldn't have been deleted.", keepMeIntact.exists());
FileUtils.deleteTree(outputDir);
}
代码示例来源:origin: mulesoft/mule
private static void addRuntimeLibrary(String libraryFileName) throws MalformedURLException {
File library = newFile(workingDirectory.getRoot(), getAppPathFor(libraryFileName));
library.mkdir();
runtimeLibs.add(workingDirectory.getRoot().toURL());
runtimeLibs.add(library.toURI().toURL());
}
代码示例来源:origin: mulesoft/mule
@BeforeClass
public static void setUpLibrary() throws IOException {
File libFile = newFile(workingDirectory.getRoot(), DOMAIN_LIB_PATH);
libFile.mkdirs();
newFile(workingDirectory.getRoot(), getDomainPathFor(SOME_JAR)).mkdir();
newFile(workingDirectory.getRoot(), getDomainPathFor(MY_ZIP)).mkdir();
}
代码示例来源:origin: mulesoft/mule
@Test
public void testUnzipFileToSameFolderTwice() throws Exception {
URL resourceAsUrl = IOUtils.getResourceAsUrl("testFolder.zip", getClass());
File zipFile = new File(resourceAsUrl.toURI());
File outputDir = FileUtils.newFile(TEST_DIRECTORY);
for (int i = 0; i < 2; i++) {
unzip(zipFile, outputDir);
File testFile = new File(UNZIPPED_FILE_PATH);
assertTrue(testFile.exists());
}
}
代码示例来源:origin: mulesoft/mule
@BeforeClass
public static void setUpLibrary() throws IOException {
File libFile = newFile(workingDirectory.getRoot(), APP_LIB_PATH);
libFile.mkdirs();
addRuntimeLibrary(MY_JAR);
}
代码示例来源:origin: mulesoft/mule
@AfterClass
public static void disposeContext() throws MuleException {
try {
if (muleContext != null && !(muleContext.isDisposed() || muleContext.isDisposing())) {
try {
muleContext.dispose();
} catch (IllegalStateException e) {
// Ignore
LOGGER.warn(e + " : " + e.getMessage());
}
verifyAndStopSchedulers();
MuleConfiguration configuration = muleContext.getConfiguration();
if (configuration != null) {
final String workingDir = configuration.getWorkingDirectory();
// do not delete TM recovery object store, everything else is good to
// go
deleteTree(newFile(workingDir), IGNORED_DOT_MULE_DIRS);
}
}
deleteTree(newFile("./ActiveMQ"));
} finally {
muleContext = null;
clearLoggingConfig();
}
}
代码示例来源:origin: mulesoft/mule
@Test
public void testExtractResources() throws Exception {
String testDir = TEST_DIRECTORY + File.separator + "Test-2";
File outputDir = FileUtils.newFile(testDir);
if (!outputDir.exists()) {
outputDir.mkdirs();
}
String res = "META-INF/";
FileUtils.extractResources(res, getClass(), outputDir, true);
File result = FileUtils.newFile(testDir, res);
assertNotNull(result);
assertTrue(result.exists());
assertTrue(result.canRead());
assertTrue(result.isDirectory());
FileUtils.deleteTree(outputDir);
}
代码示例来源:origin: mulesoft/mule
@Test
public void testExtractFileResource() throws Exception {
String testDir = TEST_DIRECTORY + File.separator + "Test-3";
File outputDir = FileUtils.newFile(testDir);
if (!outputDir.exists()) {
outputDir.mkdirs();
}
String res = "org/mule/runtime/core/api/util/FileUtils.class";
FileUtils.extractResources(res, FileUtils.class, outputDir, true);
File result = FileUtils.newFile(testDir, res);
assertNotNull(result);
assertTrue(result.exists());
assertTrue(result.canRead());
assertTrue(result.isFile());
assertTrue(result.length() > 0);
FileUtils.deleteTree(outputDir);
}
代码示例来源:origin: mulesoft/mule
@Test
public void testExtractFileResources() throws Exception {
String testDir = TEST_DIRECTORY + File.separator + "Test-4";
File outputDir = FileUtils.newFile(testDir);
if (!outputDir.exists()) {
outputDir.mkdirs();
}
String res = "org/mule/runtime/core/api/util/";
FileUtils.extractResources(res, FileUtils.class, outputDir, true);
File result = FileUtils.newFile(testDir, res);
assertNotNull(result);
assertTrue(result.exists());
assertTrue(result.canRead());
assertTrue(result.isDirectory());
FileUtils.deleteTree(outputDir);
}
代码示例来源:origin: mulesoft/mule
@Test
public void testExtractResourceWithoutKeepingDirStructure() throws Exception {
String testDir = TEST_DIRECTORY + File.separator + "Test-5";
File outputDir = FileUtils.newFile(testDir);
if (!outputDir.exists()) {
outputDir.mkdirs();
}
String fileName = "MANIFEST.MF";
String res = "META-INF/" + fileName;
FileUtils.extractResources(res, getClass(), outputDir, false);
File result = FileUtils.newFile(testDir, fileName);
assertNotNull(result);
assertTrue(result.exists());
assertTrue(result.canRead());
assertTrue(result.isFile());
assertTrue(result.length() > 0);
FileUtils.deleteTree(outputDir);
}
代码示例来源:origin: mulesoft/mule
@Test
public void testExtractFileResourceWithoutKeepingDirStructure() throws Exception {
String testDir = TEST_DIRECTORY + File.separator + "Test-7";
File outputDir = FileUtils.newFile(testDir);
if (!outputDir.exists()) {
outputDir.mkdirs();
}
String fileName = "FileUtils.class";
String res = "org/mule/runtime/core/api/util/" + fileName;
FileUtils.extractResources(res, FileUtils.class, outputDir, false);
File result = FileUtils.newFile(testDir, fileName);
assertNotNull(result);
assertTrue(result.exists());
assertTrue(result.canRead());
assertTrue(result.isFile());
assertTrue(result.length() > 0);
FileUtils.deleteTree(outputDir);
}
代码示例来源:origin: mulesoft/mule
@Test
public void testExtractFileResourcesWithoutKeepingDirStructure() throws Exception {
String testDir = TEST_DIRECTORY + File.separator + "Test-8";
File outputDir = FileUtils.newFile(testDir);
if (!outputDir.exists()) {
outputDir.mkdirs();
}
String fileName = "util/FileUtilsTestCase.class";
String res = "org/mule/runtime/core/api/";
FileUtils.extractResources(res, FileUtilsTestCase.class, outputDir, false);
File result = FileUtils.newFile(testDir, fileName);
assertNotNull(result);
assertTrue(result.exists());
assertTrue(result.canRead());
assertTrue(result.isFile());
assertTrue(result.length() > 0);
FileUtils.deleteTree(outputDir);
}
代码示例来源:origin: mulesoft/mule
@Test
public void testExtractResource() throws Exception {
String testDir = TEST_DIRECTORY + File.separator + "Test-1";
File outputDir = FileUtils.newFile(testDir);
if (!outputDir.exists()) {
assertTrue("Failed to create output dirs.", outputDir.mkdirs());
}
String res = "META-INF/MANIFEST.MF";
FileUtils.extractResources(res, getClass(), outputDir, true);
File result = FileUtils.newFile(testDir, res);
assertNotNull(result);
assertTrue(result.exists());
assertTrue(result.canRead());
assertTrue(result.isFile());
assertTrue(result.length() > 0);
FileUtils.deleteTree(outputDir);
}
代码示例来源:origin: mulesoft/mule
@Test
public void testExtractResourcesWithoutKeepingDirStructure() throws Exception {
String testDir = TEST_DIRECTORY + File.separator + "Test-6";
File outputDir = FileUtils.newFile(testDir);
if (!outputDir.exists()) {
outputDir.mkdirs();
}
String fileName = "util/FileUtilsTestCase.class";
String res = "org/mule/runtime/core/api";
FileUtils.extractResources(res, FileUtilsTestCase.class, outputDir, false);
File result = FileUtils.newFile(testDir, fileName);
assertNotNull(result);
assertTrue(result.exists());
assertTrue(result.canRead());
assertTrue(result.isFile());
assertTrue(result.length() > 0);
FileUtils.deleteTree(outputDir);
}
代码示例来源:origin: mulesoft/mule
String content = readFileToString(FileUtils.newFile(TEST_FILE), (String) null);
assertTrue(content.indexOf(" and this is appended content") > -1);
file = FileUtils.newFile(TEST_FILE);
assertNotNull(file);
assertTrue(file.exists());
file.delete();
file = FileUtils.newFile(TEST_FILE);
file.delete();
内容来源于网络,如有侵权,请联系作者删除!