CiphersuiteDelegate extends Delegate { @Override public void applyDelegate(Config config) { if (cipherSuites != null) { config.setDefaultClientSupportedCiphersuites(cipherSuites); config.setDefaultServerSupportedCiphersuites(cipherSuites); if (cipherSuites.size() > 0) { config.setDefaultSelectedCipherSuite(cipherSuites.get(0)); } } } CiphersuiteDelegate(); List<CipherSuite> getCipherSuites(); void setCipherSuites(List<CipherSuite> cipherSuites); void setCipherSuites(CipherSuite... cipherSuites); @Override void applyDelegate(Config config);  }
@Test public void testApplyDelegate() { args = new String[2]; args[0] = "-cipher"; args[1] = "TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA"; jcommander.parse(args); assertTrue("TLS_RSA_WITH_AES_128_CBC_SHA should get parsed correctly", delegate.getCipherSuites().contains(CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA)); assertTrue("TLS_RSA_WITH_AES_256_CBC_SHA should get parsed correctly", delegate.getCipherSuites().contains(CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA)); Config config = Config.createConfig(); config.setDefaultSelectedCipherSuite(CipherSuite.TLS_AES_128_GCM_SHA256); config.setDefaultClientSupportedCiphersuites(new CipherSuite[0]); delegate.applyDelegate(config); assertTrue("TLS_RSA_WITH_AES_128_CBC_SHA should get parsed correctly", config .getDefaultClientSupportedCiphersuites().contains(CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA)); assertTrue("TLS_RSA_WITH_AES_256_CBC_SHA should get parsed correctly", config .getDefaultClientSupportedCiphersuites().contains(CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA)); assertEquals(CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA, config.getDefaultSelectedCipherSuite()); }
@Test public void testNothingSetNothingChanges() { Config config = Config.createConfig(); Config config2 = Config.createConfig(); delegate.applyDelegate(config); assertTrue(EqualsBuilder.reflectionEquals(config, config2, "keyStore", "ourCertificate")); }