final AssetResolverMock assetResolverMock =
new AssetResolverMock("assetResolverMock", expectations);
policyReferenceFactoryMock.fuzzy.createLazyNormalizedReference(
runtimeProjectMock, null, mockFactory.expectsInstanceOf(String.class),
PolicyType.SCRIPT).does(new MethodAction(){
public Object perform(MethodActionEvent event) throws Throwable {
final String url = (String) event.getArguments()[2];
if (url.startsWith("URL")) {
return urlRuntimePolicyReferenceMock;
} else {
return noUrlRuntimePolicyReferenceMock;
}
}
}).any();
final SelectedVariantMock selectedVariantMock =
new SelectedVariantMock("selectedVariantMock", expectations);
selectedVariantMock.expects.getOldObject().does(new MethodAction(){
public Object perform(MethodActionEvent event) throws Throwable {
return new ScriptAsset("name", "deviceName",
"programmingLanguage", "mimeType", "characterSet",
ScriptAsset.URL, "assetGroupName", "value");
}}).any();
assetResolverMock.expects.selectBestVariant(
urlRuntimePolicyReferenceMock, null).returns(selectedVariantMock).any();
assetResolverMock.expects.selectBestVariant(
noUrlRuntimePolicyReferenceMock, null).returns(null).any();
assetResolverMock.expects.computeURLAsString(selectedVariantMock).
returns("url-for-the-script-variant").any();
assetResolverMock.expects
.rewriteURLWithPageURLRewriter("url-for-the-script-variant", PageURLType.SCRIPT)
.returns("url-for-the-script-variant").any();
final DOMProtocol protocol = createProtocol();
requestContextMock.expects.
getMarinerPageContext().returns(pageContextMock).any();
final StylingEngine stylingEngine = getStylingEngine();
final PaneInstanceMock paneInstance = getPaneInstance();
pageContextMock.expects.enteringXDIMECPElement().any();
pageContextMock.expects.insideXDIMECPElement().returns(false).any();
pageContextMock.expects.exitingXDIMECPElement().any();
pageContextMock.expects.getStylingEngine().returns(stylingEngine).any();
pageContextMock.expects.getCurrentContainerInstance().
returns(paneInstance).any();
pageContextMock.expects.initialisedCanvas().returns(true).any();
pageContextMock.expects.getProtocol().returns(protocol).any();
pageContextMock.fuzzy.pushOutputBuffer(
mockFactory.expectsInstanceOf(DOMOutputBuffer.class)).does(
new MethodAction() {
public Object perform(MethodActionEvent event)
throws Throwable {
Object buffer = event.getArgument(OutputBuffer.class);
outputBufferStack.push(buffer);
return null;
}
}).any();
pageContextMock.fuzzy.popOutputBuffer(
mockFactory.expectsInstanceOf(DOMOutputBuffer.class)).does(
new MethodAction() {
public Object perform(MethodActionEvent event)
throws Throwable {
return outputBufferStack.pop();
}
}).any();
pageContextMock.expects.getCurrentOutputBuffer().does(
new MethodAction() {
public Object perform(MethodActionEvent event) throws Throwable {
return outputBufferStack.peek();
}
}).any();
pageContextMock.expects.getVolantisBean().returns(volantisBeanMock).any();