@Test public void testExecute_valid() throws Exception { InstallPluginCommand itc = new InstallPluginCommand(); ByteArrayOutputStream os = new ByteArrayOutputStream(); itc.out = new PrintStream( os, true, "UTF-8" ); itc.targetName = "script"; itc.roboconfVersion = "0.5"; final String expected = "bundle:install --start mvn:net.roboconf/roboconf-plugin-script/0.5"; Session session = Mockito.mock( Session.class ); Mockito.when( session.execute( expected )).thenReturn( null ); for( Class<?> c = itc.getClass(); c != null; c = c.getSuperclass()) { try { Field field = c.getDeclaredField( "session" ); field.setAccessible( true ); field.set( itc, session ); } catch( NoSuchFieldException e ) { } } itc.execute(); String s = os.toString( "UTF-8" ); Assert.assertFalse( s.contains( "the Roboconf version" )); Assert.assertFalse( s.contains( "Unknown plug-in" )); Mockito.verify( session ).execute( expected ); }
@Override public Object execute() throws Exception { SupportedPlugin st = SupportedPlugin.which( this.targetName ); if( st == null ) { this.out.println( "Unknown plug-in: " + this.targetName + ". Make sure it is correct or install it manually." ); } else if( this.roboconfVersion == null ) { this.out.println( "Error: the Roboconf version could not be determined." ); } else for( String cmd : st.findCommands( this.roboconfVersion )) { this.logger.fine( "Executing " + cmd + "..." ); this.out.println( "Executing " + cmd + "..." ); this.session.execute( cmd ); } return null; }
InstallPluginCommand implements Action { @Override public Object execute() throws Exception { SupportedPlugin st = SupportedPlugin.which( this.targetName ); if( st == null ) { this.out.println( "Unknown plug-in: " + this.targetName + ". Make sure it is correct or install it manually." ); } else if( this.roboconfVersion == null ) { this.out.println( "Error: the Roboconf version could not be determined." ); } else for( String cmd : st.findCommands( this.roboconfVersion )) { this.logger.fine( "Executing " + cmd + "..." ); this.out.println( "Executing " + cmd + "..." ); this.session.execute( cmd ); } return null; } }
InstallPluginCommand implements Action { @Override public Object execute() throws Exception { SupportedPlugin st = SupportedPlugin.which( this.targetName ); if( st == null ) { this.out.println( "Unknown plug-in: " + this.targetName + ". Make sure it is correct or install it manually." ); } else if( this.roboconfVersion == null ) { this.out.println( "Error: the Roboconf version could not be determined." ); } else for( String cmd : st.findCommands( this.roboconfVersion )) { this.logger.fine( "Executing " + cmd + "..." ); this.out.println( "Executing " + cmd + "..." ); this.session.execute( cmd ); } return null; } InstallPluginCommand(); }
InstallPluginCommand implements Action { @Override public Object execute() throws Exception { SupportedPlugin st = SupportedPlugin.which( this.targetName ); if( st == null ) { this.out.println( "Unknown plug-in: " + this.targetName + ". Make sure it is correct or install it manually." ); } else if( this.roboconfVersion == null ) { this.out.println( "Error: the Roboconf version could not be determined." ); } else for( String cmd : st.findCommands( this.roboconfVersion )) { this.logger.fine( "Executing " + cmd + "..." ); this.out.println( "Executing " + cmd + "..." ); this.session.execute( cmd ); } return null; } InstallPluginCommand(); @Override Object execute(); }
InstallPluginCommand implements Action { @Override public Object execute() throws Exception { SupportedPlugin st = SupportedPlugin.which( this.targetName ); if( st == null ) { this.out.println( "Unknown plug-in: " + this.targetName + ". Make sure it is correct or install it manually." ); } else if( this.roboconfVersion == null ) { this.out.println( "Error: the Roboconf version could not be determined." ); } else for( String cmd : st.findCommands( this.roboconfVersion )) { this.logger.fine( "Executing " + cmd + "..." ); this.out.println( "Executing " + cmd + "..." ); this.session.execute( cmd ); } return null; } InstallPluginCommand(); @Override Object execute();  }