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


Java JUnit4Mockery.checking方法代码示例

本文整理汇总了Java中org.jmock.integration.junit4.JUnit4Mockery.checking方法的典型用法代码示例。如果您正苦于以下问题:Java JUnit4Mockery.checking方法的具体用法?Java JUnit4Mockery.checking怎么用?Java JUnit4Mockery.checking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jmock.integration.junit4.JUnit4Mockery的用法示例。


在下文中一共展示了JUnit4Mockery.checking方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() {
  myMockery = new JUnit4Mockery() {{
    setImposteriser(ClassImposteriser.INSTANCE);
  }};
  myDocument = myMockery.mock(DocumentImpl.class);
  
  myMockery.checking(new Expectations() {{
    allowing(myDocument).getTextLength(); will(new CustomAction("getTextLength") {
      @Override
      public Object invoke(Invocation invocation) throws Throwable {
        return myArray.length();
      }
    });
  }});
  
  init(10);
  if (myConfig != null) {
    myArray.insert(myConfig.text(), 0);
    myArray.setDeferredChangeMode(myConfig.deferred());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:CharArrayTest.java

示例2: initNoAnalyses

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Test
public void initNoAnalyses() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty(CONFKEY_ANALYSIS_COG_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_SOG_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_TYPESIZE_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_DRIFT_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_CLOSEENCOUNTER_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_FREEFLOW_ENABLED, false);

    final JUnit4Mockery context = new JUnit4Mockery();
    Injector injectorMock = context.mock(Injector.class);

    context.checking(new Expectations() {{
    }});

    PacketHandlerImpl sut = new PacketHandlerImpl(configuration, injectorMock, null, null, null, null);
    Set<Analysis> analyses = sut.getAnalyses();

    assertEquals(0, analyses.size());
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:23,代码来源:PacketHandlerImplTest.java

示例3: testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseLength

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Test
public void testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseLength() {
    JUnit4Mockery context = new JUnit4Mockery();
    Configuration configurationMock = context.mock(Configuration.class);
    context.checking(new Expectations() {{
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH));
        will(returnValue(1.0));
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH));
        will(returnValue(3.0));
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND));
        will(returnValue(0.25));
    }});

    SafetyZoneService sut = new SafetyZoneService(configurationMock);

    Ellipse safetyEllipse = sut.safetyZone(position, position, 90.0f, 0.0f, 100.0f, 15.0f, 65.0f, 5.5f);

    assertEquals(-15.0, safetyEllipse.getX(), 1e-6);
    assertEquals(-2.0, safetyEllipse.getY(), 1e-6);
    assertEquals(22.5, safetyEllipse.getBeta(), 1e-6);
    assertEquals(75.0, safetyEllipse.getAlpha(), 1e-6);
    assertEquals(0.0, safetyEllipse.getThetaDeg(), 1e-6);
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:24,代码来源:SafetyZoneServiceTest.java

示例4: testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseBreadth

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Test
public void testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseBreadth() {
    JUnit4Mockery context = new JUnit4Mockery();
    Configuration configurationMock = context.mock(Configuration.class);
    context.checking(new Expectations() {{
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH));
        will(returnValue(2.0));
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH));
        will(returnValue(5.0));
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND));
        will(returnValue(0.25));
    }});

    SafetyZoneService sut = new SafetyZoneService(configurationMock);

    Ellipse safetyEllipse = sut.safetyZone(position, position, 90.0f, 0.0f, 100.0f, 15.0f, 65.0f, 5.5f);

    assertEquals(10.0, safetyEllipse.getX(), 1e-6);
    assertEquals(-2.0, safetyEllipse.getY(), 1e-6);
    assertEquals(37.5, safetyEllipse.getBeta(), 1e-6);
    assertEquals(100.0, safetyEllipse.getAlpha(), 1e-6);
    assertEquals(0.0, safetyEllipse.getThetaDeg(), 1e-6);
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:24,代码来源:SafetyZoneServiceTest.java

示例5: testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseBehind

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Test
public void testComputeSafetyZoneWithAlternativeConfigurationParameterEllipseBehind() {
    JUnit4Mockery context = new JUnit4Mockery();
    Configuration configurationMock = context.mock(Configuration.class);
    context.checking(new Expectations() {{
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH));
        will(returnValue(2.0));
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH));
        will(returnValue(3.0));
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND));
        will(returnValue(0.75));
    }});

    SafetyZoneService sut = new SafetyZoneService(configurationMock);

    Ellipse safetyEllipse = sut.safetyZone(position, position, 90.0f, 0.0f, 100.0f, 15.0f, 65.0f, 5.5f);

    assertEquals(-15.0, safetyEllipse.getX(), 1e-6);
    assertEquals(-2.0, safetyEllipse.getY(), 1e-6);
    assertEquals(22.5, safetyEllipse.getBeta(), 1e-6);
    assertEquals(125.0, safetyEllipse.getAlpha(), 1e-6);
    assertEquals(0.0, safetyEllipse.getThetaDeg(), 1e-6);
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:24,代码来源:SafetyZoneServiceTest.java

示例6: initJmock

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
   public void initJmock() throws AuthenticationException, InvalidUserIdException {
mockery = new JUnit4Mockery() ;
anzo = mockery.mock(AnzoService.class) ;
mockery.checking(new Expectations() {{
    allowing(anzo).getRdfFactory() ; will(returnValue(rdfFactory)) ;
    oneOf(anzo).setCurrentUser(with(any(String.class))) ;
    allowing(anzo).getCurrentUser() ; will(returnValue(USER_ID)) ;
}}) ;
authService = mockery.mock(AuthorizationService.class) ;
authorizer = mockery.mock(UserAuthorizer.class) ;
mockery.checking(new Expectations() {{
    oneOf(authService).getUserAuthorizer(with(any(String.class))) ; will(returnValue(authorizer)) ;
    allowing(authorizer).getUri() ; will(returnValue(USER_URI)) ;
}}) ;
mapper = mockery.mock(RdfMapper.class) ;
queryProcessor = mockery.mock(CqlProcessor.class) ;
dmr = new AnzoDMRService(anzo, authService, mapper, queryProcessor) ;
dmr.setUser(USER_ID) ;
   }
 
开发者ID:NCIP,项目名称:digital-model-repository,代码行数:21,代码来源:AnzoDmrServiceTests.java

示例7: setUp

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() {
  myCollector = new DocumentChangesCollector();
  buffer = new StringBuilder(TEXT);
  myCollector.setCollectChanges(true);
  myMockery = new JUnit4Mockery() {{
    setImposteriser(ClassImposteriser.INSTANCE);
  }};

  myDocument = myMockery.mock(Document.class);

  myMockery.checking(new Expectations() {{
    allowing(myDocument).getTextLength(); will(returnValue(TEXT.length()));
  }});
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:DocumentChangesCollectorTest.java

示例8: setUp

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() {
  myBuilder = new RichTextControlBuilder();
  myMockery = new JUnit4Mockery() {{
    setImposteriser(ClassImposteriser.INSTANCE);
  }};
  
  myProcessor = myMockery.mock(RichTextControlBuilder.RichTextProcessor.class);
  myMockery.checking(new Expectations() {{
    allowing(myProcessor).getKey(); will(returnValue(META_KEY));
  }});
  myBuilder.registerProcessor(myProcessor);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:RichTextControlBuilderTest.java

示例9: setupApplication

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public final void setupApplication() throws Exception {
  context = new JUnit4Mockery();
  context.setImposteriser(ClassImposteriser.INSTANCE);
  myApplication = context.mock(ApplicationEx.class, "application");

  context.checking(new Expectations() {
    {
      allowing(myApplication).isUnitTestMode(); will(returnValue(false));
      allowing(myApplication).getName(); will(returnValue("IDEA"));

      // some tests leave invokeLater()'s after them
      allowing(myApplication).invokeLater(with(any(Runnable.class)), with(any(ModalityState.class)));

      allowing(myApplication).runReadAction(with(any(Runnable.class)));
      will(new Action() {
        @Override
        public void describeTo(final Description description) {
          description.appendText("runs runnable");
        }

        @Override
        @Nullable
        public Object invoke(final Invocation invocation) throws Throwable {
          ((Runnable)invocation.getParameter(0)).run();
          return null;
        }
      });
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:PathMacroManagerTest.java

示例10: initSelectedAnalyses

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Test
public void initSelectedAnalyses() throws Exception {
    PropertiesConfiguration configuration = new PropertiesConfiguration();
    configuration.addProperty(CONFKEY_ANALYSIS_COG_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_SOG_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_TYPESIZE_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_DRIFT_ENABLED, false);
    configuration.addProperty(CONFKEY_ANALYSIS_SUDDENSPEEDCHANGE_ENABLED, true);
    configuration.addProperty(CONFKEY_ANALYSIS_CLOSEENCOUNTER_ENABLED, true);
    configuration.addProperty(CONFKEY_ANALYSIS_FREEFLOW_ENABLED, false);
    configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH, 2.0);
    configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH, 3.0);
    configuration.addProperty(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND, 0.25);

    final JUnit4Mockery context = new JUnit4Mockery();
    Injector injectorMock = context.mock(Injector.class);
    EventEmittingTracker trackingServiceMock = context.mock(EventEmittingTracker.class);

    SafetyZoneService safetyZoneService = new SafetyZoneService(configuration);

    context.checking(new Expectations() {{
        ignoring(trackingServiceMock);
        oneOf(injectorMock).getInstance(with(SuddenSpeedChangeAnalysis.class)); will(returnValue(new SuddenSpeedChangeAnalysis(configuration, null, trackingServiceMock, null)));
        oneOf(injectorMock).getInstance(with(CloseEncounterAnalysis.class)); will(returnValue(new CloseEncounterAnalysis(configuration, null, trackingServiceMock, null, safetyZoneService)));
    }});

    PacketHandlerImpl sut = new PacketHandlerImpl(configuration, injectorMock, null, null, null, null);

    Set<Analysis> analyses = sut.getAnalyses();
    assertEquals(2, analyses.size());
    assertEquals(false, analyses.stream().anyMatch(a -> a instanceof CourseOverGroundAnalysis));
    assertEquals(false, analyses.stream().anyMatch(a -> a instanceof SpeedOverGroundAnalysis));
    assertEquals(false, analyses.stream().anyMatch(a -> a instanceof ShipTypeAndSizeAnalysis));
    assertEquals(false, analyses.stream().anyMatch(a -> a instanceof DriftAnalysis));
    assertEquals(true, analyses.stream().anyMatch(a -> a instanceof SuddenSpeedChangeAnalysis));
    assertEquals(true, analyses.stream().anyMatch(a -> a instanceof CloseEncounterAnalysis));
    assertEquals(false, analyses.stream().anyMatch(a -> a instanceof FreeFlowAnalysis));
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:39,代码来源:PacketHandlerImplTest.java

示例11: setup

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setup() {
    JUnit4Mockery context = new JUnit4Mockery();
    Configuration configurationMock = context.mock(Configuration.class);
    context.checking(new Expectations() {{
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_LENGTH));
        will(returnValue(2.0));
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BREADTH));
        will(returnValue(3.0));
        oneOf(configurationMock).getDouble(with(CONFKEY_SAFETYZONES_SAFETY_ELLIPSE_BEHIND));
        will(returnValue(0.25));
    }});
    sut = new SafetyZoneService(configurationMock);
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:15,代码来源:SafetyZoneServiceTest.java

示例12: setupApplication

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public final void setupApplication() throws Exception {
  // in fact the test accesses extension points so it rather should be converted to a platform one
  assumeNotNull(ApplicationManager.getApplication());

  context = new JUnit4Mockery();
  context.setImposteriser(ClassImposteriser.INSTANCE);
  myApplication = context.mock(ApplicationEx.class, "application");

  context.checking(new Expectations() {
    {
      allowing(myApplication).isUnitTestMode(); will(returnValue(false));

      // some tests leave invokeLater()'s after them
      allowing(myApplication).invokeLater(with(any(Runnable.class)), with(any(ModalityState.class)));

      allowing(myApplication).runReadAction(with(any(Runnable.class)));
      will(new Action() {
        @Override
        public void describeTo(final Description description) {
          description.appendText("runs runnable");
        }

        @Override
        @javax.annotation.Nullable
        public Object invoke(final Invocation invocation) throws Throwable {
          ((Runnable)invocation.getParameter(0)).run();
          return null;
        }
      });
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:34,代码来源:PathMacroManagerTest.java

示例13: setUp

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  controller = new ExportHandler();
  context = new JUnit4Mockery() {
    {
      // only here to mock types that are not interfaces
      setImposteriser(ClassImposteriser.INSTANCE);
    }
  };
  doc = context.mock(Document.class);
  container = context.mock(XulDomContainer.class);
  outputService = context.mock(OutputService.class);
  executor = context.mock(SqlExecutor.class);

  aggList = new AggListImpl();

  controller.setOutputService(outputService);
  controller.setAggList(aggList);
  controller.setDdlDmlExecutor(executor);

  // need some expectations here as setXulDomContainer calls getDocumentRoot on the container
  context.checking(new Expectations() {
    {
      one(container).getDocumentRoot();
      will(returnValue(doc));
    }
  });

  controller.setXulDomContainer(container);

}
 
开发者ID:pentaho,项目名称:pentaho-aggdesigner,代码行数:32,代码来源:ExportHandlerTest.java

示例14: setUp

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  controller = new ConnectionController();
  context = new JUnit4Mockery();
  doc = context.mock(Document.class);
  container = context.mock(XulDomContainer.class);
  dataHandler = context.mock(XulEventHandler.class);
  model = context.mock(ConnectionModel.class);
  controller.setConnectionModel(model);
  workspace = new Workspace();
  controller.setWorkspace(workspace);
  outputService = context.mock(OutputService.class);
  controller.setOutputService(outputService);
  aSchemaProvider = context.mock(SchemaProviderUiExtension.class);
  cubeNames = Arrays.asList("testCube1", "testCube2");
  providerModel = context.mock(SchemaModel.class);

  // need some expectations here as setXulDomContainer calls getDocumentRoot on the container
  context.checking(new Expectations() {
    {
      one(container).getDocumentRoot();
      will(returnValue(doc));
      allowing(doc).invokeLater(with(any(Runnable.class))); //don't care if the controller uses invokeLater or not
    }
  });

  controller.setXulDomContainer(container);
  controller.setDataHandler(dataHandler);
}
 
开发者ID:pentaho,项目名称:pentaho-aggdesigner,代码行数:30,代码来源:ConnectionControllerTest.java

示例15: setUp

import org.jmock.integration.junit4.JUnit4Mockery; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
  controller = new AggListController();
  context = new JUnit4Mockery() {
    {
      // only here to mock types that are not interfaces
      setImposteriser(ClassImposteriser.INSTANCE);
    }
  };
  doc = context.mock(Document.class);
  container = context.mock(XulDomContainer.class);
  outputService = context.mock(OutputService.class);
  workspace = context.mock(Workspace.class);
  connModel = context.mock(ConnectionModel.class);
  schema = context.mock(Schema.class);
  uiExt = context.mock(AlgorithmUiExtension.class);
  algo = context.mock(Algorithm.class);
  aggregateSummaryModel = context.mock(AggregateSummaryModel.class);

  aggList = new AggListImpl();

  controller.setOutputService(outputService);
  controller.setAggList(aggList);
  controller.setAlgorithmUiExtension(uiExt);
  controller.setAlgorithm(algo);

  // need some expectations here as setXulDomContainer calls getDocumentRoot on the container
  context.checking(new Expectations() {
    {
      one(container).getDocumentRoot();
      will(returnValue(doc));
    }
  });

  controller.setXulDomContainer(container);
  controller.setWorkspace(workspace);
  controller.setConnectionModel(connModel);
  controller.setAggregateSummaryModel(aggregateSummaryModel);
  
}
 
开发者ID:pentaho,项目名称:pentaho-aggdesigner,代码行数:41,代码来源:AggListControllerTest.java


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