diff --git a/navalplanner-business/src/test/java/org/navalplanner/business/test/resources/services/CriterionTypeServiceTest.java b/navalplanner-business/src/test/java/org/navalplanner/business/test/resources/services/CriterionTypeServiceTest.java
index 756143d15..110ac133d 100644
--- a/navalplanner-business/src/test/java/org/navalplanner/business/test/resources/services/CriterionTypeServiceTest.java
+++ b/navalplanner-business/src/test/java/org/navalplanner/business/test/resources/services/CriterionTypeServiceTest.java
@@ -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}
* @author Diego Pino García
+ * @author Javier Moran Rúa
*/
@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