Copying files and directories in test setup
I'm a complete dummy in Java. I have service for which I need to setup a file directory structure in the test setup.
I thought of using Groovy scripts to copy the files rather than creating batch files. It seems to be an easy task with Apache FileUtils but I can’t figure out how to use it in my Extension script.
I tried to add the org.apache.commons.io jar to the ClassPath and adding an import
import org.apache.commons.io;
but I get the error message:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:, Script13.groovy: 3: unable to resolve class org.apache.commons.io, @ line 3, column 1., import org.apache.commons.io;, ^, , 1 error,
Anyone can help or can suggest another way of doing?
Thanks
Comments
-
I really am a dummy! Only thing I was missing is the star in the import. No need to add ant Classpath...
Here's a working example:
import com.parasoft.api.*; import org.apache.commons.io.*; boolean copyFilesToWorkingDir(Object input, ExtensionToolContext context) { File source = new File("c:\\temp\\a\\a.txt"); File dest = new File("c:\\temp\\b"); FileUtils.copyFileToDirectory(source, dest, true); return true; }
0