@@ -87,16 +87,14 @@ public void test2xStylePlugin()
8787 {
8888 String pluginXml = "META-INF/maven/plugin-2.1.xml" ;
8989
90- List <String > messages = run ( pluginXml , true );
90+ List <String > messages = run ( pluginXml );
9191
92- assertPresence ( messages , "Unpacked Ant build scripts (in Maven build directory)." , false );
93- assertPresence ( messages , "Maven parameter expression evaluator for Ant properties." , false );
94- assertPresence ( messages , "Maven standard project-based classpath references." , false );
95- assertPresence ( messages , "Maven standard plugin-based classpath references." , false );
96- assertPresence ( messages ,
97- "Maven project, session, mojo-execution, or path-translation parameter information is" , false );
98- assertPresence ( messages , "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release" ,
99- false );
92+ assertPresence ( messages , "Unpacked Ant build scripts (in Maven build directory)." );
93+ assertPresence ( messages , "Maven parameter expression evaluator for Ant properties." );
94+ assertPresence ( messages , "Maven standard project-based classpath references." );
95+ assertPresence ( messages , "Maven standard plugin-based classpath references." );
96+ assertPresence ( messages , "Maven project, session, mojo-execution, or path-translation parameter information is" );
97+ assertPresence ( messages , "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release" );
10098
10199 ArgumentCaptor <BuildEvent > buildEvent = ArgumentCaptor .forClass (BuildEvent .class );
102100 verify ( buildListener , atLeastOnce () ).messageLogged ( buildEvent .capture () );
@@ -106,52 +104,19 @@ public void test2xStylePlugin()
106104 assertThat ( buildEvent .getValue ().getMessage (), endsWith ( ".test.jar" ) );
107105 }
108106
109- @ Test
110- public void test20StylePlugin ()
111- throws PlexusConfigurationException , IOException , ComponentInstantiationException , MojoExecutionException ,
112- ComponentConfigurationException , ArchiverException , URISyntaxException
113- {
114- String pluginXml = "META-INF/maven/plugin-2.0.xml" ;
115-
116- List <String > messages = run ( pluginXml , false );
117-
118- assertPresence ( messages , "Unpacked Ant build scripts (in Maven build directory)." , true );
119- assertPresence ( messages , "Maven parameter expression evaluator for Ant properties." , true );
120- assertPresence ( messages , "Maven standard project-based classpath references." , true );
121- assertPresence ( messages , "Maven standard plugin-based classpath references." , true );
122- assertPresence ( messages ,
123- "Maven project, session, mojo-execution, or path-translation parameter information is" , true );
124- assertPresence ( messages , "maven-script-ant < 2.1.0, or used maven-plugin-tools-ant < 2.2 during release" , true );
125-
126- ArgumentCaptor <BuildEvent > buildEvent = ArgumentCaptor .forClass (BuildEvent .class );
127- verify ( buildListener , atLeastOnce () ).messageLogged ( buildEvent .capture () );
128-
129- // last message
130- assertThat ( buildEvent .getValue ().getMessage (), startsWith ( "plugin classpath is: " ) );
131- assertThat ( buildEvent .getValue ().getMessage (), endsWith ( "path-is-missing" ) );
132- }
133-
134- private void assertPresence ( List <String > messages , String test , boolean shouldBePresent )
107+ private void assertPresence ( List <String > messages , String test )
135108 {
136109 for ( String message : messages )
137110 {
138111 if ( message .contains ( test ) )
139112 {
140- if ( !shouldBePresent )
141- {
142- fail ( "Test string: '" + test + "' was found in output, but SHOULD NOT BE THERE." );
143- }
113+ fail ( "Test string: '" + test + "' was found in output, but SHOULD NOT BE THERE." );
144114 return ;
145115 }
146116 }
147-
148- if ( shouldBePresent )
149- {
150- fail ( "Test string: '" + test + "' was NOT found in output, but SHOULD BE THERE." );
151- }
152117 }
153118
154- private List <String > run ( String pluginXml , boolean includeImplied )
119+ private List <String > run ( String pluginXml )
155120 throws PlexusConfigurationException , IOException , ComponentInstantiationException , MojoExecutionException ,
156121 ComponentConfigurationException , ArchiverException , URISyntaxException
157122 {
@@ -185,43 +150,40 @@ private List<String> run( String pluginXml, boolean includeImplied )
185150 Artifact artifact = mock ( Artifact .class );
186151 PathTranslator pt = mock ( PathTranslator .class );
187152
188- if ( includeImplied )
189- {
190- File pluginXmlFile = Paths .get ( resource .toURI () ).toFile ();
153+ File pluginXmlFile = Paths .get ( resource .toURI () ).toFile ();
191154
192- File jarFile = File .createTempFile ( "AntMojoWrapperTest." , ".test.jar" );
193- jarFile .deleteOnExit ();
155+ File jarFile = File .createTempFile ( "AntMojoWrapperTest." , ".test.jar" );
156+ jarFile .deleteOnExit ();
194157
195- JarArchiver archiver = new JarArchiver ();
196- archiver .enableLogging ( new ConsoleLogger ( Logger .LEVEL_ERROR , "archiver" ) );
197- archiver .setDestFile ( jarFile );
198- archiver .addFile ( pluginXmlFile , pluginXml );
199- archiver .createArchive ();
158+ JarArchiver archiver = new JarArchiver ();
159+ archiver .enableLogging ( new ConsoleLogger ( Logger .LEVEL_ERROR , "archiver" ) );
160+ archiver .setDestFile ( jarFile );
161+ archiver .addFile ( pluginXmlFile , pluginXml );
162+ archiver .createArchive ();
200163
201- when ( artifact .getFile () ).thenReturn ( jarFile );
164+ when ( artifact .getFile () ).thenReturn ( jarFile );
202165
203- Model model = new Model ();
166+ Model model = new Model ();
204167
205- Build build = new Build ();
206- build .setDirectory ( "target" );
168+ Build build = new Build ();
169+ build .setDirectory ( "target" );
207170
208- model .setBuild ( build );
171+ model .setBuild ( build );
209172
210- MavenProject project = new MavenProject ( model );
211- project .setFile ( new File ( "pom.xml" ).getAbsoluteFile () );
173+ MavenProject project = new MavenProject ( model );
174+ project .setFile ( new File ( "pom.xml" ).getAbsoluteFile () );
212175
213- pd .setPluginArtifact ( artifact );
214- pd .setArtifacts ( Collections .singletonList ( artifact ) );
176+ pd .setPluginArtifact ( artifact );
177+ pd .setArtifacts ( Collections .singletonList ( artifact ) );
215178
216- config .put ( "project" , project );
217- config .put ( "session" , new MavenSession ( null , null , null , null , null , null , null , null , null , null ) );
218- config .put ( "mojoExecution" , new MojoExecution ( md ) );
179+ config .put ( "project" , project );
180+ config .put ( "session" , new MavenSession ( null , null , null , null , null , null , null , null , null , null ) );
181+ config .put ( "mojoExecution" , new MojoExecution ( md ) );
219182
220- ComponentRequirement cr = new ComponentRequirement ();
221- cr .setRole ( PathTranslator .class .getName () );
183+ ComponentRequirement cr = new ComponentRequirement ();
184+ cr .setRole ( PathTranslator .class .getName () );
222185
223- wrapper .addComponentRequirement ( cr , pt );
224- }
186+ wrapper .addComponentRequirement ( cr , pt );
225187
226188 wrapper .setComponentConfiguration ( config );
227189
@@ -251,15 +213,15 @@ private List<String> run( String pluginXml, boolean includeImplied )
251213 messages .addAll ( tbl .messages );
252214 }
253215
254- messages .add ( new String ( baos .toByteArray () ) );
216+ messages .add ( baos .toString ( ) );
255217
256218 return messages ;
257219 }
258220
259221 private static final class TestBuildListener
260222 implements BuildListener
261223 {
262- private List <String > messages = new ArrayList <>();
224+ private final List <String > messages = new ArrayList <>();
263225
264226 public void buildFinished ( BuildEvent arg0 )
265227 {
0 commit comments