Java Code Examples for org.apache.commons.lang.SystemUtils#FILE_SEPARATOR
The following examples show how to use
org.apache.commons.lang.SystemUtils#FILE_SEPARATOR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GatfConfigToolMojo.java From gatf with Apache License 2.0 | 4 votes |
public void execute() throws MojoExecutionException, MojoFailureException { HttpServer server = new HttpServer(); final String mainDir = rootDir + SystemUtils.FILE_SEPARATOR + "gatf-config-tool"; InputStream resourcesIS = GatfConfigToolMojo.class.getResourceAsStream("/gatf-config-tool.zip"); if (resourcesIS != null) { ReportHandler.unzipZipFile(resourcesIS, rootDir); } final GatfConfigToolMojo mojo = this; GatfConfigToolUtil.createConfigFileIfNotExists(mojo, true, null); GatfConfigToolUtil.createConfigFileIfNotExists(mojo, false, null); GatfConfigToolUtil.createServerApiAndIssueTrackingApiFilesIfNotExists(mojo); server.addListener(new NetworkListener("ConfigServer", ipAddress, port)); GatfConfigToolUtil.handleRootContext(server, mainDir, mojo); Function<String, GatfPlugin> f = new Function<String, GatfPlugin>() { @Override public GatfPlugin apply(String type) { GatfPlugin gp = null; if(type.equals("executor")) { gp = new GatfTestCaseExecutorMojo(); } else { gp = new GatfTestGeneratorMojo(); } gp.setProject(project); return gp; } }; server.getServerConfiguration().addHttpHandler(new GatfConfigurationHandler(mojo, f), "/configure"); server.getServerConfiguration().addHttpHandler(new GatfReportsHandler(mojo, f), "/reports"); server.getServerConfiguration().addHttpHandler(new GatfMiscHandler(mojo), "/misc"); server.getServerConfiguration().addHttpHandler(new GatfTestCaseFilesHandler(mojo), "/testcasefiles"); server.getServerConfiguration().addHttpHandler(new GatfTestCaseHandler(mojo), "/testcases"); server.getServerConfiguration().addHttpHandler(new GatfPluginExecutionHandler(mojo, f), "/execute"); server.getServerConfiguration().addHttpHandler(new GatfProfileHandler(mojo, f), "/profile"); try { server.start(); System.out.println("Press any key to stop the server..."); System.in.read(); } catch (Exception e) { System.err.println(e); } }
Example 2
Source File: GatfReportsHandler.java From gatf with Apache License 2.0 | 4 votes |
@Override public void service(Request request, Response response) throws Exception { response.setHeader("Cache-Control", "no-cache, no-store"); try { final GatfExecutorConfig gatfConfig = GatfConfigToolUtil.getGatfExecutorConfig(mojo, null); String basepath = gatfConfig.getOutFilesBasePath()==null?mojo.getRootDir():gatfConfig.getOutFilesBasePath(); String dirPath = basepath + SystemUtils.FILE_SEPARATOR + gatfConfig.getOutFilesDir(); if(!new File(dirPath).exists()) { new File(dirPath).mkdir(); } if(request.getMethod().equals(Method.GET) ) { new CacheLessStaticHttpHandler(dirPath).service(request, response); } else if(request.getMethod().equals(Method.PUT) ) { String action = request.getParameter("action"); String testcaseFileName = request.getParameter("testcaseFileName"); String testCaseName = request.getParameter("testCaseName"); boolean isServerLogsApi = request.getParameter("isServerLogsApi")!=null; boolean isExternalLogsApi = request.getParameter("isExternalLogsApi")!=null; TestCaseReport tcReport = null; if(action.equals("replayTest")) { tcReport = new org.codehaus.jackson.map.ObjectMapper().readValue(request.getInputStream(), TestCaseReport.class); if(tcReport == null) { throw new RuntimeException("Invalid testcase report details provided"); } } else if(isExternalLogsApi && !action.equals("playTest")) { tcReport = new org.codehaus.jackson.map.ObjectMapper().readValue(request.getInputStream(), TestCaseReport.class); } Object[] out = executeTest(gatfConfig, tcReport, action, testcaseFileName, testCaseName, isServerLogsApi, isExternalLogsApi, 0, false); if(out[1]!=null) { response.setContentType(out[2].toString()); response.setContentLength(((String)out[1]).length()); response.getWriter().write((String)out[1]); } response.setStatus((HttpStatus)out[0]); } } catch (Exception e) { GatfConfigToolUtil.handleError(e, response, null); } finally { if(lock.isLocked()) { lock.unlock(); } } }
Example 3
Source File: GatfConfigToolUtil.java From gatf with Apache License 2.0 | 4 votes |
public void execute() throws Exception { HttpServer server = new HttpServer(); final String mainDir = rootDir + SystemUtils.FILE_SEPARATOR + "gatf-config-tool"; InputStream resourcesIS = GatfConfigToolUtil.class.getResourceAsStream("/gatf-config-tool.zip"); if (resourcesIS != null) { ReportHandler.unzipZipFile(resourcesIS, rootDir); } final GatfConfigToolUtil mojo = this; createConfigFileIfNotExists(mojo, true, null); createConfigFileIfNotExists(mojo, false, null); createServerApiAndIssueTrackingApiFilesIfNotExists(mojo); server.addListener(new NetworkListener("ConfigServer", ipAddress, port)); handleRootContext(server, mainDir, mojo); Function<String, GatfPlugin> f = new Function<String, GatfPlugin>() { @Override public GatfPlugin apply(String type) { GatfPlugin gp = null; if(type.equals("executor")) { gp = new GatfTestCaseExecutorUtil(); } else { gp = new GatfTestGeneratorUtil(); } return gp; } }; server.getServerConfiguration().addHttpHandler(new GatfConfigurationHandler(mojo, f), "/configure"); server.getServerConfiguration().addHttpHandler(new GatfReportsHandler(mojo, f), "/reports"); server.getServerConfiguration().addHttpHandler(new GatfMiscHandler(mojo), "/misc"); server.getServerConfiguration().addHttpHandler(new GatfTestCaseFilesHandler(mojo), "/testcasefiles"); server.getServerConfiguration().addHttpHandler(new GatfTestCaseHandler(mojo), "/testcases"); server.getServerConfiguration().addHttpHandler(new GatfPluginExecutionHandler(mojo, f), "/execute"); server.getServerConfiguration().addHttpHandler(new GatfProfileHandler(mojo, f), "/profile"); try { server.start(); System.out.println("Press any key to stop the server..."); System.in.read(); } catch (Exception e) { System.err.println(e); } }