0

I'm trying to configure property for test, using @ConfigurationProperties.

My config-class with properties:

 @Data
 @Configuration
 @ConfigurationProperties(prefix = "data")
 public class TestFileSettings {
     private String dockerMountPath;
}

Property-file "application-test.properties" contains:

data.docker_mount_path=testMountHostDirectory/

And test-class:

  @ActiveProfiles("test")
  @TestPropertySource(locations = "classpath:application-test.properties")
  @EnableConfigurationProperties(value = {TestFileSettings.class})
  @RunWith(SpringRunner.class)
  @SpringBootTest()
  public class PropertyAcessTest {
       @Autowired
       private TestFileSettings testFileSettings;

       @Test()
       public void testPropertyAcess() {        
       String getDockerMountPath = testFileSettings.getDockerMountPath();
       assertEquals("testMountHostDirectory/", getDockerMountPath)
     {

But I get the following error:

  error: cannot find symbol
    String getDockerMountPath = testFileSettings.getDockerMountPath();
                                                ^
 symbol:   method getDockerMountPath()
 location: variable testFileSettings of type TestFileSettings

What am I doing wrong?

Ryuzaki L
  • 37,302
  • 12
  • 68
  • 98
Jelly
  • 972
  • 1
  • 17
  • 40
  • 2
    looks like your lombok is not enabled for test compile time – Ryuzaki L Feb 02 '21 at 15:18
  • Yep, apart from the prior comment it seems that the title of this question is slightly misleading as this one seems to be an issue at compile time. Spring Boot hasn't got the chance yet to apply any properties. ;-) – mle Feb 02 '21 at 17:16
  • Deadpool, yes, its lombok jokes!) – Jelly Feb 03 '21 at 08:03

0 Answers0