Detailed information about defect clone:
22-C1.H0.M0.L0_S_S_11.war
Nickname of the defect
malfunction-of-button
Brief desctiption
The button Register in Other Exam Dates does NOT register exam date in the DB nor at the screen.
How to activate the defect
-
Click on Login in the header
-
Username
blue
, password pass
, click on Login button
-
Click on Other Exam Dates
-
Click on Register in the column Register below the subheader Computation Structures
Visibility of the defect
Parts
StudentService |
TeacherService |
DateUtility |
GradeDAO |
UserDAO |
E11StudentService
|
BaseTeacherService
|
BaseDateUtility
|
GradeTypeDaoCriteria
|
UserDaoCriteria
|
URL to the defect source code
https://gitlab.kiv.zcu.cz/herout/TbUIS-UIS/blob/master/src/main/java/cz/zcu/kiv/matyasj/dp/service/users/error/E11StudentService.java
Source code with the injected defect
/**
* DELIBERATE ERROR
*
* This error method does not register student on specific examination date.
*
* @param studentId database id of student
* @param examDateId database id of exam date
* @return Indication of registering examination date.
*/
@Override
@ErrorMethod(errorMessage = "This error method simulates successful examination date setting.")
public boolean setExaminationDate(Long studentId, Long examDateId) {
ExaminationDate DateTmp = examinationDateDao.findOne(examDateId);
if (DateTmp == null) {
log.error("Setting examination date failed.");
return false;
}
if (DateTmp.getParticipants().size() == DateTmp.getMaxParticipants()) {
log.error("Setting examination date failed.");
return false;
}
// Test if student is learning subject of exam date
User student = userDao.findOne(studentId);
if (student instanceof Student) {
log.error(propertyLoader.getProperty("log.E11StudentService.setExaminationDate"));
return true;
}
log.error("Setting examination date failed.");
return false;
}
URL to the correct source code
https://gitlab.kiv.zcu.cz/herout/TbUIS-UIS/blob/master/src/main/java/cz/zcu/kiv/matyasj/dp/service/users/correct/BaseStudentService.java
Correct source code
/**
* This method registers student on specific examination date.
*
* @param studentId database id of student
* @param examDateId database id of exam date
* @return true if examination date was successfully registered, false otherwise.
*/
@Override
public boolean setExaminationDate(Long studentId, Long examDateId) {
ExaminationDate DateTmp = examinationDateDao.findOne(examDateId);
if (DateTmp == null) {
log.error("Setting examination date failed.");
return false;
}
if (DateTmp.getParticipants().size() == DateTmp.getMaxParticipants()) {
log.error("Setting examination date failed.");
return false;
}
// Test if student is learning subject of exam date
User student = userDao.findOne(studentId);
if (student instanceof Student) {
log.info("Setting examination date with id " + examDateId + " to student with id " + studentId + ".");
for (Subject subject : ((Student) student).getListOfLearnedSubjects()) {
if (subject.getId().longValue() == DateTmp.getSubject().getId().longValue()) {
ExaminationDate date = examinationDateDao.registerStudentOnTerm(examDateId, studentId);
if (date != null) {
return true;
}
}
}
}
log.error("Setting examination date failed.");
return false;
}
Logged information up to failure
2019-10-15 18:30:16.225 -- INFO LogHelper:31 - HHH000204: Processing PersistenceUnitInfo [name: cz.zcu.kiv.matyasj.dp]
2019-10-15 18:30:16.444 -- INFO Version:46 - HHH000412: Hibernate Core {5.4.1.Final}
2019-10-15 18:30:16.834 -- INFO Version:49 - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2019-10-15 18:30:17.256 -- INFO C3P0ConnectionProvider:116 - HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/uis-web-db
2019-10-15 18:30:17.256 -- INFO C3P0ConnectionProvider:117 - HHH10001001: Connection properties: {password=****, useUnicode=true, handling_mode=DELAYED_ACQUISITION_AND_HOLD, characterEncoding=UTF-8, user=uis-web}
2019-10-15 18:30:17.256 -- INFO C3P0ConnectionProvider:120 - HHH10001003: Autocommit mode: false
2019-10-15 18:30:17.459 -- INFO C3P0ConnectionProvider:200 - HHH10001007: JDBC isolation level:
2019-10-15 18:30:17.850 -- INFO Dialect:158 - HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
2019-10-15 18:30:19.672 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@4c046a12] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
2019-10-15 18:30:22.550 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@7f3964b0] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
2019-10-15 18:30:35.308 -- INFO JtaPlatformInitiator:52 - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2019-10-15 18:30:35.558 -- INFO SecurityConfig:75 - SECURITY JDBC authentication process is running
2019-10-15 18:30:37.829 -- INFO SecurityConfig:93 - Authorization configuration process is running
2019-10-15 18:30:38.173 -- INFO BaseInitializer:97 - Initializing ...
2019-10-15 18:30:45.672 -- INFO BaseInitializer:463 - Initialized!
2019-10-15 18:30:45.828 -- INFO BaseInitializer:97 - Initializing ...
2019-10-15 18:33:56.593 -- INFO LoginController:30 - Request for login view
2019-10-15 18:34:01.421 -- INFO UserDaoCriteria:74 - User with username blue found.
2019-10-15 18:34:01.500 -- INFO SecurityConfig:121 - Success login - blue
2019-10-15 18:34:01.500 -- INFO SecurityConfig:125 - User login role: ROLE_STUDENT
2019-10-15 18:34:01.515 -- INFO UserDaoCriteria:74 - User with username blue found.
2019-10-15 18:34:01.531 -- INFO OverviewController:49 - Request for overview of student with id 17 for view.
2019-10-15 18:34:02.999 -- INFO ExamDatesController:49 - Request for other exam dates view.
2019-10-15 18:34:02.999 -- INFO UserDaoCriteria:74 - User with username blue found.
2019-10-15 18:34:03.046 -- INFO BaseStudentService:164 - Getting list of not registered examination dates for student with id 17.
2019-10-15 18:34:03.109 -- INFO ExaminationDateDaoCriteria:170 - Returning list of all 3 examination dates for student with id 17.
2019-10-15 18:34:03.124 -- INFO BaseStudentService:197 - Getting list of examination dates for student with id 17.
2019-10-15 18:34:03.140 -- INFO GradeDaoCriteria:102 - Returning list of 0 for student with id 17
2019-10-15 18:34:03.140 -- INFO ExaminationDateDaoCriteria:70 - Returning list of 0 examination dates for student with id 17.
2019-10-15 18:34:03.156 -- INFO BaseStudentService:248 - Getting list of subjects with registered exam date for student with id 17.
2019-10-15 18:34:03.171 -- INFO BaseStudentService:82 - Getting list of studied subjects for student with id 17.
2019-10-15 18:34:45.126 -- INFO UserDaoCriteria:74 - User with username blue found.
2019-10-15 18:34:45.157 -- INFO ExamDatesController:91 - Request for registering exam date with 34 from user with id 17.
2019-10-15 18:34:45.188 -- ERROR E11StudentService:72 - INJECTED_ERROR: E11StudentService_setExaminationDate_simulates_successful_examination_date_setting
Overview of functional tests full log
Overview of acceptance tests full report