Skip to content

Commit d833969

Browse files
Creating default dashboard page onStart
1 parent 8fc958b commit d833969

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

RealTimeReportTestNG/src/main/java/report/realtime/filehandler/CreateFiles.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ synchronized public static void createRequiredFolders(ISuite iSuite) {
8888
}
8989

9090
/*
91-
* STEP 6: Finally create index.html page
91+
* STEP 6: Finally create index.html page and one dashboard.html page per suite
9292
*/
9393
createIndexPage();
94-
94+
createBlankDashboardPage();
9595
}
9696

9797
synchronized private static void copyFilesToDestination(String[] files, String destDirPath) {
@@ -198,6 +198,37 @@ synchronized private static void createIndexPage() {
198198
}
199199
}
200200

201+
/**
202+
* Method will create a dashboard.html page per suite. This page
203+
* will contain only one line - "You are too quick. Please Wait for at least 1 test to end..."
204+
* and will set to auto refresh in every 3sec.
205+
*/
206+
synchronized private static void createBlankDashboardPage(){
207+
for (DataSuite ds : DataMap.suiteSet){
208+
String dashboradHtml = REPORT_DIR + ds.getSuiteHTMLPath();
209+
if (new File(dashboradHtml).exists()) {
210+
new File(dashboradHtml).delete();
211+
}
212+
PrintWriter pw = null;
213+
try {
214+
pw = new PrintWriter(new FileOutputStream(
215+
new File(dashboradHtml), false));
216+
} catch (FileNotFoundException e) {
217+
}
218+
if (pw != null) {
219+
pw.write("<!DOCTYPE HTML>" + "<html>" + "<head>" + "<title>Dashboard</title>"
220+
+ "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />"
221+
+ "<meta http-equiv='refresh' content='3'>" + "</head>"
222+
+ "<body>" + "<div style='font-size: 48px;'>"
223+
+ "You are too quick. Please Wait for at least 1 test to end...</div>"
224+
+ "</body>" + "</html>");
225+
pw.flush();
226+
pw.close();
227+
228+
}
229+
}
230+
}
231+
201232
synchronized private static void writeToFile(final InputStream input, final File target){
202233
try(OutputStream output = Files.newOutputStream(target.toPath())){
203234
byte[] buffer = new byte[8 * 1024];

0 commit comments

Comments
 (0)