Java Code Examples for org.easymock.classextension.EasyMock#expectLastCall()

The following examples show how to use org.easymock.classextension.EasyMock#expectLastCall() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileBasedProctorStoreTest.java    From proctor with Apache License 2.0 6 votes vote down vote up
@Test
public void updateTestDefinitionTestDoesNotExist() throws Exception {
    final TestDefinition definition = new TestDefinition();
    final Map<String, String> metadata = Maps.newHashMap();

    final Capture<FileBasedProctorStore.ProctorUpdater> capturedArgument = new Capture<>();
    coreMock.doInWorkingDirectory(
            eq("fooUser"),
            eq("fooPassw0rd"),
            eq("fooComment"),
            eq("r0"),
            capture(capturedArgument)
    );
    EasyMock.expectLastCall();
    replay(coreMock);

    try {
        store.updateTestDefinition("fooUser", "fooPassw0rd", "fooAuthor", "r0",
                definition, metadata, "fooComment");
        fail("Expected Exception");
    } catch (final StoreException.TestUpdateException tue) {
        assertEquals("Attempting to update non-existent test r0", tue.getCause().getMessage());
    }
}
 
Example 2
Source File: ServiceTest.java    From travelguide with Apache License 2.0 5 votes vote down vote up
public void testNewReflectiveService() {
  ServiceWithNoOuter.Interface impl =
      control.createMock(ServiceWithNoOuter.Interface.class);
  RpcController controller = control.createMock(RpcController.class);
  Service service = ServiceWithNoOuter.newReflectiveService(impl);

  MethodDescriptor fooMethod =
      ServiceWithNoOuter.getDescriptor().findMethodByName("Foo");
  MessageWithNoOuter request = MessageWithNoOuter.getDefaultInstance();
  RpcCallback<Message> callback = new RpcCallback<Message>() {
    public void run(Message parameter) {
      // No reason this should be run.
      fail();
    }
  };
  RpcCallback<TestAllTypes> specializedCallback =
      RpcUtil.specializeCallback(callback);

  impl.foo(EasyMock.same(controller), EasyMock.same(request),
      EasyMock.same(specializedCallback));
  EasyMock.expectLastCall();

  control.replay();

  service.callMethod(fooMethod, controller, request, callback);

  control.verify();
}
 
Example 3
Source File: FileBasedProctorStoreTest.java    From proctor with Apache License 2.0 5 votes vote down vote up
@Test
public void updateTestDefinitionTestNoChange() throws Exception {
    final Map<String, String> metadata = Maps.newHashMap();

    final File definitionFolder = store.getTestDefinitionDirectoryForTest("r0", temporaryFolder.getRoot());
    assertTrue(definitionFolder.mkdirs());
    final TestDefinition definition = new TestDefinition();
    OBJECT_MAPPER.writeValue(new File(definitionFolder, FileBasedProctorStore.TEST_DEFINITION_FILENAME), definition);
    OBJECT_MAPPER.writeValue(new File(definitionFolder, FileBasedProctorStore.TEST_METADATA_FILENAME), metadata);

    final Capture<FileBasedProctorStore.ProctorUpdater> capturedArgument = new Capture<>();
    coreMock.doInWorkingDirectory(
            eq("fooUser"),
            eq("fooPassw0rd"),
            eq("fooComment"),
            eq("r0"),
            capture(capturedArgument)
    );
    EasyMock.expectLastCall();
    replay(coreMock);

    try {
        store.updateTestDefinition("fooUser", "fooPassw0rd", "fooAuthor", "r0",
                definition, metadata, "fooComment");
        fail("Expected Exception");
    } catch (final StoreException.TestUpdateException tue) {
        assertEquals("Attempting to save test definition without changes for test r0", tue.getCause().getMessage());
    }
}