本文整理汇总了Java中org.jmock.Mock.verify方法的典型用法代码示例。如果您正苦于以下问题:Java Mock.verify方法的具体用法?Java Mock.verify怎么用?Java Mock.verify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jmock.Mock
的用法示例。
在下文中一共展示了Mock.verify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExceptionalEvents
import org.jmock.Mock; //导入方法依赖的package包/类
public void testExceptionalEvents() throws MalformedURLException,
InterruptedException
{
Mock testListenerMock = this.buildMockForExceptionalCall();
FakeListener fakeListener = (FakeListener) this.servlet.getListeners().getListener(LISTENER_NAME);
fakeListener.setDelegate((JrpipEventListener) testListenerMock.proxy());
Echo echo = this.buildEchoProxy();
try
{
echo.throwUnexpectedException();
}
catch (RuntimeException e)
{
//caught test exception
}
testListenerMock.verify();
}
示例2: testStateHolderSaveRestore
import org.jmock.Mock; //导入方法依赖的package包/类
/**
* Tests that dates after the date range cause a ValidationException.
*/
public void testStateHolderSaveRestore()
{
ColorConverter converter = new ColorConverter();
Mock mock = mock(UIComponent.class);
UIComponent component = (UIComponent) mock.proxy();
MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
String[] patterns = {"#RRGGBB","RR.GG.BB"};
converter.setPatterns(patterns);
converter.setMessageDetailConvert("Works fine");
ColorConverter restoreConverter = new ColorConverter();
doTestStateHolderSaveRestore(converter, restoreConverter,
facesContext, wrapper);
mock.verify();
}
示例3: testBeforeMaximumDate
import org.jmock.Mock; //导入方法依赖的package包/类
/**
* Tests that dates before the maximum date are valid.
*
* @throws ValidatorException when test fails
*/
public void testBeforeMaximumDate() throws ValidatorException
{
long millis = System.currentTimeMillis();
DateTimeRangeValidator validator = new DateTimeRangeValidator();
validator.setMaximum(new Date(millis));
Mock mock = buildMockUIComponent();
UIComponent component = (UIComponent) mock.proxy();
try
{
setFacesContext(facesContext);
validator.validate(facesContext, component, new Date(millis - 1));
}
finally
{
setFacesContext(null);
}
mock.verify();
}
示例4: testWrongType
import org.jmock.Mock; //导入方法依赖的package包/类
public void testWrongType()
{
// since the pattern has not been set it will be null
// let us push some arbitary value
Mock mock = mock(UIComponent.class);
UIComponent component = (UIComponent) mock.proxy();
MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
setMockLabelForComponent(wrapper);
try
{
DoubleRangeValidator validator = new DoubleRangeValidator();
validator.setMaximum(2);
validator.validate(facesContext, component, "thisShouldFail");
// test fails if it is here
fail("Expected Null pointer exception");
}
catch (ValidatorException ve)
{
// suppress it - this is as expected
}
mock.verify();
}
示例5: testGetAsObjectIllegalValue
import org.jmock.Mock; //导入方法依赖的package包/类
public void testGetAsObjectIllegalValue()
{
ColorConverter converter = new ColorConverter();
Mock mock = mock(UIComponent.class);
UIComponent component = (UIComponent) mock.proxy();
mock.stubs().method("getId").will(returnValue("test"));
//component.setupGetId("test");
try
{
converter.getAsString(facesContext, component, new Integer(1));
fail("Expected a converter exception");
} catch (IllegalArgumentException ex)
{
// expected
}
mock.verify();
}
示例6: testWithinDateRange
import org.jmock.Mock; //导入方法依赖的package包/类
/**
* Tests that dates within the date range are valid.
*
* @throws ValidatorException when test fails
*/
public void testWithinDateRange() throws ValidatorException
{
long millis = System.currentTimeMillis();
DateTimeRangeValidator validator = new DateTimeRangeValidator();
validator.setMinimum(new Date(millis));
validator.setMaximum(new Date(millis + 2));
Mock mock = buildMockUIComponent();
UIComponent component = (UIComponent) mock.proxy();
try
{
setFacesContext(facesContext);
validator.validate(facesContext, component, new Date(millis + 1));
}
finally
{
setFacesContext(null);
}
mock.verify();
}
示例7: doTestProcessValidations
import org.jmock.Mock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected void doTestProcessValidations(
FacesContext context,
UIViewRoot root,
UIComponent component)
{
Mock mock = createMockUIComponent();
UIComponent child = (UIComponent) mock.proxy();
// JavaServer Faces 1.0 Specification, section 2.2.3
// During the process-validations phase,
// only the processValidators lifecycle method may be called.
if (willChildrenBeProcessed(component))
mock.expects(once()).method("processValidators");
// construct the UIComponent tree and
// execute the apply-request-values lifecycle phase
if (component.getParent() == null)
root.getChildren().add(component);
component.getChildren().add(child);
root.processValidators(context);
mock.verify();
}
示例8: testBlankValueOnPattern
import org.jmock.Mock; //导入方法依赖的package包/类
/**
* Test that pattern when set to "" should fail validation
*/
public void testBlankValueOnPattern()
{
// some very basic sanity test
Mock mock = buildMockUIComponent();
UIComponent component = (UIComponent) mock.proxy();
MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
setMockLabelForComponent(wrapper);
try
{
RegExpValidator validator = new RegExpValidator();
String value = "999999";
validator.setPattern("");
validator.validate(facesContext, component, value);
fail("Expected ValidatorException");
}
catch (ValidatorException ve)
{
// if exception then fine.
}
mock.verify();
}
示例9: testTooLarge
import org.jmock.Mock; //导入方法依赖的package包/类
public void testTooLarge()
{
// since the pattern has not been set it will be null
// let us push some arbitary value
Mock mock = mock(UIComponent.class);
UIComponent component = (UIComponent) mock.proxy();
MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
setMockLabelForComponent(wrapper);
try
{
LongRangeValidator validator = new LongRangeValidator();
validator.setMaximum(100);
validator.validate(facesContext, component, 1000);
// test fails if it is here
fail("Expected Null pointer exception");
}
catch (ValidatorException ve)
{
// suppress it - this is as expected
}
mock.verify();
}
示例10: testWrongType
import org.jmock.Mock; //导入方法依赖的package包/类
public void testWrongType()
{
// since the pattern has not been set it will be null
// let us push some arbitary value
Mock mock = mock(UIComponent.class);
UIComponent component = (UIComponent) mock.proxy();
MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
setMockLabelForComponent(wrapper);
try
{
LongRangeValidator validator = new LongRangeValidator();
validator.setMaximum(2);
validator.validate(facesContext, component, "thisShouldFail");
// test fails if it is here
fail("Expected Null pointer exception");
}
catch (ValidatorException ve)
{
// suppress it - this is as expected
}
mock.verify();
}
示例11: testValueType
import org.jmock.Mock; //导入方法依赖的package包/类
public void testValueType()
{
Mock mock = mock(UIComponent.class);
UIComponent component = (UIComponent) mock.proxy();
//we do not care about getValueExpression() being called or not
mock.stubs().method("getValueExpression");
setFacesContext(facesContext);
try
{
String input = "123";
NumberConverter converter = getNumberConverter();
Object number = converter.getAsObject(facesContext, component, input);
assertEquals(true, number instanceof Number);
assertEquals(true, (((Number)number).intValue() == 123));
String outVal = converter.getAsString(facesContext, component, number);
assertEquals(input, outVal);
}
finally
{
setFacesContext(null);
}
mock.verify();
}
示例12: doTestValidateFailure
import org.jmock.Mock; //导入方法依赖的package包/类
protected void doTestValidateFailure(
UIViewRoot root)
{
// -= Simon =-
// All those variables do not seem to be used and do not seem
// to test anything either
/*Mock mockRenderkit = getMockRenderKitWrapper().getMock();
RenderKit renderkit = getMockRenderKitWrapper().getRenderKit();
*/
Mock mockRenderer = mock(Renderer.class);
/*Renderer renderer = (Renderer) mockRenderer.proxy();
Mock mockValidator = mock(Validator.class);
Validator validator = (Validator) mockValidator.proxy();
ViewHandler viewhandler = this.facesContext.getApplication().getViewHandler();*/
setCurrentContext(facesContext);
root.processValidators(facesContext);
mockRenderer.verify();
setCurrentContext(null);
}
示例13: doTestInvokeApplication
import org.jmock.Mock; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
protected void doTestInvokeApplication(
FacesContext context,
UIViewRoot root,
UIComponent component,
FacesEvent event)
{
Mock mock = createMockUIComponent();
UIComponent child = (UIComponent) mock.proxy();
// JavaServer Faces 1.0 Specification, section 2.2.5
// During the invoke-application phase,
// no per-component lifecycle methods may be called.
// construct the UIComponent tree and
// execute the apply-request-values lifecycle phase
root.getChildren().add(component);
if (event != null)
event.queue();
component.getChildren().add(child);
// getRenderer called as part of UIXComponentBase.broadcast
Mock mockRenderkit = getMockRenderKitWrapper().getMock();
Mock mockRenderer = mock(Renderer.class);
Renderer renderer = (Renderer)mockRenderer.proxy();
mockRenderkit.stubs().method("getRenderer").will(returnValue(renderer));
root.processApplication(context);
mock.verify();
}
示例14: testGetAsObjectConversion
import org.jmock.Mock; //导入方法依赖的package包/类
/**
* Test ColorConverte's getAsObject(FacesContext, UIComponent, String) method
* works fine.
*/
public void testGetAsObjectConversion()
{
ColorConverter converter = new ColorConverter();
Mock mock = mock(UIComponent.class);
UIComponent component = (UIComponent) mock.proxy();
MockUIComponentWrapper wrapper = new MockUIComponentWrapper(mock, component);
String[] patterns = { "#RRGGBB",
"RR.GG.BB",
"RRGGBB",
"RR GG BB",
"rrr-ggg-bbb",
"rrr ggg bbb",
"r-g-b",
};
String values[] = { "#FF0204",
"FF0206",
"FF FF FF",
"0-0-0",
"105 105 105",
};
Color[] matchColors = { new Color(255,2,4),
new Color(255,2,6),
new Color(255,255,255),
new Color(0,0,0),
new Color(105,105,105)
};
converter.setPatterns(patterns);
for (int i = 0; i < values.length; i++)
{
doTestGetAsObject(converter, facesContext, wrapper, values[i], matchColors[i]);
}
mock.verify();
}
示例15: testSettingFractDigitsAndSettingMinDigitsDoesNotAffectParsing
import org.jmock.Mock; //导入方法依赖的package包/类
public void testSettingFractDigitsAndSettingMinDigitsDoesNotAffectParsing()
{
// integerOnly is used only while parsing to create number objects
NumberConverter converter = getNumberConverter();
Mock mock = mock(UIComponent.class);
UIComponent component = (UIComponent) mock.proxy();
//we do not care about getValueExpression() being called or not
mock.stubs().method("getValueExpression");
converter.setLocale(Locale.US);
String[] inputs = {"23.10", "44.90876", "11111", "67859.0001"};
Number[] expectedValues = {new Long(23), new Long(44), new Long(11111), new Long(67859)};
setFacesContext(facesContext);
try
{
for (int i = 0; i < inputs.length; i++)
{
// setting these values should not affect parsing.
converter.setMaxFractionDigits(10);
converter.setMaxIntegerDigits(1);
converter.setMinFractionDigits(1);
converter.setMinFractionDigits(0);
// this should be taken care by the parsing code
converter.setIntegerOnly(true);
Number num = (Number) converter.getAsObject(facesContext, component, inputs[i]);
assertEquals(expectedValues[i], num);
}
}
finally
{
setFacesContext(null);
}
mock.verify();
}