polishing

Updating pull request for SPR-9541
This commit is contained in:
Stephane Nicoll
2014-05-06 16:04:39 +02:00
parent 371e3a7ac0
commit e18308851d
6 changed files with 41 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,26 +16,29 @@
package org.springframework.orm.eclipselink;
import junit.framework.TestCase;
import static org.junit.Assert.*;
import org.eclipse.persistence.exceptions.DatabaseException;
import org.springframework.dao.DataAccessException;
import org.junit.Test;
/**
* @author Jan Stamer
* @since 3.2
*/
public class EclipseLinkExceptionTranslatorTests extends TestCase {
public class EclipseLinkExceptionTranslatorTests {
public void testWithWrongException() {
@Test
public void wrongException() {
EclipseLinkExceptionTranslator exceptionTranslator = new EclipseLinkExceptionTranslator();
assertNull(exceptionTranslator.translateExceptionIfPossible(new IllegalArgumentException()));
}
public void testWithEclipseLinkException() {
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Test
public void eclipseLinkException() {
EclipseLinkExceptionTranslator exceptionTranslator = new EclipseLinkExceptionTranslator();
assertNotNull(exceptionTranslator.translateExceptionIfPossible(DatabaseException.databaseAccessorNotConnected()));
assertTrue(exceptionTranslator.translateExceptionIfPossible(DatabaseException.databaseAccessorNotConnected()) instanceof DataAccessException);
assertNotNull(exceptionTranslator.translateExceptionIfPossible(
DatabaseException.databaseAccessorNotConnected()));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,24 +16,27 @@
package org.springframework.orm.eclipselink;
import junit.framework.TestCase;
import static org.junit.Assert.*;
import org.eclipse.persistence.exceptions.DatabaseException;
import org.hibernate.HibernateException;
import org.junit.Test;
/**
* @author Jan Stamer
* @since 3.2
*/
public class EclipseLinkSytemExceptionTests extends TestCase {
@SuppressWarnings("serial")
public class EclipseLinkSystemExceptionTests {
public void testWithNull() {
@Test
public void withNull() {
EclipseLinkSystemException exception = new EclipseLinkSystemException(null);
assertNull(exception.getCause());
assertNull(exception.getMessage());
}
public void testCreateWithCause() {
@Test
public void createWithCause() {
DatabaseException dbExceptionWithCause = new DatabaseException("my custom exception cause") {
};
EclipseLinkSystemException elSystemException = new EclipseLinkSystemException(dbExceptionWithCause);
@@ -41,7 +44,8 @@ public class EclipseLinkSytemExceptionTests extends TestCase {
assertTrue(elSystemException.getMessage().contains("my custom exception cause"));
}
public void testCreateWithNullCause() throws HibernateException {
@Test
public void createWithNullCause() throws HibernateException {
DatabaseException dbExceptionWithCause = new DatabaseException((String) null) {
};
EclipseLinkSystemException elSystemException = new EclipseLinkSystemException(dbExceptionWithCause);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,23 +16,25 @@
package org.springframework.orm.eclipselink;
import junit.framework.TestCase;
import static org.junit.Assert.*;
import org.eclipse.persistence.exceptions.DatabaseException;
import org.springframework.dao.DataAccessException;
import org.junit.Test;
/**
* @author Jan Stamer
* @since 3.2
*/
public class EclipseLinkUtilsTests extends TestCase {
public class EclipseLinkUtilsTests {
public void testWithNull() {
assertTrue(EclipseLinkUtils.convertEclipseLinkAccessException(null) instanceof DataAccessException);
@Test
public void withNull() {
assertNotNull(EclipseLinkUtils.convertEclipseLinkAccessException(null));
}
@Test
public void testWithEclipseLinkException() {
assertTrue(EclipseLinkUtils.convertEclipseLinkAccessException(DatabaseException.databaseAccessorNotConnected()) instanceof DataAccessException);
assertNotNull(EclipseLinkUtils.convertEclipseLinkAccessException(
DatabaseException.databaseAccessorNotConnected()));
}
}