1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package ru.akman.maven.plugins.jlink;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertFalse;
21 import static org.junit.Assert.assertNotNull;
22 import static org.junit.Assert.assertTrue;
23 import static org.junit.Assert.fail;
24
25 import java.io.File;
26 import java.io.IOException;
27 import java.util.Arrays;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.stream.Collectors;
31 import org.apache.maven.execution.MavenSession;
32 import org.apache.maven.plugin.MojoExecution;
33 import org.apache.maven.plugin.testing.MojoRule;
34 import org.apache.maven.project.MavenProject;
35 import org.apache.maven.shared.model.fileset.FileSet;
36 import org.apache.maven.toolchain.ToolchainManager;
37 import org.codehaus.plexus.PlexusContainer;
38 import org.junit.Rule;
39 import org.junit.Test;
40 import ru.akman.maven.plugins.TestUtils;
41
42
43
44
45 public class JlinkMojoTest {
46
47
48
49
50 private static final String PROJECT_DIR = "target/test-classes/project/";
51
52
53
54
55 private static final String MOJO_EXECUTION = "jlink";
56
57
58
59
60 private PlexusContainer container;
61
62
63
64
65 private ToolchainManager toolchainManager;
66
67
68
69
70 private MavenProject project;
71
72
73
74
75 private MavenSession session;
76
77
78
79
80 private MojoExecution execution;
81
82
83
84
85 private JlinkMojo mojo;
86
87
88
89
90
91 @Rule
92 public MojoRule rule = new MojoRule() {
93
94 @Override
95 protected void before() throws Throwable {
96
97 container = getContainer();
98 assertNotNull("Has access to the plexus container", container);
99
100 toolchainManager = (ToolchainManager) container.lookup(
101 ToolchainManager.class.getName());
102 assertNotNull("Can get the toolchain manager", toolchainManager);
103
104 final File pom = new File(PROJECT_DIR);
105 assertNotNull("Project directory path is valid", pom);
106 assertTrue("Project directory exists", pom.exists());
107
108 project = readMavenProject(pom);
109 assertNotNull("Can read the project", project);
110
111 session = newMavenSession(project);
112 assertNotNull("Can create new session", session);
113
114 execution = newMojoExecution(MOJO_EXECUTION);
115 assertNotNull("Can create new execution", execution);
116
117 mojo = (JlinkMojo) lookupConfiguredMojo(session, execution);
118 assertNotNull("Can lookup configured mojo", mojo);
119 }
120
121 @Override
122 protected void after() {
123
124 }
125
126 };
127
128
129
130
131
132
133 @Test
134 public void testMojoHasToolHome() throws Exception {
135 final File toolhome =
136 (File) rule.getVariableValueFromObject(mojo, "toolhome");
137 assertEquals("toolhome",
138 TestUtils.getCanonicalPath(toolhome),
139 TestUtils.getCanonicalPath(new File(project.getBasedir(),
140 "path/to/jlink/home"))
141 );
142 }
143
144
145
146
147
148
149 @Test
150 public void testMojoHasModsDir() throws Exception {
151 final File modsdir =
152 (File) rule.getVariableValueFromObject(mojo, "modsdir");
153 assertEquals("modsdir",
154 TestUtils.getCanonicalPath(modsdir),
155 TestUtils.getCanonicalPath(new File(project.getBuild().getDirectory(),
156 "jlink/mods"))
157 );
158 }
159
160
161
162
163
164
165 @Test
166 public void testMojoHasLibsDir() throws Exception {
167 final File libsdir =
168 (File) rule.getVariableValueFromObject(mojo, "libsdir");
169 assertEquals("libsdir",
170 TestUtils.getCanonicalPath(libsdir),
171 TestUtils.getCanonicalPath(new File(project.getBuild().getDirectory(),
172 "jlink/libs"))
173 );
174 }
175
176
177
178
179
180
181 @Test
182 public void testMojoHasModulePath() throws Exception {
183 final ModulePath modulepath =
184 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
185 assertNotNull("modulepath",
186 modulepath);
187 }
188
189
190
191
192
193
194 @Test
195 public void testMojoHasPathElements() throws Exception {
196 final ModulePath modulepath =
197 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
198 final List<File> pathelements = modulepath.getPathElements();
199 assertEquals("modulepath/pathelements",
200 TestUtils.buildPathFromFiles(pathelements),
201 TestUtils.buildPathFromNames(PROJECT_DIR, Arrays.asList(
202 "mod.jar",
203 "mod.jmod",
204 "mods/exploded/mod"
205 ))
206 );
207 }
208
209
210
211
212
213
214 @Test
215 public void testMojoHasFilesets() throws Exception {
216 final ModulePath modulepath =
217 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
218 final List<FileSet> filesets = modulepath.getFileSets();
219 assertEquals("modulepath/filesets",
220 filesets.size(), 1);
221 }
222
223
224
225
226
227
228
229 @Test
230 public void testMojoHasFilesetFollowSymlinks() throws Exception {
231 final ModulePath modulepath =
232 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
233 final List<FileSet> filesets = modulepath.getFileSets();
234 final FileSet fileset = filesets.get(0);
235 assertFalse("modulepath/filesets/fileset/isfollowsymlinks",
236 fileset.isFollowSymlinks());
237 }
238
239
240
241
242
243
244 @Test
245 public void testMojoHasFilesetIncludes() throws Exception {
246 final ModulePath modulepath =
247 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
248 final List<FileSet> filesets = modulepath.getFileSets();
249 final FileSet fileset = filesets.get(0);
250 assertEquals("modulepath/filesets/fileset/includes",
251 TestUtils.buildStringFromNames(fileset.getIncludes()),
252 TestUtils.buildStringFromNames(Arrays.asList("**/*"))
253 );
254 }
255
256
257
258
259
260
261 @Test
262 public void testMojoHasFilesetExcludes() throws Exception {
263 final ModulePath modulepath =
264 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
265 final List<FileSet> filesets = modulepath.getFileSets();
266 final FileSet fileset = filesets.get(0);
267 assertEquals("modulepath/filesets/fileset/excludes",
268 TestUtils.buildStringFromNames(fileset.getExcludes()),
269 TestUtils.buildStringFromNames(Arrays.asList(
270 "**/*Empty.jar",
271 "jlink.opts",
272 "jlink-opts"
273 ))
274 );
275 }
276
277
278
279
280
281
282 @Test
283 public void testMojoHasFilesetDirectory() throws Exception {
284 final ModulePath modulepath =
285 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
286 final List<FileSet> filesets = modulepath.getFileSets();
287 final FileSet fileset = filesets.get(0);
288 try {
289 PluginUtils.normalizeFileSetBaseDir(project.getBasedir(), fileset);
290 } catch (IOException ex) {
291 fail("Error: Unable to resolve fileset base directory: ["
292 + project.getBasedir() + "]."
293 + System.lineSeparator()
294 + ex.toString()
295 );
296 }
297 assertEquals("modulepath/filesets/fileset/directory",
298 TestUtils.getCanonicalPath(new File(fileset.getDirectory())),
299 TestUtils.getCanonicalPath(new File(project.getBuild().getDirectory()))
300 );
301 }
302
303
304
305
306
307
308 @Test
309 public void testMojoHasDirsets() throws Exception {
310 final ModulePath modulepath =
311 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
312 final List<FileSet> dirsets = modulepath.getDirSets();
313 assertEquals("modulepath/dirsets",
314 dirsets.size(), 1);
315 }
316
317
318
319
320
321
322
323 @Test
324 public void testMojoHasDirsetFollowSymlinks() throws Exception {
325 final ModulePath modulepath =
326 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
327 final List<FileSet> dirsets = modulepath.getDirSets();
328 final FileSet dirset = dirsets.get(0);
329 assertTrue("modulepath/dirsets/dirset/isfollowsymlinks",
330 dirset.isFollowSymlinks());
331 }
332
333
334
335
336
337
338 @Test
339 public void testMojoHasDirsetIncludes() throws Exception {
340 final ModulePath modulepath =
341 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
342 final List<FileSet> dirsets = modulepath.getDirSets();
343 final FileSet dirset = dirsets.get(0);
344 assertEquals("modulepath/dirsets/dirset/includes",
345 TestUtils.buildStringFromNames(dirset.getIncludes()),
346 TestUtils.buildStringFromNames(Arrays.asList("**/*"))
347 );
348 }
349
350
351
352
353
354
355 @Test
356 public void testMojoHasDirsetExcludes() throws Exception {
357 final ModulePath modulepath =
358 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
359 final List<FileSet> dirsets = modulepath.getDirSets();
360 final FileSet dirset = dirsets.get(0);
361 assertEquals("modulepath/dirsets/dirset/excludes",
362 TestUtils.buildStringFromNames(dirset.getExcludes()),
363 TestUtils.buildStringFromNames(Arrays.asList("**/*Test"))
364 );
365 }
366
367
368
369
370
371
372 @Test
373 public void testMojoHasDirsetDirectory() throws Exception {
374 final ModulePath modulepath =
375 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
376 final List<FileSet> dirsets = modulepath.getDirSets();
377 final FileSet dirset = dirsets.get(0);
378 try {
379 PluginUtils.normalizeFileSetBaseDir(project.getBasedir(), dirset);
380 } catch (IOException ex) {
381 fail("Error: Unable to resolve fileset base directory: ["
382 + project.getBasedir() + "]."
383 + System.lineSeparator()
384 + ex.toString()
385 );
386 }
387 assertEquals("modulepath/dirsets/dirset/directory",
388 TestUtils.getCanonicalPath(new File(dirset.getDirectory())),
389 TestUtils.getCanonicalPath(new File(project.getBuild().getDirectory()))
390 );
391 }
392
393
394
395
396
397
398 @Test
399 public void testMojoHasDependencysets() throws Exception {
400 final ModulePath modulepath =
401 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
402 final List<DependencySet> dependencysets = modulepath.getDependencySets();
403 assertEquals("modulepath/dependencysets",
404 dependencysets.size(), 1);
405 }
406
407
408
409
410
411
412
413 @Test
414 public void testMojoHasDependencysetOutputIncluded() throws Exception {
415 final ModulePath modulepath =
416 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
417 final List<DependencySet> dependencysets = modulepath.getDependencySets();
418 final DependencySet depset = dependencysets.get(0);
419 assertFalse("modulepath/dependencysets/dependencyset/outputincluded",
420 depset.isOutputIncluded());
421 }
422
423
424
425
426
427
428
429 @Test
430 public void testMojoHasDependencysetAutomaticExcluded() throws Exception {
431 final ModulePath modulepath =
432 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
433 final List<DependencySet> dependencysets = modulepath.getDependencySets();
434 final DependencySet depset = dependencysets.get(0);
435 assertFalse("modulepath/dependencysets/dependencyset/automaticexcluded",
436 depset.isAutomaticExcluded());
437 }
438
439
440
441
442
443
444
445 @Test
446 public void testMojoHasDependencysetIncludes() throws Exception {
447 final ModulePath modulepath =
448 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
449 final List<DependencySet> dependencysets = modulepath.getDependencySets();
450 final DependencySet depset = dependencysets.get(0);
451 assertEquals("modulepath/dependencysets/dependencyset/includes",
452 TestUtils.buildStringFromNames(depset.getIncludes()),
453 TestUtils.buildStringFromNames(Arrays.asList(
454 "glob:**/*.jar",
455 "regex:foo-(bar|baz)-.*?\\.jar"
456 ))
457 );
458 }
459
460
461
462
463
464
465
466 @Test
467 public void testMojoHasDependencysetExcludes() throws Exception {
468 final ModulePath modulepath =
469 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
470 final List<DependencySet> dependencysets = modulepath.getDependencySets();
471 final DependencySet depset = dependencysets.get(0);
472 assertEquals("modulepath/dependencysets/dependencyset/excludes",
473 TestUtils.buildStringFromNames(depset.getExcludes()),
474 TestUtils.buildStringFromNames(Arrays.asList("glob:**/javafx.*Empty"))
475 );
476 }
477
478
479
480
481
482
483
484 @Test
485 public void testMojoHasDependencysetIncludeNames() throws Exception {
486 final ModulePath modulepath =
487 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
488 final List<DependencySet> dependencysets = modulepath.getDependencySets();
489 final DependencySet depset = dependencysets.get(0);
490 assertEquals("modulepath/dependencysets/dependencyset/includenames",
491 TestUtils.buildStringFromNames(depset.getIncludeNames()),
492 TestUtils.buildStringFromNames(Arrays.asList(".*"))
493 );
494 }
495
496
497
498
499
500
501
502 @Test
503 public void testMojoHasDependencysetExcludeNames() throws Exception {
504 final ModulePath modulepath =
505 (ModulePath) rule.getVariableValueFromObject(mojo, "modulepath");
506 final List<DependencySet> dependencysets = modulepath.getDependencySets();
507 final DependencySet depset = dependencysets.get(0);
508 assertEquals("modulepath/dependencysets/dependencyset/excludenames",
509 TestUtils.buildStringFromNames(depset.getExcludeNames()),
510 TestUtils.buildStringFromNames(Arrays.asList("javafx\\..+Empty"))
511 );
512 }
513
514
515
516
517
518
519 @Test
520 @SuppressWarnings("unchecked")
521 public void testMojoHasAddModules() throws Exception {
522 final List<String> addmodules =
523 (List<String>) rule.getVariableValueFromObject(mojo, "addmodules");
524 assertEquals("addmodules",
525 TestUtils.buildStringFromNames(addmodules),
526 TestUtils.buildStringFromNames(Arrays.asList(
527 "java.base", "org.example.rootmodule"))
528 );
529 }
530
531
532
533
534
535
536 @Test
537 public void testMojoHasOutput() throws Exception {
538 final File output =
539 (File) rule.getVariableValueFromObject(mojo, "output");
540 assertEquals("output",
541 TestUtils.getCanonicalPath(output),
542 TestUtils.getCanonicalPath(new File(project.getBuild().getDirectory(),
543 "jlink/image"))
544 );
545 }
546
547
548
549
550
551
552 @Test
553 @SuppressWarnings("unchecked")
554 public void testMojoHasLimitModules() throws Exception {
555 final List<String> limitmodules =
556 (List<String>) rule.getVariableValueFromObject(mojo, "limitmodules");
557 assertEquals("limitmodules",
558 TestUtils.buildStringFromNames(limitmodules),
559 TestUtils.buildStringFromNames(Arrays.asList(
560 "java.base", "org.example.limitmodule"))
561 );
562 }
563
564
565
566
567
568
569 @Test
570 @SuppressWarnings("unchecked")
571 public void testMojoHasSuggestProviders() throws Exception {
572 final List<String> suggestproviders =
573 (List<String>) rule.getVariableValueFromObject(mojo,
574 "suggestproviders");
575 assertEquals("suggestproviders",
576 TestUtils.buildStringFromNames(suggestproviders),
577 TestUtils.buildStringFromNames(Arrays.asList(
578 "provider.name"))
579 );
580 }
581
582
583
584
585
586
587 @Test
588 public void testMojoHasSaveOpts() throws Exception {
589 final File saveopts =
590 (File) rule.getVariableValueFromObject(mojo, "saveopts");
591 assertEquals("saveopts",
592 TestUtils.getCanonicalPath(saveopts),
593 TestUtils.getCanonicalPath(new File(project.getBuild().getDirectory(),
594 "jlink-opts"))
595 );
596 }
597
598
599
600
601
602
603 @Test
604 public void testMojoHasResourcesLastSorter() throws Exception {
605 final String resourceslastsorter =
606 (String) rule.getVariableValueFromObject(mojo, "resourceslastsorter");
607 assertEquals("resourceslastsorter",
608 resourceslastsorter,
609 "resource-sorter-name"
610 );
611 }
612
613
614
615
616
617
618 @Test
619 public void testMojoHasPostProcessPath() throws Exception {
620 final File postprocesspath =
621 (File) rule.getVariableValueFromObject(mojo, "postprocesspath");
622 assertEquals("postprocesspath",
623 TestUtils.getCanonicalPath(postprocesspath),
624 TestUtils.getCanonicalPath(new File(project.getBuild().getDirectory(),
625 "imagefile"))
626 );
627 }
628
629
630
631
632
633
634 @Test
635 public void testMojoHasVerbose() throws Exception {
636 final boolean verbose =
637 (boolean) rule.getVariableValueFromObject(mojo, "verbose");
638 assertTrue("verbose",
639 verbose);
640 }
641
642
643
644
645
646
647 @Test
648 public void testMojoHasBindServices() throws Exception {
649 final boolean bindservices =
650 (boolean) rule.getVariableValueFromObject(mojo, "bindservices");
651 assertTrue("bindservices",
652 bindservices);
653 }
654
655
656
657
658
659
660 @Test
661 public void testMojoHasLauncher() throws Exception {
662 final Launcher launcher =
663 (Launcher) rule.getVariableValueFromObject(mojo, "launcher");
664 assertNotNull("launcher",
665 launcher);
666 }
667
668
669
670
671
672
673 @Test
674 public void testMojoHasLauncherCommand() throws Exception {
675 final Launcher launcher =
676 (Launcher) rule.getVariableValueFromObject(mojo, "launcher");
677 assertEquals("launcher/command",
678 launcher.getCommand(),
679 "myLauncher"
680 );
681 }
682
683
684
685
686
687
688 @Test
689 public void testMojoHasLauncherMainModule() throws Exception {
690 final Launcher launcher =
691 (Launcher) rule.getVariableValueFromObject(mojo, "launcher");
692 assertEquals("launcher/mainmodule",
693 launcher.getMainModule(),
694 "mainModule"
695 );
696 }
697
698
699
700
701
702
703
704 @Test
705 public void testMojoHasLauncherMainClass() throws Exception {
706 final Launcher launcher =
707 (Launcher) rule.getVariableValueFromObject(mojo, "launcher");
708 assertEquals("launcher/mainclass",
709 launcher.getMainClass(),
710 "mainClass"
711 );
712 }
713
714
715
716
717
718
719 @Test
720 public void testMojoHasLauncherJvmArgs() throws Exception {
721 final Launcher launcher =
722 (Launcher) rule.getVariableValueFromObject(mojo, "launcher");
723 assertEquals("launcher/jvmargs",
724 launcher.getJvmArgs(),
725 "-Dfile.encoding=UTF-8 -Xms256m -Xmx512m"
726 );
727 }
728
729
730
731
732
733
734 @Test
735 public void testMojoHasLauncherArgs() throws Exception {
736 final Launcher launcher =
737 (Launcher) rule.getVariableValueFromObject(mojo, "launcher");
738 assertEquals("launcher/args",
739 launcher.getArgs(),
740 "--debug"
741 );
742 }
743
744
745
746
747
748
749 @Test
750 public void testMojoHasLauncherNixTemplate() throws Exception {
751 final Launcher launcher =
752 (Launcher) rule.getVariableValueFromObject(mojo, "launcher");
753 final File nixtemplate = launcher.getNixTemplate();
754 assertEquals("launcher/nixtemplate",
755 TestUtils.getCanonicalPath(nixtemplate),
756 TestUtils.getCanonicalPath(new File(project.getBasedir(),
757 "config/jlink/nix.template"))
758 );
759 }
760
761
762
763
764
765
766 @Test
767 public void testMojoHasLauncherWinTemplate() throws Exception {
768 final Launcher launcher =
769 (Launcher) rule.getVariableValueFromObject(mojo, "launcher");
770 final File wintemplate = launcher.getWinTemplate();
771 assertEquals("launcher/wintemplate",
772 TestUtils.getCanonicalPath(wintemplate),
773 TestUtils.getCanonicalPath(new File(project.getBasedir(),
774 "config/jlink/win.template"))
775 );
776 }
777
778
779
780
781
782
783 @Test
784 public void testMojoHasNoHeaderFiles() throws Exception {
785 final boolean noheaderfiles =
786 (boolean) rule.getVariableValueFromObject(mojo, "noheaderfiles");
787 assertTrue("noheaderfiles",
788 noheaderfiles);
789 }
790
791
792
793
794
795
796 @Test
797 public void testMojoHasNoManPages() throws Exception {
798 final boolean nomanpages =
799 (boolean) rule.getVariableValueFromObject(mojo, "nomanpages");
800 assertTrue("nomanpages",
801 nomanpages);
802 }
803
804
805
806
807
808
809 @Test
810 public void testMojoHasEndian() throws Exception {
811 final Endian endian =
812 (Endian) rule.getVariableValueFromObject(mojo, "endian");
813 assertEquals("endian",
814 endian,
815 Endian.LITTLE
816 );
817 }
818
819
820
821
822
823
824 @Test
825 public void testMojoHasIgnoreSigningInformation() throws Exception {
826 final boolean ignoresigninginformation =
827 (boolean) rule.getVariableValueFromObject(mojo,
828 "ignoresigninginformation");
829 assertTrue("ignoresigninginformation",
830 ignoresigninginformation);
831 }
832
833
834
835
836
837
838 @Test
839 @SuppressWarnings("unchecked")
840 public void testMojoHasDisablePlugins() throws Exception {
841 final List<String> disableplugins =
842 (List<String>) rule.getVariableValueFromObject(mojo, "disableplugins");
843 assertEquals("disableplugins",
844 TestUtils.buildStringFromNames(disableplugins),
845 TestUtils.buildStringFromNames(Arrays.asList(
846 "compress", "dedup-legal-notices"))
847 );
848 }
849
850
851
852
853
854
855 @Test
856 public void testMojoHasCompress() throws Exception {
857 final Compress compress =
858 (Compress) rule.getVariableValueFromObject(mojo, "compress");
859 assertNotNull("compress",
860 compress);
861 }
862
863
864
865
866
867
868 @Test
869 public void testMojoHasCompressCompression() throws Exception {
870 final Compress compress =
871 (Compress) rule.getVariableValueFromObject(mojo, "compress");
872 final Compression compression = compress.getCompression();
873 assertEquals("compress/compression",
874 compression,
875 Compression.ZIP
876 );
877 }
878
879
880
881
882
883
884 @Test
885 public void testMojoHasCompressFilters() throws Exception {
886 final Compress compress =
887 (Compress) rule.getVariableValueFromObject(mojo, "compress");
888 final List<String> filters = compress.getFilters();
889 assertEquals("compress/filters",
890 TestUtils.buildStringFromNames(filters),
891 TestUtils.buildStringFromNames(Arrays.asList(
892 "**/*-info.class",
893 "glob:**/module-info.class",
894 "regex:/java[a-z]+$",
895 "@filename"
896 ))
897 );
898 }
899
900
901
902
903
904
905 @Test
906 @SuppressWarnings("unchecked")
907 public void testMojoHasIncludeLocales() throws Exception {
908 final List<String> includelocales =
909 (List<String>) rule.getVariableValueFromObject(mojo, "includelocales");
910 assertEquals("includelocales",
911 TestUtils.buildStringFromNames(includelocales),
912 TestUtils.buildStringFromNames(Arrays.asList("en", "ja", "*-IN"))
913 );
914 }
915
916
917
918
919
920
921 @Test
922 @SuppressWarnings("unchecked")
923 public void testMojoHasOrderResources() throws Exception {
924 final List<String> orderresources =
925 (List<String>) rule.getVariableValueFromObject(mojo, "orderresources");
926 assertEquals("orderresources",
927 TestUtils.buildStringFromNames(orderresources),
928 TestUtils.buildStringFromNames(Arrays.asList(
929 "**/*-info.class",
930 "glob:**/module-info.class",
931 "regex:/java[a-z]+$",
932 "@filename"
933 ))
934 );
935 }
936
937
938
939
940
941
942 @Test
943 @SuppressWarnings("unchecked")
944 public void testMojoHasExcludeResources() throws Exception {
945 final List<String> excluderesources =
946 (List<String>) rule.getVariableValueFromObject(mojo,
947 "excluderesources");
948 assertEquals("excluderesources",
949 TestUtils.buildStringFromNames(excluderesources),
950 TestUtils.buildStringFromNames(Arrays.asList(
951 "**/*-info.class",
952 "glob:**/META-INF/**",
953 "regex:/java[a-z]+$",
954 "@filename"
955 ))
956 );
957 }
958
959
960
961
962
963
964 @Test
965 public void testMojoHasStripDebug() throws Exception {
966 final boolean stripdebug =
967 (boolean) rule.getVariableValueFromObject(mojo, "stripdebug");
968 assertTrue("stripdebug",
969 stripdebug);
970 }
971
972
973
974
975
976
977 @Test
978 public void testMojoHasStripJavaDebugAttributes() throws Exception {
979 final boolean stripjavadebugattributes =
980 (boolean) rule.getVariableValueFromObject(mojo,
981 "stripjavadebugattributes");
982 assertTrue("stripjavadebugattributes",
983 stripjavadebugattributes);
984 }
985
986
987
988
989
990
991 @Test
992 public void testMojoHasStripNativeCommands() throws Exception {
993 final boolean stripnativecommands =
994 (boolean) rule.getVariableValueFromObject(mojo, "stripnativecommands");
995 assertTrue("stripnativecommands",
996 stripnativecommands);
997 }
998
999
1000
1001
1002
1003
1004 @Test
1005 public void testMojoHasDedupLegalNotices() throws Exception {
1006 final boolean deduplegalnotices =
1007 (boolean) rule.getVariableValueFromObject(mojo, "deduplegalnotices");
1008 assertTrue("deduplegalnotices",
1009 deduplegalnotices);
1010 }
1011
1012
1013
1014
1015
1016
1017 @Test
1018 @SuppressWarnings("unchecked")
1019 public void testMojoHasExcludeFiles() throws Exception {
1020 final List<String> excludefiles =
1021 (List<String>) rule.getVariableValueFromObject(mojo, "excludefiles");
1022 assertEquals("excludefiles",
1023 TestUtils.buildStringFromNames(excludefiles),
1024 TestUtils.buildStringFromNames(Arrays.asList(
1025 "**/*-info.class",
1026 "glob:**/META-INF/**",
1027 "regex:/java[a-z]+$",
1028 "@filename"
1029 ))
1030 );
1031 }
1032
1033
1034
1035
1036
1037
1038 @Test
1039 public void testMojoHasExcludeJmodSection() throws Exception {
1040 final Section excludejmodsection =
1041 (Section) rule.getVariableValueFromObject(mojo, "excludejmodsection");
1042 assertEquals("excludejmodsection",
1043 excludejmodsection,
1044 Section.MAN
1045 );
1046 }
1047
1048
1049
1050
1051
1052
1053 @Test
1054 public void testMojoHasGenerateJliClasses() throws Exception {
1055 final File generatejliclasses =
1056 (File) rule.getVariableValueFromObject(mojo, "generatejliclasses");
1057 assertEquals("generatejliclasses",
1058 TestUtils.getCanonicalPath(generatejliclasses),
1059 TestUtils.getCanonicalPath(new File(PROJECT_DIR, "jli-classes"))
1060 );
1061 }
1062
1063
1064
1065
1066
1067
1068 @Test
1069 public void testMojoHasReleaseInfo() throws Exception {
1070 final ReleaseInfo releaseinfo =
1071 (ReleaseInfo) rule.getVariableValueFromObject(mojo, "releaseinfo");
1072 assertNotNull("releaseinfo",
1073 releaseinfo);
1074 }
1075
1076
1077
1078
1079
1080
1081 @Test
1082 public void testMojoHasReleaseInfoFile() throws Exception {
1083 final ReleaseInfo releaseinfo =
1084 (ReleaseInfo) rule.getVariableValueFromObject(mojo, "releaseinfo");
1085 final File releaseinfofile = releaseinfo.getFile();
1086 assertEquals("releaseinfo/file",
1087 TestUtils.getCanonicalPath(releaseinfofile),
1088 TestUtils.getCanonicalPath(new File(PROJECT_DIR, "file"))
1089 );
1090 }
1091
1092
1093
1094
1095
1096
1097 @Test
1098 public void testMojoHasReleaseInfoAdds() throws Exception {
1099 final ReleaseInfo releaseinfo =
1100 (ReleaseInfo) rule.getVariableValueFromObject(mojo, "releaseinfo");
1101 final Map<String, String> adds = releaseinfo.getAdds();
1102 assertEquals("releaseinfo/adds",
1103 adds.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue())
1104 .collect(Collectors.joining(":")),
1105 "key1=value1:key2=value2"
1106 );
1107 }
1108
1109
1110
1111
1112
1113
1114 @Test
1115 public void testMojoHasReleaseInfoDels() throws Exception {
1116 final ReleaseInfo releaseinfo =
1117 (ReleaseInfo) rule.getVariableValueFromObject(mojo, "releaseinfo");
1118 final Map<String, String> dels = releaseinfo.getDels();
1119 assertEquals("releaseinfo/dels",
1120 dels.entrySet().stream().map(e -> e.getKey())
1121 .collect(Collectors.joining(":")),
1122 "key1:key2"
1123 );
1124 }
1125
1126
1127
1128
1129
1130
1131 @Test
1132 public void testMojoHasVM() throws Exception {
1133 final HotSpot vm =
1134 (HotSpot) rule.getVariableValueFromObject(mojo, "vm");
1135 assertEquals("vm",
1136 vm,
1137 HotSpot.SERVER
1138 );
1139 }
1140
1141 }