Revision 42159

View differences:

tags/org.gvsig.desktop-2.0.95/org.gvsig.desktop.library/org.gvsig.utils/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!--
3

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
28

  
29
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
30

  
31
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
32
		<layout class="org.apache.log4j.PatternLayout">
33
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
34
		</layout>
35
	</appender>
36

  
37
	<category name="org.gvsig.tools">
38
		<priority value="DEBUG" />
39
	</category>
40

  
41
	<category name="org.gvsig.utils">
42
		<priority value="DEBUG" />
43
	</category>
44

  
45
	<root>
46
		<priority value="INFO" />
47
		<appender-ref ref="CONSOLE" />
48
	</root>
49
</log4j:configuration>
0 50

  
tags/org.gvsig.desktop-2.0.95/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/stringNumberUtilities/TestStringNumberUtilities.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.utils.stringNumberUtilities;
25

  
26
import org.gvsig.utils.stringNumberUtilities.StringNumberUtilities;
27

  
28
import junit.framework.TestCase;
29

  
30
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
31
 *
32
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
33
 *
34
 * This program is free software; you can redistribute it and/or
35
 * modify it under the terms of the GNU General Public License
36
 * as published by the Free Software Foundation; either version 2
37
 * of the License, or (at your option) any later version.
38
 *
39
 * This program is distributed in the hope that it will be useful,
40
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42
 * GNU General Public License for more details.
43
 *
44
 * You should have received a copy of the GNU General Public License
45
 * along with this program; if not, write to the Free Software
46
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
47
 *
48
 * For more information, contact:
49
 *
50
 *  Generalitat Valenciana
51
 *   Conselleria d'Infraestructures i Transport
52
 *   Av. Blasco Ib??ez, 50
53
 *   46010 VALENCIA
54
 *   SPAIN
55
 *
56
 *      +34 963862235
57
 *   gvsig@gva.es
58
 *      www.gvsig.gva.es
59
 *
60
 *    or
61
 *
62
 *   IVER T.I. S.A
63
 *   Salamanca 50
64
 *   46005 Valencia
65
 *   Spain
66
 *
67
 *   +34 963163400
68
 *   dac@iver.es
69
 */
70

  
71
/**
72
 * Tests the methods of the class StringNumberUtilities
73
 * 
74
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
75
 */
76
public class TestStringNumberUtilities extends TestCase{
77
	private String word;
78
	
79
	/*
80
	 *  (non-Javadoc)
81
	 * @see junit.framework.TestCase#setUp()
82
	 */
83
	protected void setUp() throws Exception {
84
		super.setUp();
85
		word = new String();
86
	}
87

  
88
	/*
89
	 *  (non-Javadoc)
90
	 * @see junit.framework.TestCase#tearDown()
91
	 */
92
	protected void tearDown() throws Exception {
93
		super.tearDown();
94
	}
95
	
96
	/**
97
	 * A test
98
	 */
99
	public void test1() {
100
		word = "2.3";
101
		ShowText.showIsNumberText(word);
102

  
103
		if (StringNumberUtilities.isNumber(word)) {
104
			ShowText.showYes();
105
		}
106
		else {
107
			ShowText.showNo();
108
			fail();
109
		}
110
	}
111

  
112
	/**
113
	 * A test
114
	 */
115
	public void test2() {
116
		word = "a as wz rwa";
117
		ShowText.showIsNumberText(word);
118

  
119
		if (StringNumberUtilities.isNumber(word)) {
120
			ShowText.showYes();
121
		}
122
		else {
123
			ShowText.showNo();
124
			fail();
125
		}
126
	}
127

  
128
	/**
129
	 * A test
130
	 */
131
	public void test3() {
132
		word = "2";
133
		ShowText.showIsNumberText(word);
134

  
135
		if (StringNumberUtilities.isNumber(word)) {
136
			ShowText.showYes();
137
		}
138
		else {
139
			ShowText.showNo();
140
			fail();
141
		}
142
	}
143

  
144
	/**
145
	 * A test
146
	 */
147
	public void test4() {
148
		word = "";
149
		ShowText.showIsNumberText(word);
150

  
151
		if (StringNumberUtilities.isNumber(word)) {
152
			ShowText.showYes();
153
		}
154
		else {
155
			ShowText.showNo();
156
			fail();
157
		}
158
	}
159

  
160
	/**
161
	 * A test
162
	 */
163
	public void test5() {
164
		word = "-2.3";
165
		ShowText.showIsNumberText(word);
166

  
167
		if (StringNumberUtilities.isNumber(word)) {
168
			ShowText.showYes();
169
		}
170
		else {
171
			ShowText.showNo();
172
			fail();
173
		}
174
	}
175

  
176
	/**
177
	 * A test
178
	 */
179
	public void test6() {
180
		word = "-300";
181
		ShowText.showIsNumberText(word);
182

  
183
		if (StringNumberUtilities.isNumber(word)) {
184
			ShowText.showYes();
185
		}
186
		else {
187
			ShowText.showNo();
188
			fail();
189
		}
190
	}
191

  
192
	/**
193
	 * A test
194
	 */
195
	public void test7() {
196
		word = "2.3";
197
		ShowText.showIsNaturalText(word);
198

  
199
		if (StringNumberUtilities.isNaturalNumber(word)) {
200
			ShowText.showYes();
201
		}
202
		else {
203
			ShowText.showNo();
204
			fail();
205
		}
206
	}
207

  
208
	/**
209
	 * A test
210
	 */
211
	public void test8() {
212
		word = "334";
213
		ShowText.showIsNaturalText(word);
214

  
215
		if (StringNumberUtilities.isNaturalNumber(word)) {
216
			ShowText.showYes();
217
		}
218
		else {
219
			ShowText.showNo();
220
			fail();
221
		}
222
	}
223

  
224
	/**
225
	 * A test
226
	 */
227
	public void test9() {
228
		word = "-2a3";
229
		ShowText.showIsIntegerText(word);
230

  
231
		if (StringNumberUtilities.isIntegerNumber(word)) {
232
			ShowText.showYes();
233
		}
234
		else {
235
			ShowText.showNo();
236
			fail();
237
		}
238
	}
239

  
240
	/**
241
	 * A test
242
	 */
243
	public void test10() {
244
		word = "-23";
245
		ShowText.showIsIntegerText(word);
246

  
247
		if (StringNumberUtilities.isIntegerNumber(word)) {
248
			ShowText.showYes();
249
		}
250
		else {
251
			ShowText.showNo();
252
			fail();
253
		}
254
	}
255
	
256
	/**
257
	 * A test
258
	 */
259
	public void test11() {
260
		word = "7";
261
		ShowText.showIsIntegerText(word);
262

  
263
		if (StringNumberUtilities.isIntegerNumber(word)) {
264
			ShowText.showYes();
265
		}
266
		else {
267
			ShowText.showNo();
268
			fail();
269
		}
270
	}
271
	
272
	/**
273
	 * A test
274
	 */
275
	public void test12() {
276
		word = "2.3";
277
		ShowText.showIsIntegerText(word);
278

  
279
		if (StringNumberUtilities.isIntegerNumber(word)) {
280
			ShowText.showYes();
281
		}
282
		else {
283
			ShowText.showNo();
284
			fail();
285
		}
286
	}
287

  
288
	/**
289
	 * A test
290
	 */
291
	public void test13() {
292
		word = "2.3";
293
		ShowText.showIsRealText(word);
294

  
295
		if (StringNumberUtilities.isRealNumber(word)) {
296
			ShowText.showYes();
297
		}
298
		else {
299
			ShowText.showNo();
300
			fail();
301
		}
302
	}
303
	
304
	/**
305
	 * A test
306
	 */
307
	public void test14() {
308
		word = "37";
309
		ShowText.showIsRealText(word);
310

  
311
		if (StringNumberUtilities.isRealNumber(word)) {
312
			ShowText.showYes();
313
		}
314
		else {
315
			ShowText.showNo();
316
			fail();
317
		}
318
	}
319
	
320
	/**
321
	 * A test
322
	 */
323
	public void test15() {
324
		word = "-4.6";
325
		ShowText.showIsRealText(word);
326

  
327
		if (StringNumberUtilities.isRealNumber(word)) {
328
			ShowText.showYes();
329
		}
330
		else {
331
			ShowText.showNo();
332
			fail();
333
		}
334
	}
335
	
336
	/**
337
	 * A test
338
	 */
339
	public void test16() {
340
		word = "-8000";
341
		ShowText.showIsRealText(word);
342

  
343
		if (StringNumberUtilities.isRealNumber(word)) {
344
			ShowText.showYes();
345
		}
346
		else {
347
			ShowText.showNo();
348
			fail();
349
		}
350
	}
351

  
352
	/**
353
	 * A test
354
	 */
355
	public void test17() {
356
		word = "-80k00";
357
		ShowText.showIsRealText(word);
358

  
359
		if (StringNumberUtilities.isRealNumber(word)) {
360
			ShowText.showYes();
361
		}
362
		else {
363
			ShowText.showNo();
364
			fail();
365
		}
366
	}
367
		
368
	/**
369
	 * A test
370
	 */
371
	public void test18() {
372
		word = ".6";
373
		ShowText.showIsRealText(word);
374

  
375
		if (StringNumberUtilities.isRealNumber(word)) {
376
			ShowText.showYes();
377
		}
378
		else {
379
			ShowText.showNo();
380
			fail();
381
		}
382
	}
383
	
384
	/**
385
	 * A test
386
	 */
387
	public void test19() {
388
		word = "-.6";
389
		ShowText.showIsRealText(word);
390

  
391
		if (StringNumberUtilities.isRealNumber(word)) {
392
			ShowText.showYes();
393
		}
394
		else {
395
			ShowText.showNo();
396
			fail();
397
		}
398
	}
399
	
400
	/**
401
	 * A test
402
	 */
403
	public void test20() {
404
		word = "b-.6";
405
		ShowText.showIsRealText(word);
406

  
407
		if (StringNumberUtilities.isRealNumber(word)) {
408
			ShowText.showYes();
409
		}
410
		else {
411
			ShowText.showNo();
412
			fail();
413
		}
414
	}
415
	
416
	
417
	/**
418
	 * A test
419
	 */
420
	public void test21() {
421
		word = "-c.6";
422
		ShowText.showIsRealText(word);
423

  
424
		if (StringNumberUtilities.isRealNumber(word)) {
425
			ShowText.showYes();
426
		}
427
		else {
428
			ShowText.showNo();
429
			fail();
430
		}
431
	}
432
	
433
	
434
	/**
435
	 * A test
436
	 */
437
	public void test22() {
438
		word = "-.d6";
439
		ShowText.showIsRealText(word);
440

  
441
		if (StringNumberUtilities.isRealNumber(word)) {
442
			ShowText.showYes();
443
		}
444
		else {
445
			ShowText.showNo();
446
			fail();
447
		}
448
	}
449
	
450
	/**
451
	 * A test
452
	 */
453
	public void test23() {
454
		word = "-.6e";
455
		ShowText.showIsRealText(word);
456

  
457
		if (StringNumberUtilities.isRealNumber(word)) {
458
			ShowText.showYes();
459
		}
460
		else {
461
			ShowText.showNo();
462
			fail();
463
		}
464
	}
465
	
466
	/**
467
	 * A test
468
	 */
469
	public void test24() {
470
		word = "+.6";
471
		ShowText.showIsRealText(word);
472

  
473
		if (StringNumberUtilities.isRealNumber(word)) {
474
			ShowText.showYes();
475
		}
476
		else {
477
			ShowText.showNo();
478
			fail();
479
		}
480
	}
481
	
482
	/**
483
	 * A test
484
	 */
485
	public void test25() {
486
		word = "+.6";
487
		ShowText.showIsRealWithIntegerExponentText(word);
488

  
489
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
490
			ShowText.showYes();
491
		}
492
		else {
493
			ShowText.showNo();
494
			fail();
495
		}
496
	}
497
	
498
	
499
	/**
500
	 * A test
501
	 */
502
	public void test26() {
503
		word = ".6";
504
		ShowText.showIsRealWithIntegerExponentText(word);
505

  
506
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
507
			ShowText.showYes();
508
		}
509
		else {
510
			ShowText.showNo();
511
			fail();
512
		}
513
	}
514

  
515
	
516
	/**
517
	 * A test
518
	 */
519
	public void test27() {
520
		word = "-.6";
521
		ShowText.showIsRealWithIntegerExponentText(word);
522

  
523
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
524
			ShowText.showYes();
525
		}
526
		else {
527
			ShowText.showNo();
528
			fail();
529
		}
530
	}
531

  
532
	
533
	/**
534
	 * A test
535
	 */
536
	public void test28() {
537
		word = "+6";
538
		ShowText.showIsRealWithIntegerExponentText(word);
539

  
540
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
541
			ShowText.showYes();
542
		}
543
		else {
544
			ShowText.showNo();
545
			fail();
546
		}
547
	}
548

  
549
	
550
	/**
551
	 * A test
552
	 */
553
	public void test29() {
554
		word = "-6";
555
		ShowText.showIsRealWithIntegerExponentText(word);
556

  
557
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
558
			ShowText.showYes();
559
		}
560
		else {
561
			ShowText.showNo();
562
			fail();
563
		}
564
	}
565

  
566
	
567
	/**
568
	 * A test
569
	 */
570
	public void test30() {
571
		word = "6";
572
		ShowText.showIsRealWithIntegerExponentText(word);
573

  
574
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
575
			ShowText.showYes();
576
		}
577
		else {
578
			ShowText.showNo();
579
			fail();
580
		}
581
	}
582
	
583
	/**
584
	 * A test
585
	 */
586
	public void test31() {
587
		word = "136.13";
588
		ShowText.showIsRealWithIntegerExponentText(word);
589

  
590
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
591
			ShowText.showYes();
592
		}
593
		else {
594
			ShowText.showNo();
595
			fail();
596
		}
597
	}
598
	
599
	
600
	/**
601
	 * A test
602
	 */
603
	public void test32() {
604
		word = "+13.42";
605
		ShowText.showIsRealWithIntegerExponentText(word);
606

  
607
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
608
			ShowText.showYes();
609
		}
610
		else {
611
			ShowText.showNo();
612
			fail();
613
		}
614
	}
615
	
616
	/**
617
	 * A test
618
	 */
619
	public void test33() {
620
		word = "-246.24";
621
		ShowText.showIsRealWithIntegerExponentText(word);
622

  
623
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
624
			ShowText.showYes();
625
		}
626
		else {
627
			ShowText.showNo();
628
			fail();
629
		}
630
	}
631
	
632
	/**
633
	 * A test
634
	 */
635
	public void test34() {
636
		word = "146.134E+13";
637
		ShowText.showIsRealWithIntegerExponentText(word);
638

  
639
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
640
			ShowText.showYes();
641
		}
642
		else {
643
			ShowText.showNo();
644
			fail();
645
		}
646
	}
647
	
648
	/**
649
	 * A test
650
	 */
651
	public void test35() {
652
		word = "614.425E-67";
653
		ShowText.showIsRealWithIntegerExponentText(word);
654

  
655
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
656
			ShowText.showYes();
657
		}
658
		else {
659
			ShowText.showNo();
660
			fail();
661
		}
662
	}
663
	
664
	/**
665
	 * A test
666
	 */
667
	public void test36() {
668
		word = "-8945.1201e48.141";
669
		ShowText.showIsRealWithIntegerExponentText(word);
670

  
671
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
672
			ShowText.showYes();
673
		}
674
		else {
675
			ShowText.showNo();
676
			fail();
677
		}
678
	}
679
	
680
	/**
681
	 * A test
682
	 */
683
	public void test37() {
684
		word = "-8945.1201e48.141.";
685
		ShowText.showIsRealWithIntegerExponentText(word);
686

  
687
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
688
			ShowText.showYes();
689
		}
690
		else {
691
			ShowText.showNo();
692
			fail();
693
		}
694
	}
695
	
696
	/**
697
	 * A test
698
	 */
699
	public void test38() {
700
		word = "8945.1201ee48.141";
701
		ShowText.showIsRealWithIntegerExponentText(word);
702

  
703
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
704
			ShowText.showYes();
705
		}
706
		else {
707
			ShowText.showNo();
708
			fail();
709
		}
710
	}
711
		
712
	/**
713
	 * A test
714
	 */
715
	public void test39() {
716
		word = "8945.1201E";
717
		ShowText.showIsRealWithIntegerExponentText(word);
718

  
719
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
720
			ShowText.showYes();
721
		}
722
		else {
723
			ShowText.showNo();
724
			fail();
725
		}
726
	}
727
	
728
	/**
729
	 * A test
730
	 */
731
	public void test40() {
732
		word = "8945.1201e+";
733
		ShowText.showIsRealWithIntegerExponentText(word);
734

  
735
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
736
			ShowText.showYes();
737
		}
738
		else {
739
			ShowText.showNo();
740
			fail();
741
		}
742
	}
743
	
744
	/**
745
	 * A test
746
	 */
747
	public void test41() {
748
		word = "8945.1201e+1";
749
		ShowText.showIsRealWithIntegerExponentText(word);
750

  
751
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
752
			ShowText.showYes();
753
		}
754
		else {
755
			ShowText.showNo();
756
			fail();
757
		}
758
	}
759
	
760
	
761
	/**
762
	 * A test
763
	 */
764
	public void test42() {
765
		word = "8945.1201e+.32";
766
		ShowText.showIsRealWithIntegerExponentText(word);
767

  
768
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
769
			ShowText.showYes();
770
		}
771
		else {
772
			ShowText.showNo();
773
			fail();
774
		}
775
	}
776
	
777
	/**
778
	 * A test
779
	 */
780
	public void test43() {
781
		word = "+.6";
782
		ShowText.showIsRealWithRealExponentText(word);
783

  
784
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
785
			ShowText.showYes();
786
		}
787
		else {
788
			ShowText.showNo();
789
			fail();
790
		}
791
	}
792
	
793
	
794
	/**
795
	 * A test
796
	 */
797
	public void test44() {
798
		word = ".6";
799
		ShowText.showIsRealWithRealExponentText(word);
800

  
801
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
802
			ShowText.showYes();
803
		}
804
		else {
805
			ShowText.showNo();
806
			fail();
807
		}
808
	}
809

  
810
	
811
	/**
812
	 * A test
813
	 */
814
	public void test45() {
815
		word = "-.6";
816
		ShowText.showIsRealWithRealExponentText(word);
817

  
818
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
819
			ShowText.showYes();
820
		}
821
		else {
822
			ShowText.showNo();
823
			fail();
824
		}
825
	}
826

  
827
	
828
	/**
829
	 * A test
830
	 */
831
	public void test46() {
832
		word = "+6";
833
		ShowText.showIsRealWithRealExponentText(word);
834

  
835
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
836
			ShowText.showYes();
837
		}
838
		else {
839
			ShowText.showNo();
840
			fail();
841
		}
842
	}
843

  
844
	
845
	/**
846
	 * A test
847
	 */
848
	public void test47() {
849
		word = "-6";
850
		ShowText.showIsRealWithRealExponentText(word);
851

  
852
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
853
			ShowText.showYes();
854
		}
855
		else {
856
			ShowText.showNo();
857
			fail();
858
		}
859
	}
860

  
861
	
862
	/**
863
	 * A test
864
	 */
865
	public void test48() {
866
		word = "6";
867
		ShowText.showIsRealWithRealExponentText(word);
868

  
869
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
870
			ShowText.showYes();
871
		}
872
		else {
873
			ShowText.showNo();
874
			fail();
875
		}
876
	}
877
	
878
	/**
879
	 * A test
880
	 */
881
	public void test49() {
882
		word = "136.13";
883
		ShowText.showIsRealWithRealExponentText(word);
884

  
885
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
886
			ShowText.showYes();
887
		}
888
		else {
889
			ShowText.showNo();
890
			fail();
891
		}
892
	}
893
	
894
	
895
	/**
896
	 * A test
897
	 */
898
	public void test50() {
899
		word = "+13.42";
900
		ShowText.showIsRealWithRealExponentText(word);
901

  
902
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
903
			ShowText.showYes();
904
		}
905
		else {
906
			ShowText.showNo();
907
			fail();
908
		}
909
	}
910
	
911
	/**
912
	 * A test
913
	 */
914
	public void test51() {
915
		word = "-246.24";
916
		ShowText.showIsRealWithRealExponentText(word);
917

  
918
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
919
			ShowText.showYes();
920
		}
921
		else {
922
			ShowText.showNo();
923
			fail();
924
		}
925
	}
926
	
927
	/**
928
	 * A test
929
	 */
930
	public void test52() {
931
		word = "146.134E+13";
932
		ShowText.showIsRealWithRealExponentText(word);
933

  
934
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
935
			ShowText.showYes();
936
		}
937
		else {
938
			ShowText.showNo();
939
			fail();
940
		}
941
	}
942
	
943
	/**
944
	 * A test
945
	 */
946
	public void test53() {
947
		word = "614.425E-67";
948
		ShowText.showIsRealWithRealExponentText(word);
949

  
950
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
951
			ShowText.showYes();
952
		}
953
		else {
954
			ShowText.showNo();
955
			fail();
956
		}
957
	}
958
	
959
	/**
960
	 * A test
961
	 */
962
	public void test54() {
963
		word = "-8945.1201e48.141";
964
		ShowText.showIsRealWithRealExponentText(word);
965

  
966
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
967
			ShowText.showYes();
968
		}
969
		else {
970
			ShowText.showNo();
971
			fail();
972
		}
973
	}
974
	
975
	/**
976
	 * A test
977
	 */
978
	public void test55() {
979
		word = "-8945.1201e48.141.";
980
		ShowText.showIsRealWithRealExponentText(word);
981

  
982
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
983
			ShowText.showYes();
984
		}
985
		else {
986
			ShowText.showNo();
987
			fail();
988
		}
989
	}
990
	
991
	/**
992
	 * A test
993
	 */
994
	public void test56() {
995
		word = "8945.1201ee48.141";
996
		ShowText.showIsRealWithRealExponentText(word);
997

  
998
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
999
			ShowText.showYes();
1000
		}
1001
		else {
1002
			ShowText.showNo();
1003
			fail();
1004
		}
1005
	}
1006
		
1007
	/**
1008
	 * A test
1009
	 */
1010
	public void test57() {
1011
		word = "8945.1201E";
1012
		ShowText.showIsRealWithRealExponentText(word);
1013

  
1014
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1015
			ShowText.showYes();
1016
		}
1017
		else {
1018
			ShowText.showNo();
1019
			fail();
1020
		}
1021
	}
1022
	
1023
	/**
1024
	 * A test
1025
	 */
1026
	public void test58() {
1027
		word = "8945.1201e+";
1028
		ShowText.showIsRealWithRealExponentText(word);
1029

  
1030
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1031
			ShowText.showYes();
1032
		}
1033
		else {
1034
			ShowText.showNo();
1035
			fail();
1036
		}
1037
	}
1038
	
1039
	/**
1040
	 * A test
1041
	 */
1042
	public void test59() {
1043
		word = "8945.1201e+1";
1044
		ShowText.showIsRealWithRealExponentText(word);
1045

  
1046
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1047
			ShowText.showYes();
1048
		}
1049
		else {
1050
			ShowText.showNo();
1051
			fail();
1052
		}
1053
	}
1054
	
1055
	/**
1056
	 * A test
1057
	 */
1058
	public void test60() {
1059
		word = "8945.1201e+.32";
1060
		ShowText.showIsRealWithRealExponentText(word);
1061

  
1062
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1063
			ShowText.showYes();
1064
		}
1065
		else {
1066
			ShowText.showNo();
1067
			fail();
1068
		}
1069
	}
1070

  
1071
	/**
1072
	 * A test
1073
	 */
1074
	public void test61() {
1075
		word = "-";
1076
		ShowText.showIsIntegerText(word);
1077

  
1078
		if (StringNumberUtilities.isIntegerNumber(word)) {
1079
			ShowText.showYes();
1080
		}
1081
		else {
1082
			ShowText.showNo();
1083
			fail();
1084
		}
1085
	}
1086
	
1087
	/**
1088
	 * A test
1089
	 */
1090
	public void test62() {
1091
		word = "-";
1092
		ShowText.showIsNaturalText(word);
1093

  
1094
		if (StringNumberUtilities.isNaturalNumber(word)) {
1095
			ShowText.showYes();
1096
		}
1097
		else {
1098
			ShowText.showNo();
1099
			fail();
1100
		}
1101
	}
1102
	
1103
	/**
1104
	 * A test
1105
	 */
1106
	public void test63() {
1107
		word = "-";
1108
		ShowText.showIsNumberText(word);
1109

  
1110
		if (StringNumberUtilities.isNumber(word)) {
1111
			ShowText.showYes();
1112
		}
1113
		else {
1114
			ShowText.showNo();
1115
			fail();
1116
		}
1117
	}
1118
	
1119
	/**
1120
	 * A test
1121
	 */
1122
	public void test64() {
1123
		word = "-";
1124
		ShowText.showIsRealText(word);
1125

  
1126
		if (StringNumberUtilities.isRealNumber(word)) {
1127
			ShowText.showYes();
1128
		}
1129
		else {
1130
			ShowText.showNo();
1131
			fail();
1132
		}
1133
	}
1134
	
1135
	/**
1136
	 * A test
1137
	 */
1138
	public void test65() {
1139
		word = "-";
1140
		ShowText.showIsRealWithIntegerExponentText(word);
1141

  
1142
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
1143
			ShowText.showYes();
1144
		}
1145
		else {
1146
			ShowText.showNo();
1147
			fail();
1148
		}
1149
	}
1150
	
1151
	/**
1152
	 * A test
1153
	 */
1154
	public void test66() {
1155
		word = "-";
1156
		ShowText.showIsRealWithRealExponentText(word);
1157

  
1158
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1159
			ShowText.showYes();
1160
		}
1161
		else {
1162
			ShowText.showNo();
1163
			fail();
1164
		}
1165
	}
1166

  
1167
	/**
1168
	 * A test
1169
	 */
1170
	public void test67() {
1171
		word = "+";
1172
		ShowText.showIsIntegerText(word);
1173

  
1174
		if (StringNumberUtilities.isIntegerNumber(word)) {
1175
			ShowText.showYes();
1176
		}
1177
		else {
1178
			ShowText.showNo();
1179
			fail();
1180
		}
1181
	}
1182
	
1183
	/**
1184
	 * A test
1185
	 */
1186
	public void test68() {
1187
		word = "+";
1188
		ShowText.showIsNaturalText(word);
1189

  
1190
		if (StringNumberUtilities.isNaturalNumber(word)) {
1191
			ShowText.showYes();
1192
		}
1193
		else {
1194
			ShowText.showNo();
1195
			fail();
1196
		}
1197
	}
1198
	
1199
	/**
1200
	 * A test
1201
	 */
1202
	public void test69() {
1203
		word = "+";
1204
		ShowText.showIsNumberText(word);
1205

  
1206
		if (StringNumberUtilities.isNumber(word)) {
1207
			ShowText.showYes();
1208
		}
1209
		else {
1210
			ShowText.showNo();
1211
			fail();
1212
		}
1213
	}
1214
	
1215
	/**
1216
	 * A test
1217
	 */
1218
	public void test70() {
1219
		word = "+";
1220
		ShowText.showIsRealText(word);
1221

  
1222
		if (StringNumberUtilities.isRealNumber(word)) {
1223
			ShowText.showYes();
1224
		}
1225
		else {
1226
			ShowText.showNo();
1227
			fail();
1228
		}
1229
	}
1230
	
1231
	/**
1232
	 * A test
1233
	 */
1234
	public void test71() {
1235
		word = "+";
1236
		ShowText.showIsRealWithIntegerExponentText(word);
1237

  
1238
		if (StringNumberUtilities.isRealNumberWithIntegerExponent(word)) {
1239
			ShowText.showYes();
1240
		}
1241
		else {
1242
			ShowText.showNo();
1243
			fail();
1244
		}
1245
	}
1246
	
1247
	/**
1248
	 * A test
1249
	 */
1250
	public void test72() {
1251
		word = "+";
1252
		ShowText.showIsRealWithRealExponentText(word);
1253

  
1254
		if (StringNumberUtilities.isRealNumberWithRealExponent(word)) {
1255
			ShowText.showYes();
1256
		}
1257
		else {
1258
			ShowText.showNo();
1259
			fail();
1260
		}
1261
	}
1262

  
1263
	/**
1264
	 * Shows a text sentence
1265
	 * 
1266
	 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
1267
	 */
1268
	private static class ShowText {
1269
		/**
1270
		 * Shows the text: Is number?
1271
		 * 
1272
		 * @param word An String
1273
		 */
1274
		public static void showIsNumberText(String word) {
1275
			System.out.print("? Es n?mero \'" + word + "\' ? ");
1276
		}
1277

  
1278
		/**
1279
		 * Shows the text: Is natural number?
1280
		 * 
1281
		 * @param word An String
1282
		 */
1283
		public static void showIsNaturalText(String word) {
1284
			System.out.print("? Es n?mero natural \'" + word + "\' ? ");
1285
		}
1286

  
1287
		/**
1288
		 * Shows the text: Is integer number?
1289
		 * 
1290
		 * @param word An String
1291
		 */
1292
		public static void showIsIntegerText(String word) {
1293
			System.out.print("? Es n?mero entero \'" + word + "\' ? ");
1294
		}
1295

  
1296
		/**
1297
		 * Shows the text: Is rational number?
1298
		 * 
1299
		 * @param word An String
1300
		 */
1301
		public static void showIsRealText(String word) {
1302
			System.out.print("? Es n?mero real \'" + word + "\' ? ");
1303
		}
1304
		
1305
		/**
1306
		 * Shows the text: Is integer exponent rational number?
1307
		 * 
1308
		 * @param word An String
1309
		 */
1310
		public static void showIsRealWithIntegerExponentText(String word) {
1311
			System.out.print("? Es n?mero real con exponente entero \'" + word + "\' ? ");
1312
		}
1313
		
1314
		/**
1315
		 * Shows the text: Is rational exponent rational number?
1316
		 * 
1317
		 * @param word An String
1318
		 */
1319
		public static void showIsRealWithRealExponentText(String word) {
1320
			System.out.print("? Es n?mero real con exponente real \'" + word + "\' ? ");
1321
		}
1322

  
1323
		/**
1324
		 * Shows the text: Yes
1325
		 * 
1326
		 * @param word An String
1327
		 */
1328
		public static void showYes() {
1329
			System.out.println("Si.");
1330
		}
1331
		
1332
		/**
1333
		 * Shows the text: No
1334
		 * 
1335
		 * @param word An String
1336
		 */
1337
		public static void showNo() {
1338
			System.out.println("No.");
1339
		}
1340
	}
1341
}
0 1342

  
tags/org.gvsig.desktop-2.0.95/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/TestXMLEntity.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* CVS MESSAGES:
25
*
26
* $Id: TestXMLEntity.java 30754 2009-09-09 06:42:28Z cordinyana $
27
* $Log$
28
* Revision 1.7  2007-03-05 11:15:43  jaume
29
* *** empty log message ***
30
*
31
* Revision 1.6  2007/03/05 10:03:12  jaume
32
* *** empty log message ***
33
*
34
* Revision 1.5  2007/03/05 09:00:11  jaume
35
* *** empty log message ***
36
*
37
* Revision 1.4  2007/03/02 13:35:56  jaume
38
* *** empty log message ***
39
*
40
* Revision 1.3  2007/03/02 13:27:32  jaume
41
* *** empty log message ***
42
*
43
* Revision 1.2  2007/03/02 13:24:53  jaume
44
* *** empty log message ***
45
*
46
* Revision 1.1  2007/03/02 13:23:50  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.1  2006/08/29 06:18:17  jaume
50
* *** empty log message ***
51
*
52
*
53
*/
54
package org.gvsig.utils;
55

  
56
import java.io.File;
57
import java.io.FileReader;
58

  
59
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
60
import org.gvsig.utils.xmlEntity.generate.XmlTag;
61

  
62

  
63
public class TestXMLEntity extends AbstractLibraryAutoInitTestCase {
64
	private XMLEntity x1, x2, x3, x4;
65
	private XMLEntity gvp1;
66
	private XMLEntity gvp2;
67

  
68
	@Override
69
	protected void doSetUp() throws Exception {
70

  
71
		x1 = new XMLEntity();
72
		x2 = new XMLEntity();
73
		x3 = new XMLEntity();
74

  
75
		
76
		final Object obj1 = new XMLEntity();
77
		final Object obj2 = new XMLEntity();
78
		final Object obj3 = "StringClass";
79

  
80
		
81
		x1.putProperty("boolean1", false);
82
		x1.putProperty("boolean2", true);
83

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff