gt: 		confDir = new File(testDirectory, "conf");
context: /*******************************************************************************
   * Pineapple - a tool to install, configure and test Java web applications 
   * and infrastructure. 
   * 
   * Copyright (C) 2007-2012 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.web.spring.rest;
  
  import static com.alpha.pineapple.web.WebApplicationConstants.LOCATION_HEADER;
  import static com.alpha.pineapple.web.WebApplicationConstants.REST_EXECUTE_EXECUTE_URI;
  import static com.alpha.pineapple.web.WebApplicationConstants.REST_EXECUTE_STATUS_URI;
  import static com.alpha.pineapple.web.WebApplicationConstants.REST_EXECUTE_URI;
  import static com.alpha.testutils.TestUtilsTestConstants.helloWorldOperation;
  import static com.alpha.testutils.TestUtilsTestConstants.pluginIdHelloWorld;
  import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
  import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
  import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
  import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
  import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
  
  import java.io.File;
  import java.util.List;
  import java.util.concurrent.CopyOnWriteArrayList;
  
  import javax.annotation.Resource;
  
  import org.apache.commons.lang3.RandomStringUtils;
  import org.hamcrest.core.StringContains;
  import org.junit.After;
  import org.junit.Before;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  import org.springframework.http.MediaType;
  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.context.support.DirtiesContextTestExecutionListener;
  import org.springframework.test.context.web.WebAppConfiguration;
  import org.springframework.test.web.servlet.MockMvc;
  import org.springframework.test.web.servlet.MvcResult;
  import org.springframework.test.web.servlet.setup.MockMvcBuilders;
  import org.springframework.web.context.WebApplicationContext;
  
  import com.alpha.javautils.ConcurrencyUtils;
  import com.alpha.javautils.SystemUtils;
  import com.alpha.pineapple.PineappleCore;
  import com.alpha.pineapple.execution.ExecutionResult;
  import com.alpha.pineapple.execution.ExecutionResultNotification;
  import com.alpha.pineapple.execution.ResultListener;
  import com.alpha.pineapple.model.configuration.Configuration;
  import com.alpha.pineapple.web.WebAppCoreFactory;
  import com.alpha.springutils.DirectoryTestExecutionListener;
  import com.alpha.testutils.ObjectMotherEnvironmentConfiguration;
  import com.alpha.testutils.ObjectMotherModule;
  
  /**
   * Integration test of class {@linkplain ExecuteController}.
   * 
   * PLEASE NOTICE: The {@linkplain WebAppCoreFactory} is used in the test to
   * reinitialize the core component. The core component is reinitialized to make
   * it pick up the definition of the Pineapple home directory in the setup()
   * method.
   * 
   * The core component is initialized when the test runner processes
   * the @ContextConfiguration annotation which will initialize the core component
   * to the default Pineapple home directory. To enable each test to have
   * individual configurations the core component is reinitialized.
   */
  @RunWith(SpringJUnit4ClassRunner.class)
  @WebAppConfiguration
  @ContextConfiguration("file:src/main/webapp/WEB-INF/spring/webapp-config.xml")
  @TestExecutionListeners({ DirtiesContextTestExecutionListener.class, DependencyInjectionTestExecutionListener.class,
  		DirectoryTestExecutionListener.class })
  public class ExecuteControllerIntegrationTest {
  
  	/**
  	 * First list index.
  	 */
  	final static int FIRST_INDEX = 0;
  
  	/**
  	 * Event capturing result listener.
  	 */
  	class CapturingResultListener implements ResultListener {
  
  		/**
  		 * Captured result notfications.
  		 */
  		List<ExecutionResultNotification> notifications;
  
  		/**
  		 * Captured root results.
  		 */
  		List<ExecutionResult> rootResults;
  
  		/**
  		 * CapturingResultListener constructor.
  		 */
  		public CapturingResultListener() {
  			super();
  			notifications = new CopyOnWriteArrayList<ExecutionResultNotification>();
  		}
  
  		@Override
  		public void notify(ExecutionResultNotification notification) {
  			notifications.add(notification);
  		}
  	}
  
  	/**
  	 * Current test directory.
  	 */
  	File testDirectory;
  
  	/**
  	 * Web application context
  	 */
  	@Resource
  	WebApplicationContext wac;
  
  	/**
  	 * Web application core component factory.
  	 */
  	@Resource
  	WebAppCoreFactory webAppCoreFactory;
  
  	/**
  	 * Object mother for environment configuration.
  	 */
  	ObjectMotherEnvironmentConfiguration envConfigMother;
  
  	/**
  	 * Core component.
  	 * 
  	 * Initialize by web application core component factory.
  	 */
  	PineappleCore coreComponent;
  
  	/**
  	 * Mock MVC.
  	 */
  	MockMvc mockMvc;
  
  	/**
  	 * Modules directory.
  	 */
  	File modulesDir;
  
  	/**
  	 * Conf directory.
  	 */
  	File confDir;
  
  	/**
  	 * Object mother for module.
  	 */
  	ObjectMotherModule moduleMother;
  
  	/**
  	 * Random execution ID.
  	 */
  	String randomExecutionID;
  
  	/**
  	 * Random module.
  	 */
  	String randomModule;
  
  	/**
  	 * Random operation.
  	 */
  	String randomOperation;
  
  	/**
  	 * Random environment.
  	 */
  	String randomEnvironment;
  
  	/**
  	 * Random resource name.
  	 */
  	String randomResource;
  
  	/**
  	 * Capturing result listener.
  	 */
  	CapturingResultListener capturingListener;
  
  	@Before
  	public void setUp() throws Exception {
  		randomExecutionID = RandomStringUtils.randomAlphabetic(10);
  		randomModule = RandomStringUtils.randomAlphabetic(10);
  		randomOperation = RandomStringUtils.randomAlphabetic(10);
  		randomEnvironment = RandomStringUtils.randomAlphabetic(10);
  		randomResource = RandomStringUtils.randomAlphabetic(10) + "-resource";
  
  		// create module object mother
  		moduleMother = new ObjectMotherModule();
  
  		// create environment configuration object mother
  		envConfigMother = new ObjectMotherEnvironmentConfiguration();
  
  		// get the test directory
  		testDirectory = DirectoryTestExecutionListener.getCurrentTestDirectory();
  
  		// define directory names
  		modulesDir = new File(testDirectory, "modules");
  