1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 package org.jomc.tools.test;
32
33 import java.io.File;
34 import java.io.FileNotFoundException;
35 import java.io.FileOutputStream;
36 import java.io.IOException;
37 import java.io.OutputStream;
38 import java.net.URL;
39 import java.text.ParseException;
40 import java.util.Calendar;
41 import java.util.Locale;
42 import java.util.Properties;
43 import java.util.logging.Level;
44 import org.apache.commons.io.FileUtils;
45 import org.jomc.model.Argument;
46 import org.jomc.model.Dependency;
47 import org.jomc.model.Implementation;
48 import org.jomc.model.JavaIdentifier;
49 import org.jomc.model.Message;
50 import org.jomc.model.ModelObject;
51 import org.jomc.model.Module;
52 import org.jomc.model.Modules;
53 import org.jomc.model.Property;
54 import org.jomc.model.Specification;
55 import org.jomc.model.SpecificationReference;
56 import org.jomc.model.Text;
57 import org.jomc.model.Texts;
58 import org.jomc.model.modlet.DefaultModelProvider;
59 import org.jomc.model.modlet.ModelHelper;
60 import org.jomc.modlet.Model;
61 import org.jomc.modlet.ModelContext;
62 import org.jomc.modlet.ModelContextFactory;
63 import org.jomc.modlet.ModelException;
64 import org.jomc.modlet.ModelValidationReport;
65 import org.jomc.tools.JomcTool;
66 import org.junit.Test;
67 import static org.junit.Assert.assertEquals;
68 import static org.junit.Assert.assertNotNull;
69 import static org.junit.Assert.assertNull;
70 import static org.junit.Assert.assertTrue;
71 import static org.junit.Assert.fail;
72
73
74
75
76
77
78
79 public class JomcToolTest
80 {
81
82
83
84
85 private static final String RESOURCE_ENCODING_PROPERTY_NAME = "jomc.test.resourceEncoding";
86
87
88
89
90 private static final String OUTPUT_DIRECTORY_PROPERTY_NAME = "jomc.test.outputDirectory";
91
92
93
94
95 private JomcTool jomcTool;
96
97
98
99
100 private ModelContext modelContext;
101
102
103
104
105 private Model model;
106
107
108
109
110 private String resourceEncoding;
111
112
113
114
115 private File outputDirectory;
116
117
118
119
120 private volatile int outputDirectoryId;
121
122
123
124
125 public JomcToolTest()
126 {
127 super();
128 }
129
130
131
132
133
134
135
136
137 public final String getResourceEncoding()
138 {
139 if ( this.resourceEncoding == null )
140 {
141 this.resourceEncoding = System.getProperty( RESOURCE_ENCODING_PROPERTY_NAME );
142 assertNotNull( "Expected '" + RESOURCE_ENCODING_PROPERTY_NAME + "' system property not found.",
143 this.resourceEncoding );
144
145 }
146
147 return this.resourceEncoding;
148 }
149
150
151
152
153
154
155
156
157 public final void setResourceEncoding( final String value )
158 {
159 this.resourceEncoding = value;
160 }
161
162
163
164
165
166
167
168
169 public final File getOutputDirectory()
170 {
171 if ( this.outputDirectory == null )
172 {
173 final String name = System.getProperty( OUTPUT_DIRECTORY_PROPERTY_NAME );
174 assertNotNull( "Expected '" + OUTPUT_DIRECTORY_PROPERTY_NAME + "' system property not found.", name );
175 this.outputDirectory = new File( new File( name ), this.getClass().getSimpleName() );
176 assertTrue( "Expected '" + OUTPUT_DIRECTORY_PROPERTY_NAME + "' system property to hold an absolute path.",
177 this.outputDirectory.isAbsolute() );
178
179 if ( !this.outputDirectory.exists() )
180 {
181 assertTrue( this.outputDirectory.mkdirs() );
182 }
183 }
184
185 return this.outputDirectory;
186 }
187
188
189
190
191
192
193
194
195 public final void setOutputDirectory( final File value )
196 {
197 if ( value != null )
198 {
199 assertTrue( "Expected absolute 'outputDirectory'.", value.isAbsolute() );
200 }
201
202 this.outputDirectory = value;
203 }
204
205
206
207
208
209
210 public final File getNextOutputDirectory()
211 {
212 try
213 {
214 final File nextOutputDirectory =
215 new File( this.getOutputDirectory(), Integer.toString( this.outputDirectoryId++ ) );
216
217 assertTrue( nextOutputDirectory.isAbsolute() );
218 if ( nextOutputDirectory.exists() )
219 {
220 FileUtils.deleteDirectory( nextOutputDirectory );
221 }
222
223 return nextOutputDirectory;
224 }
225 catch ( final IOException e )
226 {
227 throw new AssertionError( e );
228 }
229 }
230
231
232
233
234
235
236
237
238 public JomcTool getJomcTool()
239 {
240 if ( this.jomcTool == null )
241 {
242 this.jomcTool = this.newJomcTool();
243 this.jomcTool.setModel( this.getModel() );
244 this.jomcTool.getListeners().add( new JomcTool.Listener()
245 {
246
247 @Override
248 public void onLog( final Level level, final String message, final Throwable throwable )
249 {
250 super.onLog( level, message, throwable );
251 System.out.println( "[" + level.getLocalizedName() + "] " + message );
252
253 if ( throwable != null )
254 {
255 throwable.printStackTrace( System.out );
256 }
257 }
258
259 } );
260
261 }
262
263 return this.jomcTool;
264 }
265
266
267
268
269
270
271
272
273 protected JomcTool newJomcTool()
274 {
275 return new JomcTool();
276 }
277
278
279
280
281
282
283
284
285 public ModelContext getModelContext()
286 {
287 if ( this.modelContext == null )
288 {
289 this.modelContext = this.newModelContext();
290 this.modelContext.getListeners().add( new ModelContext.Listener()
291 {
292
293 @Override
294 public void onLog( final Level level, String message, Throwable t )
295 {
296 super.onLog( level, message, t );
297 System.out.println( "[" + level.getLocalizedName() + "] " + message );
298
299 if ( t != null )
300 {
301 t.printStackTrace( System.out );
302 }
303 }
304
305 } );
306
307 }
308
309 return this.modelContext;
310 }
311
312
313
314
315
316
317
318
319 protected ModelContext newModelContext()
320 {
321 return ModelContextFactory.newInstance().newModelContext();
322 }
323
324
325
326
327
328
329
330
331 public Model getModel()
332 {
333 if ( this.model == null )
334 {
335 this.model = this.newModel();
336 }
337
338 return this.model;
339 }
340
341
342
343
344
345
346
347
348 protected Model newModel()
349 {
350 try
351 {
352 DefaultModelProvider.setDefaultModuleLocation( this.getClass().getPackage().getName().replace( '.', '/' )
353 + "/jomc.xml" );
354
355 Model m = this.getModelContext().findModel( ModelObject.MODEL_PUBLIC_ID );
356
357 if ( m != null )
358 {
359 final Modules modules = ModelHelper.getModules( m );
360
361 if ( modules != null )
362 {
363 final Module cp = modules.getClasspathModule( Modules.getDefaultClasspathModuleName(),
364 this.getClass().getClassLoader() );
365
366 if ( cp != null )
367 {
368 modules.getModule().add( cp );
369 }
370 }
371
372 m = this.getModelContext().processModel( m );
373
374 if ( m != null )
375 {
376 final ModelValidationReport validationReport = this.getModelContext().validateModel( m );
377
378 for ( int i = 0, s0 = validationReport.getDetails().size(); i < s0; i++ )
379 {
380 System.out.println( validationReport.getDetails().get( i ) );
381 }
382
383 assertTrue( "Unexpected invalid '" + m.getIdentifier() + "' model.",
384 validationReport.isModelValid() );
385
386 }
387 }
388
389 return m;
390 }
391 catch ( final ModelException e )
392 {
393 throw new AssertionError( e );
394 }
395 finally
396 {
397 DefaultModelProvider.setDefaultModuleLocation( null );
398 }
399 }
400
401 @Test
402 @SuppressWarnings( "deprecation" )
403 public final void testJomcToolNullPointerException() throws Exception
404 {
405 assertNotNull( this.getJomcTool() );
406
407 try
408 {
409 this.getJomcTool().getDisplayLanguage( null );
410 fail( "Expected NullPointerException not thrown." );
411 }
412 catch ( final NullPointerException e )
413 {
414 assertNullPointerException( e );
415 }
416
417 try
418 {
419 this.getJomcTool().getImplementedJavaTypeNames( null, false );
420 fail( "Expected NullPointerException not thrown." );
421 }
422 catch ( final NullPointerException e )
423 {
424 assertNullPointerException( e );
425 }
426
427 try
428 {
429 this.getJomcTool().getJavaClasspathLocation( (Implementation) null );
430 fail( "Expected NullPointerException not thrown." );
431 }
432 catch ( final NullPointerException e )
433 {
434 assertNullPointerException( e );
435 }
436
437 try
438 {
439 this.getJomcTool().getJavaClasspathLocation( (Specification) null );
440 fail( "Expected NullPointerException not thrown." );
441 }
442 catch ( final NullPointerException e )
443 {
444 assertNullPointerException( e );
445 }
446
447 try
448 {
449 this.getJomcTool().getJavaGetterMethodName( (Dependency) null );
450 fail( "Expected NullPointerException not thrown." );
451 }
452 catch ( final NullPointerException e )
453 {
454 assertNullPointerException( e );
455 }
456
457 try
458 {
459 this.getJomcTool().getJavaGetterMethodName( (Message) null );
460 fail( "Expected NullPointerException not thrown." );
461 }
462 catch ( final NullPointerException e )
463 {
464 assertNullPointerException( e );
465 }
466
467 try
468 {
469 this.getJomcTool().getJavaGetterMethodName( (Property) null );
470 fail( "Expected NullPointerException not thrown." );
471 }
472 catch ( final NullPointerException e )
473 {
474 assertNullPointerException( e );
475 }
476
477 try
478 {
479 this.getJomcTool().getJavaMethodParameterName( (Argument) null );
480 fail( "Expected NullPointerException not thrown." );
481 }
482 catch ( final NullPointerException e )
483 {
484 assertNullPointerException( e );
485 }
486
487 try
488 {
489 this.getJomcTool().getJavaMethodParameterName( (Dependency) null );
490 fail( "Expected NullPointerException not thrown." );
491 }
492 catch ( final NullPointerException e )
493 {
494 assertNullPointerException( e );
495 }
496
497 try
498 {
499 this.getJomcTool().getJavaMethodParameterName( (Message) null );
500 fail( "Expected NullPointerException not thrown." );
501 }
502 catch ( final NullPointerException e )
503 {
504 assertNullPointerException( e );
505 }
506
507 try
508 {
509 this.getJomcTool().getJavaMethodParameterName( (Property) null );
510 fail( "Expected NullPointerException not thrown." );
511 }
512 catch ( final NullPointerException e )
513 {
514 assertNullPointerException( e );
515 }
516
517 try
518 {
519 this.getJomcTool().getJavaInterfaceNames( null, false );
520 fail( "Expected NullPointerException not thrown." );
521 }
522 catch ( final NullPointerException e )
523 {
524 assertNullPointerException( e );
525 }
526
527 try
528 {
529 this.getJomcTool().getJavaModifierName( null, (Dependency) null );
530 fail( "Expected NullPointerException not thrown." );
531 }
532 catch ( final NullPointerException e )
533 {
534 assertNullPointerException( e );
535 }
536 try
537 {
538 this.getJomcTool().getJavaModifierName( new Implementation(), (Dependency) null );
539 fail( "Expected NullPointerException not thrown." );
540 }
541 catch ( final NullPointerException e )
542 {
543 assertNullPointerException( e );
544 }
545
546 try
547 {
548 this.getJomcTool().getJavaModifierName( null, (Message) null );
549 fail( "Expected NullPointerException not thrown." );
550 }
551 catch ( final NullPointerException e )
552 {
553 assertNullPointerException( e );
554 }
555 try
556 {
557 this.getJomcTool().getJavaModifierName( new Implementation(), (Message) null );
558 fail( "Expected NullPointerException not thrown." );
559 }
560 catch ( final NullPointerException e )
561 {
562 assertNullPointerException( e );
563 }
564
565 try
566 {
567 this.getJomcTool().getJavaModifierName( null, (Property) null );
568 fail( "Expected NullPointerException not thrown." );
569 }
570 catch ( final NullPointerException e )
571 {
572 assertNullPointerException( e );
573 }
574 try
575 {
576 this.getJomcTool().getJavaModifierName( new Implementation(), (Property) null );
577 fail( "Expected NullPointerException not thrown." );
578 }
579 catch ( final NullPointerException e )
580 {
581 assertNullPointerException( e );
582 }
583
584 try
585 {
586 this.getJomcTool().getJavaPackageName( (Implementation) null );
587 fail( "Expected NullPointerException not thrown." );
588 }
589 catch ( final NullPointerException e )
590 {
591 assertNullPointerException( e );
592 }
593
594 try
595 {
596 this.getJomcTool().getJavaPackageName( (Specification) null );
597 fail( "Expected NullPointerException not thrown." );
598 }
599 catch ( final NullPointerException e )
600 {
601 assertNullPointerException( e );
602 }
603
604 try
605 {
606 this.getJomcTool().getJavaPackageName( (SpecificationReference) null );
607 fail( "Expected NullPointerException not thrown." );
608 }
609 catch ( final NullPointerException e )
610 {
611 assertNullPointerException( e );
612 }
613
614 try
615 {
616 this.getJomcTool().getJavaSetterMethodName( (Dependency) null );
617 fail( "Expected NullPointerException not thrown." );
618 }
619 catch ( final NullPointerException e )
620 {
621 assertNullPointerException( e );
622 }
623
624 try
625 {
626 this.getJomcTool().getJavaSetterMethodName( (Message) null );
627 fail( "Expected NullPointerException not thrown." );
628 }
629 catch ( final NullPointerException e )
630 {
631 assertNullPointerException( e );
632 }
633
634 try
635 {
636 this.getJomcTool().getJavaSetterMethodName( (Property) null );
637 fail( "Expected NullPointerException not thrown." );
638 }
639 catch ( final NullPointerException e )
640 {
641 assertNullPointerException( e );
642 }
643
644 try
645 {
646 this.getJomcTool().getJavaTypeName( (Argument) null );
647 fail( "Expected NullPointerException not thrown." );
648 }
649 catch ( final NullPointerException e )
650 {
651 assertNullPointerException( e );
652 }
653
654 try
655 {
656 this.getJomcTool().getJavaTypeName( (Dependency) null );
657 fail( "Expected NullPointerException not thrown." );
658 }
659 catch ( final NullPointerException e )
660 {
661 assertNullPointerException( e );
662 }
663
664 try
665 {
666 this.getJomcTool().getJavaTypeName( (Implementation) null, true );
667 fail( "Expected NullPointerException not thrown." );
668 }
669 catch ( final NullPointerException e )
670 {
671 assertNullPointerException( e );
672 }
673
674 try
675 {
676 this.getJomcTool().getJavaTypeName( (Property) null, true );
677 fail( "Expected NullPointerException not thrown." );
678 }
679 catch ( final NullPointerException e )
680 {
681 assertNullPointerException( e );
682 }
683
684 try
685 {
686 this.getJomcTool().getJavaTypeName( (Specification) null, true );
687 fail( "Expected NullPointerException not thrown." );
688 }
689 catch ( final NullPointerException e )
690 {
691 assertNullPointerException( e );
692 }
693
694 try
695 {
696 this.getJomcTool().getJavaTypeName( (SpecificationReference) null, true );
697 fail( "Expected NullPointerException not thrown." );
698 }
699 catch ( final NullPointerException e )
700 {
701 assertNullPointerException( e );
702 }
703
704 try
705 {
706 this.getJomcTool().getJavadocComment( (Text) null, 0, "\n" );
707 fail( "Expected NullPointerException not thrown." );
708 }
709 catch ( final NullPointerException e )
710 {
711 assertNullPointerException( e );
712 }
713 try
714 {
715 this.getJomcTool().getJavadocComment( new Text(), 0, null );
716 fail( "Expected NullPointerException not thrown." );
717 }
718 catch ( final NullPointerException e )
719 {
720 assertNullPointerException( e );
721 }
722 try
723 {
724 this.getJomcTool().getJavadocComment( new Text(), Integer.MIN_VALUE, "\n" );
725 fail( "Expected IllegalArgumentException not thrown." );
726 }
727 catch ( final IllegalArgumentException e )
728 {
729 assertIllegalArgumentException( e );
730 }
731
732 try
733 {
734 this.getJomcTool().getJavadocComment( (Texts) null, 0, "\n" );
735 fail( "Expected NullPointerException not thrown." );
736 }
737 catch ( final NullPointerException e )
738 {
739 assertNullPointerException( e );
740 }
741 try
742 {
743 this.getJomcTool().getJavadocComment( new Texts(), 0, null );
744 fail( "Expected NullPointerException not thrown." );
745 }
746 catch ( final NullPointerException e )
747 {
748 assertNullPointerException( e );
749 }
750 try
751 {
752 this.getJomcTool().getJavadocComment( new Texts(), Integer.MIN_VALUE, "\n" );
753 fail( "Expected IllegalArgumentException not thrown." );
754 }
755 catch ( final IllegalArgumentException e )
756 {
757 assertIllegalArgumentException( e );
758 }
759
760 try
761 {
762 this.getJomcTool().getLongDate( null );
763 fail( "Expected NullPointerException not thrown." );
764 }
765 catch ( final NullPointerException e )
766 {
767 assertNullPointerException( e );
768 }
769
770 try
771 {
772 this.getJomcTool().getLongDateTime( null );
773 fail( "Expected NullPointerException not thrown." );
774 }
775 catch ( final NullPointerException e )
776 {
777 assertNullPointerException( e );
778 }
779
780 try
781 {
782 this.getJomcTool().getLongTime( null );
783 fail( "Expected NullPointerException not thrown." );
784 }
785 catch ( final NullPointerException e )
786 {
787 assertNullPointerException( e );
788 }
789
790 try
791 {
792 this.getJomcTool().getMediumDate( null );
793 fail( "Expected NullPointerException not thrown." );
794 }
795 catch ( final NullPointerException e )
796 {
797 assertNullPointerException( e );
798 }
799
800 try
801 {
802 this.getJomcTool().getMediumDateTime( null );
803 fail( "Expected NullPointerException not thrown." );
804 }
805 catch ( final NullPointerException e )
806 {
807 assertNullPointerException( e );
808 }
809
810 try
811 {
812 this.getJomcTool().getMediumTime( null );
813 fail( "Expected NullPointerException not thrown." );
814 }
815 catch ( final NullPointerException e )
816 {
817 assertNullPointerException( e );
818 }
819
820 try
821 {
822 this.getJomcTool().getShortDate( null );
823 fail( "Expected NullPointerException not thrown." );
824 }
825 catch ( final NullPointerException e )
826 {
827 assertNullPointerException( e );
828 }
829
830 try
831 {
832 this.getJomcTool().getShortDateTime( null );
833 fail( "Expected NullPointerException not thrown." );
834 }
835 catch ( final NullPointerException e )
836 {
837 assertNullPointerException( e );
838 }
839
840 try
841 {
842 this.getJomcTool().getShortTime( null );
843 fail( "Expected NullPointerException not thrown." );
844 }
845 catch ( final NullPointerException e )
846 {
847 assertNullPointerException( e );
848 }
849
850 try
851 {
852 this.getJomcTool().getVelocityTemplate( null );
853 fail( "Expected NullPointerException not thrown." );
854 }
855 catch ( final NullPointerException e )
856 {
857 assertNullPointerException( e );
858 }
859
860 try
861 {
862 this.getJomcTool().getYears( null, Calendar.getInstance() );
863 fail( "Expected NullPointerException not thrown." );
864 }
865 catch ( final NullPointerException e )
866 {
867 assertNullPointerException( e );
868 }
869
870 try
871 {
872 this.getJomcTool().getYears( Calendar.getInstance(), null );
873 fail( "Expected NullPointerException not thrown." );
874 }
875 catch ( final NullPointerException e )
876 {
877 assertNullPointerException( e );
878 }
879
880 try
881 {
882 this.getJomcTool().isJavaDefaultPackage( (Implementation) null );
883 fail( "Expected NullPointerException not thrown." );
884 }
885 catch ( final NullPointerException e )
886 {
887 assertNullPointerException( e );
888 }
889
890 try
891 {
892 this.getJomcTool().isJavaDefaultPackage( (Specification) null );
893 fail( "Expected NullPointerException not thrown." );
894 }
895 catch ( final NullPointerException e )
896 {
897 assertNullPointerException( e );
898 }
899
900 try
901 {
902 this.getJomcTool().isJavaPrimitiveType( null );
903 fail( "Expected NullPointerException not thrown." );
904 }
905 catch ( final NullPointerException e )
906 {
907 assertNullPointerException( e );
908 }
909
910 try
911 {
912 this.getJomcTool().isLoggable( null );
913 fail( "Expected NullPointerException not thrown." );
914 }
915 catch ( final NullPointerException e )
916 {
917 assertNullPointerException( e );
918 }
919
920 try
921 {
922 this.getJomcTool().getIsoDate( null );
923 fail( "Expected NullPointerException not thrown." );
924 }
925 catch ( final NullPointerException e )
926 {
927 assertNullPointerException( e );
928 }
929
930 try
931 {
932 this.getJomcTool().getIsoTime( null );
933 fail( "Expected NullPointerException not thrown." );
934 }
935 catch ( final NullPointerException e )
936 {
937 assertNullPointerException( e );
938 }
939
940 try
941 {
942 this.getJomcTool().getIsoDateTime( null );
943 fail( "Expected NullPointerException not thrown." );
944 }
945 catch ( final NullPointerException e )
946 {
947 assertNullPointerException( e );
948 }
949
950 try
951 {
952 this.getJomcTool().getTemplateEncoding( null );
953 fail( "Expected NullPointerException not thrown." );
954 }
955 catch ( final NullPointerException e )
956 {
957 assertNullPointerException( e );
958 }
959
960 try
961 {
962 this.getJomcTool().getParentTemplateProfile( null );
963 fail( "Expected NullPointerException not thrown." );
964 }
965 catch ( final NullPointerException e )
966 {
967 assertNullPointerException( e );
968 }
969 }
970
971 @Test
972 @SuppressWarnings( "deprecation" )
973 public final void testJomcToolNotNull() throws Exception
974 {
975 final Specification specification = new Specification();
976 specification.setClazz( "java.lang.Object" );
977 specification.setIdentifier( "java.lang.Object" );
978
979 final Specification defaultPackageSpecification = new Specification();
980 defaultPackageSpecification.setClazz( "Object" );
981 defaultPackageSpecification.setIdentifier( "Object" );
982
983 final Implementation implementation = new Implementation();
984 implementation.setIdentifier( "java.lang.Object" );
985 implementation.setName( "java.lang.Object" );
986 implementation.setClazz( "java.lang.Object" );
987
988 final Implementation defaultPackageImplementation = new Implementation();
989 defaultPackageImplementation.setIdentifier( "Object" );
990 defaultPackageImplementation.setName( "Object" );
991 defaultPackageImplementation.setClazz( "Object" );
992
993 final Dependency d = new Dependency();
994 d.setIdentifier( "java.util.Locale" );
995 d.setName( "locale" );
996 d.setImplementationName( "default" );
997
998 final Property p = new Property();
999 p.setName( "property" );
1000 p.setValue( "Test" );
1001
1002 final Message m = new Message();
1003 m.setName( "message" );
1004
1005 final Calendar now = Calendar.getInstance();
1006 final Calendar nextYear = Calendar.getInstance();
1007 nextYear.set( Calendar.YEAR, nextYear.get( Calendar.YEAR ) + 1 );
1008
1009 assertNotNull( this.getJomcTool().getListeners() );
1010 assertNotNull( this.getJomcTool().getInputEncoding() );
1011 assertNotNull( this.getJomcTool().getModel() );
1012 assertNotNull( this.getJomcTool().getModules() );
1013 assertNotNull( this.getJomcTool().getOutputEncoding() );
1014 assertNotNull( this.getJomcTool().getTemplateProfile() );
1015 assertNotNull( this.getJomcTool().getTemplateEncoding() );
1016 assertNotNull( this.getJomcTool().getDefaultTemplateEncoding() );
1017 assertNotNull( this.getJomcTool().getTemplateParameters() );
1018 assertNotNull( this.getJomcTool().getIndentation() );
1019 assertNotNull( this.getJomcTool().getLineSeparator() );
1020 assertNotNull( this.getJomcTool().getVelocityContext() );
1021 assertNotNull( this.getJomcTool().getVelocityEngine() );
1022 assertNotNull( JomcTool.getDefaultLogLevel() );
1023 assertNotNull( this.getJomcTool().getLongDate( now ) );
1024 assertNotNull( this.getJomcTool().getLongDateTime( now ) );
1025 assertNotNull( this.getJomcTool().getLongTime( now ) );
1026 assertNotNull( this.getJomcTool().getMediumDate( now ) );
1027 assertNotNull( this.getJomcTool().getMediumDateTime( now ) );
1028 assertNotNull( this.getJomcTool().getMediumTime( now ) );
1029 assertNotNull( this.getJomcTool().getShortDate( now ) );
1030 assertNotNull( this.getJomcTool().getShortDateTime( now ) );
1031 assertNotNull( this.getJomcTool().getShortTime( now ) );
1032 assertNotNull( this.getJomcTool().getIsoDate( now ) );
1033 assertNotNull( this.getJomcTool().getIsoDateTime( now ) );
1034 assertNotNull( this.getJomcTool().getIsoTime( now ) );
1035 assertNotNull( this.getJomcTool().getYears( now, now ) );
1036 assertNotNull( this.getJomcTool().getYears( now, nextYear ) );
1037 assertNotNull( this.getJomcTool().getYears( nextYear, now ) );
1038 assertNotNull( this.getJomcTool().getDisplayLanguage( "en" ) );
1039
1040 assertEquals( this.getJomcTool().getYears( now, nextYear ), this.getJomcTool().getYears( nextYear, now ) );
1041 assertEquals( Locale.getDefault().getDisplayLanguage(),
1042 this.getJomcTool().getDisplayLanguage( Locale.getDefault().getLanguage() ) );
1043
1044 assertEquals( "java/lang/Object", this.getJomcTool().getJavaClasspathLocation( implementation ) );
1045 assertEquals( "Object", this.getJomcTool().getJavaClasspathLocation( defaultPackageImplementation ) );
1046 assertEquals( "java/lang/Object", this.getJomcTool().getJavaClasspathLocation( specification ) );
1047 assertEquals( "Object", this.getJomcTool().getJavaClasspathLocation( defaultPackageSpecification ) );
1048 assertEquals( "getLocale", this.getJomcTool().getJavaGetterMethodName( d ) );
1049 assertEquals( "getMessage", this.getJomcTool().getJavaGetterMethodName( m ) );
1050 assertEquals( "getProperty", this.getJomcTool().getJavaGetterMethodName( p ) );
1051 assertEquals( 0, this.getJomcTool().getJavaInterfaceNames( implementation, true ).size() );
1052 assertEquals( 0, this.getJomcTool().getImplementedJavaTypeNames( implementation, true ).size() );
1053 assertEquals( "private", this.getJomcTool().getJavaModifierName( implementation, d ) );
1054 assertEquals( "private", this.getJomcTool().getJavaModifierName( implementation, m ) );
1055 assertEquals( "private", this.getJomcTool().getJavaModifierName( implementation, p ) );
1056 assertEquals( "java.lang", this.getJomcTool().getJavaPackageName( implementation ) );
1057 assertEquals( "", this.getJomcTool().getJavaPackageName( defaultPackageImplementation ) );
1058 assertEquals( "java.lang", this.getJomcTool().getJavaPackageName( specification ) );
1059 assertEquals( "", this.getJomcTool().getJavaPackageName( defaultPackageSpecification ) );
1060 assertEquals( "java.util", this.getJomcTool().getJavaPackageName( d ) );
1061 assertEquals( "", this.getJomcTool().getJavaString( "" ) );
1062 assertEquals( this.getJomcTool().getIndentation(), this.getJomcTool().getIndentation( 1 ) );
1063 assertEquals( this.getJomcTool().getDefaultTemplateEncoding(),
1064 this.getJomcTool().getTemplateEncoding( "DOES_NOT_EXIST" ) );
1065
1066 assertEquals( this.getJomcTool().getDefaultTemplateProfile(),
1067 this.getJomcTool().getParentTemplateProfile( "DOES_NOT_EXIST" ) );
1068
1069 }
1070
1071 @Test
1072 public final void testVelocityTemplates() throws Exception
1073 {
1074 assertNotNull( this.getJomcTool().getVelocityTemplate( "Implementation.java.vm" ) );
1075 this.getJomcTool().setTemplateProfile( "DOES_NOT_EXIST" );
1076 assertNotNull( this.getJomcTool().getVelocityTemplate( "Implementation.java.vm" ) );
1077 this.getJomcTool().setTemplateProfile( null );
1078
1079 try
1080 {
1081 this.getJomcTool().getVelocityTemplate( "DOES_NOT_EXIST" );
1082 fail( "Expected FileNotFoundException not thrown." );
1083 }
1084 catch ( final FileNotFoundException e )
1085 {
1086 assertNotNull( e.getMessage() );
1087 System.out.println( e.toString() );
1088 }
1089
1090 try
1091 {
1092 this.getJomcTool().setTemplateProfile( "DOES_NOT_EXIST" );
1093 this.getJomcTool().getVelocityTemplate( "DOES_NOT_EXIST" );
1094 fail( "Expected FileNotFoundException not thrown." );
1095 }
1096 catch ( final FileNotFoundException e )
1097 {
1098 assertNotNull( e.getMessage() );
1099 System.out.println( e.toString() );
1100 }
1101 }
1102
1103 @Test
1104 public final void testDefaultLogLevel() throws Exception
1105 {
1106 final String testLogLevel = System.getProperty( "org.jomc.tools.JomcTool.defaultLogLevel" );
1107
1108 assertNotNull( JomcTool.getDefaultLogLevel() );
1109 JomcTool.setDefaultLogLevel( null );
1110 System.setProperty( "org.jomc.tools.JomcTool.defaultLogLevel", "OFF" );
1111 assertEquals( Level.OFF, JomcTool.getDefaultLogLevel() );
1112
1113 if ( testLogLevel != null )
1114 {
1115 System.setProperty( "org.jomc.tools.JomcTool.defaultLogLevel", testLogLevel );
1116 }
1117 else
1118 {
1119 System.clearProperty( "org.jomc.tools.JomcTool.defaultLogLevel" );
1120 }
1121
1122 JomcTool.setDefaultLogLevel( null );
1123 }
1124
1125 @Test
1126 public final void testLogLevel() throws Exception
1127 {
1128 JomcTool.setDefaultLogLevel( null );
1129 this.getJomcTool().setLogLevel( null );
1130 assertNotNull( this.getJomcTool().getLogLevel() );
1131
1132 JomcTool.setDefaultLogLevel( Level.OFF );
1133 this.getJomcTool().setLogLevel( null );
1134 assertEquals( Level.OFF, this.getJomcTool().getLogLevel() );
1135
1136 JomcTool.setDefaultLogLevel( null );
1137 this.getJomcTool().setLogLevel( null );
1138 }
1139
1140 @Test
1141 @SuppressWarnings( "deprecation" )
1142 public final void testDefaultTemplateProfile() throws Exception
1143 {
1144 assertNotNull( JomcTool.getDefaultTemplateProfile() );
1145 System.setProperty( "org.jomc.tools.JomcTool.defaultTemplateProfile", "TEST" );
1146 JomcTool.setDefaultTemplateProfile( null );
1147 assertEquals( "TEST", JomcTool.getDefaultTemplateProfile() );
1148 System.clearProperty( "org.jomc.tools.JomcTool.defaultTemplateProfile" );
1149 JomcTool.setDefaultTemplateProfile( null );
1150 }
1151
1152 @Test
1153 @SuppressWarnings( "deprecation" )
1154 public final void testTemplateProfile() throws Exception
1155 {
1156 JomcTool.setDefaultTemplateProfile( null );
1157 this.getJomcTool().setTemplateProfile( null );
1158 assertNotNull( this.getJomcTool().getTemplateProfile() );
1159
1160 JomcTool.setDefaultTemplateProfile( "TEST" );
1161 this.getJomcTool().setTemplateProfile( null );
1162 assertEquals( "TEST", this.getJomcTool().getTemplateProfile() );
1163
1164 JomcTool.setDefaultTemplateProfile( null );
1165 this.getJomcTool().setTemplateProfile( null );
1166 }
1167
1168 @Test
1169 public final void testIndentation() throws Exception
1170 {
1171 assertEquals( "", this.getJomcTool().getIndentation( 0 ) );
1172 assertEquals( this.getJomcTool().getIndentation(), this.getJomcTool().getIndentation( 1 ) );
1173
1174 try
1175 {
1176 this.getJomcTool().getIndentation( Integer.MIN_VALUE );
1177 fail( "Expected IllegalArgumentException not thrown." );
1178 }
1179 catch ( final IllegalArgumentException e )
1180 {
1181 assertIllegalArgumentException( e );
1182 }
1183
1184 this.getJomcTool().setIndentation( " TEST " );
1185 assertEquals( " TEST ", this.getJomcTool().getIndentation() );
1186 assertEquals( " TEST ", this.getJomcTool().getIndentation( 1 ) );
1187 this.getJomcTool().setIndentation( null );
1188 }
1189
1190 @Test
1191 public final void testModel() throws Exception
1192 {
1193 final Model m = this.getJomcTool().getModel();
1194 this.getJomcTool().setModel( null );
1195 assertNotNull( this.getJomcTool().getModel() );
1196 this.getJomcTool().setModel( m );
1197 }
1198
1199 @Test
1200 public final void testVelocityEngine() throws Exception
1201 {
1202 this.getJomcTool().setVelocityEngine( null );
1203 assertNotNull( this.getJomcTool().getVelocityEngine() );
1204 this.getJomcTool().setVelocityEngine( null );
1205 }
1206
1207 @Test
1208 public final void testVelocityContext() throws Exception
1209 {
1210 assertNotNull( this.getJomcTool().getVelocityContext() );
1211 this.getJomcTool().setTemplateProfile( "test" );
1212 assertNotNull( this.getJomcTool().getVelocityContext() );
1213 assertNotNull( this.getJomcTool().getVelocityContext().get( "test-object" ) );
1214 assertTrue( this.getJomcTool().getVelocityContext().get( "test-object" ) instanceof JomcTool );
1215 assertNotNull( this.getJomcTool().getVelocityContext().get( "test-url" ) );
1216 assertTrue( this.getJomcTool().getVelocityContext().get( "test-url" ) instanceof URL );
1217 assertEquals( new URL( "file:///tmp" ), this.getJomcTool().getVelocityContext().get( "test-url" ) );
1218 assertNotNull( this.getJomcTool().getVelocityContext().get( "test-string" ) );
1219 assertTrue( this.getJomcTool().getVelocityContext().get( "test-string" ) instanceof String );
1220 assertEquals( "Test", this.getJomcTool().getVelocityContext().get( "test-string" ) );
1221 this.getJomcTool().setTemplateProfile( null );
1222 }
1223
1224 @Test
1225 public final void testDefaultTemplateEncoding() throws Exception
1226 {
1227 this.getJomcTool().setDefaultTemplateEncoding( null );
1228 assertNotNull( this.getJomcTool().getDefaultTemplateEncoding() );
1229 this.getJomcTool().setDefaultTemplateEncoding( null );
1230 }
1231
1232 @Test
1233 public final void testTemplateEncoding() throws Exception
1234 {
1235 final File templateLocation = this.getNextOutputDirectory();
1236 File templatesDir = new File( templateLocation, "org" );
1237 templatesDir = new File( templatesDir, "jomc" );
1238 templatesDir = new File( templatesDir, "tools" );
1239 templatesDir = new File( templatesDir, "templates" );
1240 templatesDir = new File( templatesDir, "tmp" );
1241
1242 assertTrue( templatesDir.mkdirs() );
1243
1244 final Properties p = new Properties();
1245 p.setProperty( "template-encoding", "ISO-8859-1" );
1246
1247 final OutputStream profileProperties = new FileOutputStream( new File( templatesDir, "profile.properties" ) );
1248 p.store( profileProperties, this.getClass().getName() );
1249 profileProperties.close();
1250
1251 this.getJomcTool().setDefaultTemplateEncoding( null );
1252 this.getJomcTool().setTemplateLocation( templateLocation.toURI().toURL() );
1253
1254 assertEquals( "ISO-8859-1", this.getJomcTool().getTemplateEncoding( "tmp" ) );
1255 assertEquals( "US-ASCII", this.getJomcTool().getTemplateEncoding( "test" ) );
1256 assertEquals( this.getJomcTool().getDefaultTemplateEncoding(),
1257 this.getJomcTool().getTemplateEncoding( "jomc-java-bundles" ) );
1258
1259 this.getJomcTool().setTemplateLocation( null );
1260 this.getJomcTool().setDefaultTemplateEncoding( null );
1261 }
1262
1263 @Test
1264 public final void testInputEncoding() throws Exception
1265 {
1266 this.getJomcTool().setInputEncoding( null );
1267 assertNotNull( this.getJomcTool().getInputEncoding() );
1268 this.getJomcTool().setInputEncoding( null );
1269 }
1270
1271 @Test
1272 public final void testOutputEncoding() throws Exception
1273 {
1274 this.getJomcTool().setOutputEncoding( null );
1275 assertNotNull( this.getJomcTool().getOutputEncoding() );
1276 this.getJomcTool().setOutputEncoding( null );
1277 }
1278
1279 @Test
1280 public final void testLineSeparator() throws Exception
1281 {
1282 this.getJomcTool().setLineSeparator( null );
1283 assertNotNull( this.getJomcTool().getLineSeparator() );
1284 this.getJomcTool().setLineSeparator( null );
1285 }
1286
1287 @Test
1288 @SuppressWarnings( "deprecation" )
1289 public final void testJomcToolModelObjectsNotFound() throws Exception
1290 {
1291 final SpecificationReference ref = new SpecificationReference();
1292 ref.setIdentifier( "DOES_NOT_EXIST" );
1293
1294 final Implementation i = new Implementation();
1295 i.setIdentifier( "DOES_NOT_EXSIST" );
1296
1297 final Dependency d = new Dependency();
1298 d.setIdentifier( "DOES_NOT_EXIST" );
1299
1300 final Property p = new Property();
1301 p.setName( "DOES_NOT_EXIST" );
1302
1303 assertNull( this.getJomcTool().getJavaPackageName( ref ) );
1304 assertNull( this.getJomcTool().getJavaTypeName( ref, false ) );
1305 assertNull( this.getJomcTool().getJavaTypeName( d ) );
1306
1307 final Model oldModel = this.getJomcTool().getModel();
1308 this.getJomcTool().setModel( null );
1309 assertTrue( this.getJomcTool().getImplementedJavaTypeNames( i, true ).isEmpty() );
1310 assertEquals( "private", this.getJomcTool().getJavaModifierName( i, p ) );
1311 this.getJomcTool().setModel( oldModel );
1312 }
1313
1314 @Test
1315 @SuppressWarnings( "deprecation" )
1316 public final void testJavaIdentifier() throws Exception
1317 {
1318 assertEquals( "", this.getJomcTool().getJavaIdentifier( "", true ) );
1319 assertEquals( "", this.getJomcTool().getJavaIdentifier( "", false ) );
1320 assertEquals( "", this.getJomcTool().getJavaIdentifier( " ", true ) );
1321 assertEquals( "", this.getJomcTool().getJavaIdentifier( " ", false ) );
1322 assertEquals( "testTestTest", this.getJomcTool().getJavaIdentifier( " test test test ", false ) );
1323 assertEquals( "testTestTest", this.getJomcTool().getJavaIdentifier( " test test test ", false ) );
1324 assertEquals( "TestTestTest", this.getJomcTool().getJavaIdentifier( " test test test ", true ) );
1325 assertEquals( "TestTestTest", this.getJomcTool().getJavaIdentifier( " test test test ", true ) );
1326 assertEquals( "testTestTest", this.getJomcTool().getJavaIdentifier( " Test test test ", false ) );
1327 assertEquals( "testTestTest", this.getJomcTool().getJavaIdentifier( " Test test test ", false ) );
1328 assertEquals( "TestTestTest", this.getJomcTool().getJavaIdentifier( " test test test ", true ) );
1329 assertEquals( "TestTestTest", this.getJomcTool().getJavaIdentifier( " test test test ", true ) );
1330 }
1331
1332 @Test
1333 @SuppressWarnings( "deprecation" )
1334 public final void testJavaConstantName() throws Exception
1335 {
1336 assertEquals( "", this.getJomcTool().getJavaConstantName( "" ) );
1337 assertEquals( "", this.getJomcTool().getJavaConstantName( " " ) );
1338 assertEquals( "TEST_TEST_TEST", this.getJomcTool().getJavaConstantName( " test test test " ) );
1339 assertEquals( "TEST_TEST_TEST", this.getJomcTool().getJavaConstantName( " test test test " ) );
1340 assertEquals( "TEST_T_EST_TE_ST_TES_T",
1341 this.getJomcTool().getJavaConstantName( " Test tEst teSt tesT " ) );
1342
1343 }
1344
1345 @Test
1346 @SuppressWarnings( "deprecation" )
1347 public final void testJavaFieldName() throws Exception
1348 {
1349 assertEquals( "", this.getJomcTool().getJavaFieldName( "" ) );
1350 assertEquals( "", this.getJomcTool().getJavaFieldName( " " ) );
1351 assertEquals( "testTestTest", this.getJomcTool().getJavaFieldName( " test test test " ) );
1352 assertEquals( "testTestTest", this.getJomcTool().getJavaFieldName( " test test test " ) );
1353 assertEquals( "testTEstTeStTesT", this.getJomcTool().getJavaFieldName( " Test tEst teSt tesT " ) );
1354 assertEquals( "testTEstTeStTesT", this.getJomcTool().getJavaFieldName( " Test tEst teSt tesT " ) );
1355 assertEquals( "_package", this.getJomcTool().getJavaFieldName( " Package " ) );
1356 assertEquals( "_new", this.getJomcTool().getJavaFieldName( " New " ) );
1357 }
1358
1359 @Test
1360 @SuppressWarnings( "deprecation" )
1361 public final void testJavaMethodParameterName() throws Exception
1362 {
1363 assertEquals( "", this.getJomcTool().getJavaMethodParameterName( "" ) );
1364 assertEquals( "", this.getJomcTool().getJavaMethodParameterName( " " ) );
1365 assertEquals( "testTestTest", this.getJomcTool().getJavaMethodParameterName( " test test test " ) );
1366 assertEquals( "testTEstTeStTesT", this.getJomcTool().getJavaMethodParameterName( " Test tEst teSt tesT " ) );
1367 assertEquals( "testTEstTeStTesT",
1368 this.getJomcTool().getJavaMethodParameterName( " Test tEst teSt tesT " ) );
1369
1370 assertEquals( "_package", this.getJomcTool().getJavaMethodParameterName( " Package " ) );
1371 assertEquals( "_new", this.getJomcTool().getJavaMethodParameterName( " New " ) );
1372 }
1373
1374 @Test
1375 public final void testToJavaConstantName() throws Exception
1376 {
1377 try
1378 {
1379 this.getJomcTool().toJavaConstantName( "" );
1380 fail( "Expected 'ParseException' not thrown." );
1381 }
1382 catch ( final ParseException e )
1383 {
1384 System.out.println( e.toString() );
1385 assertNotNull( e.getMessage() );
1386 }
1387 try
1388 {
1389 this.getJomcTool().toJavaConstantName( " " );
1390 fail( "Expected 'ParseException' not thrown." );
1391 }
1392 catch ( final ParseException e )
1393 {
1394 System.out.println( e.toString() );
1395 assertNotNull( e.getMessage() );
1396 }
1397
1398 assertEquals( JavaIdentifier.valueOf( "TEST_TEST_TEST" ),
1399 this.getJomcTool().toJavaConstantName( " test test test " ) );
1400
1401 assertEquals( JavaIdentifier.valueOf( "TEST_TEST_TEST_TEST" ),
1402 this.getJomcTool().toJavaConstantName( " Test tEst teSt tesT " ) );
1403
1404 assertEquals( JavaIdentifier.valueOf( "TEST_TEST_TEST_TEST" ),
1405 this.getJomcTool().toJavaConstantName( " Test tEst teSt tesT " ) );
1406
1407 assertEquals( JavaIdentifier.valueOf( "PACKAGE" ), this.getJomcTool().toJavaConstantName( " Package " ) );
1408 assertEquals( JavaIdentifier.valueOf( "NEW" ), this.getJomcTool().toJavaConstantName( " New " ) );
1409 }
1410
1411 @Test
1412 public final void testToJavaMethodName() throws Exception
1413 {
1414 try
1415 {
1416 this.getJomcTool().toJavaMethodName( "" );
1417 fail( "Expected 'ParseException' not thrown." );
1418 }
1419 catch ( final ParseException e )
1420 {
1421 System.out.println( e.toString() );
1422 assertNotNull( e.getMessage() );
1423 }
1424 try
1425 {
1426 this.getJomcTool().toJavaMethodName( " " );
1427 fail( "Expected 'ParseException' not thrown." );
1428 }
1429 catch ( final ParseException e )
1430 {
1431 System.out.println( e.toString() );
1432 assertNotNull( e.getMessage() );
1433 }
1434
1435 assertEquals( JavaIdentifier.valueOf( "testTestTest" ),
1436 this.getJomcTool().toJavaMethodName( " test test test " ) );
1437
1438 assertEquals( JavaIdentifier.valueOf( "testTestTestTest" ),
1439 this.getJomcTool().toJavaMethodName( " Test tEst teSt tesT " ) );
1440
1441 assertEquals( JavaIdentifier.valueOf( "testTestTestTest" ),
1442 this.getJomcTool().toJavaMethodName( " Test tEst teSt tesT " ) );
1443
1444 assertEquals( JavaIdentifier.valueOf( "_package" ), this.getJomcTool().toJavaMethodName( " Package " ) );
1445 assertEquals( JavaIdentifier.valueOf( "_new" ), this.getJomcTool().toJavaMethodName( " New " ) );
1446 }
1447
1448 @Test
1449 public final void testToJavaVariableName() throws Exception
1450 {
1451 try
1452 {
1453 this.getJomcTool().toJavaVariableName( "" );
1454 fail( "Expected 'ParseException' not thrown." );
1455 }
1456 catch ( final ParseException e )
1457 {
1458 System.out.println( e.toString() );
1459 assertNotNull( e.getMessage() );
1460 }
1461 try
1462 {
1463 this.getJomcTool().toJavaVariableName( " " );
1464 fail( "Expected 'ParseException' not thrown." );
1465 }
1466 catch ( final ParseException e )
1467 {
1468 System.out.println( e.toString() );
1469 assertNotNull( e.getMessage() );
1470 }
1471
1472 assertEquals( JavaIdentifier.valueOf( "testTestTest" ),
1473 this.getJomcTool().toJavaVariableName( " test test test " ) );
1474
1475 assertEquals( JavaIdentifier.valueOf( "testTestTestTest" ),
1476 this.getJomcTool().toJavaVariableName( " Test tEst teSt tesT " ) );
1477
1478 assertEquals( JavaIdentifier.valueOf( "testTestTestTest" ),
1479 this.getJomcTool().toJavaVariableName( " Test tEst teSt tesT " ) );
1480
1481 assertEquals( JavaIdentifier.valueOf( "_package" ), this.getJomcTool().toJavaVariableName( " Package " ) );
1482 assertEquals( JavaIdentifier.valueOf( "_new" ), this.getJomcTool().toJavaVariableName( " New " ) );
1483 }
1484
1485 @Test
1486 @SuppressWarnings( "deprecation" )
1487 public final void testParentTemplateProfile() throws Exception
1488 {
1489 final File templateLocation = this.getNextOutputDirectory();
1490 File templatesDir = new File( templateLocation, "org" );
1491 templatesDir = new File( templatesDir, "jomc" );
1492 templatesDir = new File( templatesDir, "tools" );
1493 templatesDir = new File( templatesDir, "templates" );
1494 templatesDir = new File( templatesDir, "tmp" );
1495
1496 assertTrue( templatesDir.mkdirs() );
1497
1498 final Properties p = new Properties();
1499 p.setProperty( "parent-template-profile", "test" );
1500
1501 final OutputStream profileProperties = new FileOutputStream( new File( templatesDir, "profile.properties" ) );
1502 p.store( profileProperties, this.getClass().getName() );
1503 profileProperties.close();
1504
1505 this.getJomcTool().setDefaultTemplateProfile( null );
1506 this.getJomcTool().setTemplateLocation( templateLocation.toURI().toURL() );
1507
1508 assertEquals( "test", this.getJomcTool().getParentTemplateProfile( "tmp" ) );
1509 assertEquals( "jomc-java-bundles", this.getJomcTool().getParentTemplateProfile( "test" ) );
1510 assertEquals( this.getJomcTool().getDefaultTemplateProfile(),
1511 this.getJomcTool().getParentTemplateProfile( "jomc-java-bundles" ) );
1512
1513 assertNull( this.getJomcTool().getParentTemplateProfile( this.getJomcTool().getDefaultTemplateProfile() ) );
1514 this.getJomcTool().setTemplateLocation( null );
1515 this.getJomcTool().setDefaultTemplateEncoding( null );
1516 }
1517
1518 @Test
1519 public final void testHtmlString() throws Exception
1520 {
1521 assertEquals( "<>"∗&", this.getJomcTool().getHtmlString( "<>\"*&" ) );
1522 }
1523
1524 public static void assertNullPointerException( final NullPointerException e )
1525 {
1526 assertNotNull( e );
1527 assertNotNull( e.getMessage() );
1528 System.out.println( e.toString() );
1529 }
1530
1531 public static void assertIllegalArgumentException( final IllegalArgumentException e )
1532 {
1533 assertNotNull( e );
1534 assertNotNull( e.getMessage() );
1535 System.out.println( e.toString() );
1536 }
1537
1538 }