CompressionDelegate extends Delegate { @Override public void applyDelegate(Config config) { if (compressionMethods != null) { config.setDefaultClientSupportedCompressionMethods(compressionMethods); config.setDefaultServerSupportedCompressionMethods(compressionMethods); if (compressionMethods.size() > 0) { config.setDefaultSelectedCompressionMethod(compressionMethods.get(0)); } } } CompressionDelegate(); List<CompressionMethod> getCompressionMethods(); void setCompressionMethods(List<CompressionMethod> compressionMethods); @Override void applyDelegate(Config config);  }
@Test public void testApplyDelegate() { args = new String[2]; args[0] = "-compression"; args[1] = "NULL,DEFLATE"; jcommander.parse(args); Config config = Config.createConfig(); config.setDefaultClientSupportedCompressionMethods(new CompressionMethod[0]); config.setDefaultServerSupportedCompressionMethods(new CompressionMethod[0]); delegate.applyDelegate(config); assertTrue("NULL should get parsed correctly", config.getDefaultClientSupportedCompressionMethods().contains(CompressionMethod.NULL)); assertTrue("DEFLATE should get parsed correctly", config.getDefaultClientSupportedCompressionMethods() .contains(CompressionMethod.DEFLATE)); assertTrue("NULL should get parsed correctly", config.getDefaultServerSupportedCompressionMethods().contains(CompressionMethod.NULL)); assertTrue("DEFLATE should get parsed correctly", config.getDefaultServerSupportedCompressionMethods() .contains(CompressionMethod.DEFLATE)); }
@Test public void testNothingSetNothingChanges() { Config config = Config.createConfig(); Config config2 = Config.createConfig(); delegate.applyDelegate(config); assertTrue(EqualsBuilder.reflectionEquals(config, config2, "keyStore", "ourCertificate")); }