1
2
3
4
5
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
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
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
95
96 public void testSetSubjectString() {
97
98 }
99
100
101
102
103 public void testValidate() {
104
105 }
106
107
108
109
110 public void testGetClassName() {
111
112 }
113
114
115
116
117 public void testGetAuthors() {
118
119 }
120
121
122
123
124 public void testSetAuthors() {
125
126 }
127
128
129
130
131 public void testGetCreated() {
132
133 }
134
135
136
137
138 public void testSetCreated() {
139
140 }
141
142
143
144
145 public void testGetId() {
146
147 }
148
149
150
151
152 public void testSetId() {
153
154 }
155
156
157
158
159 public void testGetIsbn() {
160
161 }
162
163
164
165
166 public void testSetIsbn() {
167
168 }
169
170
171
172
173 public void testGetOwner() {
174
175 }
176
177
178
179
180 public void testSetOwner() {
181
182 }
183
184
185
186
187 public void testGetPub_date() {
188
189 }
190
191
192
193
194 public void testSetPub_date() {
195
196 }
197
198
199
200
201 public void testGetPublisher() {
202
203 }
204
205
206
207
208 public void testSetPublisher() {
209
210 }
211
212
213
214
215 public void testGetSubjects() {
216
217 }
218
219
220
221
222 public void testSetSubjects() {
223
224 }
225
226
227
228
229 public void testGetTitle() {
230
231 }
232
233
234
235
236 public void testSetTitle() {
237
238 }
239
240
241
242
243 public void testGetAuthorString() {
244
245 }
246
247
248
249
250 public void testGetSubjectString() {
251
252 }
253
254
255
256
257 public void testGetEnumeratedSubjectString() {
258
259 }
260
261
262
263
264 public void testGetSubjectListString() {
265
266 }
267
268
269
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
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
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
453
454 public void testStripIsbnDashes() {
455
456 }
457
458
459
460
461 public void testGetAction() {
462
463 }
464
465
466
467
468 public void testSetAction() {
469
470 }
471
472
473
474
475 public void testGetOwnerPhone() {
476
477 }
478
479
480
481
482 public void testSetOwnerPhone() {
483
484 }
485
486
487
488
489 public void testGetSubjectList() {
490
491 }
492
493
494
495
496 public void testSetSubjectList() {
497
498 }
499
500 }