-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordTests.java
More file actions
120 lines (104 loc) · 2.77 KB
/
Copy pathPasswordTests.java
File metadata and controls
120 lines (104 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package tests;
import junit.framework.TestCase;
import models.Professor;
import models.UserFactory;
import models.UserType;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class PasswordTests extends TestCase {
private Professor prof;
public PasswordTests(String name) {
super(name);
}
@Before
public void setUp() {
try {
this.prof = (Professor) UserFactory.createUser(UserType.PROFESSOR);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
@Test
public void testPasswordCorrect() {
this.prof.setPassword("a1A@a");
assertEquals("a1A@a", this.prof.getPassword());
}
@Test
public void testPasswordWrong1() {
try {
this.prof.setPassword(null);
} catch (IllegalArgumentException ex) {
System.out.println(ex.toString());
assertEquals(null, this.prof.getPassword());
}
}
@Test(expected = AssertionError.class)
public void testPasswordWrong2() {
try {
this.prof.setPassword("paro");
} catch (IllegalArgumentException ex) {
System.out.println(ex.toString());
assertEquals("paro", this.prof.getPassword());
}
}
@Test(expected = AssertionError.class)
public void testPasswordWrong3() {
try {
this.prof.setPassword("parolaparolaparolaparolaparolaparola");
} catch (IllegalArgumentException ex) {
System.out.println(ex.toString());
assertEquals("paroparolaparolaparolaparolaparola",
this.prof.getPassword());
}
}
@Test(expected = AssertionError.class)
public void testPasswordWrong4() {
try {
this.prof.setPassword("0parola");
} catch (IllegalArgumentException ex) {
System.out.println(ex.toString());
assertEquals("0parola", this.prof.getPassword());
}
}
@Test(expected = AssertionError.class)
public void testPasswordWrong5() {
try {
this.prof.setPassword("parola");
} catch (IllegalArgumentException ex) {
System.out.println(ex.toString());
assertEquals("parola", this.prof.getPassword());
}
}
@Test(expected = AssertionError.class)
public void testPasswordWrong6() {
try {
this.prof.setPassword("par0la");
} catch (IllegalArgumentException ex) {
System.out.println(ex.toString());
assertEquals("par0la", this.prof.getPassword());
}
}
@Test(expected = AssertionError.class)
public void testPasswordWrong7() {
try {
this.prof.setPassword("par0La");
} catch (IllegalArgumentException ex) {
System.out.println(ex.toString());
assertEquals("par0La", this.prof.getPassword());
}
}
@Test(expected = AssertionError.class)
public void testPasswordWrong8() {
try {
this.prof.setPassword("par0La# parola");
} catch (IllegalArgumentException ex) {
System.out.println(ex.toString());
assertEquals("par0La# parola", this.prof.getPassword());
}
}
@After
public void tearDown() throws Exception {
this.prof = null;
}
}