本文整理汇总了Java中org.springframework.extensions.webscripts.DeclarativeWebScript类的典型用法代码示例。如果您正苦于以下问题:Java DeclarativeWebScript类的具体用法?Java DeclarativeWebScript怎么用?Java DeclarativeWebScript使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeclarativeWebScript类属于org.springframework.extensions.webscripts包,在下文中一共展示了DeclarativeWebScript类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeWebScript
import org.springframework.extensions.webscripts.DeclarativeWebScript; //导入依赖的package包/类
/**
* Execute web script and return result as a string.
*
* @param parameters map of all parameter values
* @return {@link String} result of web script
*/
protected String executeWebScript(Map<String, String> parameters, String content) throws Exception
{
DeclarativeWebScript webScript = getWebScript();
String template = getWebScriptTemplate();
// initialise webscript
webScript.init(getMockedContainer(template), getMockedDescription());
// execute webscript
WebScriptResponse mockedResponse = getMockedWebScriptResponse();
webScript.execute(getMockedWebScriptRequest(webScript, parameters, content), mockedResponse);
// return results
return mockedResponse.getWriter().toString();
}
示例2: getMockedWebScriptRequest
import org.springframework.extensions.webscripts.DeclarativeWebScript; //导入依赖的package包/类
/**
* Helper method to get the mocked web script request.
*
* @param webScript declarative web script
* @param parameters web script parameter values
* @return {@link WebScriptRequest} mocked web script request
*/
@SuppressWarnings("rawtypes")
protected WebScriptRequest getMockedWebScriptRequest(DeclarativeWebScript webScript, final Map<String, String> parameters, String content) throws Exception
{
Match match = new Match(null, parameters, null, webScript);
org.springframework.extensions.webscripts.Runtime mockedRuntime = mock(org.springframework.extensions.webscripts.Runtime.class);
WebScriptRequest mockedRequest = mock(WebScriptRequest.class);
doReturn(match).when(mockedRequest).getServiceMatch();
doReturn(mockedRuntime).when(mockedRequest).getRuntime();
if (content != null && !content.isEmpty())
{
Content mockedContent = mock(Content.class);
doReturn(content).when(mockedContent).getContent();
doReturn(mockedContent).when(mockedRequest).getContent();
}
String [] paramNames = (String[])parameters.keySet().toArray(new String[parameters.size()]);
doReturn(paramNames).when(mockedRequest).getParameterNames();
doAnswer(new Answer()
{
@Override
public Object answer(InvocationOnMock invocation) throws Throwable
{
String paramName = (String)invocation.getArguments()[0];
return parameters.get(paramName);
}
}).when(mockedRequest).getParameter(anyString());
doReturn(new String[0]).when(mockedRequest).getHeaderNames();
doReturn("json").when(mockedRequest).getFormat();
return mockedRequest;
}
示例3: getWebScript
import org.springframework.extensions.webscripts.DeclarativeWebScript; //导入依赖的package包/类
/**
* @see org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest#getWebScript()
*/
@Override
protected DeclarativeWebScript getWebScript()
{
return webScript;
}
示例4: getWebScript
import org.springframework.extensions.webscripts.DeclarativeWebScript; //导入依赖的package包/类
/**
* @see org.alfresco.module.org_alfresco_module_rm.recorded.version.config.BaseRecordedVersionConfigTest#getWebScript()
*/
@Override
protected DeclarativeWebScript getWebScript()
{
return webScript;
}
示例5: getWebScript
import org.springframework.extensions.webscripts.DeclarativeWebScript; //导入依赖的package包/类
/**
* @return declarative webscript
*/
protected abstract DeclarativeWebScript getWebScript();