BundleRequestServiceImpl implements BundleRequestService, ServletContextAware { @Override public BundleBuildResponse build(BundleBuildRequest bundleRequest) { String id = getNextId(); bundleRequest.setId(id); BundleBuildResponse bundleResponse = new BundleBuildResponse(id); bundleResponse.setBundleBuildName(bundleRequest.getBundleName()); bundleResponse.setBundleStartDate(bundleRequest.getBundleStartDateString()); bundleResponse.setBundleEndDate(bundleRequest.getBundleEndDateString()); bundleResponse.setBundleComment(bundleRequest.getBundleComment()); _buildMap.put(bundleResponse.getId(), bundleResponse); bundleResponse.addStatusMessage("queueing..."); if (_bundleService != null) { _bundleService.createBundleBuildResponse(bundleResponse); } _executorService.execute(new BuildThread(bundleRequest, bundleResponse)); return bundleResponse; }  @Autowired void setEmailService(EmailService service); @Autowired void setBundleServerService(BundleServerService service); @PostConstruct void setup(); void setInstanceId(String instanceId); String getInstanceId(); @Override /** * Make an asynchronous request to validate bundle(s). The BundleResponse object is * updated upon completion (successful or otherwise) of the validation process. */ BundleResponse validate(BundleRequest bundleRequest); @Override /** * Retrieve a BundleResponse object for the given id. */ BundleResponse lookupValidationRequest(String id); @Override /** * Retrieve a BundleBuildResponse object for the given id. */ BundleBuildResponse lookupBuildRequest(String id); void sendEmail(BundleBuildRequest request, BundleBuildResponse response); @Override BundleBuildResponse buildBundleResultURL(String id); @Override /** * cleanup resources. */ void cleanup(); @Override void setServletContext(ServletContext servletContext); String getServerURL(); void setServerURL(String url); @Override BundleBuildResponse build(BundleBuildRequest bundleRequest); @Autowired void setConfigurationService(ConfigurationService configurationService);  }
@Test public void testBuild() throws Exception { BundleBuildRequest req = new BundleBuildRequest(); String key= "2012Jan"; req.setBundleDirectory(key); req.setBundleName("test_0"); req.setTmpDirectory(new NYCFileUtils().createTmpDirectory()); req.setBundleStartDate("2012-04-08"); req.setBundleEndDate("2012-07-07"); req.setBundleComment("Test Bundle"); _log.debug("calling build for dir=" + req.getBundleDirectory() + " name=" + req.getBundleName()); BundleBuildResponse res = service.build(req); assertFalse(res.isComplete()); int count = 0; while (count < 300 && !res.isComplete() && res.getException() == null) { Thread.sleep(10 * 1000); count++; _log.info("calling lookup(local) for id=" + res.getId()); res = service.lookupBuildRequest(res.getId()); assertNotNull(res); } if (res.getException() != null) { _log.error("Failed with exception=" + res.getException()); } assertNull(res.getException()); assertTrue(res.isComplete()); assertNotNull(res.getGtfsList()); assertEquals(2, res.getGtfsList().size()); }