ItEr16S10ClasificacionTraballoItEr15S13: Fix test CannotSaveTwoDifferentCriterionTypesWithTheSameName

In HSQLDB it is thrown the exception DataIntegrityViolationException instead of ConstraintViolationException
This commit is contained in:
Javier Moran Rua 2009-07-08 11:42:57 +02:00
parent 71f3dee511
commit 3fe74682ba

View file

@ -11,6 +11,7 @@ import org.navalplanner.business.common.exceptions.ValidationException;
import org.navalplanner.business.resources.entities.CriterionType;
import org.navalplanner.business.resources.services.CriterionTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
@ -21,6 +22,7 @@ import static org.navalplanner.business.test.BusinessGlobalNames.BUSINESS_SPRING
/**
* Test cases for {@link CriterionTypeService} <br />
* @author Diego Pino García <dpino@igalia.com>
* @author Javier Moran Rúa <jmoran@igalia.com>
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { BUSINESS_SPRING_CONFIG_FILE,
@ -55,13 +57,19 @@ public class CriterionTypeServiceTest {
assertTrue(criterionTypeService.exists(criterionType));
}
@Test(expected=ConstraintViolationException.class)
public void testCannotSaveTwoDifferentCriterionTypesWithTheSameName() throws ValidationException {
String unique = UUID.randomUUID().toString();
CriterionType criterionType = createValidCriterionType(unique);
criterionTypeService.save(criterionType);
criterionType = createValidCriterionType(unique);
criterionTypeService.save(criterionType);
public void testCannotSaveTwoDifferentCriterionTypesWithTheSameName()
throws ValidationException {
try {
String unique = UUID.randomUUID().toString();
CriterionType criterionType = createValidCriterionType(unique);
criterionTypeService.save(criterionType);
criterionType = createValidCriterionType(unique);
criterionTypeService.save(criterionType);
} catch (ConstraintViolationException c) {
// This exception is raised in postgresql
} catch (DataIntegrityViolationException d) {
// This exception is raised in HSQL
}
}
@Test