Dosyaları "/" dizinine yükle
This commit is contained in:
BIN
AccessControl.class
Normal file
BIN
AccessControl.class
Normal file
Binary file not shown.
BIN
AccessControlTest.class
Normal file
BIN
AccessControlTest.class
Normal file
Binary file not shown.
263
AccessControlTest.java
Normal file
263
AccessControlTest.java
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
package test.java;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import main.java.AccessControl;
|
||||||
|
|
||||||
|
public class AccessControlTest {
|
||||||
|
|
||||||
|
private AccessControl ac;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
ac = new AccessControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ---------------------------
|
||||||
|
* DECISION TABLE TESTS
|
||||||
|
* ---------------------------
|
||||||
|
* Based on the conditions, an example decision table was:
|
||||||
|
*
|
||||||
|
* Variables:
|
||||||
|
* isEmployee (E) : {T, F}
|
||||||
|
* hasSpecialAuth (A): {T, F}
|
||||||
|
* isAuditor (R): {T, F}
|
||||||
|
* hourOfDay (H): test with {8,9,16,17}
|
||||||
|
* isWeekend (W): {T, F}
|
||||||
|
*
|
||||||
|
* Example table entries (just a sample):
|
||||||
|
*
|
||||||
|
* # | E | A | R | H | W | Expected
|
||||||
|
* --|---|---|---|----|----|---------
|
||||||
|
* 1 | F | F | F | 9 | F | false (not employee, not auditor)
|
||||||
|
* 2 | T | F | F | 9 | F | true (employee, working hours, weekday)
|
||||||
|
* 3 | T | T | F | 8 | F | true (employee + special auth, no time restriction)
|
||||||
|
* 4 | T | F | F | 17 | F | false (employee but after working hours and no special auth)
|
||||||
|
* 5 | T | F | F | 9 | T | false (employee during working hours but weekend)
|
||||||
|
* 6 | F | F | T | 9 | T | true (auditor during working hours, weekend allowed)
|
||||||
|
* 7 | F | F | T | 8 | F | false (auditor outside working hours)
|
||||||
|
* 8 | T | T | F | 17 | T | true (employee with special auth, no restrictions)
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecisionTable1() {
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(false, false, false, 9, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testDecisionTable1 duration (ns): " + (end - start));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecisionTable2() {
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, false, false, 9, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testDecisionTable2 duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecisionTable3() {
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, true, false, 8, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testDecisionTable3 duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecisionTable4() {
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, false, false, 17, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testDecisionTable4 duration (ns): " + (end - start));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecisionTable5() {
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, false, false, 9, true);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testDecisionTable5 duration (ns): " + (end - start));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecisionTable6() {
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(false, false, true, 9, true);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testDecisionTable6 duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecisionTable7() {
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(false, false, true, 8, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testDecisionTable7 duration (ns): " + (end - start));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDecisionTable8() {
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, true, false, 17, true);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testDecisionTable8 duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ---------------------------
|
||||||
|
* EQUIVALENCE PARTITIONING TESTS
|
||||||
|
* ---------------------------
|
||||||
|
* Equivalence classes could be:
|
||||||
|
* - isEmployee: {employee, not employee}
|
||||||
|
* - hasSpecialAuth (only matters if employee): {special auth, no special auth}
|
||||||
|
* - isAuditor: {auditor, not auditor}
|
||||||
|
* - hourOfDay: {before working hours (<9), during working hours (9–16), after working hours (>16)}
|
||||||
|
* - isWeekend: {weekend, weekday}
|
||||||
|
*
|
||||||
|
* Choose representative combinations:
|
||||||
|
* 1) Not employee, not auditor, during working hours, weekday -> expected false
|
||||||
|
* 2) Employee, no special auth, not auditor, during working hours, weekday -> expected true
|
||||||
|
* 3) Employee, special auth, any hour, weekend -> expected true (special auth overrides)
|
||||||
|
* 4) Auditor, during working hours, weekend -> expected true (no weekend restriction)
|
||||||
|
* 5) Auditor, before working hours, weekday -> expected false
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEquivalence1() {
|
||||||
|
// Not employee, not auditor, working hours (10), weekday
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(false, false, false, 10, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testEquivalence1 duration (ns): " + (end - start));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEquivalence2() {
|
||||||
|
// Employee, no special auth, not auditor, working hours (10), weekday
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, false, false, 10, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testEquivalence2 duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEquivalence3() {
|
||||||
|
// Employee, special auth, after hours (17), weekend
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, true, false, 17, true);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testEquivalence3 duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEquivalence4() {
|
||||||
|
// Auditor, during working hours (16), weekend
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(false, false, true, 16, true);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testEquivalence4 duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEquivalence5() {
|
||||||
|
// Auditor, before working hours (8), weekday
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(false, false, true, 8, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testEquivalence5 duration (ns): " + (end - start));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ---------------------------
|
||||||
|
* BOUNDARY VALUE TESTS
|
||||||
|
* ---------------------------
|
||||||
|
* Boundary values around working hours: 8 (just before), 9 (start), 16 (end), 17 (just after)
|
||||||
|
* Test with employee, auditor, and special auth where appropriate.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBoundaryBeforeWorkHoursEmployee() {
|
||||||
|
// Employee, no special auth, hour=8 (before start), weekday
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, false, false, 8, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testBoundaryBeforeWorkHoursEmployee duration (ns): " + (end - start));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBoundaryStartWorkHoursEmployee() {
|
||||||
|
// Employee, no special auth, hour=9 (start), weekday
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, false, false, 9, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testBoundaryStartWorkHoursEmployee duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBoundaryEndWorkHoursEmployee() {
|
||||||
|
// Employee, no special auth, hour=16 (end), weekday
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, false, false, 16, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testBoundaryEndWorkHoursEmployee duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBoundaryAfterWorkHoursEmployee() {
|
||||||
|
// Employee, no special auth, hour=17 (after end), weekday
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, false, false, 17, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testBoundaryAfterWorkHoursEmployee duration (ns): " + (end - start));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBoundaryAuditorBeforeHours() {
|
||||||
|
// Auditor, hour=8, weekend/weekday doesn't matter, let's pick weekday
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(false, false, true, 8, false);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testBoundaryAuditorBeforeHours duration (ns): " + (end - start));
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBoundaryAuditorStartHours() {
|
||||||
|
// Auditor, hour=9, weekend true
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(false, false, true, 9, true);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testBoundaryAuditorStartHours duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBoundarySpecialAuthAnyTime() {
|
||||||
|
// Employee with special auth, hour=8, weekend=true
|
||||||
|
long start = System.nanoTime();
|
||||||
|
boolean result = ac.isAccessAllowed(true, true, false, 8, true);
|
||||||
|
long end = System.nanoTime();
|
||||||
|
System.out.println("testBoundarySpecialAuthAnyTime duration (ns): " + (end - start));
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Main.class
Normal file
BIN
Main.class
Normal file
Binary file not shown.
65
explanations.md
Normal file
65
explanations.md
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
|
||||||
|
Decision Table Testing Scenarios
|
||||||
|
|
||||||
|
Explanation:
|
||||||
|
The decision table enumerates various combinations of conditions (employee status, special authorization, auditor status, hour of day, and weekend) and shows the expected outcome. The conditions chosen are representative samples from the decision space.
|
||||||
|
|
||||||
|
### Decision Table Tests
|
||||||
|
|
||||||
|
| # | isEmployee | hasSpecialAuth | isAuditor | hourOfDay | isWeekend | Expected Result |
|
||||||
|
|---|------------|----------------|-----------|-----------|-----------|----------------|
|
||||||
|
| 1 | False | False | False | 9 | False | Deny (false) |
|
||||||
|
| 2 | True | False | False | 9 | False | Allow (true) |
|
||||||
|
| 3 | True | True | False | 8 | False | Allow (true) |
|
||||||
|
| 4 | True | False | False | 17 | False | Deny (false) |
|
||||||
|
| 5 | True | False | False | 9 | True | Deny (false) |
|
||||||
|
| 6 | False | False | True | 9 | True | Allow (true) |
|
||||||
|
| 7 | False | False | True | 8 | False | Deny (false) |
|
||||||
|
| 8 | True | True | False | 17 | True | Allow (true) |
|
||||||
|
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
Equivalence Partitioning Scenarios
|
||||||
|
|
||||||
|
Explanation:
|
||||||
|
Here, input domains are divided into equivalence classes. We pick one representative test from each class to reduce the total number of tests while still ensuring coverage of all logical categories.
|
||||||
|
|
||||||
|
### Equivalence Partitioning Tests
|
||||||
|
|
||||||
|
| # | Conditions (Representative) | Expected Result |
|
||||||
|
|---|----------------------------------------------------------|-----------------|
|
||||||
|
| 1 | Not Employee, Not Auditor, Hour=10 (within 9–16), Weekday=false (not weekend) | Deny (false) |
|
||||||
|
| 2 | Employee, No Special Auth, Not Auditor, Hour=10 (within 9–16), Weekday=false | Allow (true) |
|
||||||
|
| 3 | Employee, Special Auth, Any Hour (e.g., 17), Weekend=true | Allow (true) |
|
||||||
|
| 4 | Auditor, Hour=16 (within 9–16), Weekend=true | Allow (true) |
|
||||||
|
| 5 | Auditor, Hour=8 (before 9), Weekday=false | Deny (false) |
|
||||||
|
|
||||||
|
Equivalence Classes Considered:
|
||||||
|
• Employee vs. Non-Employee
|
||||||
|
• Auditor vs. Non-Auditor
|
||||||
|
• Special Authorization vs. No Special Authorization
|
||||||
|
• Inside vs. Outside Working Hours (9–16)
|
||||||
|
• Weekend vs. Weekday
|
||||||
|
|
||||||
|
|
||||||
|
---------------------------------------------
|
||||||
|
Boundary Value Analysis Scenarios
|
||||||
|
|
||||||
|
Explanation:
|
||||||
|
Boundary values are chosen around the critical time limits. For this scenario, critical hours are 8 (just before 9), 9 (start of working hours), 16 (end of working hours), and 17 (just after 16).
|
||||||
|
|
||||||
|
### Boundary Value Analysis Tests
|
||||||
|
|
||||||
|
| # | Conditions (Focus on Hour Boundaries) | Expected Result |
|
||||||
|
|---|-----------------------------------------------------------------|-----------------|
|
||||||
|
| 1 | Employee, No Special Auth, Hour=8 (just before start), Weekday=false | Deny (false) |
|
||||||
|
| 2 | Employee, No Special Auth, Hour=9 (start), Weekday=false | Allow (true) |
|
||||||
|
| 3 | Employee, No Special Auth, Hour=16 (end), Weekday=false | Allow (true) |
|
||||||
|
| 4 | Employee, No Special Auth, Hour=17 (just after end), Weekday=false | Deny (false) |
|
||||||
|
| 5 | Auditor, Hour=8 (before start), Weekend or Weekday (e.g., false) | Deny (false) |
|
||||||
|
| 6 | Auditor, Hour=9 (start), Weekend=true | Allow (true) |
|
||||||
|
| 7 | Employee, Special Auth, Hour=8 (any boundary), Weekend=true | Allow (true) |
|
||||||
|
|
||||||
|
Boundary Values Considered:
|
||||||
|
• Hours: 8, 9, 16, 17
|
||||||
|
• Weekend vs. Weekday, Employee vs. Auditor, Special Auth variations
|
||||||
Reference in New Issue
Block a user