Sorry I forgot to say that I get No such object exception when the
test is ran.
Michael
On 20 Dec 2009, at 18:53, Mike wrote:
> Hi,
>
> I am a newbie to GAE and it's the first time I try out the JDO
> facility. I followed the JUnit How-To to create all the base classes
> for Junit test and the following is my test:
>
> public class AbcTest extends LocalServiceTestCase {
>
> Abc abcType = null;
>
> PersistenceManagerFactory pmf =
> GAEPresistenceHelper.getPersistenceManagerFactory();
>
>
> @Override
> public void setUp() throws Exception {
> super.setUp();
> abcType = new Abc();
> abcType.setCreationTime(Calendar.getInstance().getTime());
> PersistenceManager pm = pmf.getPersistenceManager();
> pm.makePersistent(abcType);
> pm.close();
> }
>
>
> public void testPKGeneration(){
> assertNotNull(abcType.getPk());
> }
>
>
> @Override
> public void tearDown() throws Exception {
> super.tearDown();
> System.out.println(KeyFactory.keyToString(abcType.getPk()));
> PersistenceManager pm = pmf.getPersistenceManager();
> ObjectState state = JDOHelper.getObjectState(abcType);
> System.out.println(state.name());
> pm.getObjectById(abcType.getPk());
>
> }
>
> }
>
>
> The ABC class:
>
> @PersistenceCapable(identityType=IdentityType.APPLICATION)
> public class Abc {
>
> @PrimaryKey
> @Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
> private Key pk;
>
> public Key getPk() {
> return pk;
> }
>
> public void setPk(Key pk) {
> this.pk = pk;
> }
>
> }
>
>
>
> Could someone please advice? Am I doing anything wrong? Thanks in
> advance.
>
> Michael Chan
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
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-java?hl=en.