### Question:
AppConfig extends AbstractConfig { public synchronized void setApiServerPort(final int port) throws IOException { if(NetUtils.isValidPort(port)) { setProperty(PROPERTY_API_SERVER_PORT, String.valueOf(port)); if(OsUtils.isWindows()) { WinRegistry.setApiServerPort(port); } } else { removeProperty(PROPERTY_API_SERVER_PORT); } saveProperties(); } AppConfig(Path file); synchronized int getApiServerPort(); synchronized boolean hasApiServerPort(); synchronized void setApiServerPort(final int port); synchronized boolean isTrayNotificationEnabled(); synchronized void setTrayNotification(boolean enabled);  }### Answer:
@Test public void testSetApiServerPort() throws IOException { appConfig.setApiServerPort(0); assertEquals(appConfig.getApiServerPort(), -1); userConfigAssertPersistence(appConfig, configFile); appConfig.setApiServerPort(-1); assertEquals(appConfig.getApiServerPort(), -1); userConfigAssertPersistence(appConfig, configFile); appConfig.setApiServerPort(65536); assertEquals(appConfig.getApiServerPort(), -1); userConfigAssertPersistence(appConfig, configFile); appConfig.setApiServerPort(1); assertEquals(appConfig.getApiServerPort(), 1); userConfigAssertPersistence(appConfig, configFile); appConfig.setApiServerPort(37824); assertEquals(appConfig.getApiServerPort(), 37824); userConfigAssertPersistence(appConfig, configFile); appConfig.setApiServerPort(65535); assertEquals(appConfig.getApiServerPort(), 65535); userConfigAssertPersistence(appConfig, configFile); }