-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Mockito for Spring
By :
The Environment interface and the PropertySource class were added to Spring 3.1 in order to simplify working with properties. In Spring 3.2, MockEnvironment and MockPropertySource were added to the mock properties in tests. We'll create a program to configure a bean from a properties file value and then mock out the properties file value with MockEnvironment and MockPropertySource.
The following are the steps:
Create a myProp.properties properties file under the test source folder and add the following property:
message = I'm the king
You can define a Spring configuration context by annotating a class with the @Configuration annotation. The @PropertySource annotation takes the properties' filenames and sets the properties to the Environment resource. Create a MyConfig configuration class under the com.packt.environment package. The following is the configuration class:
@Configuration
@PropertySource({"classpath:myProp.properties"})
public class MyConfig {
@Resource...
Change the font size
Change margin width
Change background colour