### Question:
PasswordGenerator { public String generate(int length) { char[] password = new char[length]; for (int i = 0; i < length; i++) { int n = secureRandom.nextInt(characterSet.length); password[i] = characterSet[n]; } return new String(password); } PasswordGenerator(); String generate(int length);  }### Answer:
@Test public void testGenerate() { PasswordGenerator generator = new PasswordGenerator(); String password = generator.generate(50); String password2 = generator.generate(50); String password3 = generator.generate(50); log.debug(password); log.debug(password2); log.debug(password3); assertFalse(password.equals(password2)); assertFalse(password.equals(password3)); assertFalse(password2.equals(password3)); }
@Test public void testGenerate2() { PasswordGenerator generator = new PasswordGenerator(); assertEquals(50, generator.generate(50).length()); assertEquals(51, generator.generate(51).length()); assertEquals(52, generator.generate(52).length()); assertEquals(53, generator.generate(53).length()); }