01: /*
02: * Dumbster - a dummy SMTP server
03: * Copyright 2004 Jason Paul Kitchen
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package com.dumbster.smtp;
19:
20: import junit.framework.TestCase;
21:
22: public class SmtpRequestTest extends TestCase {
23:
24: public void testUnrecognizedCommandConnectState() {
25: SmtpRequest request = new SmtpRequest(SmtpActionType.UNRECOG,
26: null, SmtpState.CONNECT);
27: SmtpResponse response = request.execute();
28: assertTrue(response.getCode() == 500);
29: }
30:
31: public void testUnrecognizedCommandGreetState() {
32: SmtpRequest request = new SmtpRequest(SmtpActionType.UNRECOG,
33: null, SmtpState.GREET);
34: SmtpResponse response = request.execute();
35: assertTrue(response.getCode() == 500);
36: }
37:
38: public void testUnrecognizedCommandMailState() {
39: SmtpRequest request = new SmtpRequest(SmtpActionType.UNRECOG,
40: null, SmtpState.MAIL);
41: SmtpResponse response = request.execute();
42: assertTrue(response.getCode() == 500);
43: }
44:
45: public void testUnrecognizedCommandQuitState() {
46: SmtpRequest request = new SmtpRequest(SmtpActionType.UNRECOG,
47: null, SmtpState.QUIT);
48: SmtpResponse response = request.execute();
49: assertTrue(response.getCode() == 500);
50: }
51:
52: public void testUnrecognizedCommandRcptState() {
53: SmtpRequest request = new SmtpRequest(SmtpActionType.UNRECOG,
54: null, SmtpState.RCPT);
55: SmtpResponse response = request.execute();
56: assertTrue(response.getCode() == 500);
57: }
58:
59: public void testUnrecognizedCommandDataBodyState() {
60: SmtpRequest request = new SmtpRequest(SmtpActionType.UNRECOG,
61: null, SmtpState.DATA_BODY);
62: SmtpResponse response = request.execute();
63: assertTrue(response.getCode() == -1);
64: }
65:
66: public void testUnrecognizedCommandDataHdrState() {
67: SmtpRequest request = new SmtpRequest(SmtpActionType.UNRECOG,
68: null, SmtpState.DATA_HDR);
69: SmtpResponse response = request.execute();
70: assertTrue(response.getCode() == -1);
71: }
72:
73: }
|