1 package org.openkilda.test;
3 import java.io.BufferedInputStream;
4 import java.io.BufferedReader;
6 import java.io.FileOutputStream;
7 import java.io.FileReader;
8 import java.io.IOException;
9 import java.net.MalformedURLException;
11 import java.util.ArrayList;
12 import java.util.List;
14 import org.apache.log4j.Logger;
15 import org.junit.Assert;
16 import org.junit.Test;
27 private static final Logger LOGGER = Logger.getLogger(
BaseTest.class);
34 LOGGER.info(
"Inside method executeKildaFiles");
36 List<String> urlList =
new ArrayList<String>();
39 try (BufferedReader bufferedReader =
new BufferedReader(
new FileReader(f))) {
40 while ((readLine = bufferedReader.readLine()) != null) {
41 urlList.add(readLine);
43 }
catch (Exception exception) {
45 "exception occured Inside method executeKildaFiles: " + exception.getMessage());
48 for (String
url : urlList) {
50 String[] inputValue =
url.split(
"/");
51 String FileName = inputValue[inputValue.length - 1];
53 if (
url.contains(
".css")) {
56 Assert.assertTrue(
true);
58 if (
url.contains(
".js")) {
64 Assert.assertTrue(
true);
66 if (
url.contains(
"ttf") ||
url.contains(
"woff2") ||
url.contains(
"woff")) {
69 Assert.assertTrue(
true);
71 if (
url.contains(
"Roboto")) {
74 Assert.assertTrue(
true);
77 }
catch (Exception exception) {
78 LOGGER.error(
"exception occured Inside method executeKildaFiles : " 79 + exception.getMessage());
80 Assert.assertTrue(
false);
83 LOGGER.info(
"executeKildaFiles has been successfully executed");
93 private void downloadFiles(
final String urlStr,
final String file) {
96 if (!directory.exists()) {
100 if (file.contains(IConstantsTest.JAVASCRIPT_PATH)) {
101 File directory =
new File(IConstantsTest.CLASSPATH + IConstantsTest.JAVASCRIPT_PATH);
102 if (!directory.exists()) {
107 File fileObject =
new File(file);
108 if (fileObject.exists()) {
112 LOGGER.info(
"Downloading file " + file);
114 FileOutputStream fileOutputStream = null;
115 BufferedInputStream bufferedInputStream = null;
118 url =
new URL(urlStr);
119 bufferedInputStream =
new BufferedInputStream(
url.openStream());
120 fileOutputStream =
new FileOutputStream(file);
121 byte[] buffer =
new byte[1024];
124 while ((
count = bufferedInputStream.read(buffer, 0, 1024)) != -1) {
125 fileOutputStream.write(buffer, 0,
count);
128 }
catch (MalformedURLException malformedURLException) {
129 LOGGER.error(
"exception occured during accessing file url" + urlStr +
" : exception : " 130 + malformedURLException.getMessage());
131 }
catch (IOException ioException) {
132 LOGGER.error(
"exception occured during downloading file " + file +
" : exception : " 133 + ioException.getMessage());
134 }
catch (Exception exception) {
135 LOGGER.error(
"exception occured during downloading file " + file +
" : exception : " 136 + exception.getMessage());
138 IoUtil.close(fileOutputStream);
139 IoUtil.close(bufferedInputStream);
static final String FILE_PATH
static final String CSS_PATH
static final String JQUERY_FILE
static final String JQUERY_MIN_FILE
static final String CLASSPATH
static final String JAVASCRIPT_PATH
static final String FONTS_PATH