@@ -34,16 +34,15 @@ public void testAllOptions() throws Exception {
3434 jco .setEncoding ("UTF-8" );
3535
3636 List <String > result = jco .getOptions ();
37- int i = 0 ;
38- assertTrue (result .get (i ++).equals ("-source" ));
39- assertTrue (result .get (i ++).equals ("9" ));
40- assertTrue (result .get (i ++).equals ("-target" ));
41- assertTrue (result .get (i ++).equals ("1.8" ));
42- assertTrue (result .get (i ++).equals ("--release" ));
43- assertTrue (result .get (i ++).equals ("10" ));
44- assertTrue (result .get (i ++).equals ("-encoding" ));
45- assertTrue (result .get (i ++).equals ("UTF-8" ));
46- assertEquals (i , result .size ());
37+ assertEquals (8 , result .size ());
38+ assertTrue (result .contains ("-source" ));
39+ assertTrue (result .contains ("9" ));
40+ assertTrue (result .contains ("-target" ));
41+ assertTrue (result .contains ("1.8" ));
42+ assertTrue (result .contains ("--release" ));
43+ assertTrue (result .contains ("10" ));
44+ assertTrue (result .contains ("-encoding" ));
45+ assertTrue (result .contains ("UTF-8" ));
4746 }
4847
4948 @ Test
@@ -62,9 +61,9 @@ public void testSource() throws Exception {
6261
6362 List <String > result = jco .getOptions ();
6463 assertEquals (3 , result .size ());
65- assertTrue (result .get ( 0 ). equals ("-nowarn" ));
66- assertTrue (result .get ( 1 ). equals ("-source" ));
67- assertTrue (result .get ( 2 ). equals ("10" ));
64+ assertTrue (result .contains ("-nowarn" ));
65+ assertTrue (result .contains ("-source" ));
66+ assertTrue (result .contains ("10" ));
6867 }
6968
7069 @ Test
@@ -74,9 +73,9 @@ public void testTarget() throws Exception {
7473
7574 List <String > result = jco .getOptions ();
7675 assertEquals (3 , result .size ());
77- assertTrue (result .get ( 0 ). equals ("-nowarn" ));
78- assertTrue (result .get ( 1 ). equals ("-target" ));
79- assertTrue (result .get ( 2 ). equals ("10" ));
76+ assertTrue (result .contains ("-nowarn" ));
77+ assertTrue (result .contains ("-target" ));
78+ assertTrue (result .contains ("10" ));
8079 }
8180
8281 @ Test
@@ -86,9 +85,9 @@ public void testRelease() throws Exception {
8685
8786 List <String > result = jco .getOptions ();
8887 assertEquals (3 , result .size ());
89- assertTrue (result .get ( 0 ). equals ("-nowarn" ));
90- assertTrue (result .get ( 1 ). equals ("--release" ));
91- assertTrue (result .get ( 2 ). equals ("10" ));
88+ assertTrue (result .contains ("-nowarn" ));
89+ assertTrue (result .contains ("--release" ));
90+ assertTrue (result .contains ("10" ));
9291 }
9392
9493 @ Test
@@ -98,9 +97,106 @@ public void testEncoding() throws Exception {
9897
9998 List <String > result = jco .getOptions ();
10099 assertEquals (3 , result .size ());
100+ assertTrue (result .contains ("-nowarn" ));
101+ assertTrue (result .contains ("-encoding" ));
102+ assertTrue (result .contains ("UTF-8" ));
103+ }
104+
105+ @ Test
106+ public void testAnnotationProcessorPath () throws Exception {
107+ JavaCompilerOptions jco = new JavaCompilerOptions ();
108+ jco .setAnnotationProcessorPath ("/path/to/lombok.jar:/path/to/mapstruct.jar" );
109+
110+ List <String > result = jco .getOptions ();
111+ assertEquals (3 , result .size ());
112+ assertTrue (result .contains ("-nowarn" ));
113+ assertTrue (result .contains ("-processorpath" ));
114+ assertTrue (result .contains ("/path/to/lombok.jar:/path/to/mapstruct.jar" ));
115+ }
116+
117+ @ Test
118+ public void testAnnotationProcessorPathWithOtherOptions () throws Exception {
119+ JavaCompilerOptions jco = new JavaCompilerOptions ();
120+ jco .setRelease ("17" );
121+ jco .setEncoding ("UTF-8" );
122+ jco .setAnnotationProcessorPath ("/path/to/lombok.jar" );
123+
124+ List <String > result = jco .getOptions ();
125+ assertEquals (7 , result .size ());
126+ assertTrue (result .contains ("-nowarn" ));
127+ assertTrue (result .contains ("--release" ));
128+ assertTrue (result .contains ("17" ));
129+ assertTrue (result .contains ("-encoding" ));
130+ assertTrue (result .contains ("UTF-8" ));
131+ assertTrue (result .contains ("-processorpath" ));
132+ assertTrue (result .contains ("/path/to/lombok.jar" ));
133+ }
134+
135+ @ Test
136+ public void testAnnotationProcessorPathNull () throws Exception {
137+ JavaCompilerOptions jco = new JavaCompilerOptions ();
138+ jco .setAnnotationProcessorPath (null );
139+
140+ List <String > result = jco .getOptions ();
141+ assertEquals (1 , result .size ());
101142 assertTrue (result .get (0 ).equals ("-nowarn" ));
102- assertTrue (result .get (1 ).equals ("-encoding" ));
103- assertTrue (result .get (2 ).equals ("UTF-8" ));
143+ }
144+
145+ @ Test
146+ public void testAnnotationProcessorPathEmpty () throws Exception {
147+ JavaCompilerOptions jco = new JavaCompilerOptions ();
148+ jco .setAnnotationProcessorPath ("" );
149+
150+ List <String > result = jco .getOptions ();
151+ assertEquals (1 , result .size ());
152+ assertTrue (result .get (0 ).equals ("-nowarn" ));
153+ }
154+
155+ @ Test
156+ public void testAnnotationProcessors () throws Exception {
157+ JavaCompilerOptions jco = new JavaCompilerOptions ();
158+ jco .setAnnotationProcessors ("lombok.AnnotationProcessor,org.mapstruct.ap.MappingProcessor" );
159+
160+ List <String > result = jco .getOptions ();
161+ assertEquals (3 , result .size ());
162+ assertTrue (result .contains ("-nowarn" ));
163+ assertTrue (result .contains ("-processor" ));
164+ assertTrue (result .contains ("lombok.AnnotationProcessor,org.mapstruct.ap.MappingProcessor" ));
165+ }
166+
167+ @ Test
168+ public void testAnnotationProcessorsWithPath () throws Exception {
169+ JavaCompilerOptions jco = new JavaCompilerOptions ();
170+ jco .setAnnotationProcessorPath ("/path/to/lombok.jar" );
171+ jco .setAnnotationProcessors ("lombok.AnnotationProcessor" );
172+
173+ List <String > result = jco .getOptions ();
174+ assertEquals (5 , result .size ());
175+ assertTrue (result .contains ("-nowarn" ));
176+ assertTrue (result .contains ("-processorpath" ));
177+ assertTrue (result .contains ("/path/to/lombok.jar" ));
178+ assertTrue (result .contains ("-processor" ));
179+ assertTrue (result .contains ("lombok.AnnotationProcessor" ));
180+ }
181+
182+ @ Test
183+ public void testAnnotationProcessorsNull () throws Exception {
184+ JavaCompilerOptions jco = new JavaCompilerOptions ();
185+ jco .setAnnotationProcessors (null );
186+
187+ List <String > result = jco .getOptions ();
188+ assertEquals (1 , result .size ());
189+ assertTrue (result .contains ("-nowarn" ));
190+ }
191+
192+ @ Test
193+ public void testAnnotationProcessorsEmpty () throws Exception {
194+ JavaCompilerOptions jco = new JavaCompilerOptions ();
195+ jco .setAnnotationProcessors ("" );
196+
197+ List <String > result = jco .getOptions ();
198+ assertEquals (1 , result .size ());
199+ assertTrue (result .contains ("-nowarn" ));
104200 }
105201
106202}
0 commit comments