// Path: spring-mvc-asynch/src/main/java/se/callista/springmvc/asynch/Application.java
// @ComponentScan()
// @EnableAutoConfiguration
// public class Application {
// 
//     @SuppressWarnings("unused")
//     private static final Logger LOG = LoggerFactory.getLogger(Application.class);
// 
//     @Bean
//     public EmbeddedServletContainerCustomizer embeddedServletCustomizer(){
//         return new MyEmbeddedServletContainerCustomizer();
//     }
// 
//     @Value("${threadPool.db.init_size}")
//     private int THREAD_POOL_DB_INIT_SIZE;
// 
//     @Value("${threadPool.db.max_size}")
//     private int THREAD_POOL_DB_MAX_SIZE;
// 
//     @Value("${threadPool.db.queue_size}")
//     private int THREAD_POOL_DB_QUEUE_SIZE;
// 
//     @Bean(name="dbThreadPoolExecutor")
//     public TaskExecutor getTaskExecutor() {
//         ThreadPoolTaskExecutor tpte = new ThreadPoolTaskExecutor();
//         tpte.setCorePoolSize(THREAD_POOL_DB_INIT_SIZE);
//         tpte.setMaxPoolSize(THREAD_POOL_DB_MAX_SIZE);
//         tpte.setQueueCapacity(THREAD_POOL_DB_QUEUE_SIZE);
//         tpte.initialize();
//         return tpte;
//     }
// 
//     @Bean
//     public AsyncHttpClientLambdaAware getAsyncHttpClient() {
//         LOG.info("### Creates a new AsyncHttpClientLambdaAware-object");
//         return new AsyncHttpClientLambdaAware();
//     }
// 
//     public static void main(String[] args) {
//         SpringApplication.run(Application.class, args);
//     }
// }
// 
// Path: spring-mvc-asynch/src/test/java/se/callista/springmvc/asynch/common/AsynchTestBase.java
// abstract public class AsynchTestBase extends EmbeddedHttpServerTestBase {
// 
//     private static final Logger LOG = LoggerFactory.getLogger(AsynchTestBase.class);
// 
//     protected void createResponse(HttpServletRequest request, String requestBody, HttpServletResponse response) throws IOException, URISyntaxException {
// 
//         Map<String, String> parMap = new HashMap<>();
//         parMap.put("minMs", "0");
//         parMap.put("maxMs", "0");
//         getQueryParameters(request, parMap);
// 
//         int minMs = Integer.parseInt(parMap.get("minMs"));
//         int maxMs = Integer.parseInt(parMap.get("maxMs"));
//         int processingTimeMs = calculateProcessingTime(minMs, maxMs);
// 
//         LOG.debug("Start blocking request, processing time: {} ms (" + minMs + " - " + maxMs + ").", processingTimeMs);
//         try {
//             Thread.sleep(processingTimeMs);
//         }
//         catch (InterruptedException e) {}
// 
//         String responseBody = "{\"status\":\"Ok\",\"processingTimeMs\":" + processingTimeMs + "}";
//         response.setStatus(SC_OK);
//         response.setContentType("text/plain;charset=ISO-8859-1");
//         write(responseBody, response.getOutputStream());
//     }
// 
//     private int calculateProcessingTime(int minMs, int maxMs) {
//         if (maxMs < minMs) maxMs = minMs;
//         int processingTimeMs = minMs + (int) (Math.random() * (maxMs - minMs));
//         return processingTimeMs;
//     }
// }


import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
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 se.callista.springmvc.asynch.Application;
import se.callista.springmvc.asynch.common.AsynchTestBase;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
package se.callista.springmvc.asynch.pattern.routingslip;




/**
 * Created by magnus on 29/05/14.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
// Path: spring-mvc-asynch/src/main/java/se/callista/springmvc/asynch/Application.java
// @ComponentScan()
// @EnableAutoConfiguration
// public class Application {
// 
//     @SuppressWarnings("unused")
//     private static final Logger LOG = LoggerFactory.getLogger(Application.class);
// 
//     @Bean
//     public EmbeddedServletContainerCustomizer embeddedServletCustomizer(){
//         return new MyEmbeddedServletContainerCustomizer();
//     }
// 
//     @Value("${threadPool.db.init_size}")
//     private int THREAD_POOL_DB_INIT_SIZE;
// 
//     @Value("${threadPool.db.max_size}")
//     private int THREAD_POOL_DB_MAX_SIZE;
// 
//     @Value("${threadPool.db.queue_size}")
//     private int THREAD_POOL_DB_QUEUE_SIZE;
// 
//     @Bean(name="dbThreadPoolExecutor")
//     public TaskExecutor getTaskExecutor() {
//         ThreadPoolTaskExecutor tpte = new ThreadPoolTaskExecutor();
//         tpte.setCorePoolSize(THREAD_POOL_DB_INIT_SIZE);
//         tpte.setMaxPoolSize(THREAD_POOL_DB_MAX_SIZE);
//         tpte.setQueueCapacity(THREAD_POOL_DB_QUEUE_SIZE);
//         tpte.initialize();
//         return tpte;
//     }
// 
//     @Bean
//     public AsyncHttpClientLambdaAware getAsyncHttpClient() {
//         LOG.info("### Creates a new AsyncHttpClientLambdaAware-object");
//         return new AsyncHttpClientLambdaAware();
//     }
// 
//     public static void main(String[] args) {
//         SpringApplication.run(Application.class, args);
//     }
// }
// 
// Path: spring-mvc-asynch/src/test/java/se/callista/springmvc/asynch/common/AsynchTestBase.java
// abstract public class AsynchTestBase extends EmbeddedHttpServerTestBase {
// 
//     private static final Logger LOG = LoggerFactory.getLogger(AsynchTestBase.class);
// 
//     protected void createResponse(HttpServletRequest request, String requestBody, HttpServletResponse response) throws IOException, URISyntaxException {
// 
//         Map<String, String> parMap = new HashMap<>();
//         parMap.put("minMs", "0");
//         parMap.put("maxMs", "0");
//         getQueryParameters(request, parMap);
// 
//         int minMs = Integer.parseInt(parMap.get("minMs"));
//         int maxMs = Integer.parseInt(parMap.get("maxMs"));
//         int processingTimeMs = calculateProcessingTime(minMs, maxMs);
// 
//         LOG.debug("Start blocking request, processing time: {} ms (" + minMs + " - " + maxMs + ").", processingTimeMs);
//         try {
//             Thread.sleep(processingTimeMs);
//         }
//         catch (InterruptedException e) {}
// 
//         String responseBody = "{\"status\":\"Ok\",\"processingTimeMs\":" + processingTimeMs + "}";
//         response.setStatus(SC_OK);
//         response.setContentType("text/plain;charset=ISO-8859-1");
//         write(responseBody, response.getOutputStream());
//     }
// 
//     private int calculateProcessingTime(int minMs, int maxMs) {
//         if (maxMs < minMs) maxMs = minMs;
//         int processingTimeMs = minMs + (int) (Math.random() * (maxMs - minMs));
//         return processingTimeMs;
//     }
// }


// Path: spring-mvc-asynch/src/test/java/se/callista/springmvc/asynch/pattern/routingslip/RoutingSlipControllerTest.java
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
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 se.callista.springmvc.asynch.Application;
import se.callista.springmvc.asynch.common.AsynchTestBase;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

package se.callista.springmvc.asynch.pattern.routingslip;




/**
 * Created by magnus on 29/05/14.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
public class RoutingSlipControllerTest extends AsynchTestBase {