Package com.google.appengine.datanucleus.test.jdo

Examples of com.google.appengine.datanucleus.test.jdo.HasUnencodedStringPkJDO


    // the fact that this doesn't throw an exception is the test
    ds.get(KeyFactory.createKey(HasLongPkJDO.class.getSimpleName(), 33));
  }

  public void testUnencodedStringPk() throws EntityNotFoundException {
    HasUnencodedStringPkJDO pojo = new HasUnencodedStringPkJDO();
    pojo.setId("a name");
    beginTxn();
    pm.makePersistent(pojo);
    commitTxn();

    assertEquals("a name", pojo.getId());
    Entity e = ds.get(KeyFactory.createKey(HasUnencodedStringPkJDO.class.getSimpleName(), pojo.getId()));

    beginTxn();
    pm.getObjectById(HasUnencodedStringPkJDO.class, e.getKey().getName());
    pm.getObjectById(HasUnencodedStringPkJDO.class, e.getKey());
    pm.getObjectById(HasUnencodedStringPkJDO.class, KeyFactory.keyToString(e.getKey()));
View Full Code Here


    pm.getObjectById(HasUnencodedStringPkJDO.class, KeyFactory.keyToString(e.getKey()));
    commitTxn();
  }

  public void testUnencodedStringPk_NullValue() {
    HasUnencodedStringPkJDO pojo = new HasUnencodedStringPkJDO();
    beginTxn();
    try {
      pm.makePersistent(pojo);
      fail("expected exception");
    } catch (JDOFatalUserException e) {
View Full Code Here

    }
  }

  public void testUnencodedStringPk_BatchGet() throws EntityNotFoundException {
    switchDatasource(PersistenceManagerFactoryName.nontransactional);
    HasUnencodedStringPkJDO pojo = new HasUnencodedStringPkJDO();
    beginTxn();
    pojo.setId("yar1");
    pm.makePersistent(pojo);
    commitTxn();

    HasUnencodedStringPkJDO pojo2 = new HasUnencodedStringPkJDO();
    beginTxn();
    pojo2.setId("yar2");
    pm.makePersistent(pojo2);
    commitTxn();

    assertNotNull(pojo.getId());
    assertNotNull(pojo2.getId());

    beginTxn();
    Query q = pm.newQuery("select from " + HasUnencodedStringPkJDO.class.getName() + " where id == :ids");
    List<HasUnencodedStringPkJDO> pojos =
        (List<HasUnencodedStringPkJDO>) q.execute(Utils.newArrayList(pojo.getId(), pojo2.getId()));
    assertEquals(2, pojos.size());
    // we should preserve order but right now we don't
    Set<String> pks = Utils.newHashSet(pojos.get(0).getId(), pojos.get(1).getId());
    assertEquals(pks, Utils.newHashSet("yar1", "yar2"));
    commitTxn();
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jdo.HasUnencodedStringPkJDO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.