Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Copying files and directories in test setup

PBeland
PBeland Posts: 14

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

Tagged:

Comments

  • PBeland
    PBeland Posts: 14

    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;    
    }
    

Tagged