org.apache.commons.lang.SystemUtils#FILE_SEPARATOR源码实例Demo

下面列出了org.apache.commons.lang.SystemUtils#FILE_SEPARATOR 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gatf   文件: GatfConfigToolMojo.java
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);
	}
}
 
源代码2 项目: gatf   文件: GatfReportsHandler.java
@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();
	    }
	}
   }
 
源代码3 项目: gatf   文件: GatfConfigToolUtil.java
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);
	}
}