TournamentSelect extends SelectionOperation implements Stochastic { public void setProperties(Properties p) { super.setProperties(p); int value; String key; try { key = Constants.TOURNAMENT_SIZE; value = Integer.parseInt(p.getProperty(key)); if(value < 1) { throw new BadParameterException(key); } } catch(Exception e) { value = 3; logger.warn(e+" using default: "+value); } this.tournamentSize = value; } TournamentSelect(int size, int tourSize, RandomNumberGenerator rand);  TournamentSelect(RandomNumberGenerator rand, Properties p);  TournamentSelect(); void setProperties(Properties p); void doOperation(Individual operand); void doOperation(List<Individual> operands); void getTour(List<Individual> operands); void selectFromTour(); void setRNG(RandomNumberGenerator m); RandomNumberGenerator getRNG();  }
@Test public void testSetProperties() { System.out.println("* TournamentSelect: setProperties"); Properties p = GrammarCreator.getProperties(); p.setProperty(Constants.TOURNAMENT_SIZE, "4"); TournamentSelect instance = new TournamentSelect(); instance.setProperties(p); assertEquals(instance.tournamentSize, 4); p.setProperty(Constants.TOURNAMENT_SIZE, "0"); instance = new TournamentSelect(); instance.setProperties(p); assertEquals(instance.tournamentSize, 3); }