Example usage for org.springframework.dao RecoverableDataAccessException RecoverableDataAccessException

List of usage examples for org.springframework.dao RecoverableDataAccessException RecoverableDataAccessException

Introduction

In this page you can find the example usage for org.springframework.dao RecoverableDataAccessException RecoverableDataAccessException.

Prototype

public RecoverableDataAccessException(String msg) 

Source Link

Document

Constructor for RecoverableDataAccessException.

Usage

From source file:cz.fi.muni.pa165.calorycounter.backend.service.UserServiceTest.java

@Test
public void testChangeWrongUserPassword() {
    Mockito.stub(userDaoImplJPA.getByUsername(eq(USERNAME + "wrong")))
            .toThrow(new RecoverableDataAccessException("Stubbed operation login failed"));
    try {//from  w w w.  j  a v a 2  s  .c  om
        userService.setPassword(USERNAME + "wrong", "anything");
    } catch (RecoverableDataAccessException e) {
        return;
    }
    fail("Should have thrown RecoverableDataAccessException.");
}

From source file:com.trenako.web.controllers.RollingStocksControllerTests.java

@Test
public void shouldShowErrorMessageAfterDatabaseErrorsDuringCreation() {
    doThrow(new RecoverableDataAccessException("Database error")).when(service).createNew(eq(rollingStock()));

    when(mockResult.hasErrors()).thenReturn(false);
    when(mockFile.isEmpty()).thenReturn(true);
    RollingStockForm form = rsForm(mockFile);

    ModelMap model = new ModelMap();

    String viewName = controller.create(form, mockResult, model, mockRedirect);

    assertEquals("rollingstock/new", viewName);
    assertNotNull("Form is null", model.get("rollingStockForm"));
    assertEquals(RollingStocksController.ROLLING_STOCK_DATABASE_ERROR_MSG,
            (ControllerMessage) model.get("message"));
}

From source file:com.trenako.web.controllers.RollingStocksControllerTests.java

@Test
public void shouldShowErrorMessageAfterDatabaseErrorsDuringSave() {
    doThrow(new RecoverableDataAccessException("Database error")).when(service).save(eq(rollingStock()));

    when(mockResult.hasErrors()).thenReturn(false);
    when(mockFile.isEmpty()).thenReturn(true);
    RollingStockForm form = rsForm(mockFile);

    ModelMap model = new ModelMap();

    String viewName = controller.save(form, mockResult, model, mockRedirect);

    assertEquals("rollingstock/edit", viewName);
    assertNotNull("Form is null", model.get("rollingStockForm"));
    assertEquals(RollingStocksController.ROLLING_STOCK_DATABASE_ERROR_MSG,
            (ControllerMessage) model.get("message"));
}