1 | /**************************************************************** |
2 | ??*??Licensed??to??the??Apache??Software??Foundation??(ASF)??under??one??????* |
3 | ??*??or??more??contributor??license??agreements.????See??the??NOTICE??file??* |
4 | ??*??distributed??with??this??work??for??additional??information????????????????* |
5 | ??*??regarding??copyright??ownership.????The??ASF??licenses??this??file??????* |
6 | ??*??to??you??under??the??Apache??License,??Version??2.0??(the????????????????????????* |
7 | ??*??"License");??you??may??not??use??this??file??except??in??compliance??????* |
8 | ??*??with??the??License.????You??may??obtain??a??copy??of??the??License??at??????* |
9 | ??*????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????* |
10 | ??*??????http://www.apache.org/licenses/LICENSE-2.0??????????????????????????????????* |
11 | ??*????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????* |
12 | ??*??Unless??required??by??applicable??law??or??agreed??to??in??writing,??????* |
13 | ??*??software??distributed??under??the??License??is??distributed??on??an????* |
14 | ??*??"AS??IS"??BASIS,??WITHOUT??WARRANTIES??OR??CONDITIONS??OF??ANY??????????????* |
15 | ??*??KIND,??either??express??or??implied.????See??the??License??for??the????????* |
16 | ??*??specific??language??governing??permissions??and??limitations????????????* |
17 | ??*??under??the??License.??????????????????????????????????????????????????????????????????????????????????????* |
18 | ??****************************************************************/ |
19 | ?? |
20 | package??org.apache.james.mpt; |
21 | ?? |
22 | import??junit.framework.TestCase; |
23 | ?? |
24 | /** |
25 | ??*??Abstract??Protocol??Test??is??the??root??of??all??of??the??James??Imap??Server??test |
26 | ??*??cases.??It??provides??basic??functionality??for??running??a??protocol??session??as??a |
27 | ??*??JUnit??test,??and??failing??if??exceptions??are??thrown.??To??create??a??test??which |
28 | ??*??reads??the??entire??protocol??session??from??a??single??protocol??definition??file,??use |
29 | ??*??the??{@link??AbstractSimpleScriptedTestProtocol}. |
30 | ??*?? |
31 | ??*??@author??Darrell??DeBoer |
32 | ??*??@author??Andrew??C.??Oliver |
33 | ??*/ |
34 | public??abstract??class??AbstractProtocolTestFramework??extends??TestCase??{ |
35 | ?? |
36 | ????????protected??final??Runner??runner; |
37 | ????????private??final??HostSystem??hostSystem; |
38 | ???????? |
39 | ????????private??final??String??userName; |
40 | ????????private??final??String??password; |
41 | ?? |
42 | ????????public??AbstractProtocolTestFramework(HostSystem??hostSystem,??String??userName,??String??password)??{ |
43 | ????????????????this.hostSystem??=??hostSystem; |
44 | ????????????????this.userName??=??userName; |
45 | ????????????????this.password??=??password; |
46 | ????????????????runner??=??new??Runner(); |
47 | ????????} |
48 | ?? |
49 | ????????protected??void??setUp()??throws??Exception??{ |
50 | ????????????????super.setUp(); |
51 | ????????????????setUpEnvironment(); |
52 | ????????} |
53 | ?? |
54 | ????????protected??void??continueAfterFailure()??{ |
55 | ????????????????runner.continueAfterFailure(); |
56 | ????????} |
57 | ?? |
58 | ????????/** |
59 | ??????????*??Runs??the??pre,test??and??post??protocol??sessions??against??a??local??copy??of??the |
60 | ??????????*??ImapServer.??This??does??not??require??that??James??be??running,??and??is??useful |
61 | ??????????*??for??rapid??development??and??debugging. |
62 | ??????????*?? |
63 | ??????????*??Instead??of??sending??requests??to??a??socket??connected??to??a??running??instance |
64 | ??????????*??of??James,??this??method??uses??the??{@link??MockImapServer}??to??simplify |
65 | ??????????*??testing.??One??mock??instance??is??required??per??protocol??session/connection. |
66 | ??????????*??These??share??the??same??underlying??Mailboxes,??because??of??the??way |
67 | ??????????*??{@link??MockImapServer#getImapSession()}??works. |
68 | ??????????*/ |
69 | ????????protected??void??runSessions()??throws??Exception??{ |
70 | ????????????????runner.runSessions(hostSystem); |
71 | ????????} |
72 | ?? |
73 | ????????/** |
74 | ??????????*??Initialises??the??UsersRepository??and??ImapHost??on??first??call. |
75 | ??????????*/ |
76 | ????????private??void??setUpEnvironment()??throws??Exception??{ |
77 | ????????????????hostSystem.reset(); |
78 | ????????????????hostSystem.addUser(userName,??password); |
79 | ????????} |
80 | } |