[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
If that is all the code you have (ie. you have no Seam components that you are integration testing), this you should NOT be using SeamTest. SeamTest if for integration testing of Seam applications. This looks like a unit test. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3934631#3934631 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3934631 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
OK. If I have code like this: | @Entity | public class Hotel implements Serializable | { | ... | @PrePersist | public void initialiseRank(){ | int rank= caculate(a+b+c); | setRank(rank); | } | | @PreUpdate | public void generateHistoryRecord(){ | save(getOriginalRecord()) | } | | @PreUpdate | public void caculateRank(){ | int rank= x + y + z; | setRank(rank); | } | | } | my integration testing code would look like this: | Hotel hotel= new Hotel(name); | em.persist(hotel); | ... | Hotel savedHotel=em.find(Hotel.class, id); | assert checkHotelRank(savedHotel); | | savedHotel.getFeedbacks().add(feedback); | em.persist(savedHotel); | ... | assert checkHotelRank(savedHotel); | assert checkHotelHistory(savedHotel); | As you can see, my testing code uses EntityManager. How would you write your test for this scenario without EntityManager? View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3934629#3934629 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3934629 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
Write a plain TestNG test. The way anyone tests Hibernate stuff today View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3934670#3934670 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3934670 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
This scenario for me is more like an entity level integration test because a test case involved a set of entities e.g. Hotel + Feedback + History... From what you said, SeamTest is not suitable for entity-only level tests. What would you recommand for our scenario? We basically need a way to test our entities. Thanks for your help Gavin. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3934668#3934668 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3934668 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
It would be convienent if seam provides something like EntityTest. Had a look at http://blog.hibernate.org/cgi-bin/blosxom.cgi/2005/11/24#ejb3withtestng. To test entites is not easy as what I thought. I have to get those xmls and re-config them, write code for starting up embeded container, use those ant script, jndi 2 hours gone, still can't get it working. One thing I noticed is it tests entiteis using DAO pattern , which I don't have. What I need is simply having an EntityManager in a SeamTest and I guess it's a common requirement. Why do I need to get into a new world and config everything again? It would make sense if Seam can cover this kind of tests. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3934771#3934771 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3934771 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
Huh??? No, not at all. You just start a persistence provider. If all you are doing is testing *entities* you do NOT need an ejb3 container environment. The only XML you need is persistence.xml. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3934784#3934784 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3934784 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
Thanks Gavin. Managed to get it working by doing this: | MapString,String configOverrides = new HashMapString,String(); | configOverrides.put(hibernate.connection.driver_class, org.hsqldb.jdbcDriver); | configOverrides.put(hibernate.connection.url, jdbc:hsqldb:.); | ... | EntityManagerFactory emf=Persistence.createEntityManagerFactory(bookingDatabase,configOverrides); | EntityManager em=emf.createEntityManager(); | Another thing(the last thing) is that I have to remove jta-data-source from persistance.xml in order to run this test. So I have to keep swap the xml file when I need to run this test. Is there a good way to avoid swaping xml? View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3934844#3934844 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3934844 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
Again, SeamTest starts Seam, which will start up the entitymanager you do NOT need to hack in your own entitymanager. You only need to do things like this for unit testing, not for integration testing. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3934449#3934449 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3934449 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
Has anyone tried? I now have to put all my test code into a ejb, which is not right. How do you usually test your entities with callback listeners? View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3934438#3934438 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3934438 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
A lot of my entities has got listeners with business logic in. For example, in @PostPersist method I might caculate the balance for the entities. That's why I need em to test entities. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3933636#3933636 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3933636 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user
[JBoss-user] [JBoss Seam] - Re: How to get EntityManager in seamtest
I don't understand. Usually you call your own components from SeamTest and EJB3 or Seam injects the EM. What is the context where you want to get one in your own code? View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=3933582#3933582 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=3933582 --- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnkkid=110944bid=241720dat=121642 ___ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user