当前位置: 首页>>代码示例>>Java>>正文


Java Mock.verify方法代码示例

本文整理汇总了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();
}
 
开发者ID:goldmansachs,项目名称:jrpip,代码行数:21,代码来源:JrpipListenerTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:20,代码来源:ColorConverterTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:26,代码来源:DateTimeRangeValidatorTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:25,代码来源:DoubleRangeValidatorTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:18,代码来源:ColorConverterTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:28,代码来源:DateTimeRangeValidatorTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:27,代码来源:UIComponentTestCase.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:27,代码来源:RegExpValidatorTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:25,代码来源:LongRangeValidatorTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:25,代码来源:LongRangeValidatorTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:26,代码来源:NumberConverterTestCase.java

示例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);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:26,代码来源:UIComponentTestCase.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:33,代码来源:UIComponentTestCase.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:42,代码来源:ColorConverterTest.java

示例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();
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:38,代码来源:NumberConverterTestCase.java


注:本文中的org.jmock.Mock.verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。