1   /********************************************************************************
2    * InternetCafe is a software solution that helps the management of Cybercafes 
3    * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005.
4    * Copyright (C) 2006  Guido Angelo Ingenito
5   
6    * This program is free software; you can redistribute it and/or
7    * modify it under the terms of the GNU General Public License
8    * as published by the Free Software Foundation; either version 2
9    * of the License, or (at your option) any later version.
10  
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   * 
16   * You should have received a copy of the GNU General Public License
17   * along with this program; if not, write to the Free Software
18   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19   *******************************************************************************/
20  
21  package test.base;
22  
23  import java.util.Date;
24  import java.util.GregorianCalendar;
25  
26  import junit.framework.TestCase;
27  import base.Control;
28  
29  public class ControlTest extends TestCase {
30  	/*
31  	 * Test method for 'test.base.Control.isValidCharacterOnlyString(String)'
32  	 */
33  	public void testIsValidCharacterOnlyString() {
34  		assertEquals(Control
35  				.isValidCharacterOnlyString("abcdefghilmnopqrstuvz"), true);
36  		assertEquals(Control
37  				.isValidCharacterOnlyString("a1b2c3d4e5f6g7h8i9lnopqrstuvz"),
38  				false);
39  	}
40  
41  	/*
42  	 * Test method for 'test.base.Control.isValidDoubleString(String)'
43  	 */
44  	public void testIsValidDoubleString() {
45  		assertEquals(Control.isValidDoubleString("0"), true);
46  
47  		assertEquals(Control.isValidDoubleString("0.0"), true);
48  		assertEquals(Control.isValidDoubleString("01.0"), true);
49  		assertEquals(Control.isValidDoubleString("0.0"), true);
50  		assertEquals(Control.isValidDoubleString("0.000"), true);
51  		assertEquals(Control.isValidDoubleString("1.0"), true);
52  
53  		assertEquals(Control.isValidDoubleString("+0"), true);
54  		assertEquals(Control.isValidDoubleString("-0"), true);
55  		assertEquals(Control.isValidDoubleString("+0.0"), true);
56  		assertEquals(Control.isValidDoubleString("-0.0"), true);
57  
58  	}
59  
60  	/*
61  	 * Test method for 'test.base.Control.isValidIntegerOnlyString(String)'
62  	 */
63  	public void testIsValidIntegernlyString() {
64  		assertEquals(Control.isValidIntegerOnlyString("111233434894849849"),
65  				true);
66  		assertEquals(Control
67  				.isValidIntegerOnlyString("a1b2c3d4e5f6g7h8i9lnopqrstuvz"),
68  				false);
69  	}
70  
71  	/*
72  	 * Test method for 'test.base.Control.isValidEMailAddress(String)'
73  	 */
74  	public void testIsValidEMailAddress() {
75  		assertEquals(Control.isValidEMailAddress("junior.skunk@gmail.com"),
76  				true);
77  		assertEquals(Control.isValidEMailAddress("junior.skunkgmail.com"),
78  				false);
79  
80  	}
81  
82  	/*
83  	 * Test method for 'test.base.Control.isValidUserName(String)'
84  	 */
85  	public void testIsValidUserName() {
86  		assertEquals(Control.isValidUserName("guido 1 Angelo"), false);
87  		assertEquals(Control.isValidUserName("1 guido Angelo"), false);
88  		assertEquals(Control.isValidUserName("Guido"), true);
89  		assertEquals(Control.isValidUserName("guido Angelo"), true);
90  		assertEquals(Control.isValidUserName("Guido Angelo"), true);
91  		assertEquals(Control.isValidUserName("Mario Antonio Paolo"), true);
92  	}
93  
94  	/*
95  	 * Test method for 'test.base.Control.isValidUserNickname(String)'
96  	 */
97  	public void testIsValidUserNickname() {
98  		assertEquals(Control.isValidUserNickname("Skunk"), true);
99  		assertEquals(Control.isValidUserNickname("SkUnK"), true);
100 		assertEquals(Control.isValidUserNickname("Sku nk"), false);
101 		assertEquals(Control.isValidUserNickname("JuniorSkunk"), true);
102 		assertEquals(Control.isValidUserNickname("Junior Skunk"), false);
103 	}
104 
105 	/*
106 	 * Test method for 'test.base.Control.isValidDocumentDate(Date, Date)'
107 	 */
108 	public void testIsValidDocumentDate() {
109 		assertFalse(Control.isValidDocumentDate(new GregorianCalendar(2000, 01,
110 				01).getTime(), new GregorianCalendar(2000, 01, 01).getTime()));
111 		assertTrue(Control.isValidDocumentDate(new GregorianCalendar(2000, 01,
112 				01).getTime(), new GregorianCalendar(2010, 01, 01).getTime()));
113 		assertFalse(Control.isValidDocumentDate(new Date(),
114 				new GregorianCalendar(2000, 01, 01).getTime()));
115 		assertFalse(Control.isValidDocumentDate(new Date(), new Date()));
116 	}
117 
118 	/*
119 	 * Test method for 'test.base.Control.isValidSessionDate(Date, Date)'
120 	 */
121 	public void testIsValidSessionDate() {
122 
123 	}
124 
125 	/*
126 	 * Test method for 'test.base.Control.isValidIPAddress(String)'
127 	 */
128 	public void testIsValidIPAddress() {
129 		assertEquals(Control.isValidIPAddress("0.0.0.0"), true);
130 		assertEquals(Control.isValidIPAddress("192.168.0.1"), true);
131 		assertEquals(Control.isValidIPAddress("192.168.01"), false);
132 		assertEquals(Control.isValidIPAddress("1921.68.0.1"), false);
133 		assertEquals(Control.isValidIPAddress("019.216.80.1"), true);
134 	}
135 
136 	/*
137 	 * Test method for 'test.base.Control.isValidUserSurname(String)'
138 	 */
139 	public void testIsValidUserSurname() {
140 		assertEquals(Control.isValidUserSurname("Ingenito"), true);
141 		assertEquals(Control.isValidUserSurname("De Martino"), true);
142 		assertEquals(Control.isValidUserSurname("De martino"), true);
143 		assertEquals(Control.isValidUserSurname("ingenito"), true);
144 		assertEquals(Control.isValidUserSurname("1ingenito"), false);
145 		assertEquals(Control.isValidUserSurname("ingen1ito"), false);
146 	}
147 
148 	/*
149 	 * Test method for 'test.base.Control.isValidBirthdayDate(Date)'
150 	 */
151 	public void testIsValidBirthdayDate() {
152 		assertTrue(Control.isValidBirthdayDate(new GregorianCalendar(1981, 12,
153 				24).getTime()));
154 		assertFalse(Control.isValidBirthdayDate(new Date()));
155 	}
156 
157 	/*
158 	 * Test method for 'test.base.Control.isValidIntegerOnlyString(String)'
159 	 */
160 	public void testIsValidIntegerOnlyString() {
161 		assertTrue(Control.isValidIntegerOnlyString("0123456789"));
162 		assertTrue(Control.isValidIntegerOnlyString("123456789"));
163 		assertFalse(Control.isValidIntegerOnlyString("a123456789"));
164 		assertFalse(Control.isValidIntegerOnlyString("0123456789a"));
165 	}
166 
167 	/*
168 	 * Test method for 'test.base.Control.isValidUDPPort(int)'
169 	 */
170 	public void testIsValidUDPPort() {
171 		assertTrue(Control.isValidUDPPort(9000));
172 		assertTrue(Control.isValidUDPPort(1025));
173 		assertFalse(Control.isValidUDPPort(1024));
174 		assertFalse(Control.isValidUDPPort(70000));
175 		assertTrue(Control.isValidUDPPort(65000));
176 	}
177 
178 	/*
179 	 * Test method for 'test.base.Control.isValidUserPassword(String)'
180 	 */
181 	public void testIsValidUserPassword() {
182 
183 	}
184 
185 	/*
186 	 * Test method for 'test.base.Control.isValidUserDocument(Document)'
187 	 */
188 	public void testIsValidUserDocument() {
189 
190 	}
191 
192 	/*
193 	 * Test method for 'test.base.Control.isValidDocumentImage(String)'
194 	 */
195 	public void testIsValidDocumentImage() {
196 
197 	}
198 
199 	/*
200 	 * Test method for 'test.base.Control.isValidDocumentNumber(String, String)'
201 	 */
202 	public void testIsValidDocumentNumber() {
203 
204 	}
205 
206 	/*
207 	 * Test method for 'test.base.Control.isValidServiceMinMaxDuration(int, boolean,
208 	 * int, boolean)'
209 	 */
210 	public void testIsValidServiceMinMaxDuration() {
211 
212 	}
213 
214 	/*
215 	 * Test method for 'test.base.Control.areValidAdministratorCredentials(String,
216 	 * String)'
217 	 */
218 	public void testAreValidAdministratorCredentials() {
219 
220 	}
221 
222 }