1

I have a following property declared at my Spring Boot/Maven project:

@Value("${download.folder.path}")
private String downloadFolderPath;

where download.folder.path is a property declared at my application.properties file and at Maven profile.

Right now the property value is something like this:

<download.folder.path>d:/somedir</download.folder.path>

Everything works fine but I want to point download.folder.path property to default system temp folder for my tests instead of providing a real path.

Is it possible with Spring/Maven configuration?

alexanoid
  • 24,051
  • 54
  • 210
  • 410
  • What do you mean by "default system temp folder"? Unless there's an environment variable for this, I'm afraid it's impossible. – Sir4ur0n Jun 11 '17 at 21:50

3 Answers3

3

Use reference to java tmp dir property (check System.getProperty("java.io.tmpdir")) and reference the property like this

<download.folder.path>{java.io.tmpdir}</download.folder.path>

See the reference properties here

StanislavL
  • 56,971
  • 9
  • 68
  • 98
0

If you are using Spring Boot, check out @TestPropertySource.

https://docs.spring.io/spring/docs/current/spring-framework-reference/html/integration-testing.html#__testpropertysource

You should be able to use that to point to /tmp or wherever.

olan
  • 3,568
  • 5
  • 24
  • 30
0

1.)Writing below in SpringBoot main class for whole application to be working :

System.setProperty("java.io.tmpdir", "C:\\Users\\abcde\\Desktop\\Temp");

2.)While Running JUnit in Spring Boot application , I have set -Djava.io.tmpdir=C:\Work\TEMP in VM Arguments and it worked for me . enter image description here

Ashutosh Shukla
  • 557
  • 5
  • 9