Hello, I'm writing a java library in which I need to include some functionality that need a RenderingContext instance to work.
For example I need to extract an ImageContentComponent url, and the only way to do that (as I know) is to run
workspace.generateURL(RenderingContext context, ContentComponent component)
Another example: I need to render a content, so the api to call is
What I don't have in my library, is an instance of RenderingContext, because I want to do those operation and obtain the HTML code even without a real RenderingContext.
Why? For example simply because I need to run those operations inside a custom workflow action, where a RenderingContext is not available.
The api to create a RenderingContext is:
RenderingContext context = workspace.createRenderingContext(servletRequestObj,
do you actually have any idea on what to pass as
Is there any usable mock class?
Pinned topic WCM java api: how to create a fake rendering context?
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-08-02T07:42:50Z at 2012-08-02T07:42:50Z by nchieffo
nchieffo 270004C2XK2 Posts
Re: WCM java api: how to create a fake rendering context?2012-08-02T07:42:50ZThis is the accepted answer. This is the accepted answer.I've got a solution for this: you need the spring-core and spring-test jars.
String wcmHost = "http://localhost:10039";
String wcmServletPath = "/wps/wcm/connect";
String wcmWebAppPath = wcmHost + wcmServletPath;
ServletRequest request = new MockHttpServletRequest();
ServletResponse response = new MockHttpServletResponse();
HashMap<String, String> params = new HashMap<String, String>();
RenderingContext renderingContext = _workspace.createRenderingContext(request, response, params);