Why serenity configs cannot be loaded from application.yml - spring

I have spring boot application with tests done in cucumber and serenity.
serenity.conf file is properly traversed and all options are working. Even with serenity.properties it is working fine. How to make it work in application.yml?

Related

Thymeleaf cache set to false not working

I have a spring application under development.
The configuration of the project is as follows:
spring-dev-tools dependency is one of the maven dependencies
thymeleaf dependency is added through spring-boot-starter, that is org.springframework.boot:spring-boot-starter-thymeleaf
I have explicitly disabled template cache with spring.thymeleaf.cache=false
The src/main/resources folder is marked as resource in my IntelliJ IDEA project.
I am using IntelliJ IDEA project to run the application.
When I run the application, I can see in the console output that: LiveReload server is running on port 35729
Although, it seems like all my configuration is correct, the running application is not loading any changes I made to the templates while it is running.
If you are using Spring Tool Suite 4, you need to implement the following in your application.properties to disable the cache from Thymeleaf:
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=file:src/main/resources/templates/
Adding the spring.thymeleaf.prefix value worked for me.
For more information about the solution:
https://github.com/spring-projects/spring-boot/issues/34#issuecomment-316295791
The LiveReload server loads any changes only when one of the files on the classpath is modified Spring Doc.
Though I have resources, the folder containing templates folder, on the classpath, the changes to the html files in templates folder are not reflected in the running application.
What worked for me is to also add src/main/resources/templates to the classpath i.e. marked as resource in IntelliJ
Thanks

RestAssured Spring Boot Test returning 404s

I am building an API using Spring Boot and Katharsis. When writing integration tests using RestAssured my tests are passing in STS but getting 404s in Maven. I'm not sure what the difference might be or why it isn't working.
Running the API things are working as expected.
I was wondering if anyone had any thoughts?
Code Repo is here: https://github.com/Holmes89/liturgical-project
So the problem had to do with the fact Reflections wasn't populating my ResourcesRepository on test startup. I found a similar problem here:
Unit test using the Reflections google library fails only when executed by Maven
And used the following link to configure the Maven Surefire Plugin:
http://maven.apache.org/surefire/maven-surefire-plugin/examples/class-loading.html
Adding the following config helped:
<useSystemClassLoader>false</useSystemClassLoader>

Prevent SpringBoot from creating an EmbeddedServletContainer

I'm trying to convert an existing spring application into a spring boot application. this application is not a web application but somewhere deep in it's maven dependencies hierarchy it includes a spring-web jar and therefore spring-boot tries to autoconfigure a WebEnvironment and in turn complains about not finding an EmbeddedServletContainerFactory. But this is intended as I'm using spring-boot-starter instead of spring-boot-starter-web.
My questing is: how can I prevent spring-boot from autodiscovering web specific items in the classpath? I already tried something like
#EnableAutoConfiguration(exclude = { EmbeddedServletContainerAutoConfiguration.class })
but it doesn't seem to work. Debugging the startup process I see that it runs into a method called deduceWebEnvironment() which is called unconditionally. This method returns true as soon as the following classes are on the classpath:
javax.servlet.Servlet, org.springframework.web.context.ConfigurableWebApplicationContext
But again, even this classes exist in the cp, I don't want to startup a web-application.
Try new SpringApplicationBuilder(YourApp.class).setWebEnvironment(false).run(args) You can also disable the web mode via configuration in application.properties
spring.main.web-environment=false
See the documentation

Springboot finds files in src/main/webapp but not src/main/webapp/anything

I'm using Sprint boot to run a web application. I did not configure any classes explicitly. I have a strange problem. When running the web server using gradle bootRun, I am able to access files that are directly under webapp folder but not a sub-folder like webapp/something.
I'm not posting any code here because there is nothing explicitly I configured different from a default spring boot web app. I'm using structure as in https://github.com/jhipster/jhipster-sample-app-gradle
Anyone faced this problem before ?

End to end test across multi Spring Boot applications

Currently in our project, we are using Spring Integration to integrate many service and some protocol related endpoints.
The project is a multi Spring Boot applications, more than one executable jars will be deployed in production.
The question is:
How to run an end to end test which needs to run cross some of these applications, I have to run the one by one manually? In before none-Spring-Boot applications, I can use Maven tomcat7 plugin to complete this work(deploy the wars into an embedded tomcat and run it in pre-integration-test phase), now how to start up all related applications before I run my test. Assume I do not use Docker/Vagrant now.
Similar question found on stackoverflow, End to end integration test for multiple spring boot applications under Maven
How to run the end2end test automatically?
In an Spring Integration test, sometime I have to mock a http endpoint, so I wrote a simple Controller in test package to archive this purpose, but I want to run it at a different port, which make it more like an outside resource. How to run different #SpringBootApplicaiton classes at varied ports at the same time in the test for this purpose?
I am using the latest Maven, Java 8, Spring Boot 1.3.1.RELEASE.
Actually, Spring Boot comes with the embedded Servlet Container support. One of them is exactly Tomcat. The default on for the org.springframework.boot:spring-boot-starter-web.
With the org.springframework.boot:spring-boot-starter-test and its #SpringApplicationConfiguration and #WebIntegrationTest you can achieve your requirements, even with the random port.
Please, refer to the Spring Boot Reference Manual for more information:
To change the port you can add environment properties to #WebIntegrationTest as colon- or equals-separated name-value pairs, e.g. #WebIntegrationTest("server.port:9000"). Additionally you can set the server.port and management.port properties to 0 in order to run your integration tests using random ports.
With that your #SpringBootApplicaiton will be deployed to that embedded Tomcat and your test can get access to the ran services/controllers.
Note: it doesn't matter if your Spring Boot application has Spring Integration facilities. The behavior is the same: embedded Servlet Container and integration tests against #Value("${local.server.port}").

Resources