mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +00:00
[TASK] Added Unit test
This commit is contained in:
@@ -46,8 +46,8 @@ public class FileExceptionHandler extends ExceptionHandler {
|
||||
StringBuilder reportContent = new StringBuilder();
|
||||
reportContent.append(e.getMessage() + "\n\n");
|
||||
|
||||
for (StackTraceElement stackTraceElement : e.getStackTrace()) {
|
||||
reportContent.append(stackTraceElement);
|
||||
for (int i = 0; i < e.getStackTrace().length; i++) {
|
||||
reportContent.append((i > 0 ? " " : "") + e.getStackTrace()[i] + "\n");
|
||||
}
|
||||
|
||||
FileUtil.writeFileContents(report, reportContent.toString());
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.parabot;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.parabot.environment.handlers.exceptions.ExceptionHandler;
|
||||
import org.parabot.environment.handlers.exceptions.FileExceptionHandler;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class FileExceptionHandlerTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
FileExceptionHandler serverHandler = new FileExceptionHandler(ExceptionHandler.ExceptionType.SERVER);
|
||||
serverHandler.setIgnored(true);
|
||||
|
||||
File[] reports = serverHandler.getReportsDirectory().listFiles();
|
||||
int reportCount = 0;
|
||||
if (reports != null) {
|
||||
reportCount = reports.length;
|
||||
}
|
||||
|
||||
Exception exception = new Exception("Test");
|
||||
serverHandler.handle(exception);
|
||||
|
||||
Assert.assertTrue(serverHandler.getReportsDirectory().listFiles().length > reportCount);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user