1 /*
2 * BookFormTest.java
3 * JUnit based test
4 *
5 * Created on December 15, 2006, 6:29 PM
6 */
7
8 package org.sourceforge.vlibrary.user.forms;
9
10 import junit.framework.*;
11 import org.apache.struts.action.ActionForm;
12 import javax.servlet.http.HttpServletRequest;
13 import org.apache.struts.action.ActionMessage;
14 import org.apache.struts.action.ActionErrors;
15 import org.apache.struts.action.ActionMapping;
16 import java.util.StringTokenizer;
17 import java.util.ArrayList;
18 import org.sourceforge.vlibrary.user.domain.Author;
19 import org.sourceforge.vlibrary.user.domain.Subject;
20
21 import org.apache.log4j.Logger;
22 import java.io.CharArrayReader;
23
24 /**
25 *
26 */
27 public class BookFormTest extends TestCase {
28 /** log4j Logger */
29 private static Logger logger =
30 Logger.getLogger(BookFormTest.class.getName());
31
32
33 public BookFormTest(String testName) {
34 super(testName);
35 }
36
37 protected void setUp() throws Exception {
38 }
39
40 protected void tearDown() throws Exception {
41 }
42
43
44 /**
45 * Test of setAuthorString method, of class org.sourceforge.vlibrary.user.forms.BookForm.
46 */
47 public void testSetAuthorString() {
48 BookForm bf = new BookForm();
49
50 String authorString = "John Doe\nJane Doe";
51
52 logger.debug("in testSetAuthorString: " + authorString);
53
54 bf.setAuthorString(authorString);
55
56 logger.debug(bf.getAuthors());
57
58
59 bf = new BookForm();
60
61 authorString = "John Doe";
62
63 logger.debug("in testSetAuthorString: " + authorString);
64
65 bf.setAuthorString(authorString);
66
67 logger.debug(bf.getAuthors());
68
69
70 bf = new BookForm();
71
72 authorString = "John";
73
74 logger.debug("in testSetAuthorString: " + authorString);
75
76 bf.setAuthorString(authorString);
77
78 logger.debug(bf.getAuthors());
79
80
81 bf = new BookForm();
82
83 authorString = "John\nJane";
84
85 logger.debug("in testSetAuthorString: " + authorString);
86
87 bf.setAuthorString(authorString);
88
89 logger.debug(bf.getAuthors());
90 }
91
92
93 /**
94 * Test of setSubjectString method, of class org.sourceforge.vlibrary.user.forms.BookForm.
95 */
96 public void testSetSubjectString() {
97 // TODO add your test code.
98 }
99
100 /**
101 * Test of validate method, of class org.sourceforge.vlibrary.user.forms.BookForm.
102 */
103 public void testValidate() {
104 // TODO add your test code.
105 }
106
107 /**
108 * Test of getClassName method, of class org.sourceforge.vlibrary.user.forms.BookForm.
109 */
110 public void testGetClassName() {
111 // TODO add your test code.
112 }
113
114 /**
115 * Test of getAuthors method, of class org.sourceforge.vlibrary.user.forms.BookForm.
116 */
117 public void testGetAuthors() {
118 // TODO add your test code.
119 }
120
121 /**
122 * Test of setAuthors method, of class org.sourceforge.vlibrary.user.forms.BookForm.
123 */
124 public void testSetAuthors() {
125 // TODO add your test code.
126 }
127
128 /**
129 * Test of getCreated method, of class org.sourceforge.vlibrary.user.forms.BookForm.
130 */
131 public void testGetCreated() {
132 // TODO add your test code.
133 }
134
135 /**
136 * Test of setCreated method, of class org.sourceforge.vlibrary.user.forms.BookForm.
137 */
138 public void testSetCreated() {
139 // TODO add your test code.
140 }
141
142 /**
143 * Test of getId method, of class org.sourceforge.vlibrary.user.forms.BookForm.
144 */
145 public void testGetId() {
146 // TODO add your test code.
147 }
148
149 /**
150 * Test of setId method, of class org.sourceforge.vlibrary.user.forms.BookForm.
151 */
152 public void testSetId() {
153 // TODO add your test code.
154 }
155
156 /**
157 * Test of getIsbn method, of class org.sourceforge.vlibrary.user.forms.BookForm.
158 */
159 public void testGetIsbn() {
160 // TODO add your test code.
161 }
162
163 /**
164 * Test of setIsbn method, of class org.sourceforge.vlibrary.user.forms.BookForm.
165 */
166 public void testSetIsbn() {
167 // TODO add your test code.
168 }
169
170 /**
171 * Test of getOwner method, of class org.sourceforge.vlibrary.user.forms.BookForm.
172 */
173 public void testGetOwner() {
174 // TODO add your test code.
175 }
176
177 /**
178 * Test of setOwner method, of class org.sourceforge.vlibrary.user.forms.BookForm.
179 */
180 public void testSetOwner() {
181 // TODO add your test code.
182 }
183
184 /**
185 * Test of getPub_date method, of class org.sourceforge.vlibrary.user.forms.BookForm.
186 */
187 public void testGetPub_date() {
188 // TODO add your test code.
189 }
190
191 /**
192 * Test of setPub_date method, of class org.sourceforge.vlibrary.user.forms.BookForm.
193 */
194 public void testSetPub_date() {
195 // TODO add your test code.
196 }
197
198 /**
199 * Test of getPublisher method, of class org.sourceforge.vlibrary.user.forms.BookForm.
200 */
201 public void testGetPublisher() {
202 // TODO add your test code.
203 }
204
205 /**
206 * Test of setPublisher method, of class org.sourceforge.vlibrary.user.forms.BookForm.
207 */
208 public void testSetPublisher() {
209 // TODO add your test code.
210 }
211
212 /**
213 * Test of getSubjects method, of class org.sourceforge.vlibrary.user.forms.BookForm.
214 */
215 public void testGetSubjects() {
216 // TODO add your test code.
217 }
218
219 /**
220 * Test of setSubjects method, of class org.sourceforge.vlibrary.user.forms.BookForm.
221 */
222 public void testSetSubjects() {
223 // TODO add your test code.
224 }
225
226 /**
227 * Test of getTitle method, of class org.sourceforge.vlibrary.user.forms.BookForm.
228 */
229 public void testGetTitle() {
230 // TODO add your test code.
231 }
232
233 /**
234 * Test of setTitle method, of class org.sourceforge.vlibrary.user.forms.BookForm.
235 */
236 public void testSetTitle() {
237 // TODO add your test code.
238 }
239
240 /**
241 * Test of getAuthorString method, of class org.sourceforge.vlibrary.user.forms.BookForm.
242 */
243 public void testGetAuthorString() {
244 // TODO add your test code.
245 }
246
247 /**
248 * Test of getSubjectString method, of class org.sourceforge.vlibrary.user.forms.BookForm.
249 */
250 public void testGetSubjectString() {
251 // TODO add your test code.
252 }
253
254 /**
255 * Test of getEnumeratedSubjectString method, of class org.sourceforge.vlibrary.user.forms.BookForm.
256 */
257 public void testGetEnumeratedSubjectString() {
258 // TODO add your test code.
259 }
260
261 /**
262 * Test of getSubjectListString method, of class org.sourceforge.vlibrary.user.forms.BookForm.
263 */
264 public void testGetSubjectListString() {
265 // TODO add your test code.
266 }
267
268 /**
269 * Test of validateIsbn method, of class org.sourceforge.vlibrary.user.forms.BookForm.
270 */
271 public void testValidateIsbn() {
272 ActionErrors errors = new ActionErrors();
273
274 BookForm bf = new BookForm();
275
276 ////////////////////////////////////////////////////////
277 errors = new ActionErrors();
278
279 bf.validateIsbn( "".toUpperCase(), errors );
280
281 assertFalse(errors.isEmpty());
282
283 ////////////////////////////////////////////////////////
284 errors = new ActionErrors();
285
286 bf.validateIsbn( " --- - - ".toUpperCase(), errors );
287
288 assertFalse(errors.isEmpty());
289
290 ////////////////////////////////////////////////////////
291 errors = new ActionErrors();
292
293 bf.validateIsbn( "0843 610-72-".toUpperCase(), errors );
294
295 assertFalse(errors.isEmpty());
296
297 ////////////////////////////////////////////////////////
298 errors = new ActionErrors();
299
300 bf.validateIsbn( "0843 610-727".toUpperCase(), errors );
301
302 assertTrue(errors.isEmpty());
303
304 ////////////////////////////////////////////////////////
305 errors = new ActionErrors();
306
307 bf.validateIsbn( "033 -398--224X".toUpperCase(), errors );
308
309 assertTrue(errors.isEmpty());
310
311 ////////////////////////////////////////////////////////
312 errors = new ActionErrors();
313
314 bf.validateIsbn( "0843610 ---700".toUpperCase(), errors );
315
316 assertTrue(errors.isEmpty());
317
318 ////////////////////////////////////////////////////////
319 errors = new ActionErrors();
320
321 bf.validateIsbn( "084-3610-728".toUpperCase(), errors );
322
323 assertFalse(errors.isEmpty());
324
325 ////////////////////////////////////////////////////////
326 errors = new ActionErrors();
327
328 bf.validateIsbn( "qwer--tyu--iop".toUpperCase(), errors );
329
330 assertFalse(errors.isEmpty());
331
332 ////////////////////////////////////////////////////////
333 errors = new ActionErrors();
334
335 bf.validateIsbn( "978 01-10-- 0022--24".toUpperCase(), errors );
336
337 assertTrue(errors.isEmpty());
338
339 ////////////////////////////////////////////////////////
340 errors = new ActionErrors();
341
342 bf.validateIsbn( "978-- 0571-- --089- 895".toUpperCase(), errors );
343
344 assertTrue(errors.isEmpty());
345
346 ////////////////////////////////////////////////////////
347 errors = new ActionErrors();
348
349 bf.validateIsbn( "978600-- 000--0004".toUpperCase(), errors );
350
351 assertTrue(errors.isEmpty());
352
353 ////////////////////////////////////////////////////////
354 errors = new ActionErrors();
355
356 bf.validateIsbn( "978--0777--7777--70".toUpperCase(), errors );
357
358 assertTrue(errors.isEmpty());
359
360 ////////////////////////////////////////////////////////
361 errors = new ActionErrors();
362
363 bf.validateIsbn( "97895-- 1459--6933".toUpperCase(), errors );
364
365 assertTrue(errors.isEmpty());
366
367 ////////////////////////////////////////////////////////
368 errors = new ActionErrors();
369
370 bf.validateIsbn( "9789--51459--6940".toUpperCase(), errors );
371
372 assertTrue(errors.isEmpty());
373
374 ////////////////////////////////////////////////////////
375 errors = new ActionErrors();
376
377 bf.validateIsbn( "9-7-8-9-5-1-4-5-9-6-9-5-7".toUpperCase(), errors );
378
379 assertTrue(errors.isEmpty());
380
381 ////////////////////////////////////////////////////////
382 errors = new ActionErrors();
383
384 bf.validateIsbn( "9789514596964".toUpperCase(), errors );
385
386 assertTrue(errors.isEmpty());
387
388 ////////////////////////////////////////////////////////
389 errors = new ActionErrors();
390
391 bf.validateIsbn( "9789514599996".toUpperCase(), errors );
392
393 assertTrue(errors.isEmpty());
394
395 ////////////////////////////////////////////////////////
396 errors = new ActionErrors();
397
398 bf.validateIsbn( "978952dfgh884".toUpperCase(), errors );
399
400 assertFalse(errors.isEmpty());
401 }
402
403 /**
404 * Test of isIsbn10Valid method, of class org.sourceforge.vlibrary.user.forms.BookForm.
405 */
406 public void testIsIsbn10Valid() {
407
408 BookForm bf = new BookForm();
409
410 assertTrue(bf.isIsbn10Valid("0843610727"));
411
412 assertTrue(bf.isIsbn10Valid("033398224X"));
413
414 assertTrue(bf.isIsbn10Valid("0843610700"));
415
416 assertFalse(bf.isIsbn10Valid("0843610728"));
417
418 assertFalse(bf.isIsbn10Valid("qwertyuiop"));
419 }
420
421 /**
422 * Test of isIsbn13Valid method, of class org.sourceforge.vlibrary.user.forms.BookForm.
423 */
424 public void testIsIsbn13Valid() {
425
426 BookForm bf = new BookForm();
427
428 assertTrue(bf.isIsbn13Valid("9780110002224"));
429
430 assertTrue(bf.isIsbn13Valid("9780571089895"));
431
432 assertTrue(bf.isIsbn13Valid("9786000000004"));
433
434 assertTrue(bf.isIsbn13Valid("9780777777770"));
435
436 assertTrue(bf.isIsbn13Valid("9789514596933"));
437
438 assertTrue(bf.isIsbn13Valid("9789514596940"));
439
440 assertTrue(bf.isIsbn13Valid("9789514596957"));
441
442 assertTrue(bf.isIsbn13Valid("9789514596964"));
443
444 assertTrue(bf.isIsbn13Valid("9789514599996"));
445
446 assertFalse(bf.isIsbn13Valid("0843610727"));
447
448 assertFalse(bf.isIsbn13Valid("978952dfgh884"));
449 }
450
451 /**
452 * Test of stripIsbnDashes method, of class org.sourceforge.vlibrary.user.forms.BookForm.
453 */
454 public void testStripIsbnDashes() {
455 // TODO add your test code.
456 }
457
458 /**
459 * Test of getAction method, of class org.sourceforge.vlibrary.user.forms.BookForm.
460 */
461 public void testGetAction() {
462 // TODO add your test code.
463 }
464
465 /**
466 * Test of setAction method, of class org.sourceforge.vlibrary.user.forms.BookForm.
467 */
468 public void testSetAction() {
469 // TODO add your test code.
470 }
471
472 /**
473 * Test of getOwnerPhone method, of class org.sourceforge.vlibrary.user.forms.BookForm.
474 */
475 public void testGetOwnerPhone() {
476 // TODO add your test code.
477 }
478
479 /**
480 * Test of setOwnerPhone method, of class org.sourceforge.vlibrary.user.forms.BookForm.
481 */
482 public void testSetOwnerPhone() {
483 // TODO add your test code.
484 }
485
486 /**
487 * Test of getSubjectList method, of class org.sourceforge.vlibrary.user.forms.BookForm.
488 */
489 public void testGetSubjectList() {
490 // TODO add your test code.
491 }
492
493 /**
494 * Test of setSubjectList method, of class org.sourceforge.vlibrary.user.forms.BookForm.
495 */
496 public void testSetSubjectList() {
497 // TODO add your test code.
498 }
499
500 }