public void RunTestMethod(JavaTestClass javaTestClass, JavaTestMethod javaTestMethod, string originalCodeDirectory, string traceDirectory, string referenceCode = null) { var packageClassAndMethod = $"{javaTestClass.Package}.{javaTestClass.Name}#{javaTestMethod.Name}"; var commandOptions = GetCommandOptions(packageClassAndMethod, originalCodeDirectory, javaTestClass.ClassPath, javaTestClass.Name, javaTestMethod.Name, traceDirectory, referenceCode); var process = new EngineProcess(Command, commandOptions, originalCodeDirectory); try { var exitCode = process.Run(); javaTestMethod.Passed = exitCode == 0; } catch (Exception e) { var exception = new EngineExceptionDto() { Report = JavaEngineReportExceptionFactory .GenerateReportForJunitTestRunnerTestMethodProcess(process, e, javaTestClass, javaTestMethod) }; process.Stop(); throw exception; } process.Stop(); }
private void VerifyCompilation(EngineProcess process, IList <string> sourceFiles) { if (!VerifyCompile(sourceFiles)) { var exception = new EngineExceptionDto() { Report = JavaEngineReportExceptionFactory.GenerateReportForCompileVerification(process, sourceFiles), }; process.Stop(); throw exception; } }
private static void WriteToDisk(string uri, MemoryStream stream) { try { File.WriteAllBytes(uri, stream.GetBuffer()); } catch (Exception exception) { throw new EngineExceptionDto() { Report = JavaEngineReportExceptionFactory .GenerateReportForUnpackWriteToDisk(exception, uri) }; } }
private static void CreateDirectoryPath(string path) { try { Directory.CreateDirectory(path); } catch (IOException exception) { throw new EngineExceptionDto() { Report = JavaEngineReportExceptionFactory .GenerateReportForUnpackCreateDirectoryPath(exception, path) }; } }
private void RunProcess(EngineProcess process) { try { process.Run(); } catch (Exception e) { var exception = new EngineExceptionDto() { Report = JavaEngineReportExceptionFactory .GenerateReportForCompileProcess(process, e) }; process.Stop(); throw exception; } }
public static void UnzipByteArray(byte[] bytes, string source, string destination) { try { var path = Path.Combine(source, "temp.zip"); File.WriteAllText(path, System.Text.Encoding.UTF8.GetString(bytes)); ZipFile.ExtractToDirectory(path, destination); if (File.Exists(path)) { File.Delete(path); } } catch (IOException exception) { throw new EngineExceptionDto { Report = JavaEngineReportExceptionFactory .GenerateReportForUnzipByteArray(exception, source, destination) }; } }