@Test public void testExplicitPropertyMappings() { Map<String, String> properties = new ImmutableMap.Builder<String, String>() .put("jmx.dump-tables", "table1,table\\,with\\,commas") .put("jmx.dump-period", "1s") .put("jmx.max-entries", "100") .build(); JmxConnectorConfig expected = new JmxConnectorConfig() .setDumpTables(ImmutableSet.of("table1", "table,with,commas")) .setDumpPeriod(new Duration(1, TimeUnit.SECONDS)) .setMaxEntries(100); assertFullMapping(properties, expected); assertDeprecatedEquivalence(JmxConnectorConfig.class, properties); } }
@Test public void testNoDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .put("home-page", "http://example.com") .build(); ConfigAssertions.assertDeprecatedEquivalence(NoDeprecatedConfig.class, currentProperties); }
@Test public void testDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("store.ttl", "1h") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("store.ttl-in-ms", "3600000") .build(); ConfigAssertions.assertDeprecatedEquivalence(StoreConfig.class, currentProperties, oldProperties); } }
@Test public void testNoDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .put("home-page", "http://example.com") .build(); ConfigAssertions.assertDeprecatedEquivalence(NoDeprecatedConfig.class, currentProperties); }
@Test public void testNoDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .put("home-page", "http://example.com") .build(); ConfigAssertions.assertDeprecatedEquivalence(NoDeprecatedConfig.class, currentProperties); }
@Test public void testDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("http-client.idle-timeout", "111m") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("http-client.read-timeout", "111m") .build(); ConfigAssertions.assertDeprecatedEquivalence(HttpClientConfig.class, currentProperties, oldProperties); }
@Test public void testDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("http-client.idle-timeout", "111m") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("http-client.read-timeout", "111m") .build(); ConfigAssertions.assertDeprecatedEquivalence(HttpClientConfig.class, currentProperties, oldProperties); }
@Test public void testDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("http-client.idle-timeout", "111m") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("http-client.read-timeout", "111m") .build(); ConfigAssertions.assertDeprecatedEquivalence(HttpClientConfig.class, currentProperties, oldProperties); }
@Test public void testDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("http-client.max-threads", "111") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("http-client.threads", "111") .build(); ConfigAssertions.assertDeprecatedEquivalence(JettyIoPoolConfig.class, currentProperties, oldProperties); } }
@Test public void testDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .put("home-page", "http://example.com") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .put("home-page", "http://example.com") .build(); Map<String, String> olderProperties = new ImmutableMap.Builder<String, String>() .put("notes-id", "alice@example.com") .put("home-page-url", "http://example.com") .build(); ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties, olderProperties); }
@Test public void testDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .put("home-page", "http://example.com") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .put("home-page", "http://example.com") .build(); Map<String, String> olderProperties = new ImmutableMap.Builder<String, String>() .put("notes-id", "alice@example.com") .put("home-page-url", "http://example.com") .build(); ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties, olderProperties); }
@Test public void testDeprecatedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .put("home-page", "http://example.com") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .put("home-page", "http://example.com") .build(); Map<String, String> olderProperties = new ImmutableMap.Builder<String, String>() .put("notes-id", "alice@example.com") .put("home-page-url", "http://example.com") .build(); ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties, olderProperties); }
@Test public void testDeprecatedPropertiesFailUnsupportedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .put("unsupported-property", "value") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .build(); Map<String, String> olderProperties = new ImmutableMap.Builder<String, String>() .put("notes-id", "alice@example.com") .build(); boolean pass = true; try { ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties, olderProperties); } catch (AssertionError e) { // expected pass = false; assertContains(e.getMessage(), "unsupported-property"); } if (pass) { fail("Expected AssertionError"); } }
@Test public void testDeprecatedPropertiesFailUntestedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .build(); boolean pass = true; try { ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties); } catch (AssertionError e) { // expected pass = false; assertContains(e.getMessage(), "notes-id"); } if (pass) { fail("Expected AssertionError"); } }
@Test public void testDeprecatedPropertiesFailUntestedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .build(); boolean pass = true; try { ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties); } catch (AssertionError e) { // expected pass = false; assertContains(e.getMessage(), "notes-id"); } if (pass) { fail("Expected AssertionError"); } }
@Test public void testDeprecatedPropertiesFailUntestedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .build(); boolean pass = true; try { ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties); } catch (AssertionError e) { // expected pass = false; Assertions.assertContains(e.getMessage(), "notes-id"); } if (pass) { Assert.fail("Expected AssertionError"); } }
@Test public void testDeprecatedPropertiesFailDeprecatedCurrentProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("notes-id", "alice@example.com") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .build(); Map<String, String> olderProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .build(); boolean pass = true; try { ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties, olderProperties); } catch (AssertionError e) { // expected pass = false; assertContains(e.getMessage(), "notes-id"); } if (pass) { fail("Expected AssertionError"); } }
@Test public void testDeprecatedPropertiesFailDeprecatedCurrentProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("notes-id", "alice@example.com") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .build(); Map<String, String> olderProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .build(); boolean pass = true; try { ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties, olderProperties); } catch (AssertionError e) { // expected pass = false; assertContains(e.getMessage(), "notes-id"); } if (pass) { fail("Expected AssertionError"); } }
@Test public void testDeprecatedPropertiesFailUnsupportedProperties() { Map<String, String> currentProperties = new ImmutableMap.Builder<String, String>() .put("email", "alice@example.com") .put("unsupported-property", "value") .build(); Map<String, String> oldProperties = new ImmutableMap.Builder<String, String>() .put("exchange-id", "alice@example.com") .build(); Map<String, String> olderProperties = new ImmutableMap.Builder<String, String>() .put("notes-id", "alice@example.com") .build(); boolean pass = true; try { ConfigAssertions.assertDeprecatedEquivalence(PersonConfig.class, currentProperties, oldProperties, olderProperties); } catch (AssertionError e) { // expected pass = false; assertContains(e.getMessage(), "unsupported-property"); } if (pass) { fail("Expected AssertionError"); } }
@Test public void testExplicitPropertyMappings() { Map<String, String> properties = new ImmutableMap.Builder<String, String>() .put("jmx.dump-tables", "table1,table\\,with\\,commas") .put("jmx.dump-period", "1s") .put("jmx.max-entries", "100") .build(); JmxConnectorConfig expected = new JmxConnectorConfig() .setDumpTables(ImmutableSet.of("table1", "table,with,commas")) .setDumpPeriod(new Duration(1, TimeUnit.SECONDS)) .setMaxEntries(100); assertFullMapping(properties, expected); assertDeprecatedEquivalence(JmxConnectorConfig.class, properties); } }