removed all XML-related code

This commit is contained in:
Gerardo Roza 2020-11-25 09:26:47 -03:00
parent 0185b2d0fb
commit aa44953fe9
18 changed files with 1 additions and 370 deletions

View File

@ -1,30 +0,0 @@
package com.baeldung.properties.core;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
public class ComponentInXmlUsingProperties implements InitializingBean {
@Autowired
private Environment env;
@Value("${key.something}")
private String injectedProperty;
public ComponentInXmlUsingProperties(final String propertyValue) {
super();
System.out.println("Constructor Injection - Property Value resolved to: " + propertyValue);
}
//
@Override
public void afterPropertiesSet() throws Exception {
System.out.println("in afterPropertiesSet via @Value: " + injectedProperty);
System.out.println("in afterPropertiesSet Environment: " + env.getProperty("key.something"));
}
}

View File

@ -1,16 +0,0 @@
package com.baeldung.properties.external;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
@ImportResource("classpath:configForProperties.xml")
@ComponentScan("com.baeldung.core")
public class ExternalPropertiesWithXmlConfig {
public ExternalPropertiesWithXmlConfig() {
super();
}
}

View File

@ -1,16 +0,0 @@
package com.baeldung.properties.external;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
@ImportResource("classpath:configForPropertiesOne.xml")
@ComponentScan("com.baeldung.core")
public class ExternalPropertiesWithXmlConfigOne {
public ExternalPropertiesWithXmlConfigOne() {
super();
}
}

View File

@ -1,14 +0,0 @@
package com.baeldung.properties.external;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
@ImportResource("classpath:basicConfigForPropertiesTwo.xml")
public class ExternalPropertiesWithXmlConfigTwo {
public ExternalPropertiesWithXmlConfigTwo() {
super();
}
}

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
>
<context:property-placeholder location="classpath:foo.properties"/>
</beans>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
>
<context:property-placeholder location="classpath:foo.properties" ignore-unresolvable="true" order="1"/>
</beans>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<context:property-placeholder location="classpath:bar.properties"
order="2" />
</beans>

View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
>
<context:property-placeholder location="classpath:database.properties"/>
<bean id="dataSource" class="com.baeldung.configurationproperties.Database">
<property name="url" value="${jdbc.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>
</beans>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
>
<context:property-placeholder location="classpath:foo.properties,classpath:bar.properties,classpath:database.properties"/>
<bean id="componentInXmlUsingProperties" class="com.baeldung.properties.core.ComponentInXmlUsingProperties">
<constructor-arg value="${key.something}"/>
</bean>
</beans>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
>
<context:property-placeholder location="classpath:foo.properties" ignore-unresolvable="true" order="1"/>
<bean id="componentInXmlUsingProperties" class="com.baeldung.properties.core.ComponentInXmlUsingProperties">
<constructor-arg value="${key.something2}"/>
</bean>
</beans>

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd"
>
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:foo.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
</beans>

View File

@ -1,27 +0,0 @@
package com.baeldung.properties.basic;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:basicConfigForPropertiesOne.xml", "classpath:basicConfigForPropertiesTwo.xml" })
public class PropertiesWithMultipleXmlsIntegrationTest {
@Autowired
private Environment env;
@Value("${key.something}")
private String injectedProperty;
@Test
public final void givenContextIsInitialized_thenNoException() {
System.out.println("in test via @Value: " + injectedProperty);
System.out.println("in test Environment: " + env.getProperty("key.something"));
}
}

View File

@ -1,27 +0,0 @@
package com.baeldung.properties.basic;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:basicConfigForProperties.xml")
public class PropertiesWithXmlIntegrationTest {
@Autowired
private Environment env;
@Value("${key.something}")
private String injectedProperty;
@Test
public final void givenContextIsInitialized_thenNoException() {
System.out.println("in test via @Value: " + injectedProperty);
System.out.println("in test Environment: " + env.getProperty("key.something"));
}
}

View File

@ -1,39 +0,0 @@
package com.baeldung.properties.external;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import com.baeldung.properties.external.ExternalPropertiesWithXmlConfigOne;
import com.baeldung.properties.external.ExternalPropertiesWithXmlConfigTwo;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { ExternalPropertiesWithXmlConfigOne.class, ExternalPropertiesWithXmlConfigTwo.class }, loader = AnnotationConfigContextLoader.class)
@Ignore("manual only")
public class ExternalPropertiesWithMultipleXmlsIntegrationTest {
@Autowired
private Environment env;
@Value("${key.something}")
private String injectedProperty;
@Value("${external.something}")
private String injectedExternalProperty;
@Test
public final void givenContextIsInitialized_thenNoException() {
System.out.println("in test via @Value: " + injectedProperty);
System.out.println("in test Environment: " + env.getProperty("key.something"));
System.out.println("in test via @Value - external: " + injectedExternalProperty);
System.out.println("in test Environment - external: " + env.getProperty("external.something"));
}
}

View File

@ -1,38 +0,0 @@
package com.baeldung.properties.external;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
import com.baeldung.properties.external.ExternalPropertiesWithXmlConfig;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { ExternalPropertiesWithXmlConfig.class }, loader = AnnotationConfigContextLoader.class)
@Ignore("manual only")
public class ExternalPropertiesWithXmlManualTest {
@Autowired
private Environment env;
@Value("${key.something}")
private String injectedProperty;
@Value("${external.something}")
private String injectedExternalProperty;
@Test
public final void givenContextIsInitialized_thenNoException() {
System.out.println("in test via @Value: " + injectedProperty);
System.out.println("in test Environment: " + env.getProperty("key.something"));
System.out.println("in test via @Value - external: " + injectedExternalProperty);
System.out.println("in test Environment - external: " + env.getProperty("external.something"));
}
}

View File

@ -1,25 +0,0 @@
package com.baeldung.properties.multiple;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@SpringJUnitConfig(locations = "classpath:configForPropertyPlaceholderBeans.xml")
public class MultiplePlaceholdersXmlConfigIntegrationTest {
@Value("${foo}")
private String something;
@Value("${key.something}")
private String something2;
@Test
public void whenReadInjectedValues_thenGetCorrectValues() {
assertThat(something).isEqualTo("bar");
assertThat(something2).isEqualTo("val");
}
}

View File

@ -1,24 +0,0 @@
package com.baeldung.properties.multiple;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat;
@SpringJUnitConfig(locations = {"classpath:configForProperties.xml", "classpath:configForDbProperties.xml"})
public class MultiplePropertiesXmlConfigIntegrationTest {
@Value("${key.something}") private String something;
@Value("${key.something2}") private String something2;
@Value("${jdbc.url}") private String jdbcUrl;
@Test
public void whenReadInjectedValues_thenGetCorrectValues() {
assertThat(something).isEqualTo("val");
assertThat(something2).isEqualTo("val2");
assertThat(jdbcUrl).isEqualTo("jdbc:postgresql:/localhost:5432");
}
}

View File

@ -5,22 +5,12 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
import com.baeldung.properties.basic.ExtendedPropertiesWithJavaIntegrationTest;
import com.baeldung.properties.basic.PropertiesWithMultipleXmlsIntegrationTest;
import com.baeldung.properties.basic.PropertiesWithXmlIntegrationTest;
import com.baeldung.properties.external.ExternalPropertiesWithJavaIntegrationTest;
import com.baeldung.properties.external.ExternalPropertiesWithMultipleXmlsIntegrationTest;
import com.baeldung.properties.external.ExternalPropertiesWithXmlManualTest;
import com.baeldung.properties.multiple.MultiplePropertiesXmlConfigIntegrationTest;
import com.baeldung.properties.multiple.MultiplePlaceholdersXmlConfigIntegrationTest;
@RunWith(Suite.class)
@SuiteClasses({ //@formatter:off
PropertiesWithXmlIntegrationTest.class,
ExternalPropertiesWithJavaIntegrationTest.class,
ExternalPropertiesWithMultipleXmlsIntegrationTest.class,
ExternalPropertiesWithXmlManualTest.class,
ExtendedPropertiesWithJavaIntegrationTest.class, MultiplePropertiesXmlConfigIntegrationTest.class,
PropertiesWithMultipleXmlsIntegrationTest.class, MultiplePlaceholdersXmlConfigIntegrationTest.class
ExtendedPropertiesWithJavaIntegrationTest.class,
})// @formatter:on
public final class IntegrationTestSuite {
//