|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Session in view with MockRoundtripHi,
In my ActionBeans I use lazy loading Hibernate entities that are accessed in the JSP view. Runtime this session in view pattern work excellent. But it does not work during JUnit testing. The session is closed after calling execute on the MockRoundtrip, making it impossible to check the results. How can I make sure the session of the MockRoundtrip does not end after the 'execute' command? Kind regards, Karen ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users |
|
|
Re: Session in view with MockRoundtripHi Karen,
The solution I use is to "simulate" the OSIV filter in my TestCases. I write a base test class that can open/close an hb session and tx, and then use it in setUp/tearDown, or directly in test methods, like this : public void testMe() { Transaction tx = openSessionAndTransaction(); try { // do some tests getSession().load(...); ... } finally { tx.commit(); } } The base test class implements the methods for opening the session/tx, binding it to the current thread, and closing it. Used in setUp/tearDown, you don't even notice it's there, just like the regular OSIV behavior... Of course, depending on the type of OSIV you use, you'll have more or less code to write to implement those methods in your base class. I'm derivating from Spring's OSIV, and basically migrated the filter's session/tx demarcation code into my base test class. HTH Cheers Remi 2009/11/4 KR <k-no-spam@...>: > Hi, > > > > In my ActionBeans I use lazy loading Hibernate entities that are accessed in > the JSP view. > > > > Runtime this session in view pattern work excellent. But it does not work > during JUnit testing. The session is closed after calling execute on the > MockRoundtrip, making it impossible to check the results. > > > > How can I make sure the session of the MockRoundtrip does not end after the > 'execute' command? > > > > Kind regards, > > Karen > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Stripes-users mailing list > Stripes-users@... > https://lists.sourceforge.net/lists/listinfo/stripes-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users |
|
|
Re: Session in view with MockRoundtripThanks Remi,
That's exactly what I want to do. Unfortunatly I failed to mention in my opening post that I also use Stripersist (Stripesstuff) to manage hibernate/JPA in my actionBeans. The Stripersist extension package does add entity formaters, entity converters and a filter that starts and stops transactions. So when the MockRoundtrip is done executing the session is gone because the Stripersist filter closed it. Problem is, I just don't know of a way to manage the Stripersist transaction manualy, without also disabeling the other extensions in the Stripersist package (because my actionBeans also use entity formater and converter). "VANKEISBELCK Remi" <remi@...> wrote in message news:8856709a0911041344q4884552dva61409cd4b698673@...... Hi Karen, The solution I use is to "simulate" the OSIV filter in my TestCases. I write a base test class that can open/close an hb session and tx, and then use it in setUp/tearDown, or directly in test methods, like this : public void testMe() { Transaction tx = openSessionAndTransaction(); try { // do some tests getSession().load(...); ... } finally { tx.commit(); } } The base test class implements the methods for opening the session/tx, binding it to the current thread, and closing it. Used in setUp/tearDown, you don't even notice it's there, just like the regular OSIV behavior... Of course, depending on the type of OSIV you use, you'll have more or less code to write to implement those methods in your base class. I'm derivating from Spring's OSIV, and basically migrated the filter's session/tx demarcation code into my base test class. HTH Cheers Remi 2009/11/4 KR <k-no-spam@...>: > Hi, > > > > In my ActionBeans I use lazy loading Hibernate entities that are accessed > in > the JSP view. > > > > Runtime this session in view pattern work excellent. But it does not work > during JUnit testing. The session is closed after calling execute on the > MockRoundtrip, making it impossible to check the results. > > > > How can I make sure the session of the MockRoundtrip does not end after > the > 'execute' command? > > > > Kind regards, > > Karen > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Stripes-users mailing list > Stripes-users@... > https://lists.sourceforge.net/lists/listinfo/stripes-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users |
|
|
Re: Session in view with MockRoundtripHi again,
Well, I've never used JPA myself so I can't tell, but I guess you just have to get hold of an EntityManager and do the open/close thing inside a good old try/finally block... Have a look at Stripersist's Interceptor, it just does this (plus some classpath scanning and other things). http://stripes-stuff.svn.sourceforge.net/viewvc/stripes-stuff/Stripersist/trunk/src/org/stripesstuff/stripersist/Stripersist.java?revision=123&view=markup I think you just need to rewrite this class, probably as a "template" that can be used in your tests. HTH Cheers remi 2009/11/5 KR <k-no-spam@...>: > Thanks Remi, > > That's exactly what I want to do. Unfortunatly I failed to mention in my > opening post that I also use Stripersist (Stripesstuff) to manage > hibernate/JPA in my actionBeans. The Stripersist extension package does add > entity formaters, entity converters and a filter that starts and stops > transactions. > > So when the MockRoundtrip is done executing the session is gone because the > Stripersist filter closed it. > > Problem is, I just don't know of a way to manage the Stripersist transaction > manualy, without also disabeling the other extensions in the Stripersist > package (because my actionBeans also use entity formater and converter). > > > "VANKEISBELCK Remi" <remi@...> wrote in message > news:8856709a0911041344q4884552dva61409cd4b698673@...... > Hi Karen, > > The solution I use is to "simulate" the OSIV filter in my TestCases. I > write a base test class that can open/close an hb session and tx, and > then use it in setUp/tearDown, or directly in test methods, like this > : > > public void testMe() { > Transaction tx = openSessionAndTransaction(); > try { > // do some tests > getSession().load(...); > ... > } finally { > tx.commit(); > } > } > > The base test class implements the methods for opening the session/tx, > binding it to the current thread, and closing it. Used in > setUp/tearDown, you don't even notice it's there, just like the > regular OSIV behavior... > > Of course, depending on the type of OSIV you use, you'll have more or > less code to write to implement those methods in your base class. I'm > derivating from Spring's OSIV, and basically migrated the filter's > session/tx demarcation code into my base test class. > > HTH > > Cheers > > Remi > > > 2009/11/4 KR <k-no-spam@...>: >> Hi, >> >> >> >> In my ActionBeans I use lazy loading Hibernate entities that are accessed >> in >> the JSP view. >> >> >> >> Runtime this session in view pattern work excellent. But it does not work >> during JUnit testing. The session is closed after calling execute on the >> MockRoundtrip, making it impossible to check the results. >> >> >> >> How can I make sure the session of the MockRoundtrip does not end after >> the >> 'execute' command? >> >> >> >> Kind regards, >> >> Karen >> >> >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Stripes-users mailing list >> Stripes-users@... >> https://lists.sourceforge.net/lists/listinfo/stripes-users >> > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Stripes-users mailing list > Stripes-users@... > https://lists.sourceforge.net/lists/listinfo/stripes-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users |
|
|
Re: Session in view with MockRoundtripRemi,
I'm fairly new to Java and Stripes, do you know if I can disable these interceptors on the Stripersist class, so I can handle the JPA session my selves? "VANKEISBELCK Remi" <remi@...> wrote in message news:8856709a0911050712qc97122cr2cb223439b7babe6@...... Hi again, Well, I've never used JPA myself so I can't tell, but I guess you just have to get hold of an EntityManager and do the open/close thing inside a good old try/finally block... Have a look at Stripersist's Interceptor, it just does this (plus some classpath scanning and other things). http://stripes-stuff.svn.sourceforge.net/viewvc/stripes-stuff/Stripersist/trunk/src/org/stripesstuff/stripersist/Stripersist.java?revision=123&view=markup I think you just need to rewrite this class, probably as a "template" that can be used in your tests. HTH Cheers remi 2009/11/5 KR <k-no-spam@...>: > Thanks Remi, > > That's exactly what I want to do. Unfortunatly I failed to mention in my > opening post that I also use Stripersist (Stripesstuff) to manage > hibernate/JPA in my actionBeans. The Stripersist extension package does > add > entity formaters, entity converters and a filter that starts and stops > transactions. > > So when the MockRoundtrip is done executing the session is gone because > the > Stripersist filter closed it. > > Problem is, I just don't know of a way to manage the Stripersist > transaction > manualy, without also disabeling the other extensions in the Stripersist > package (because my actionBeans also use entity formater and converter). > > > "VANKEISBELCK Remi" <remi@...> wrote in message > news:8856709a0911041344q4884552dva61409cd4b698673@...... > Hi Karen, > > The solution I use is to "simulate" the OSIV filter in my TestCases. I > write a base test class that can open/close an hb session and tx, and > then use it in setUp/tearDown, or directly in test methods, like this > : > > public void testMe() { > Transaction tx = openSessionAndTransaction(); > try { > // do some tests > getSession().load(...); > ... > } finally { > tx.commit(); > } > } > > The base test class implements the methods for opening the session/tx, > binding it to the current thread, and closing it. Used in > setUp/tearDown, you don't even notice it's there, just like the > regular OSIV behavior... > > Of course, depending on the type of OSIV you use, you'll have more or > less code to write to implement those methods in your base class. I'm > derivating from Spring's OSIV, and basically migrated the filter's > session/tx demarcation code into my base test class. > > HTH > > Cheers > > Remi > > > 2009/11/4 KR <k-no-spam@...>: >> Hi, >> >> >> >> In my ActionBeans I use lazy loading Hibernate entities that are accessed >> in >> the JSP view. >> >> >> >> Runtime this session in view pattern work excellent. But it does not work >> during JUnit testing. The session is closed after calling execute on the >> MockRoundtrip, making it impossible to check the results. >> >> >> >> How can I make sure the session of the MockRoundtrip does not end after >> the >> 'execute' command? >> >> >> >> Kind regards, >> >> Karen >> >> >> >> >> ------------------------------------------------------------------------------ >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and >> focus >> on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Stripes-users mailing list >> Stripes-users@... >> https://lists.sourceforge.net/lists/listinfo/stripes-users >> > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > > > > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 > 30-Day > trial. Simplify your report design, integration and deployment - and focus > on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Stripes-users mailing list > Stripes-users@... > https://lists.sourceforge.net/lists/listinfo/stripes-users > ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users |
|
|
Re: Session in view with MockRoundtrip
For anybody interested we worked this out over IRC and there's a new
MockStripersist class committed in SVN now. :-)
Aaron KR wrote: Remi, I'm fairly new to Java and Stripes, do you know if I can disable these interceptors on the Stripersist class, so I can handle the JPA session my selves? "VANKEISBELCK Remi" remi@... wrote in message news:8856709a0911050712qc97122cr2cb223439b7babe6@...... Hi again, Well, I've never used JPA myself so I can't tell, but I guess you just have to get hold of an EntityManager and do the open/close thing inside a good old try/finally block... Have a look at Stripersist's Interceptor, it just does this (plus some classpath scanning and other things). http://stripes-stuff.svn.sourceforge.net/viewvc/stripes-stuff/Stripersist/trunk/src/org/stripesstuff/stripersist/Stripersist.java?revision=123&view=markup I think you just need to rewrite this class, probably as a "template" that can be used in your tests. HTH Cheers remi 2009/11/5 KR k-no-spam@...:Thanks Remi, That's exactly what I want to do. Unfortunatly I failed to mention in my opening post that I also use Stripersist (Stripesstuff) to manage hibernate/JPA in my actionBeans. The Stripersist extension package does add entity formaters, entity converters and a filter that starts and stops transactions. So when the MockRoundtrip is done executing the session is gone because the Stripersist filter closed it. Problem is, I just don't know of a way to manage the Stripersist transaction manualy, without also disabeling the other extensions in the Stripersist package (because my actionBeans also use entity formater and converter). "VANKEISBELCK Remi" remi@... wrote in message news:8856709a0911041344q4884552dva61409cd4b698673@...... Hi Karen, The solution I use is to "simulate" the OSIV filter in my TestCases. I write a base test class that can open/close an hb session and tx, and then use it in setUp/tearDown, or directly in test methods, like this : public void testMe() { Transaction tx = openSessionAndTransaction(); try { // do some tests getSession().load(...); ... } finally { tx.commit(); } } The base test class implements the methods for opening the session/tx, binding it to the current thread, and closing it. Used in setUp/tearDown, you don't even notice it's there, just like the regular OSIV behavior... Of course, depending on the type of OSIV you use, you'll have more or less code to write to implement those methods in your base class. I'm derivating from Spring's OSIV, and basically migrated the filter's session/tx demarcation code into my base test class. HTH Cheers Remi 2009/11/4 KR k-no-spam@...:Hi, In my ActionBeans I use lazy loading Hibernate entities that are accessed in the JSP view. Runtime this session in view pattern work excellent. But it does not work during JUnit testing. The session is closed after calling execute on the MockRoundtrip, making it impossible to check the results. How can I make sure the session of the MockRoundtrip does not end after the 'execute' command? Kind regards, Karen ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Stripes-users mailing list Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users |
| Free embeddable forum powered by Nabble | Forum Help |