demos/testing
3 years agoTODO: Layout genĂ¼gend angepasst? exception-handling-todo
Kai Moritz [Sun, 20 Sep 2020 12:43:32 +0000 (14:43 +0200)]
TODO: Layout genĂ¼gend angepasst?
Added a layout

3 years agoAdded a customized error-page
Kai Moritz [Sun, 20 Sep 2020 13:05:12 +0000 (15:05 +0200)]
Added a customized error-page

3 years agoAdded an integration-test that tests the exception-handling
Kai Moritz [Sat, 19 Sep 2020 12:08:38 +0000 (14:08 +0200)]
Added an integration-test that tests the exception-handling

* The integration-test uses WebTestClient to test the exception-handling
* Since this is a real integration-test, the exception-handling behave
  exactly the same way
* The test-setup with the WebTestClient needs an additional dependency, to
  work correctly - without it, the WebTestClient-Bean would not be intanciated
* The added test ExceptionHandlingApplicationIT tests exaclty the same stuff,
  as ExceptionHandlingApplicationTest - this is no good test-design, but it
  serves the intention, to compare the two approaches
* Since Spring-Boot configures the surefire-maven-plugin to ignore all tests,
  that end with IT, the failsafe-maven-plugin has to be added to automatically
  fire the new test - remember: you have to call "mvn verify" to fire IT

3 years agoTODO... Passt der neue Test noch?
Kai Moritz [Sat, 19 Sep 2020 11:54:30 +0000 (13:54 +0200)]
TODO... Passt der neue Test noch?
Added a working component-test for exceptions, thrown outside of controllers

3 years agoTODO: An neuen Fehler anpassen, Separates Fehler-Template weg? Mehr...?
Kai Moritz [Sat, 19 Sep 2020 10:46:52 +0000 (12:46 +0200)]
TODO: An neuen Fehler anpassen, Separates Fehler-Template weg? Mehr...?
Added a working @ExceptionHandler

* Both handlers resolve the handled exception as 503 Internal Server Error
  and are using the template "error/503", which was extended to print a
  message, that the reported exception was catched and handled.
* If one starts the app, it is clearly visible, that the mechanism only
  works for exceptions, that are thrown in the context of the controller.
* Also added a test-case, that shows, that MockMvc shows the expected
  behaviour for exceptions, that are thrown inside the container.

3 years agoWIP:Further refined the example...
Kai Moritz [Sun, 27 Sep 2020 17:59:16 +0000 (19:59 +0200)]
WIP:Further refined the example...

* The view renders the question, if no answer is specified (initial request!)
* If a valid request is specified, the answer and the outcome is rendered
* If an invalid request (negative number!) is specified, the view generates
  an exception, because it tries to resolve the Optional anyway

3 years agoAdded spring-boot-devtools
Kai Moritz [Sun, 27 Sep 2020 17:54:53 +0000 (19:54 +0200)]
Added spring-boot-devtools

3 years agoFurther refined the example
Kai Moritz [Sun, 27 Sep 2020 09:23:03 +0000 (11:23 +0200)]
Further refined the example

* Introduced an ExampleService
* The service checks the answer for
  The Ultimate Question Of Life, The Universe And Everything
* Requests without any answer are tolarated, so that the page with the
  question can be rendered
* Only numbers (Integer) are allowed as answer.
* Negative numbers are not allowed as answers: the service answers with an
  empty Optional.
* The view contains a bug, that results in a 503 for negative answers.

3 years agoRefined the example, to clearify the intent
Kai Moritz [Sat, 19 Sep 2020 08:24:44 +0000 (10:24 +0200)]
Refined the example, to clearify the intent

* Removed unnecessary Annotation from test
* Renamed and pimped up the example templates
* Splitted up the test in separate units
* Remapped the controller to the root of the web-context
* Switched to @WebMvcTest, to load only the controller-layer

3 years agoRenamed and repackaged the example for the blog-article
Kai Moritz [Sat, 19 Sep 2020 08:11:41 +0000 (10:11 +0200)]
Renamed and repackaged the example for the blog-article

3 years agoInitial Commit: Spring-Boot-Project, that pinns down a bug in a test-case
Kai Moritz [Sat, 19 Sep 2020 07:50:41 +0000 (09:50 +0200)]
Initial Commit: Spring-Boot-Project, that pinns down a bug in a test-case

* I stumbled accros the unexpected behaviour of Springs MockMvc in a
  test-case for one of my projects.
* This version pinned down the unexpected behaviour explicitly.