SimplePropertySource extends BasePropertySource { @Override public Map<String, PropertyValue> getProperties() { return this.properties; } SimplePropertySource(File propertiesLocation);  SimplePropertySource(URL propertiesLocation);  SimplePropertySource(String name, Map<String, String> properties, int defaultOrdinal);  SimplePropertySource(String name, Map<String, String> properties);  SimplePropertySource(String name, URL propertiesLocation); private  SimplePropertySource(Builder builder); static Builder newBuilder(); @Override Map<String, PropertyValue> getProperties(); @Override ChangeSupport getChangeSupport();  }
@Test public void successfulCreationWithPropertiesFromXMLPropertiesFile() throws URISyntaxException { URL resource = getClass().getResource("/valid-properties.xml"); File resourceFile = new File(resource.toURI()); SimplePropertySource source = new SimplePropertySource(resourceFile); assertThat(source).isNotNull(); assertThat(source.getProperties()).hasSize(2); assertThat(source.getProperties()).contains(entry("a", PropertyValue.createValue("a", "b"))); assertThat(source.getProperties()).contains(entry("b", PropertyValue.createValue("b", "1"))); }
@Test public void successfulCreationWithPropertiesFromURL() throws URISyntaxException { URL resource = getClass().getResource("/valid-properties.xml"); SimplePropertySource source = new SimplePropertySource(resource); assertThat(source).isNotNull(); assertThat(source.getProperties()).hasSize(2); assertThat(source.getProperties()).contains(entry("a", PropertyValue.createValue("a", "b"))); assertThat(source.getProperties()).contains(entry("b", PropertyValue.createValue("b", "1"))); }
@Test public void successfulCreationWithPropertiesFromXMLPropertiesResource() { URL resource = getClass().getResource("/valid-properties.xml"); SimplePropertySource source = new SimplePropertySource(resource); assertThat(source).isNotNull(); assertThat(source.getProperties()).hasSize(2); assertThat(source.getProperties()).contains(entry("a", PropertyValue.createValue("a", "b"))); assertThat(source.getProperties()).contains(entry("b", PropertyValue.createValue("b", "1"))); }
@Test public void successfulCreationWithProperties() { URL resource = getClass().getResource("/valid-properties.xml"); Map<String,String> props = new HashMap<>(); props.put("a", "b"); props.put("b", "1"); SimplePropertySource source = new SimplePropertySource("test", props); assertThat(source).isNotNull(); assertThat(source.getProperties()).hasSize(2); assertThat(source.getProperties()).contains(entry("a", PropertyValue.createValue("a", "b").setMeta("source", "test"))); assertThat(source.getProperties()).contains(entry("b", PropertyValue.createValue("b", "1").setMeta("source", "test"))); }
@Test public void successfulCreationWithPropertiesFromSimplePropertiesFile() { URL resource = getClass().getResource("/testfile.properties"); SimplePropertySource source = new SimplePropertySource(resource); assertThat(source).isNotNull(); assertThat(source.getProperties()).hasSize(5); }
@Test public void testWithMap() { Map<String, String> propertyFirst = new HashMap<>(); propertyFirst.put("firstKey", "firstValue"); SimplePropertySource source = new SimplePropertySource("testWithMap", propertyFirst, 166); assertThat(source.getName()).isEqualTo("testWithMap"); assertThat(source.getDefaultOrdinal()).isEqualTo(166); assertThat(source.getProperties()).containsKey("firstKey"); }
@Test public void getProperties() throws Exception { SimplePropertySource ps1 = SimplePropertySource.newBuilder() .withUuidName() .withProperty("a", "b") .build(); assertThat(ps1.getProperties()).isNotNull(); assertThat(ps1.getProperties()).hasSize(1); assertThat(ps1.getProperties().get("a").getValue()).isEqualTo("b"); }