@Test public void testCanNotChangeAlreadyInitializedProxyType() { Proxy proxy = new Proxy(); proxy.setProxyType(ProxyType.DIRECT); try { proxy.setAutodetect(true); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } try { proxy.setSocksPassword(""); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } try { proxy.setSocksUsername(""); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } try { proxy.setSocksProxy(""); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } try { proxy.setFtpProxy(""); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } try { proxy.setHttpProxy(""); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } try { proxy.setNoProxy(""); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } try { proxy.setProxyAutoconfigUrl(""); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } try { proxy.setProxyType(ProxyType.SYSTEM); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } try { proxy.setSslProxy(""); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } proxy = new Proxy(); proxy.setProxyType(ProxyType.AUTODETECT); try { proxy.setProxyType(ProxyType.SYSTEM); fail("Didn't throw expected assertion"); } catch (IllegalStateException e) { // Success - expected. } }