/** * Tests the Builder for ServiceBuilderConfig. */ @Test public void testBuilder() throws Exception { final int propertyCount = 20; // Create three raw Properties. val p1 = buildProperties(0, propertyCount / 2, 0); val p2 = buildProperties(propertyCount / 4, propertyCount / 2, 100); val p3 = buildProperties(propertyCount / 2, propertyCount / 2, 1000); // Save #1 to a temp file. @Cleanup("delete") File tmpFile = File.createTempFile("pravega-", "-servicebuildertest"); try (val writer = new FileWriter(tmpFile)) { p1.store(writer, ""); } // Create a builder and load up #1 from file val b = ServiceBuilderConfig.builder().include(tmpFile.getPath()); val expected = new Properties(); expected.putAll(p1); verifyContents("Unexpected contents after: file. ", expected, b); // Include #2. b.include(p2); expected.putAll(p2); verifyContents("Unexpected contents after: file + Properties.", expected, b); // Include a test config builder with #3. b.include(new ConfigBuilderSupplier<>(p3, s -> s)); expected.putAll(p3); verifyContents("Unexpected contents after: file + Properties + ConfigBuilder.", expected, b); }
&& isSupportedType(f.getGenericType().getTypeName())) { @SuppressWarnings("rawtypes") Property p = (Property) f.get(null); Object actualValue = m.invoke(actualConfig); if (expectedValue == null) { Assert.assertNull("Expected a null value for " + getPropName(c, m), actualValue); } else { Assert.assertNotNull("Not expected a null value for " + getPropName(c, m), actualValue); if (isSupportedType(expectedValue)) { Assert.assertEquals("Unexpected value for " + getPropName(c, m), expectedValue, actualValue);