@Test public void testCreateTestCodeCpp() throws Exception { Submission submission = submissionMapper.getSubmission(1000); String workDirectory = "/tmp/voj-1000/"; String baseFileName = "random-name"; preprocessor.createTestCode(submission, workDirectory, baseFileName); FileInputStream inputStream = new FileInputStream("/tmp/voj-1000/random-name.cpp"); String code = IOUtils.toString(inputStream); inputStream.close(); Assertions.assertEquals(submission.getCode(), code); }
public void createTestCode(Submission submission, String workDirectory, String baseFileName) throws Exception { File workDirFile = new File(workDirectory); if ( !workDirFile.exists() && !workDirFile.mkdirs() ) { throw new CreateDirectoryException("Failed to create directory: " + workDirectory); } setWorkDirectoryPermission(workDirFile); Language language = submission.getLanguage(); String code = replaceClassName(language, submission.getCode(), baseFileName); String codeFilePath = String.format("%s/%s.%s", new Object[] {workDirectory, baseFileName, getCodeFileSuffix(language)}); FileOutputStream outputStream = new FileOutputStream(new File(codeFilePath)); IOUtils.write(code, outputStream); IOUtils.closeQuietly(outputStream); }
Preprocessor { public void createTestCode(Submission submission, String workDirectory, String baseFileName) throws Exception { File workDirFile = new File(workDirectory); if ( !workDirFile.exists() && !workDirFile.mkdirs() ) { throw new CreateDirectoryException("Failed to create directory: " + workDirectory); } setWorkDirectoryPermission(workDirFile); Language language = submission.getLanguage(); String code = replaceClassName(language, submission.getCode(), baseFileName); String codeFilePath = String.format("%s/%s.%s", new Object[] {workDirectory, baseFileName, getCodeFileSuffix(language)}); FileOutputStream outputStream = new FileOutputStream(new File(codeFilePath)); IOUtils.write(code, outputStream); IOUtils.closeQuietly(outputStream); } }
Preprocessor { public void createTestCode(Submission submission, String workDirectory, String baseFileName) throws Exception { File workDirFile = new File(workDirectory); if ( !workDirFile.exists() && !workDirFile.mkdirs() ) { throw new CreateDirectoryException("Failed to create directory: " + workDirectory); } setWorkDirectoryPermission(workDirFile); Language language = submission.getLanguage(); String code = replaceClassName(language, submission.getCode(), baseFileName); String codeFilePath = String.format("%s/%s.%s", new Object[] {workDirectory, baseFileName, getCodeFileSuffix(language)}); FileOutputStream outputStream = new FileOutputStream(new File(codeFilePath)); IOUtils.write(code, outputStream); IOUtils.closeQuietly(outputStream); }  }
Preprocessor { public void createTestCode(Submission submission, String workDirectory, String baseFileName) throws Exception { File workDirFile = new File(workDirectory); if ( !workDirFile.exists() && !workDirFile.mkdirs() ) { throw new CreateDirectoryException("Failed to create directory: " + workDirectory); } setWorkDirectoryPermission(workDirFile); Language language = submission.getLanguage(); String code = replaceClassName(language, submission.getCode(), baseFileName); String codeFilePath = String.format("%s/%s.%s", new Object[] {workDirectory, baseFileName, getCodeFileSuffix(language)}); FileOutputStream outputStream = new FileOutputStream(new File(codeFilePath)); IOUtils.write(code, outputStream); IOUtils.closeQuietly(outputStream); }  void createTestCode(Submission submission, 
			String workDirectory, String baseFileName); void fetchTestPoints(long problemId); }
Preprocessor { public void createTestCode(Submission submission, String workDirectory, String baseFileName) throws Exception { File workDirFile = new File(workDirectory); if ( !workDirFile.exists() && !workDirFile.mkdirs() ) { throw new CreateDirectoryException("Failed to create directory: " + workDirectory); } setWorkDirectoryPermission(workDirFile); Language language = submission.getLanguage(); String code = replaceClassName(language, submission.getCode(), baseFileName); String codeFilePath = String.format("%s/%s.%s", new Object[] {workDirectory, baseFileName, getCodeFileSuffix(language)}); FileOutputStream outputStream = new FileOutputStream(new File(codeFilePath)); IOUtils.write(code, outputStream); IOUtils.closeQuietly(outputStream); }  void createTestCode(Submission submission, 
			String workDirectory, String baseFileName); void fetchTestPoints(long problemId);  }