Reputation: 389
I want a to create a test for my spring boot application that uses specific JVM arguments, I want the JVM arguments to be used with only this test.
Is this possible ? My goal is to set up a proxy for just one test, so if there is another approach to achieve that, please suggest it.
Upvotes: 0
Views: 10452
Reputation: 389
I solved this by adding a static bloc in the class and setting the system properties:
static {
System.setProperty("http.proxyHost", "myproxyserver.com");
System.setProperty("http.proxyPort", "80");
System.setProperty("https.proxyHost", "myproxyserver.com");
System.setProperty("https.proxyPort", "80");
}
Upvotes: 12
Reputation: 4146
If you're using IntelliJ Idea, you can pass arguments to test from Run/Debug configuration -> VM options. If you're using Maven, you can pass arguments in surefire-plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx1G</argLine>
</configuration>
</plugin>
And remember, that Maven options overrides Idea defaults (if set).
Upvotes: 1