gt: 		File finalTestDir = new File(testDirectory, randomDirName);
context: /*******************************************************************************
   * Pineapple - a tool to install, configure and test Java web applications 
   * and infrastructure. 
   * 
  * Copyright (C) 2007-2019 Allan Thrane Andersen.
   * 
   * This file is part of Pineapple.
   * 
   * Pineapple is free software: you can redistribute it and/or modify it under
   *  the terms of the GNU General Public License as published by the Free 
   * Software Foundation, either version 3 of the License, or (at your option) 
   * any later version.
   * 
   * Pineapple is distributed in the hope that it will be useful, but WITHOUT 
   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
   * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public 
   * license for more details.
   * 
   * You should have received a copy of the GNU General Public License along 
   * with Pineapple. If not, see <http://www.gnu.org/licenses/>.
   ******************************************************************************/
  
  package com.alpha.pineapple.command;
  
  import static org.junit.Assert.assertEquals;
  import static org.junit.Assert.assertFalse;
  import static org.junit.Assert.assertTrue;
  
  import java.io.File;
  import java.util.List;
  
  import javax.annotation.Resource;
  
  import org.apache.commons.chain.Command;
  import org.apache.commons.chain.Context;
  import org.apache.commons.chain.impl.ContextBase;
  import org.apache.commons.io.FileUtils;
  import org.apache.commons.lang3.RandomStringUtils;
  import org.easymock.EasyMock;
  import org.junit.After;
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.test.context.ContextConfiguration;
  import org.springframework.test.context.TestExecutionListeners;
  import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
  import org.springframework.test.util.ReflectionTestUtils;
  
  import com.alpha.pineapple.CoreConstants;
  import com.alpha.pineapple.execution.ExecutionResult;
  import com.alpha.pineapple.execution.ExecutionResultImpl;
  import com.alpha.pineapple.io.file.RuntimeDirectoryProvider;
  import com.alpha.pineapple.model.configuration.Configuration;
  import com.alpha.pineapple.model.configuration.Environment;
  import com.alpha.springutils.DirectoryTestExecutionListener;
  import com.alpha.testutils.ObjectMotherEnvironmentConfiguration;
  
  /**
   * integration test of the class
   * {@link CreateDefaultEnvironmentConfigurationCommand}.
   * 
   * Please notice that the runtime directory provider is mocked to enable
   * override of the configured directories.
   */
  @RunWith(SpringJUnit4ClassRunner.class)
  @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirectoryTestExecutionListener.class })
  @ContextConfiguration(locations = { "/com.alpha.pineapple.core-config.xml" })
  public class CreateDefaulConfigurationCommandIntegrationTest {
  
  	/**
  	 * Name of test module of class path.
  	 */
  	static final String ARCHIVE_ON_CLASSPATH = "test-archive-on-plasspath.jar";
  
  	/**
  	 * Object under test.
  	 */
  	@Resource
  	Command createDefaultEnvironmentConfigurationCommand;
  
  	/**
  	 * Execution result.
  	 */
  	ExecutionResult executionResult;
  
  	/**
  	 * Current test directory.
  	 */
  	File testDirectory;
  
  	/**
  	 * Configuration object mother
  	 */
  	ObjectMotherEnvironmentConfiguration configMother;
  
  	/**
  	 * Random resouces name.
  	 */
  	String randomXmlResourceName;
  
  	/**
  	 * Random credentials name.
  	 */
  	String randomXmlCredentialsName;
  
  	/**
  	 * Random name.
  	 */
  	String randomName;
  
  	/**
  	 * Random dir name.
  	 */
  	String randomDirName;
  
  	/**
  	 * Random dir name.
  	 */
  	String randomDirName2;
  
  	/**
  	 * Mock Runtime directory resolver.
  	 */
  	RuntimeDirectoryProvider runtimeDirectoryProvider;
  
  	/**
  	 * Example modules directory.
  	 */
  	File exampleModulesdir = new File("example-modules");
  
  	@Before
  	public void setUp() throws Exception {
  		randomName = RandomStringUtils.randomAlphabetic(10);
  		randomXmlResourceName = RandomStringUtils.randomAlphabetic(10) + ".xml";
  		randomXmlCredentialsName = RandomStringUtils.randomAlphabetic(10) + ".xml";
  		randomDirName = RandomStringUtils.randomAlphabetic(10);
  		randomDirName2 = RandomStringUtils.randomAlphabetic(10);
  
  		// get the test directory
  		testDirectory = DirectoryTestExecutionListener.getCurrentTestDirectory();
  
  		// create execution result
  		executionResult = new ExecutionResultImpl("Root result");
  
  		// configuration object mother
  		configMother = new ObjectMotherEnvironmentConfiguration();
  
  		// create mock provider
  		runtimeDirectoryProvider = EasyMock.createMock(RuntimeDirectoryProvider.class);
  
  		// inject provider
  		ReflectionTestUtils.setField(createDefaultEnvironmentConfigurationCommand, "runtimeDirectoryProvider",
  				runtimeDirectoryProvider);
  	}
  
  	@After
  	public void tearDown() throws Exception {
  		testDirectory = null;
  		configMother = null;
  		createDefaultEnvironmentConfigurationCommand = null;
  		executionResult = null;
  	}
  
  	/**
  	 * Test that files are create if none exists.
  	 * 
  	 * @throws Exception If test fails.
  	 */
  	@SuppressWarnings("unchecked")
  	@Test
  	public void testDefaultConfigurationIsCreated() throws Exception {
  		// complete mock setup
  		EasyMock.expect(runtimeDirectoryProvider.getConfigurationDirectory()).andReturn(testDirectory);
  		EasyMock.expect(runtimeDirectoryProvider.getModulesDirectory()).andReturn(testDirectory);
  		EasyMock.replay(runtimeDirectoryProvider);
  
  		// create file names
  		File resourcesFile = new File(testDirectory, CoreConstants.RESOURCE_FILE);
  		File credentailsFile = new File(testDirectory, CoreConstants.CREDENTIALS_FILE);
  
  		// test
  		assertFalse(resourcesFile.exists());
  		assertFalse(credentailsFile.exists());
  
  		// setup context
  		Context context = new ContextBase();
  		context.put(CreateDefaultEnvironmentConfigurationCommand.EXECUTIONRESULT_KEY, executionResult);
  
  		// execute command
  		createDefaultEnvironmentConfigurationCommand.execute(context);
  
  		// test
  		assertTrue(resourcesFile.exists());
  		assertTrue(resourcesFile.isFile());
  		assertTrue(credentailsFile.exists());
  		assertTrue(credentailsFile.isFile());
  		assertTrue(executionResult.isSuccess());
  		assertFalse(executionResult.isExecuting());
  
  		// verify
  		EasyMock.verify(runtimeDirectoryProvider);
  	}
  
  	/**
  	 * Test that files are create if none exists and even if all directories doesn't
  	 * exist
  	 * 
  	 * @throws Exception If test fails.
  	 */
  	@SuppressWarnings("unchecked")
  	@Test
  	public void testDefaultConfigurationIsCreatedIfDirectoriesDoesnExist() throws Exception {
  