[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[List Home]
|
[eclipselink-users] Re: Transactional Testing in Spring
|
- From: "Tim Hollosy" <hollosyt@xxxxxxxxx>
- Date: Tue, 14 Oct 2008 08:41:45 -0400
- Delivered-to: eclipselink-users@eclipse.org
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=1lOwaRULY5DP8ZzH3x842SL80LSjRAsZcNOl196+SHw=; b=qnXfm1V6WvSmyDty1XqnR8iYxZbi15NHGZ59QJFgjXGFttE3SlCPXzvOOHsQ5IiLl2 tQ7Fi2RqHZHxyeblQYx0jAodbNRIihrVZPCpgERvHf1EBU3+dhbuD8stjpH5GiCyHGrN Og8GLXpIBE8x0NNjzv1BT5ONiM8UrjypcZKl4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=JWEX/e0U8AZOo7uHruAQ+j0mKOlyy3S3NM8AZd8TpoUskTyV38qwtSy9u/rEAPLLof JHWtwEtXP4W69XJ6Buysc8beeLkDuXDD4AaANJdg/x1a3jqVcSG7gF7alPYisL46pQDH 1zJuL9xCOW0FbcKmesCm7by0Jbl3HVNvC1n7w=
After a cup of coffee I have figured this obvious problem out. The
flush command (duh).
Example for completeness:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="/applicationContext-test.xml")
@Transactional
public class EmployeeEntityTest extends TestCase{
@Autowired
protected SimpleDao dao;
@Test
public void testEmployeeCrud()
{
Employee hs = new Employee();
dao.insert(hs);
dao.getEntityManager().flush();
assertNotNull(hs);
}
}
./tch
On Tue, Oct 14, 2008 at 8:22 AM, Tim Hollosy <hollosyt@xxxxxxxxx> wrote:
> I'm having a problem doing some integration testing in spring with transactions.
>
> I've got my test case that injects a DAO. I want to verify that a
> unique constraint occurs on insert, well since eclipselink is smart
> enough to not bother sending the SQL until a commit happens my SQL is
> never executed.
>
> How are people working around this? Are you somehow loading a
> different persistence.xml that changes the caching behavior when
> testing?
>
> I would prefer to not have to do a commit and a delete to test an insert...
>
> Ideas?
>
> Thanks,
> Tim
>