Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to test a Controller, specifying a Tiles ViewResolver?

 
Ranch Hand
Posts: 58
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is a pretty basic issue, but after Googling and trying various things I have had no success.

I suppose this is an integration test given that it'll also be testing my tiles configuration, though my initial intent was to find the simplest way to unit test the controller. I have actually written the simple controller I'm trying to test, and my tiles configuration works fine.

I have a Spring Boot app with three Java configuration classes (listed in the code below).As you can see from my failed attempt, I'm simply trying to test that a specific view name is returned, at this stage. What I haven't been able to do is configure the test so that it uses my existing ViewResolver. I've seen examples that create a new ViewResolver in the setup method, but... DRY.



The above code results in the following Exception:
java.lang.NullPointerException at org.apache.tiles.request.ApplicationAccess.register(ApplicationAccess.java:50)

How should I be going about this?

Thanks.
 
Gordon Brown
Ranch Hand
Posts: 58
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just in case anyone comes across this issue in future: I needed to add ...and the name of the class to be passed to the @SpringApplicationConfiguration was that of the Spring Boot Application e.g.

 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Gordy for coming back and telling us what worked. That'll help others in future. Have a cow for the effort!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic