@Test public void testOneVersionOfRoboconf() throws Exception { Map<String,String> versionToBundle = new LinkedHashMap<> (); versionToBundle.put( "2.0", "whatever" ); versionToBundle.put( "5.1", "bundle 1" ); versionToBundle.put( "0.8", Constants.RBCF_CORE_SYMBOLIC_NAME ); versionToBundle.put( "10", "oops" ); versionToBundle.put( "36.5.1", "hey" ); List<Bundle> bundles = new ArrayList<> (); for( Map.Entry<String,String> entry : versionToBundle.entrySet()) { Bundle bundleMock = Mockito.mock( Bundle.class ); Mockito.when( bundleMock.getSymbolicName()).thenReturn( entry.getValue()); Version v = Mockito.mock( Version.class ); Mockito.when( v.toString()).thenReturn( entry.getKey()); Mockito.when( bundleMock.getVersion()).thenReturn( v ); bundles.add( bundleMock ); } Mockito.when( this.ctx.getBundles()).thenReturn( bundles.toArray( new Bundle[ bundles.size()])); this.cmd.execute(); String outputText = filterOutput( this.os.toString( "UTF-8" )); Assert.assertEquals( "Roboconf\n Roboconf version 0.8", outputText ); Mockito.verify( this.session, Mockito.only()).execute( RoboconfInfoCommand.KARAF_INFO ); Mockito.verify( this.ctx, Mockito.only()).getBundles(); }
@Override public Object execute() throws Exception { List<String> versions = new ArrayList<> (); for( Bundle bundle : this.ctx.getBundles()) { if( Constants.RBCF_CORE_SYMBOLIC_NAME.equals( bundle.getSymbolicName())) versions.add( bundle.getVersion().toString()); } this.out.println(); this.out.println( "Roboconf" ); if( versions.size() > 1 ) { this.out.println( "\n[ WARNING ] Several versions of Roboconf run in the server." ); this.out.println( "[ WARNING ] Please, run bundle:list | grep roboconf-core for more details." ); this.out.println(); printValue( "Roboconf versions", versions.get( 0 )); for( int i=1; i<versions.size(); i++ ) printValue( "", versions.get( i )); } else if( versions.size() == 1 ) { printValue( "Roboconf version", versions.get( 0 )); } else { printValue( "Roboconf version", "Undetermined" ); } this.out.println(); this.session.execute( KARAF_INFO ); this.out.println(); return null; }
RoboconfInfoCommand implements Action { @Override public Object execute() throws Exception { List<String> versions = new ArrayList<> (); for( Bundle bundle : this.ctx.getBundles()) { if( Constants.RBCF_CORE_SYMBOLIC_NAME.equals( bundle.getSymbolicName())) versions.add( bundle.getVersion().toString()); } this.out.println(); this.out.println( "Roboconf" ); if( versions.size() > 1 ) { this.out.println( "\n[ WARNING ] Several versions of Roboconf run in the server." ); this.out.println( "[ WARNING ] Please, run bundle:list | grep roboconf-core for more details." ); this.out.println(); printValue( "Roboconf versions", versions.get( 0 )); for( int i=1; i<versions.size(); i++ ) printValue( "", versions.get( i )); } else if( versions.size() == 1 ) { printValue( "Roboconf version", versions.get( 0 )); } else { printValue( "Roboconf version", "Undetermined" ); } this.out.println(); this.session.execute( KARAF_INFO ); this.out.println(); return null; } }
RoboconfInfoCommand implements Action { @Override public Object execute() throws Exception { List<String> versions = new ArrayList<> (); for( Bundle bundle : this.ctx.getBundles()) { if( Constants.RBCF_CORE_SYMBOLIC_NAME.equals( bundle.getSymbolicName())) versions.add( bundle.getVersion().toString()); } this.out.println(); this.out.println( "Roboconf" ); if( versions.size() > 1 ) { this.out.println( "\n[ WARNING ] Several versions of Roboconf run in the server." ); this.out.println( "[ WARNING ] Please, run bundle:list | grep roboconf-core for more details." ); this.out.println(); printValue( "Roboconf versions", versions.get( 0 )); for( int i=1; i<versions.size(); i++ ) printValue( "", versions.get( i )); } else if( versions.size() == 1 ) { printValue( "Roboconf version", versions.get( 0 )); } else { printValue( "Roboconf version", "Undetermined" ); } this.out.println(); this.session.execute( KARAF_INFO ); this.out.println(); return null; }  }
RoboconfInfoCommand implements Action { @Override public Object execute() throws Exception { List<String> versions = new ArrayList<> (); for( Bundle bundle : this.ctx.getBundles()) { if( Constants.RBCF_CORE_SYMBOLIC_NAME.equals( bundle.getSymbolicName())) versions.add( bundle.getVersion().toString()); } this.out.println(); this.out.println( "Roboconf" ); if( versions.size() > 1 ) { this.out.println( "\n[ WARNING ] Several versions of Roboconf run in the server." ); this.out.println( "[ WARNING ] Please, run bundle:list | grep roboconf-core for more details." ); this.out.println(); printValue( "Roboconf versions", versions.get( 0 )); for( int i=1; i<versions.size(); i++ ) printValue( "", versions.get( i )); } else if( versions.size() == 1 ) { printValue( "Roboconf version", versions.get( 0 )); } else { printValue( "Roboconf version", "Undetermined" ); } this.out.println(); this.session.execute( KARAF_INFO ); this.out.println(); return null; }  @Override Object execute(); }
RoboconfInfoCommand implements Action { @Override public Object execute() throws Exception { List<String> versions = new ArrayList<> (); for( Bundle bundle : this.ctx.getBundles()) { if( Constants.RBCF_CORE_SYMBOLIC_NAME.equals( bundle.getSymbolicName())) versions.add( bundle.getVersion().toString()); } this.out.println(); this.out.println( "Roboconf" ); if( versions.size() > 1 ) { this.out.println( "\n[ WARNING ] Several versions of Roboconf run in the server." ); this.out.println( "[ WARNING ] Please, run bundle:list | grep roboconf-core for more details." ); this.out.println(); printValue( "Roboconf versions", versions.get( 0 )); for( int i=1; i<versions.size(); i++ ) printValue( "", versions.get( i )); } else if( versions.size() == 1 ) { printValue( "Roboconf version", versions.get( 0 )); } else { printValue( "Roboconf version", "Undetermined" ); } this.out.println(); this.session.execute( KARAF_INFO ); this.out.println(); return null; }  @Override Object execute();  }