Skip to content

Commit

Permalink
Added loggers to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Iker007 committed May 25, 2021
1 parent 9fcc029 commit 1f5ed17
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.awt.HeadlessException;
import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.databene.contiperf.PerfTest;
import org.databene.contiperf.Required;
import org.junit.Before;
Expand All @@ -20,8 +21,11 @@ public class ChooseLeaderWindowContTest {
ClientWindow cw;
ArrayList<EmployeeData> al;

final Logger logger = Logger.getLogger(ChooseLeaderWindowContTest.class.getName());

@Before
public void setUp() {
logger.info("set UP");
try {

ca = new ClientApp("127.0.0.1", "8080");
Expand All @@ -41,6 +45,7 @@ public void setUp() {
@PerfTest(invocations = 100, threads = 2)
@Required(max = 200, average = 100)
public void WindowTest() {
logger.info("Testing ChooseLeaderWindow");
try {
clw = new ChooseLeaderWindow("Chosse Leader Window test", al);
assertTrue(clw.isVisible());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import java.awt.HeadlessException;

import org.apache.log4j.Logger;
import org.databene.contiperf.PerfTest;
import org.databene.contiperf.Required;
import org.junit.Before;
Expand All @@ -17,9 +18,12 @@ public class EmployeeInfoWindowContTest {
ClientApp ca;
EmployeeData expected;
ClientWindow cw;

final Logger logger = Logger.getLogger(EmployeeInfoWindowContTest.class.getName());

@Before
public void setUp() {
logger.info("Set UP");
try {

ca = new ClientApp("127.0.0.1", "8080");
Expand All @@ -36,6 +40,7 @@ public void setUp() {
@PerfTest(invocations = 100, threads = 2)
@Required(max = 200, average = 100)
public void testEmployeeInfoWindow() {
logger.info("Testing employeeInfoWindow");
try {
eiw = new EmployeeInfoWindow("Employee Info Window test");
assertTrue(eiw.isVisible());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@
import java.awt.HeadlessException;
import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.junit.Test;

import es.deusto.serialization.EmployeeData;
import es.deusto.server.ServerContTest;

public class RemoveEmployeeTest {
EmployeeData employee;
RemoveEmployee re;
ArrayList<EmployeeData> al;

final Logger logger = Logger.getLogger(RemoveEmployee.class.getName());

@Test
public void testRemoveEmployee() {
try {
logger.info("Testing removeEmployee");
employee = new EmployeeData(8364, "Eneko", "Gernika", "este");
al = new ArrayList<EmployeeData>();
al.add(employee);
Expand Down
20 changes: 14 additions & 6 deletions src/test/java/es/deusto/server/ServerContTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Iterator;
import java.util.Set;

import org.apache.log4j.Logger;
import org.databene.contiperf.PerfTest;
import org.databene.contiperf.Required;
import org.databene.contiperf.junit.ContiPerfRule;
Expand All @@ -16,23 +17,27 @@

import es.deusto.serialization.EmployeeData;
import es.deusto.serialization.EmployeeList;
import es.deusto.server.dto.EmployeeDTOContTest;

//@PerfTest(invocations = 5)
//@Required(max = 10000, average = 5000)
@PerfTest(invocations = 5)
@Required(max = 10000, average = 5000)
public class ServerContTest {

private Server server;
private EmployeeData employee;

final Logger logger = Logger.getLogger(ServerContTest.class.getName());

@Rule
public ContiPerfRule i = new ContiPerfRule();

@Test
@PerfTest(invocations = 10, threads = 2)
@Required(max = 1000, average = 1000)
@Required(max = 10000, average = 3000)
public void testAddEmployee() {
server = new Server();
employee = new EmployeeData(69, "Iker", "Bilbao", "IT");
logger.info("Testing AddEmployee");

try {
assertTrue(server.addEmployee(employee) != null);
Expand All @@ -44,10 +49,11 @@ public void testAddEmployee() {

@Test
@PerfTest(invocations = 10, threads = 2)
@Required(max = 2000, average = 1000)
@Required(max = 10000, average = 3000)
public void testUpdateEmployee() {
server = new Server();
employee = new EmployeeData(69, "Iker", "Bilbao", "IT");
employee = new EmployeeData(1, "Iker", "Bilbao", "IT");
logger.info("Testing UpdateEmployee");

try {
assertTrue(server.updateEmployee(employee) != null);
Expand Down Expand Up @@ -75,6 +81,7 @@ public void testUpdateEmployee() {
@PerfTest(invocations = 10, threads = 2)
@Required(max = 10000, average = 8000)
public void testDeleteEmployee() {
logger.info("Testing DeleteEmployee");
server = new Server();
int employeeID = 69;

Expand All @@ -88,8 +95,9 @@ public void testDeleteEmployee() {

@Test
@PerfTest(invocations = 10, threads = 2)
@Required(max = 2000, average = 1000)
@Required(max = 5000, average = 3000)
public void testGetEmployees() {
logger.info("Testing GetEmployee");
server = new Server();

try {
Expand Down
13 changes: 11 additions & 2 deletions src/test/java/es/deusto/server/ServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
import java.util.Iterator;
import java.util.Set;


import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import es.deusto.serialization.EmployeeData;
import es.deusto.serialization.EmployeeList;
import es.deusto.testing.junit.ContiperfSimple;

public class ServerTest {

private Server server;

final Logger logger = Logger.getLogger(ServerTest.class.getName());


@Before
public void init() {
Expand All @@ -28,6 +31,7 @@ public void init() {
@Test
public void testAddEmployee() {
EmployeeData employee = new EmployeeData(30, "Iker", "Bilbao", "IT");
logger.info("Testing AddEmployee");

try {
assertTrue(server.addEmployee(employee) != null);
Expand All @@ -40,7 +44,8 @@ public void testAddEmployee() {
@Test
public void testUpdateEmployee() {
EmployeeData employee = new EmployeeData(30, "Iker", "Bilbao", "IT");

logger.info("Testing UpdateEmployee");

try {
assertTrue(server.updateEmployee(employee) != null);
} catch (AssertionError e) {
Expand All @@ -64,6 +69,8 @@ public void testUpdateEmployee() {
@Test
public void testDeleteEmployee() {
int employeeID = 30;
logger.info("Testing DeleteEmployee");


try {
assertTrue(server.deleteEmployee(employeeID) != null);
Expand All @@ -75,6 +82,8 @@ public void testDeleteEmployee() {

@Test
public void testGetEmployees() {
logger.info("Testing GetEmployee");

try {
assertTrue(server.getEmployees() != null);
} catch (AssertionError e) {
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/es/deusto/server/db/DBManagerContTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
import java.sql.DriverManager;
import java.sql.SQLException;

import org.apache.log4j.Logger;
import org.databene.contiperf.PerfTest;
import org.databene.contiperf.Required;
import org.databene.contiperf.junit.ContiPerfRule;
import org.junit.Rule;
import org.junit.Test;

import es.deusto.testing.junit.ContiperfSimple;

public class DBManagerContTest {

final Logger logger = Logger.getLogger(DBManagerContTest.class.getName());

@Rule
public ContiPerfRule i = new ContiPerfRule();

Expand All @@ -23,10 +28,12 @@ public class DBManagerContTest {
@PerfTest(invocations = 100, threads = 5)
@Required(max = 5000, average = 3000)
public void createNewDBconnection() throws Exception{
logger.info("Testing DB connection");

Connection conn = DBManager.createNewDBconnection();
try {
assertTrue(conn != null);
logger.info("Conection succesfull");
} catch (AssertionError e) {
fail();
}
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/es/deusto/server/dto/EmployeeContTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import static org.junit.Assert.*;

import org.apache.log4j.Logger;
import org.databene.contiperf.PerfTest;
import org.databene.contiperf.Required;
import org.databene.contiperf.junit.ContiPerfRule;
import org.junit.Rule;
import org.junit.Test;

import es.deusto.testing.junit.ContiperfSimple;



public class EmployeeContTest {
Expand All @@ -17,6 +20,8 @@ public class EmployeeContTest {
private Employee e3 = new Employee(03, "Ana", "Bilbao", "IT");
private Employee e4 = new Employee(04, "Maria", "Bilbao", "IT");

final Logger logger = Logger.getLogger(EmployeeContTest.class.getName());

private Employee expected;

@Rule
Expand All @@ -28,6 +33,7 @@ public class EmployeeContTest {
@Required(max = 100, average = 20)
public void getId() throws Exception {
expected = new Employee(01, "Iker", "Bilbao", "IT");
logger.info("Testing getID");
assertEquals(expected.getId(), e1.getId());
}

Expand All @@ -36,6 +42,7 @@ public void getId() throws Exception {
@Required(max = 100, average = 20)
public void getName() throws Exception {
expected = new Employee(01, "Iker", "Bilbao", "IT");
logger.info("Testing getName");
assertEquals(expected.getName(), e1.getName());
}

Expand All @@ -44,6 +51,7 @@ public void getName() throws Exception {
@Required(max = 100, average = 20)
public void getAddress() throws Exception {
expected = new Employee(01, "Iker", "Bilbao", "IT");
logger.info("Testing getAddress");
assertEquals(expected.getAddress(), e1.getAddress());
}

Expand All @@ -52,6 +60,7 @@ public void getAddress() throws Exception {
@Required(max = 100, average = 20)
public void getDepartment() throws Exception {
expected = new Employee(01, "Iker", "Bilbao", "IT");
logger.info("Testing getDepartment");
assertEquals(expected.getDepartment(), e1.getDepartment());
}

Expand Down
9 changes: 9 additions & 0 deletions src/test/java/es/deusto/server/dto/EmployeeDTOContTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import static org.junit.Assert.*;

import org.apache.log4j.Logger;
import org.databene.contiperf.PerfTest;
import org.databene.contiperf.Required;
import org.databene.contiperf.junit.ContiPerfRule;
import org.junit.Rule;
import org.junit.Test;

import es.deusto.testing.junit.ContiperfSimple;



public class EmployeeDTOContTest {
Expand All @@ -16,6 +19,8 @@ public class EmployeeDTOContTest {

private EmployeeDTO expected;

final Logger logger = Logger.getLogger(EmployeeDTOContTest.class.getName());

@Rule
public ContiPerfRule i = new ContiPerfRule();

Expand All @@ -24,6 +29,7 @@ public class EmployeeDTOContTest {
@Required(max = 50, average = 20)
public void getId() throws Exception {
expected = new EmployeeDTO(01, "Iker", "Bilbao", "IT");
logger.info("Testing getID");
assertEquals(expected.getId(), e1.getId());
}

Expand All @@ -32,6 +38,7 @@ public void getId() throws Exception {
@Required(max = 50, average = 20)
public void getName() throws Exception {
expected = new EmployeeDTO(01, "Iker", "Bilbao", "IT");
logger.info("Testing getName");
assertEquals(expected.getName(), e1.getName());
}

Expand All @@ -40,6 +47,7 @@ public void getName() throws Exception {
@Required(max = 50, average = 20)
public void getAddress() throws Exception {
expected = new EmployeeDTO(01, "Iker", "Bilbao", "IT");
logger.info("Testing getAddress");
assertEquals(expected.getAddress(), e1.getAddress());
}

Expand All @@ -48,6 +56,7 @@ public void getAddress() throws Exception {
@Required(max = 50, average = 20)
public void getDepartment() throws Exception {
expected = new EmployeeDTO(01, "Iker", "Bilbao", "IT");
logger.info("Testing getDepartment");
assertEquals(expected.getDepartment(), e1.getDepartment());
}

Expand Down
23 changes: 14 additions & 9 deletions src/test/java/es/deusto/testing/junit/ContiperfSimple.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package es.deusto.testing.junit;

import org.junit.*;
import org.apache.log4j.Logger;
import org.databene.contiperf.*;
import org.databene.contiperf.junit.ContiPerfRule;

public class ContiperfSimple {
@Rule
public ContiPerfRule i = new ContiPerfRule();

@Test
@PerfTest(invocations = 1000, threads = 20)
@Required(max = 1200, average = 250)
public void test1() throws Exception {
Thread.sleep(200);
}

final Logger logger = Logger.getLogger(ContiperfSimple.class.getName());

@Rule
public ContiPerfRule i = new ContiPerfRule();

@Test
@PerfTest(invocations = 1000, threads = 20)
@Required(max = 1200, average = 250)
public void test1() throws Exception {
logger.info("Making initial test");
Thread.sleep(200);
}
}

0 comments on commit 1f5ed17

Please sign in to comment.