fix: adding Logs
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -35,4 +35,4 @@ build/
|
|||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store.codiumai
|
||||||
Generated
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
,ilyes,fedora,18.10.2024 11:53,file:///home/ilyes/.config/libreoffice/4;
|
||||||
@@ -73,14 +73,22 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-core</artifactId>
|
<artifactId>log4j-core</artifactId>
|
||||||
<version>2.24.0</version>
|
<version>2.24.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-api</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
<version>3.0.0-beta2</version>
|
<version>3.0.0-beta2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-slf4j2-impl -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-slf4j2-impl</artifactId>
|
||||||
|
<version>2.24.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
|
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Configuration status="WARN">
|
||||||
|
<Properties>
|
||||||
|
<!-- Set the base path for the log files -->
|
||||||
|
<Property name="basePath">./logs</Property>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
<Appenders>
|
||||||
|
<!-- Rolling file appender for log rotation -->
|
||||||
|
<RollingFile name="File" fileName="${basePath}/application.log"
|
||||||
|
filePattern="${basePath}/application-%d{yyyy-MM-dd}-%i.log.gz">
|
||||||
|
|
||||||
|
<!-- Layout for the log message format -->
|
||||||
|
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- Triggering Policy to roll files when they reach 10MB -->
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||||
|
</Policies>
|
||||||
|
|
||||||
|
<!-- Define rollover strategy to keep 7 backup files -->
|
||||||
|
<DefaultRolloverStrategy max="7"/>
|
||||||
|
</RollingFile>
|
||||||
|
</Appenders>
|
||||||
|
|
||||||
|
<Loggers>
|
||||||
|
<!-- Root logger with INFO level -->
|
||||||
|
<Root level="info">
|
||||||
|
<AppenderRef ref="File"/>
|
||||||
|
</Root>
|
||||||
|
</Loggers>
|
||||||
|
</Configuration>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
package api.test;
|
||||||
|
|
||||||
|
import api.endpoints.UserEndpoints;
|
||||||
|
import api.payload.User;
|
||||||
|
import io.restassured.response.Response;
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
public class DataDrivenTest {
|
||||||
|
User userPayload;
|
||||||
|
@Test(priority = 1, dataProvider = "Data", dataProviderClass = DataProvider.class)
|
||||||
|
public void testPostUser(String userID, String userName, String fName, String lName, String email, String passwd, String phone){
|
||||||
|
userPayload = new User();
|
||||||
|
|
||||||
|
userPayload.setId(Integer.parseInt(userID));
|
||||||
|
userPayload.setUsername(userName);
|
||||||
|
userPayload.setFirstname(fName);
|
||||||
|
userPayload.setLastname(lName);
|
||||||
|
userPayload.setEmail(email);
|
||||||
|
userPayload.setPassword(passwd);
|
||||||
|
userPayload.setPhone(phone);
|
||||||
|
|
||||||
|
Response response = UserEndpoints.createUser(userPayload);
|
||||||
|
Assert.assertEquals(response.getStatusCode(), 200);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
package api.utilities;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import org.testng.annotations.DataProvider;
|
||||||
|
|
||||||
|
public class Dataproviders {
|
||||||
|
|
||||||
|
@DataProvider(name = "Data")
|
||||||
|
public String[][] getAllData() throws IOException {
|
||||||
|
String path = System.getProperty("/home/ilyes/SeleniumPractice/RestAssuredAutomation/Data.xlsx");
|
||||||
|
XLUtility xl = new XLUtility(path);
|
||||||
|
int rownum = xl.getRowCount("Sheet1");
|
||||||
|
int colcount = xl.getCellCount("Sheet1", 1);
|
||||||
|
String[][] apidata = new String[rownum][colcount];
|
||||||
|
for (int i = 1; i <= rownum; i++) {
|
||||||
|
for (int j = 0; j < colcount; j++) {
|
||||||
|
apidata[i - 1][j] = xl.getCellData("Sheet1", i, j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return apidata;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DataProvider(name = "UserNames")
|
||||||
|
|
||||||
|
public String[] getUserNames() throws IOException {
|
||||||
|
String path = System.getProperty("user.dir") + "//testData//Userdata.xlsx";
|
||||||
|
XLUtility xl = new XLUtility(path);
|
||||||
|
int rownum = xl.getRowCount("Sheet1");
|
||||||
|
String apidata[] = new String[rownum];
|
||||||
|
for (int i = 1; i <= rownum; i++) {
|
||||||
|
apidata[i - 1] = xl.getCellData("Sheet1", i, 1);
|
||||||
|
}
|
||||||
|
return apidata;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
@@ -1,4 +1,93 @@
|
|||||||
|
/*
|
||||||
package api.utilities;
|
package api.utilities;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import org.apache.poi.ss.usermodel.CellStyle;
|
||||||
|
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
public class XLUtility {
|
public class XLUtility {
|
||||||
|
public FileInputStream fi;
|
||||||
|
public FileOutputStream fo;
|
||||||
|
public XSSFWorkbook workbook;
|
||||||
|
public XSSFSheet sheet;
|
||||||
|
public XSSFRow row;
|
||||||
|
public XSSFCell cell;
|
||||||
|
public CellStyle style;
|
||||||
|
String path;
|
||||||
|
|
||||||
|
public XLUtility(String path) {
|
||||||
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRowCount(String sheetName) throws IOException {
|
||||||
|
fi = new FileInputStream(path);
|
||||||
|
workbook = new XSSFWorkbook(fi);
|
||||||
|
sheet = workbook.getSheet(sheetName);
|
||||||
|
int rowcount = sheet.getLastRowNum();
|
||||||
|
workbook.close();
|
||||||
|
fi.close();
|
||||||
|
return rowcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCellCount(String sheetName, int rownum) throws IOException {
|
||||||
|
fi = new FileInputStream(path);
|
||||||
|
workbook = new XSSFWorkbook(fi);
|
||||||
|
sheet = workbook.getSheet(sheetName);
|
||||||
|
row = sheet.getRow(rownum);
|
||||||
|
int cellcount = row.getLastCellNum();
|
||||||
|
workbook.close();
|
||||||
|
fi.close();
|
||||||
|
return cellcount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCellData(String sheetName, int rownum, int colnum) throws IOException {
|
||||||
|
fi = new FileInputStream(path);
|
||||||
|
workbook = new XSSFWorkbook(fi);
|
||||||
|
sheet = workbook.getSheet(sheetName);
|
||||||
|
row = sheet.getRow(rownum);
|
||||||
|
cell = row.getCell(colnum);
|
||||||
|
DataFormatter formatter = new DataFormatter();
|
||||||
|
String data;
|
||||||
|
try {
|
||||||
|
data = formatter.formatCellValue(cell);
|
||||||
|
} catch (Exception e) {
|
||||||
|
data = "";
|
||||||
|
}
|
||||||
|
workbook.close();
|
||||||
|
fi.close();
|
||||||
|
return data;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCellData(String sheetName, int rownum, int colnum, String data) throws IOException {
|
||||||
|
File xlfile = new File(path);
|
||||||
|
if (!xlfile.exists()) {
|
||||||
|
workbook = new XSSFWorkbook();
|
||||||
|
fo = new FileOutputStream(path);
|
||||||
|
workbook.write(fo);
|
||||||
|
}
|
||||||
|
fi = new FileInputStream(path);
|
||||||
|
workbook = new XSSFWorkbook(fi);
|
||||||
|
if (workbook.getSheetIndex(sheetName) == -1)
|
||||||
|
workbook.createSheet(sheetName);
|
||||||
|
sheet = workbook.getSheet(sheetName);
|
||||||
|
if (sheet.getRow(rownum) == null)
|
||||||
|
sheet.createRow(rownum);
|
||||||
|
row = sheet.getRow(rownum);
|
||||||
|
cell = row.createCell(colnum);
|
||||||
|
cell.setCellValue(data);
|
||||||
|
fo = new FileOutputStream(path);
|
||||||
|
workbook.write(fo);
|
||||||
|
workbook.close();
|
||||||
|
fi.close();
|
||||||
|
fo.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|||||||
@@ -1,14 +1,30 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Configuration status="WARN">
|
<Configuration status="WARN">
|
||||||
<Properties>
|
<Properties>
|
||||||
|
<!-- Set the base path for the log files -->
|
||||||
<Property name="basePath">./logs</Property>
|
<Property name="basePath">./logs</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
|
||||||
<Appenders>
|
<Appenders>
|
||||||
<RollingFile name="File" fileName="${basePath}/application.log">
|
<!-- Rolling file appender for log rotation -->
|
||||||
|
<RollingFile name="File" fileName="${basePath}/application.log"
|
||||||
|
filePattern="${basePath}/application-%d{yyyy-MM-dd}-%i.log.gz">
|
||||||
|
|
||||||
|
<!-- Layout for the log message format -->
|
||||||
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- Triggering Policy to roll files when they reach 10MB -->
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="10MB"/>
|
||||||
|
</Policies>
|
||||||
|
|
||||||
|
<!-- Define rollover strategy to keep 7 backup files -->
|
||||||
|
<DefaultRolloverStrategy max="7"/>
|
||||||
</RollingFile>
|
</RollingFile>
|
||||||
</Appenders>
|
</Appenders>
|
||||||
|
|
||||||
<Loggers>
|
<Loggers>
|
||||||
|
<!-- Root logger with INFO level -->
|
||||||
<Root level="info">
|
<Root level="info">
|
||||||
<AppenderRef ref="File"/>
|
<AppenderRef ref="File"/>
|
||||||
</Root>
|
</Root>
|
||||||
|
|||||||
Reference in New Issue
Block a user