List of usage examples for org.apache.commons.io FileUtils toFile
public static File toFile(URL url)
URL
to a File
. From source file:org.jboss.pressgang.ccms.contentspec.client.commands.PullCommandTest.java
@Before public void setUp() { bindStdOut();/*from ww w. j ava 2s . c o m*/ command = new PullCommand(parser, cspConfig, clientConfig); rootTestDirectory = FileUtils.toFile(ClassLoader.getSystemResource("")); when(cspConfig.getRootOutputDirectory()).thenReturn(rootTestDirectory.getAbsolutePath() + File.separator); }
From source file:org.jboss.pressgang.ccms.contentspec.client.commands.PullSnapshotCommandTest.java
@Before public void setUp() { bindStdOut();/* w ww . j av a2 s . c o m*/ command = new PullSnapshotCommand(parser, cspConfig, clientConfig); // Authentication is tested in the base implementation so assume all users are valid TestUtil.setUpAuthorisedUser(command, userProvider, users, user, username); when(providerFactory.getRESTManager()).thenReturn(restManager); when(restManager.getRESTClient()).thenReturn(restClient); rootTestDirectory = FileUtils.toFile(ClassLoader.getSystemResource("")); when(cspConfig.getRootOutputDirectory()).thenReturn(rootTestDirectory.getAbsolutePath() + File.separator); }
From source file:org.jboss.pressgang.ccms.contentspec.client.commands.SetupCommandTest.java
@Before public void setUp() { bindStdOut();/*w w w .j a v a 2 s . co m*/ command = new SetupCommand(parser, cspConfig, clientConfig); rootTestDirectory = FileUtils.toFile(ClassLoader.getSystemResource("")); }
From source file:org.jboss.pressgang.ccms.contentspec.client.commands.SnapshotCommandTest.java
@Before public void setUp() { bindStdOut();// w w w. ja va 2 s. c o m command = spy(new SnapshotCommand(parser, cspConfig, clientConfig)); // Authentication is tested in the base implementation so assume all users are valid TestUtil.setUpAuthorisedUser(command, userProvider, users, user, username); when(providerFactory.getRESTManager()).thenReturn(restManager); when(restManager.getRESTClient()).thenReturn(restClient); when(restClient.freezeJSONTextContentSpec(anyInt(), anyString(), anyBoolean(), anyInt(), anyBoolean(), anyString(), anyInt(), anyString())).thenReturn(textContentSpec); rootTestDirectory = FileUtils.toFile(ClassLoader.getSystemResource("")); when(cspConfig.getRootOutputDirectory()).thenReturn(rootTestDirectory.getAbsolutePath() + File.separator); }
From source file:org.jboss.pressgang.ccms.contentspec.client.commands.TemplateCommandTest.java
@Before public void setUp() { bindStdOut();/*from ww w. j a va 2 s. c o m*/ command = new TemplateCommand(parser, cspConfig, clientConfig); // Return the test directory as the root directory rootTestDirectory = FileUtils.toFile(ClassLoader.getSystemResource("")); }
From source file:org.jboss.pressgang.ccms.contentspec.client.utils.ClientUtilitiesTest.java
@Before public void setUp() throws IOException { bindStdOut();//from w w w . j a v a2 s . com doCallRealMethod().when(command).printErrorAndShutdown(anyInt(), anyString(), anyBoolean()); // Return the test directory as the root directory rootTestDirectory = FileUtils.toFile(ClassLoader.getSystemResource("")); when(cspConfig.getRootOutputDirectory()).thenReturn(rootTestDirectory.getAbsolutePath() + File.separator); // Make the book title directory bookDir = new File(rootTestDirectory, BOOK_TITLE); bookDir.mkdir(); // Make a empty file in that directory emptyFile = new File(bookDir, EMPTY_FILE_NAME); emptyFile.createNewFile(); // Set up the server settings mock TestUtil.setUpServerSettings(serverSettings, serverEntities); }
From source file:org.jboss.pvt.generic.PVTTestSuite.java
private void init() throws PVTSystemException { if (System.getProperty(PROPERTY_CONFIG) != null && !System.getProperty(PROPERTY_CONFIG).trim().isEmpty()) { configFile = System.getProperty(PROPERTY_CONFIG).trim(); }//ww w.j a va 2 s .co m logger.info("Config file: " + configFile); File confFile = new File(configFile); if (configFile.startsWith("http://")) { try { FileUtils.copyURLToFile(new URL(configFile), confFile); } catch (Exception e) { throw new PVTSystemException(e); } } else { confFile = FileUtils.toFile(PVTTestSuite.class.getResource("/" + configFile)); } logger.info("Config file loaded: " + confFile); configuration = new YAMLConfigurationLoader().loadConfig(confFile); if (System.getProperty(PROPERTY_VERSION) != null && !System.getProperty(PROPERTY_VERSION).trim().isEmpty()) { // override the version defined in config file configuration.setVersion(System.getProperty(PROPERTY_VERSION).trim()); } if (System.getProperty(PROPERTY_TARGET) != null && !System.getProperty(PROPERTY_TARGET).trim().isEmpty()) { // override the version defined in config file configuration.setTarget(System.getProperty(PROPERTY_TARGET).trim()); } // init report report = new Report(configuration); for (Map.Entry<String, TestConfig> entry : configuration.getTests().entrySet()) { report.addTestReport(new TestReport(entry.getKey(), entry.getValue())); } }
From source file:org.jbpm.form.builder.services.impl.fs.FSMenuService.java
protected void writeToURL(URL url, String json) throws FileNotFoundException, IOException { if (url.toExternalForm().startsWith("vfs")) { FileObject to = VFS.getManager().resolveFile(url.toExternalForm()); File tmpFile = File.createTempFile("xxFilexx", ".json"); FileUtils.writeStringToFile(tmpFile, json); FileObject from = VFS.getManager().toFileObject(tmpFile); to.copyFrom(from, new AllFileSelector()); FileUtils.deleteQuietly(tmpFile); } else {//w w w . j a v a 2s . c o m FileUtils.writeStringToFile(FileUtils.toFile(url), json); } }
From source file:org.jbpm.form.builder.services.impl.fs.FSMenuService.java
protected String readURL(URL url) throws FileNotFoundException, IOException { if (url.toExternalForm().startsWith("vfs")) { FileObject from = VFS.getManager().resolveFile(url.toExternalForm()); return IOUtils.toString(from.getContent().getInputStream()); } else {// www . j a v a 2 s . com return FileUtils.readFileToString(FileUtils.toFile(url)); } }
From source file:org.kalypso.afgui.wizards.UnpackProjectTemplateOperation.java
private void unpackProjectData(final URL data, final File destinationDir) throws IOException, CoreException { final String location = data.toString(); final String extension = FilenameUtils.getExtension(location); if ("zip".equalsIgnoreCase(extension)) //$NON-NLS-1$ ZipUtilities.unzip(data, destinationDir); else {// ww w. j a va2 s . com final URL fileURL = FileLocator.toFileURL(data); final File dataDir = FileUtils.toFile(fileURL); if (dataDir == null) { final String msg = String.format("Invalid dataLocation: %s", data); //$NON-NLS-1$ final IStatus status = new Status(IStatus.ERROR, KalypsoAFGUIFrameworkPlugin.PLUGIN_ID, msg); throw new CoreException(status); } if (dataDir.isDirectory()) { FileUtils.copyDirectory(dataDir, destinationDir, FileFilterUtils.makeSVNAware(null)); removePDEfiles(destinationDir); } else { final String msg = String.format("Invalid dataLocation (not a directory): %s", data); //$NON-NLS-1$ final IStatus status = new Status(IStatus.ERROR, KalypsoAFGUIFrameworkPlugin.PLUGIN_ID, msg); throw new CoreException(status); } } }