Just fig'ed out - go back to elementary SD principles, mock it up. 

On Sunday, 13 May 2012 19:39:43 UTC+10, Patrick Fong wrote:
>
> Hi 
>
> I have two classes, DBKeyImpl which implements DBKey and extends 
> AbstractDBImpl. AbstractDBImpl extends AbstractDB which has a method 
> which returns the PersistenceManager. 
>
> public abstract class AbstractDBImpl extends AbstractDB {
>
> @Override
>
> protected PersistenceManager getPmf()
>
> {
>
> return PMF.get().getPersistenceManager();
>
> }
>
> }
>
> DBKeyImpl extends AbstractDBImpl calls the getPmf(). I want to write a 
> JUnit which tests DBKeyImpl. 
>
>
> public class DBKeyEventOldTest extends BaseTest
>
> {
>
> public void testAdd()
>
> {
>
>
> KeyObject keyObject = new KeyObject();
>
> keyObject.setKey("key");
>
> keyObject.setUserid("userId");
>
> DBKey dbKey = new DBKeyImpl();
>
> dbKey.save(keyObject);
>
> ...
>
> }
>
> }
>
> GAE does not support sun.reflect.Reflection, so we can't use Reflection
> .getCallerClass(arg0). 
>
> In order to test the DBKeyImpl and the PersistenceManager, you will use a 
> *mocked* up PersistenceManager. 
>
> Is it possible for me to find the calling class (via reflection) - ie the 
> test class for me to determine the calling class, so that I can use the 
> mocked up PersistenceManager?
>
> One work around for this is for me to extend my Testclass to DBKeyImpland 
> override the PersistenceManager. This is a hack and is tightly coupled. 
>
> Cheers
> Patrick
>
>      

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/qFJ1tgebt3QJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to