.withBoxUrl(VagrantUtils.getInstance().getLucid32Url())
.withName("UniTestVm").build();
VagrantEnvironmentConfig envConfig = new VagrantEnvironmentConfigBuilder()
.withVagrantVmConfig(vmConfig).build();
VagrantEnvironment environment = null;
try {
environment = vagrant.createEnvironment(vagrantTempDir, envConfig);
environment.up();
} catch (Exception exception) {
exception.printStackTrace();
Assert.fail(exception.getMessage());
} finally {
if(environment != null) {
try {
environment.removeBox(boxName);
environment.destroy();
try {
FileUtils.forceDelete(vagrantTempDir);
} catch (Exception e) {
try {
FileUtils.forceDeleteOnExit(vagrantTempDir);
} catch (IOException e1) {
System.err.println("Can not delete vagrantfolder: "
+ vagrantTempDir);
}
}
} catch (Exception removeException) {
removeException.printStackTrace();
String boxPath = null;
try {
boxPath = environment.getBoxesPath();
} catch (Exception e) {
//...
}
try {
FileUtils.forceDelete(vagrantTempDir);