Search in sources :

Example 1 with NoSuchParameterException

use of org.evosuite.Properties.NoSuchParameterException in project evosuite by EvoSuite.

the class Setup method setup.

private static void setup(String target, String[] args, List<String> javaArgs, boolean doInheritance) {
    Properties.CP = "";
    /*
			Important that target will be first on the CP.
			Otherwise, if for some reasons a dependency uses a same class,
			that would take precedence
		 */
    File targetFile = new File(target);
    if (targetFile.exists()) {
        if (targetFile.isDirectory() || target.endsWith(".jar")) {
            addEntryToCP(target);
        } else if (target.endsWith(".class")) {
            String pathName = targetFile.getParent();
            addEntryToCP(pathName);
        } else {
            LoggingUtils.getEvoLogger().info("Failed to set up classpath for " + target);
            return;
        }
    }
    if (args.length > 0) {
        for (int i = 0; i < args.length; i++) {
            String element = args[i].trim();
            if (element.isEmpty()) {
                continue;
            }
            addEntryToCP(element);
        }
    }
    // TODO why this is done???
    Properties.MIN_FREE_MEM = 0;
    File directory = new File(EvoSuite.base_dir_path + File.separator + Properties.OUTPUT_DIR);
    if (!directory.exists()) {
        directory.mkdir();
    }
    if (doInheritance) {
        try {
            String fileName = EvoSuite.generateInheritanceTree(Properties.CP);
            FileUtils.copyFile(new File(fileName), new File(Properties.OUTPUT_DIR + File.separator + "inheritance.xml.gz"));
            /* 
				  * we need to use '/' instead of File.separator because this value will be written on a text file.
				  * As the relative path will be given to a File object, this will work also on a Windows machine 
				  */
            Properties.getInstance().setValue("inheritance_file", Properties.OUTPUT_DIR + "/" + "inheritance.xml.gz");
        } catch (IOException | IllegalArgumentException | NoSuchParameterException | IllegalAccessException e) {
            LoggingUtils.getEvoLogger().error("* Error while creating inheritance tree: " + e.getMessage());
        }
    }
    LoggingUtils.getEvoLogger().info("* Creating new evosuite.properties in " + EvoSuite.base_dir_path + File.separator + Properties.OUTPUT_DIR);
    LoggingUtils.getEvoLogger().info("* Classpath: " + Properties.CP);
    Properties.getInstance().writeConfiguration(EvoSuite.base_dir_path + File.separator + Properties.OUTPUT_DIR + File.separator + "evosuite.properties");
}
Also used : NoSuchParameterException(org.evosuite.Properties.NoSuchParameterException) IOException(java.io.IOException) File(java.io.File)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 NoSuchParameterException (org.evosuite.Properties.NoSuchParameterException)1