0

I am adding cargo and failsafe to my Spring-Boot application.

Failsafe: Great. Finds my 1 IT and runs it fine as long as I have the localhost running. Up until now, I have gotten by with running it locally and then running the IT.

maven: Also great. It builds correctly with a minimum of fuss

Cargo: I am going nuts.

I have 3 property files that the Spring-Boot application resolves. Everything works and when I'm doing unit tests with SpringBootTest, it's great and everything resolves. (I have an application.properties in /src/main/resources and a test version in /src/test/resources and then a third outside my jar.)

When I try to start the application in cargo, only the /src/main/resources is loaded. I'm going nuts trying to figure out how to provide those other two files.

I've tried:

  1. tried
@TestSource(location = { "..../path/to/application.properties" })
@Theories
public class MyIT {
  1. I tried adding to the arguments in my IDE. This worked, but I do not want to have all of that on the command line since there will be some security things.

  2. I tried adding to the systemProperties, but that didn't work for spring properties.

How can I specify spring properties (not -Dsystem.properties) to cargo? This is going to be on a corporate Bamboo, and everything but this works. I even have sensitive properties encrypted with JaSypt, so that they aren't hanging around in the clear. I suppose I could re-run the verify task and use the spring arguments on the command line there, but it would be much better if it would just use the Spring properties.

There has to be a way to give cargo arguments that don't clobber everything else?

Edited and Added I'm looking to do Selenium/HTMLUnit tests for the front end. @SpringBootTest is not working for these automated tests, so the application properties are getting clobbered. The regular tests (i.e. mvn test) work fine. The running of the application (i.e. java -jar MyApp.jar) works fine and uses the internal, embedded Tomcat just fine. I'm looking for a setup that will run on mvn verify, start the application in some kind of background (such as cargo?), and then run the tests.

I admit I'm not familiar with front end testing. If cargo still isn't the right tool, then I would appreciate tips on what is.

newbo
  • 163
  • 1
  • 9
  • 1
    If you are using Spring Boot, is there is constraint that obliges you to use cargo instead of FAT jar? – HL'REB Nov 13 '19 at 15:44
  • @HL'REB - my ignorance? Sorry--this is my first attempt at doing a full integration suite. Could you please provide a link to FAT jar? Right now it's a Spring MVC project with an executable jar. I need some way to run it so that my integration tests can get to "https://localhost:8443" because I am eventually putting this into Bamboo or Jenkins to build. – newbo Nov 13 '19 at 19:45
  • I did a quick google, and I am not sure if shade FAT jar will work. I am using Spring Boot (with all the properties files and stuff that means). All I need is a way to run the executable jar so that I can run my integration tests. It seemed like cargo would do that, but it never picks up any of the properties files except for the one inside /src/main/resources -- no /src/test/resources or anything. – newbo Nov 13 '19 at 19:50
  • Spring Boot supports, out of the box, the creation of an executable Jar that already contains all the depenencies (including Tomcat embedded). That Jar will be launched using java -jar command. This article explains how to it works (https://www.baeldung.com/spring-boot-run-maven-vs-executable-jar). All you have to do is to inclue spring-boot-maven-plugin in your POM file. Also, if you are not familiar with Spring Boot, go to start.spring.io. The Initializr application will allow you to download a working application with a Fat Jar (using Gradle or Maven). You can start from there. – HL'REB Nov 13 '19 at 21:11
  • I appreciate your article, but I have apparently failed to be clear. I already have the Spring MVC executable. It already runs with "java -jar Blahblah.jar" in production use. It runs an instance of Tomcat inside of it as a part of the spring boot starters I used. I need to find a way to get Cargo or something similar to run it fully in the background as my integration and front end tests run. My integration and front end tests require that the application be fully running--in the embedded Tomcat until there's some way to automate that--so that they can run. – newbo Nov 13 '19 at 21:35
  • You don't need cargo. Your integration test can start the application (that is what the `@SpringBootTest` is for. If you want to run it externally, then just run it externally. You don't need cargo for that, just execute `java -jar `. – M. Deinum Nov 14 '19 at 07:25
  • @M.Deinum - I have already tried to run the tests with `@SpringBootTest`. The HTMLUnit/Selenium doesn't resolve the paths and the headless browser doesn't seem to run. I'll try again, but I have doubts. – newbo Nov 14 '19 at 12:45
  • @HL'REB - I am aware the Spring Boot supports that. It's literally what I'm using in production. Unfortunately, I am asking about how to do this automatically in `mvn verify` so that I can run front end tests in my builds. – newbo Nov 14 '19 at 12:46
  • @M.Deinum - As expected, the `@SpringBootTest` does not allow HTMLUnit/Selenium to find the pages. Unfortunately, this is not the way to have my tests work and the error is `Connection refused`. – newbo Nov 14 '19 at 12:54
  • So, the unfortunate thing is that to get cargo and so on to run, I've had to expand the application properties in /src/main/resources. – newbo Nov 14 '19 at 12:55
  • If you use Selenium (please add that to your question) you need to write a little integration to bootstrap the SPring BOot application as the runner used doesn't support the spring annotations. – M. Deinum Nov 14 '19 at 12:55
  • @M. Deinum - I'll add it to the question. – newbo Nov 14 '19 at 12:57

0 Answers0