|
From: <gca...@us...> - 2013-03-11 15:45:37
|
Revision: 4199
http://openutils.svn.sourceforge.net/openutils/?rev=4199&view=rev
Author: gcatania
Date: 2013-03-11 15:45:30 +0000 (Mon, 11 Mar 2013)
Log Message:
-----------
Merged revisions 4195 via svnmerge from
https://openutils.svn.sourceforge.net/svnroot/openutils/trunk/openutils-bshd5
........
r4195 | gcatania | 2013-03-11 16:03:14 +0100 (lun, 11 mar 2013) | 1 line
BSHD-19 failing tests added (currently disabled)
........
Revision Links:
--------------
http://openutils.svn.sourceforge.net/openutils/?rev=4195&view=rev
Modified Paths:
--------------
branches/openutils-bshd5-backport/src/test/resources/hibernate.cfg.xml
Added Paths:
-----------
branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/HibernateDAOLazyLoadTest.java
branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/dao/BarDAO.java
branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/dao/FooDAO.java
branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/model/Bar.java
branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/model/Foo.java
branches/openutils-bshd5-backport/src/test/resources/preload-data.sql
Property Changed:
----------------
branches/openutils-bshd5-backport/
branches/openutils-bshd5-backport/src/
Property changes on: branches/openutils-bshd5-backport
___________________________________________________________________
Modified: svnmerge-integrated
- /trunk/openutils-bshd5:1-4040,4042-4056,4058-4092,4192
+ /trunk/openutils-bshd5:1-4040,4042-4056,4058-4092,4192,4195
Modified: svn:mergeinfo
- /trunk/openutils-bshd5:4045-4047*,4057,4059,4069-4070*,4073*,4075-4078*,4080*,4082*,4084-4085*,4087*,4089*,4091-4092*,4192*
+ /trunk/openutils-bshd5:4045-4047*,4057,4059,4069-4070*,4073*,4075-4078*,4080*,4082*,4084-4085*,4087*,4089*,4091-4092*,4192*,4195*
Property changes on: branches/openutils-bshd5-backport/src
___________________________________________________________________
Modified: svn:mergeinfo
- /trunk/openutils-bshd5/src:4045-4047,4057,4069-4070,4073,4075-4078,4080,4082,4084-4085,4087,4089,4091-4092,4192
+ /trunk/openutils-bshd5/src:4045-4047,4057,4069-4070,4073,4075-4078,4080,4082,4084-4085,4087,4089,4091-4092,4192,4195
Copied: branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/HibernateDAOLazyLoadTest.java (from rev 4195, trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/HibernateDAOLazyLoadTest.java)
===================================================================
--- branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/HibernateDAOLazyLoadTest.java (rev 0)
+++ branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/HibernateDAOLazyLoadTest.java 2013-03-11 15:45:30 UTC (rev 4199)
@@ -0,0 +1,147 @@
+/**
+ *
+ * openutils base Spring-Hibernate DAO (http://www.openmindlab.com/lab/products/bshd5.html)
+ *
+ * Copyright(C) 2005-2012, Openmind S.r.l. http://www.openmindonline.it
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package it.openutils.hibernate.test;
+
+import it.openutils.hibernate.test.dao.BarDAO;
+import it.openutils.hibernate.test.dao.FooDAO;
+import it.openutils.hibernate.test.model.Bar;
+import it.openutils.hibernate.test.model.Foo;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+
+/**
+ * @author gcatania
+ */
+@ContextConfiguration(locations = "/spring-tests.xml")
+public class HibernateDAOLazyLoadTest extends AbstractTransactionalTestNGSpringContextTests
+{
+
+ @Autowired
+ private FooDAO fooDAO;
+
+ @Autowired
+ private BarDAO barDAO;
+
+ @BeforeClass
+ protected final void preloadData()
+ {
+ executeSqlScript("/preload-data.sql", false);
+ }
+
+ private List<Foo> findFoo(String s, Bar bar)
+ {
+ Foo filter = new Foo();
+ filter.setBar(bar);
+ filter.setS(s);
+ List<Foo> found = fooDAO.findFiltered(filter);
+ return found;
+ }
+
+ private void testFind(long barId, String fooStr, Bar bar)
+ {
+ List<Foo> found = findFoo(fooStr, bar);
+ Assert.assertEquals(found.size(), 1);
+ Foo foo = found.get(0);
+ Assert.assertEquals(foo.getS(), fooStr);
+ Assert.assertEquals(foo.getBar().getId().longValue(), barId);
+ }
+
+ private void testDontFind(String fooStr, Bar bar)
+ {
+ List<Foo> found = findFoo(fooStr, bar);
+ Assert.assertEquals(found.size(), 0);
+ }
+
+ private void testFindEager(long barId, String fooStr)
+ {
+ Bar bar = barDAO.get(barId);
+ testFind(barId, fooStr, bar);
+ }
+
+ private void testFindLazy(long barId, String fooStr)
+ {
+ Bar bar = barDAO.load(barId);
+ testFind(barId, fooStr, bar);
+ }
+
+ @Test
+ public void testFindWithEagerParent1()
+ {
+ testFindEager(1L, "foo1_2");
+ }
+
+ @Test
+ public void testFindWithEagerParent2()
+ {
+ testFindEager(1L, "fooX_X");
+ }
+
+ @Test
+ public void testFindWithLazyParent1()
+ {
+ testFindLazy(1L, "foo1_2");
+ }
+
+ /**
+ * FIXME enable this test and fix BSHD-19
+ */
+ @Test(enabled = false)
+ public void testFindWithLazyParent2()
+ {
+ testFindLazy(1L, "fooX_X");
+ }
+
+ @Test
+ public void testDontFindWithEagerParent()
+ {
+ long barId = 1L;
+ String fooStr = "foo2_2";
+
+ Bar bar1 = barDAO.get(barId);
+ testDontFind(fooStr, bar1);
+ }
+
+ /**
+ * FIXME enable this test and fix BSHD-19
+ */
+ @Test(enabled = false)
+ public void testDontFindWithLazyParent()
+ {
+ long barId = 1L;
+ String fooStr = "foo2_2";
+
+ Bar bar1 = barDAO.load(barId);
+ testDontFind(fooStr, bar1);
+ }
+}
Copied: branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/dao/BarDAO.java (from rev 4195, trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/dao/BarDAO.java)
===================================================================
--- branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/dao/BarDAO.java (rev 0)
+++ branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/dao/BarDAO.java 2013-03-11 15:45:30 UTC (rev 4199)
@@ -0,0 +1,55 @@
+/**
+ *
+ * openutils base Spring-Hibernate DAO (http://www.openmindlab.com/lab/products/bshd5.html)
+ *
+ * Copyright(C) 2005-2012, Openmind S.r.l. http://www.openmindonline.it
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package it.openutils.hibernate.test.dao;
+
+import it.openutils.dao.hibernate.HibernateDAO;
+import it.openutils.dao.hibernate.HibernateDAOImpl;
+import it.openutils.hibernate.test.model.Bar;
+
+import org.hibernate.SessionFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+
+/**
+ * @author gcatania
+ */
+public interface BarDAO extends HibernateDAO<Bar, Long>
+{
+
+ @Repository("barDAO")
+ class PersonDAOImpl extends HibernateDAOImpl<Bar, Long> implements BarDAO
+ {
+
+ @Autowired
+ public PersonDAOImpl(SessionFactory factory)
+ {
+ super(Bar.class);
+ setSessionFactory(factory);
+ }
+ }
+
+}
Copied: branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/dao/FooDAO.java (from rev 4195, trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/dao/FooDAO.java)
===================================================================
--- branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/dao/FooDAO.java (rev 0)
+++ branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/dao/FooDAO.java 2013-03-11 15:45:30 UTC (rev 4199)
@@ -0,0 +1,55 @@
+/**
+ *
+ * openutils base Spring-Hibernate DAO (http://www.openmindlab.com/lab/products/bshd5.html)
+ *
+ * Copyright(C) 2005-2012, Openmind S.r.l. http://www.openmindonline.it
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package it.openutils.hibernate.test.dao;
+
+import it.openutils.dao.hibernate.HibernateDAO;
+import it.openutils.dao.hibernate.HibernateDAOImpl;
+import it.openutils.hibernate.test.model.Foo;
+
+import org.hibernate.SessionFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Repository;
+
+
+/**
+ * @author gcatania
+ */
+public interface FooDAO extends HibernateDAO<Foo, Long>
+{
+
+ @Repository("fooDAO")
+ class PersonDAOImpl extends HibernateDAOImpl<Foo, Long> implements FooDAO
+ {
+
+ @Autowired
+ public PersonDAOImpl(SessionFactory factory)
+ {
+ super(Foo.class);
+ setSessionFactory(factory);
+ }
+ }
+
+}
Copied: branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/model/Bar.java (from rev 4195, trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Bar.java)
===================================================================
--- branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/model/Bar.java (rev 0)
+++ branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/model/Bar.java 2013-03-11 15:45:30 UTC (rev 4199)
@@ -0,0 +1,80 @@
+/**
+ *
+ * openutils base Spring-Hibernate DAO (http://www.openmindlab.com/lab/products/bshd5.html)
+ *
+ * Copyright(C) 2005-2012, Openmind S.r.l. http://www.openmindonline.it
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package it.openutils.hibernate.test.model;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+
+/**
+ * @author gcatania
+ * @version $Id$
+ */
+@Entity
+public class Bar implements Cloneable
+{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ private String s;
+
+ /**
+ * @return the id
+ */
+ public Long getId()
+ {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * @return the s
+ */
+ public String getS()
+ {
+ return s;
+ }
+
+ /**
+ * @param s the s to set
+ */
+ public void setS(String s)
+ {
+ this.s = s;
+ }
+
+}
Copied: branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/model/Foo.java (from rev 4195, trunk/openutils-bshd5/src/test/java/it/openutils/hibernate/test/model/Foo.java)
===================================================================
--- branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/model/Foo.java (rev 0)
+++ branches/openutils-bshd5-backport/src/test/java/it/openutils/hibernate/test/model/Foo.java 2013-03-11 15:45:30 UTC (rev 4199)
@@ -0,0 +1,102 @@
+/**
+ *
+ * openutils base Spring-Hibernate DAO (http://www.openmindlab.com/lab/products/bshd5.html)
+ *
+ * Copyright(C) 2005-2012, Openmind S.r.l. http://www.openmindonline.it
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * You may obtain a copy of the License at
+ *
+ * http://www.gnu.org/licenses/lgpl-2.1.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package it.openutils.hibernate.test.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+
+/**
+ * @author gcatania
+ * @version $Id$
+ */
+@Entity
+public class Foo implements Cloneable
+{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ @ManyToOne
+ private Bar bar;
+
+ @Column
+ private String s;
+
+ /**
+ * @return the id
+ */
+ public Long getId()
+ {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ /**
+ * @return the bar
+ */
+ public Bar getBar()
+ {
+ return bar;
+ }
+
+ /**
+ * @param bar the bar to set
+ */
+ public void setBar(Bar bar)
+ {
+ this.bar = bar;
+ }
+
+ /**
+ * @return the s
+ */
+ public String getS()
+ {
+ return s;
+ }
+
+ /**
+ * @param s the s to set
+ */
+ public void setS(String s)
+ {
+ this.s = s;
+ }
+
+}
Modified: branches/openutils-bshd5-backport/src/test/resources/hibernate.cfg.xml
===================================================================
--- branches/openutils-bshd5-backport/src/test/resources/hibernate.cfg.xml 2013-03-11 15:34:58 UTC (rev 4198)
+++ branches/openutils-bshd5-backport/src/test/resources/hibernate.cfg.xml 2013-03-11 15:45:30 UTC (rev 4199)
@@ -13,5 +13,8 @@
<mapping class="it.openutils.hibernate.test.model.Owner" />
<mapping class="it.openutils.hibernate.test.model.Person" />
<mapping class="it.openutils.hibernate.test.model.Sticker" />
+
+ <mapping class="it.openutils.hibernate.test.model.Foo" />
+ <mapping class="it.openutils.hibernate.test.model.Bar" />
</session-factory>
</hibernate-configuration>
\ No newline at end of file
Copied: branches/openutils-bshd5-backport/src/test/resources/preload-data.sql (from rev 4195, trunk/openutils-bshd5/src/test/resources/preload-data.sql)
===================================================================
--- branches/openutils-bshd5-backport/src/test/resources/preload-data.sql (rev 0)
+++ branches/openutils-bshd5-backport/src/test/resources/preload-data.sql 2013-03-11 15:45:30 UTC (rev 4199)
@@ -0,0 +1,17 @@
+insert into bar (id, s)
+values (1, 'bar1');
+insert into bar (id, s)
+values (2, 'bar2');
+
+insert into foo (id, bar_id, s)
+values ( 1, 1, 'foo1_1' );
+insert into foo (id, bar_id, s)
+values ( 2, 1, 'foo1_2' );
+insert into foo (id, bar_id, s)
+values ( 3, 1, 'fooX_X' );
+insert into foo (id, bar_id, s)
+values ( 4, 2, 'foo2_1' );
+insert into foo (id, bar_id, s)
+values ( 5, 2, 'foo2_2' );
+insert into foo (id, bar_id, s)
+values ( 6, 2, 'fooX_X' );
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|