@@ -266,18 +266,17 @@ MockTerminal installPlugin(String pluginUrl, Path home, InstallPluginCommand com
266266 }
267267
268268 void assertMetaPlugin (String metaPlugin , String name , Path original , Environment env ) throws IOException {
269- assertPluginInternal (name , original , env ,
270- env . pluginsFile (). resolve ( metaPlugin ), env . configFile (). resolve ( metaPlugin ) , env . binFile (). resolve ( metaPlugin ) );
269+ assertPluginInternal (name , env . pluginsFile (). resolve ( metaPlugin ));
270+ assertConfigAndBin ( metaPlugin , original , env );
271271 }
272272
273-
274273 void assertPlugin (String name , Path original , Environment env ) throws IOException {
275- assertPluginInternal (name , original , env ,
276- env .pluginsFile (), env .configFile (), env .binFile ());
274+ assertPluginInternal (name , env .pluginsFile ());
275+ assertConfigAndBin (name , original , env );
276+ assertInstallCleaned (env );
277277 }
278278
279- void assertPluginInternal (String name , Path original , Environment env ,
280- Path pluginsFile , Path configFile , Path binFile ) throws IOException {
279+ void assertPluginInternal (String name , Path pluginsFile ) throws IOException {
281280 Path got = pluginsFile .resolve (name );
282281 assertTrue ("dir " + name + " exists" , Files .exists (got ));
283282
@@ -294,17 +293,19 @@ void assertPluginInternal(String name, Path original, Environment env,
294293 PosixFilePermission .OTHERS_READ ,
295294 PosixFilePermission .OTHERS_EXECUTE ));
296295 }
297-
298296 assertTrue ("jar was copied" , Files .exists (got .resolve ("plugin.jar" )));
299297 assertFalse ("bin was not copied" , Files .exists (got .resolve ("bin" )));
300298 assertFalse ("config was not copied" , Files .exists (got .resolve ("config" )));
299+ }
300+
301+ void assertConfigAndBin (String name , Path original , Environment env ) throws IOException {
301302 if (Files .exists (original .resolve ("bin" ))) {
302- Path binDir = binFile .resolve (name );
303+ Path binDir = env . binFile () .resolve (name );
303304 assertTrue ("bin dir exists" , Files .exists (binDir ));
304305 assertTrue ("bin is a dir" , Files .isDirectory (binDir ));
305306 PosixFileAttributes binAttributes = null ;
306307 if (isPosix ) {
307- binAttributes = Files .readAttributes (binFile , PosixFileAttributes .class );
308+ binAttributes = Files .readAttributes (env . binFile () , PosixFileAttributes .class );
308309 }
309310 try (DirectoryStream <Path > stream = Files .newDirectoryStream (binDir )) {
310311 for (Path file : stream ) {
@@ -317,7 +318,7 @@ void assertPluginInternal(String name, Path original, Environment env,
317318 }
318319 }
319320 if (Files .exists (original .resolve ("config" ))) {
320- Path configDir = configFile .resolve (name );
321+ Path configDir = env . configFile () .resolve (name );
321322 assertTrue ("config dir exists" , Files .exists (configDir ));
322323 assertTrue ("config is a dir" , Files .isDirectory (configDir ));
323324
@@ -326,7 +327,7 @@ void assertPluginInternal(String name, Path original, Environment env,
326327
327328 if (isPosix ) {
328329 PosixFileAttributes configAttributes =
329- Files .getFileAttributeView (configFile , PosixFileAttributeView .class ).readAttributes ();
330+ Files .getFileAttributeView (env . configFile () , PosixFileAttributeView .class ).readAttributes ();
330331 user = configAttributes .owner ();
331332 group = configAttributes .group ();
332333
@@ -351,7 +352,6 @@ void assertPluginInternal(String name, Path original, Environment env,
351352 }
352353 }
353354 }
354- assertInstallCleaned (env );
355355 }
356356
357357 void assertInstallCleaned (Environment env ) throws IOException {
@@ -734,7 +734,7 @@ public void testExistingConfig() throws Exception {
734734
735735 public void testExistingMetaConfig () throws Exception {
736736 Tuple <Path , Environment > env = createEnv (fs , temp );
737- Path envConfigDir = env .v2 ().configFile ().resolve ("my_plugins" ). resolve ( "fake" ) ;
737+ Path envConfigDir = env .v2 ().configFile ().resolve ("my_plugins" );
738738 Files .createDirectories (envConfigDir );
739739 Files .write (envConfigDir .resolve ("custom.yml" ), "existing config" .getBytes (StandardCharsets .UTF_8 ));
740740 Path metaDir = createPluginDir (temp );
0 commit comments