use of com.mockobjects.dynamic.Mock in project struts by apache.
the class DefaultUrlHelperTest method testBuildUrlCorrectlyAddsDoNotEscapeAmp.
/**
* just one &, not &
*/
public void testBuildUrlCorrectlyAddsDoNotEscapeAmp() {
String expectedString = "my.actionName?foo=bar&hello=world";
Mock mockHttpServletRequest = new Mock(HttpServletRequest.class);
mockHttpServletRequest.expectAndReturn("getScheme", "http");
Mock mockHttpServletResponse = new Mock(HttpServletResponse.class);
mockHttpServletResponse.expectAndReturn("encodeURL", expectedString, expectedString);
String actionName = "my.actionName";
TreeMap params = new TreeMap();
params.put("hello", "world");
params.put("foo", "bar");
String urlString = urlHelper.buildUrl(actionName, (HttpServletRequest) mockHttpServletRequest.proxy(), (HttpServletResponse) mockHttpServletResponse.proxy(), params, null, true, true, false, false);
assertEquals(expectedString, urlString);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class DefaultUrlHelperTest method testBuildUrlCorrectlyAddsAmp.
/**
* just one &, not &
*/
public void testBuildUrlCorrectlyAddsAmp() {
String expectedString = "my.actionName?foo=bar&hello=world";
Mock mockHttpServletRequest = new Mock(HttpServletRequest.class);
mockHttpServletRequest.expectAndReturn("getScheme", "http");
Mock mockHttpServletResponse = new Mock(HttpServletResponse.class);
mockHttpServletResponse.expectAndReturn("encodeURL", expectedString, expectedString);
String actionName = "my.actionName";
TreeMap params = new TreeMap();
params.put("hello", "world");
params.put("foo", "bar");
String urlString = urlHelper.buildUrl(actionName, (HttpServletRequest) mockHttpServletRequest.proxy(), (HttpServletResponse) mockHttpServletResponse.proxy(), params);
assertEquals(expectedString, urlString);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class DefaultUrlHelperTest method testBuildUrlWithStringArray.
public void testBuildUrlWithStringArray() {
String expectedString = "my.actionName?foo=bar&hello=earth&hello=mars";
Mock mockHttpServletRequest = new Mock(HttpServletRequest.class);
mockHttpServletRequest.expectAndReturn("getScheme", "http");
Mock mockHttpServletResponse = new Mock(HttpServletResponse.class);
mockHttpServletResponse.expectAndReturn("encodeURL", expectedString, expectedString);
String actionName = "my.actionName";
TreeMap params = new TreeMap();
params.put("hello", new String[] { "earth", "mars" });
params.put("foo", "bar");
String urlString = urlHelper.buildUrl(actionName, (HttpServletRequest) mockHttpServletRequest.proxy(), (HttpServletResponse) mockHttpServletResponse.proxy(), params);
assertEquals(expectedString, urlString);
}
use of com.mockobjects.dynamic.Mock in project struts by apache.
the class VelocityResultTest method setUp.
protected void setUp() throws Exception {
super.setUp();
namespace = "/html";
result = new VelocityResult();
stack = ActionContext.getContext().getValueStack();
velocity = new TestVelocityEngine();
mockActionProxy = new Mock(ActionProxy.class);
mockActionProxy.expectAndReturn("getNamespace", "/html");
Mock mockActionInvocation = new Mock(ActionInvocation.class);
mockActionInvocation.expectAndReturn("getProxy", mockActionProxy.proxy());
mockActionInvocation.expectAndReturn("getStack", stack);
actionInvocation = (ActionInvocation) mockActionInvocation.proxy();
}
use of com.mockobjects.dynamic.Mock in project commons-configuration by apache.
the class MockInitialContextFactory method createCtxMock.
/**
* Creates a mock for a Context with the specified prefix.
*
* @param prefix the prefix
* @return the mock for the context
*/
private Mock createCtxMock(final String prefix) {
final Mock mockCtx = new Mock(Context.class);
for (int i = 0; i < PROP_NAMES.length; i++) {
bind(mockCtx, prefix + PROP_NAMES[i], PROP_VALUES[i]);
final String errProp = prefix.isEmpty() ? PREFIX + PROP_NAMES[i] : PROP_NAMES[i];
bindError(mockCtx, errProp);
}
for (final String element : MISSING_NAMES) {
bindError(mockCtx, element);
}
mockCtx.matchAndReturn("hashCode", System.identityHashCode(mockCtx.proxy()));
return mockCtx;
}
Aggregations