Package org.objectweb.speedo.pobjects.fetchgroup

Examples of org.objectweb.speedo.pobjects.fetchgroup.Person


   */
  public void testLoadingNone() {
    logger.log(BasicLevel.DEBUG, "***************testLoadingNone*****************");
    Country country = new Country("uk","Royaume-Uni");
    Address address = new Address("Sharrow Street", "Luton", country);
    Person parent = new Person();
    parent.setName("None Joel");
    parent.setAge(32);
    parent.setAddress(address);
    Person child1 = new Person("None Sophie", address, null, 14);
    Person child2 = new Person("None Mikael", address, null, 11);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.removeGroup("default").addGroup("none");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
   
    FetchPlan f = pm.getFetchPlan();
    logger.log(BasicLevel.DEBUG, "FG: " + f.getGroups());
   
    try
      pm.currentTransaction().begin();
      Person detachedParent = (Person) pm.detachCopy(parent);
      logger.log(BasicLevel.DEBUG, "Name can be accessed: " + detachedParent.getName());
      logger.log(BasicLevel.DEBUG, "Age can be accessed: " + detachedParent.getAge());
      assertEquals(parent.getName(), detachedParent.getName());
      assertEquals(parent.getAge(), detachedParent.getAge());
      logger.log(BasicLevel.DEBUG, "Address should not be accessed: " + detachedParent.getAddress());
      logger.log(BasicLevel.DEBUG, "Children should not be accessed: " + detachedParent.getChildren());
    }
    catch(Exception e){
      assertEquals(e.getClass(), JDODetachedFieldAccessException.class);
      if(e instanceof JDODetachedFieldAccessException)
        logger.log(BasicLevel.DEBUG, "Correct exception type caught: " + e);
View Full Code Here


   */
  public void testLoadingValues() {
    logger.log(BasicLevel.DEBUG, "***************testLoadingValues*****************");
    Country country = new Country("gr","Grece");
    Address address = new Address("Feta", "Athenes", country);
    Person parent = new Person();
    parent.setName("Kapic Joel");
    parent.setAge(32);
    parent.setAddress(address);
    Person child1 = new Person("Kapic Sophie", address, null, 14);
    Person child2 = new Person("Kapic Mikael", address, null, 11);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.removeGroup("none").addGroup("values");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
   
    FetchPlan f = pm.getFetchPlan();
    logger.log(BasicLevel.DEBUG, "FG: " + f.getGroups());
   
    try{
      pm.currentTransaction().begin();
      Person detachedParent = (Person) pm.detachCopy(parent);
      logger.log(BasicLevel.DEBUG, "Name can be accessed: " + detachedParent.getName());
      logger.log(BasicLevel.DEBUG, "Age can be accessed: " + detachedParent.getAge());
      assertEquals(parent.getName(), detachedParent.getName());
      assertEquals(parent.getAge(), detachedParent.getAge());
      logger.log(BasicLevel.DEBUG, "Address should not be accessed: " + detachedParent.getAddress());
      logger.log(BasicLevel.DEBUG, "Children should not be accessed: " + detachedParent.getChildren());
    }
    catch(Exception e){
      assertEquals(e.getClass(), JDODetachedFieldAccessException.class);
      if(e instanceof JDODetachedFieldAccessException)
        logger.log(BasicLevel.DEBUG, "Correct exception type caught: " + e);
View Full Code Here

   */
  public void testLoadingReference() {
    logger.log(BasicLevel.DEBUG, "***************testLoadingReference*****************");
    Country country = new Country("it","Italie");
    Address address = new Address("Rue Spiaggi", "Milan", country);
    Person parent = new Person();
    parent.setName("Del Piero Joel");
    parent.setAge(32);
    parent.setAddress(address);
    Person child1 = new Person("Del Piero Sophie", address, null, 14);
    Person child2 = new Person("Del Piero Mikael", address, null, 11);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detail").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
    logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
    try {
      pm.currentTransaction().begin();
      Person detachedParent = (Person) pm.detachCopy(parent);
      logger.log(BasicLevel.DEBUG, "Name can be accessed: " + detachedParent.getName());
      logger.log(BasicLevel.DEBUG, "Age can be accessed: " + detachedParent.getAge());
      logger.log(BasicLevel.DEBUG, "Address can be accessed: " + detachedParent.getAddress().toString());
      assertEquals(parent.getName(), detachedParent.getName());
      assertEquals(parent.getAge(), detachedParent.getAge());
      assertEquals(parent.getAddress().getCity(), detachedParent.getAddress().getCity());
      assertEquals(parent.getAddress().getCountry().getCode(), detachedParent.getAddress().getCountry().getCode());
      assertEquals(parent.getAddress().getCountry().getName(), detachedParent.getAddress().getCountry().getName());
      assertEquals(parent.getAddress().getStreet(), detachedParent.getAddress().getStreet());
      logger.log(BasicLevel.DEBUG, "Children should not be accessed: " + detachedParent.getChildren().toString());
    } catch(Exception e) {
      if (!JDODetachedFieldAccessException.class.equals(e.getClass())) {
        logger.log(BasicLevel.ERROR, "Exception found: ", e);
        assertEquals(e.getClass(), JDODetachedFieldAccessException.class);
      }
View Full Code Here

   */
  public void testLoadingArrayElement() {
    logger.log(BasicLevel.DEBUG, "************testLoadingArrayElement**************");
    Country country = new Country("be","Belgique");
    Address address = new Address("Rue Anvers", "Bruges", country);
    Person parent = new Person();
    parent.setName("Dermuck Joel");
    parent.setAge(32);
    parent.setAddress(address);
    Person child1 = new Person("Dermuck Sophie", address, null, 14);
    Person child2 = new Person("Dermuck Mikael", address, null, 11);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detail+children-names").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
   
    logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
    try {
      pm.currentTransaction().begin();
      Person detachedParent = (Person) pm.detachCopy(parent);
      logger.log(BasicLevel.DEBUG, "Name can be accessed: " + detachedParent.getName());
      logger.log(BasicLevel.DEBUG, "Age can be accessed: " + detachedParent.getAge());
      logger.log(BasicLevel.DEBUG, "Address can be accessed: " +
          detachedParent.getAddress().getStreet() + ", " + detachedParent.getAddress().getCity()
          + ", " + detachedParent.getAddress().getCountry().getCode());
      assertEquals(parent.getName(), detachedParent.getName());
      assertEquals(parent.getAge(), detachedParent.getAge());
      assertEquals(parent.getAddress().getCity(), detachedParent.getAddress().getCity());
      assertEquals(parent.getAddress().getCountry().getCode(), detachedParent.getAddress().getCountry().getCode());
      assertEquals(parent.getAddress().getCountry().getName(), detachedParent.getAddress().getCountry().getName());
      assertEquals(parent.getAddress().getStreet(), detachedParent.getAddress().getStreet());
      assertEquals(parent.getChildren().size(), detachedParent.getChildren().size());
      Collection childrenTmp = detachedParent.getChildren();
      logger.log(BasicLevel.DEBUG, "Children names can be accessed: ");
      Iterator it = childrenTmp.iterator();
      while(it.hasNext()){
        Person p = (Person) it.next();
        logger.log(BasicLevel.DEBUG, "Child: " + p.getName() + ", " + p.getAge());
      }
      it = childrenTmp.iterator();
      while(it.hasNext()){
        Person p = (Person) it.next();
        logger.log(BasicLevel.DEBUG, "Children address should not be accessed: " + p.getAddress().toString());
      }
    } catch(Exception e) {
      assertEquals(e.getClass(), JDODetachedFieldAccessException.class);
      assertTrue(e.getMessage().indexOf("address") != -1);
      if (e instanceof JDODetachedFieldAccessException && e.getMessage().indexOf("address") != -1) {
View Full Code Here

   */
  public void testLoadingFetchGroupField() {
    logger.log(BasicLevel.DEBUG, "************testLoadingFetchGroupField**************");
    Country country = new Country("us","Etats-Unis");
    Address address = new Address("Rue Enclif", "San Diego", country);
    Person parent = new Person();
    parent.setName("Smith Joel");
    parent.setAge(32);
    parent.setAddress(address);
    Person child1 = new Person("Smith Sofia", address, null, 14);
    Person child2 = new Person("Smith Michael", address, null, 11);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detail+children-list").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
   
    logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
    try {
      pm.currentTransaction().begin();
      Person detachedParent = (Person) pm.detachCopy(parent);
      logger.log(BasicLevel.DEBUG, "Name can be accessed: " + detachedParent.getName());
      logger.log(BasicLevel.DEBUG, "Age can be accessed: " + detachedParent.getAge());
      logger.log(BasicLevel.DEBUG, "Address can be accessed: " +
          detachedParent.getAddress().getStreet() + ", " + detachedParent.getAddress().getCity()
          + ", " + detachedParent.getAddress().getCountry().getCode());
      Collection childrenTmp = detachedParent.getChildren();
      logger.log(BasicLevel.DEBUG, "Children names can be accessed: ");
      assertEquals(parent.getName(), detachedParent.getName());
      assertEquals(parent.getAge(), detachedParent.getAge());
      assertEquals(parent.getAddress().getCity(), detachedParent.getAddress().getCity());
      assertEquals(parent.getAddress().getCountry().getCode(), detachedParent.getAddress().getCountry().getCode());
      assertEquals(parent.getAddress().getCountry().getName(), detachedParent.getAddress().getCountry().getName());
      assertEquals(parent.getAddress().getStreet(), detachedParent.getAddress().getStreet());
      assertEquals(parent.getChildren().size(), detachedParent.getChildren().size());
      Iterator it = childrenTmp.iterator();
      while(it.hasNext()){
        Person p = (Person) it.next();
        logger.log(BasicLevel.DEBUG, "Child: " + p.getName() + ", " + p.getAge());
      }
      it = childrenTmp.iterator();
      while(it.hasNext()){
        Person p = (Person) it.next();
        logger.log(BasicLevel.DEBUG, "Child address should not be accessed: " + p.getAddress().toString());
      }
    } catch(Exception e){
      assertEquals(e.getClass(), JDODetachedFieldAccessException.class);
      assertTrue(e.getMessage().indexOf("address") != -1);
      if (e instanceof JDODetachedFieldAccessException && e.getMessage().indexOf("address") != -1) {
View Full Code Here

   */
  public void testLoadingRecursiveDepth() {
    logger.log(BasicLevel.DEBUG, "************testLoadingRecursiveDepth**************");
    Country country = new Country("sp","Espagne");
    Address address = new Address("Rue Rio", "Santander", country);
    Person parent = new Person();
    parent.setName("Casillas Joel");
    parent.setAge(63);
    parent.setAddress(address);
    Person child1 = new Person("Casillas Sofia", address, null, 30);
    Person child2 = new Person("Casillas Michael", address, null, 40);
    Set children = new HashSet();
    children.add(child1);
    children.add(child2);
    parent.setChildren(children);
    Person child11 = new Person("Casillas Maria", address, null, 14);
    Person child21 = new Person("Casillas Juan", address, null, 11);
    Set children1 = new HashSet();
    children1.add(child11);
    Set children2 = new HashSet();
    children2.add(child21);
    child1.setChildren(children1);
    child2.setChildren(children2);
   
    PersistenceManager pm = pmf.getPersistenceManager();
    FetchPlan fp = pm.getFetchPlan();
    fp.clearGroups();
    fp.addGroup("detailChildren").removeGroup("default");
    pm.currentTransaction().begin();
    logger.log(BasicLevel.DEBUG, "make persistent the person " + parent.toString());
    pm.makePersistent(parent);
    pm.currentTransaction().commit();
    logger.log(BasicLevel.DEBUG, "FG: " + fp.getGroups());
   
    try {
      pm.currentTransaction().begin();
      Person detachedParent = (Person) pm.detachCopy(parent);
      assertEquals(parent.getName(), detachedParent.getName());
      assertEquals(parent.getAge(), detachedParent.getAge());
      assertEquals(parent.getAddress().getCity(), detachedParent.getAddress().getCity());
      assertEquals(parent.getAddress().getCountry().getCode(), detachedParent.getAddress().getCountry().getCode());
      assertEquals(parent.getAddress().getCountry().getName(), detachedParent.getAddress().getCountry().getName());
      assertEquals(parent.getAddress().getStreet(), detachedParent.getAddress().getStreet());
      assertEquals(parent.getChildren().size(), detachedParent.getChildren().size());
      logger.log(BasicLevel.DEBUG, "Name can be accessed: " + detachedParent.getName());
      logger.log(BasicLevel.DEBUG, "Age can be accessed: " + detachedParent.getAge());
      logger.log(BasicLevel.DEBUG, "Address can be accessed: " +
          detachedParent.getAddress().getStreet() + ", " + detachedParent.getAddress().getCity()
          + ", " + detachedParent.getAddress().getCountry().getCode());
      Collection childrenTmp = detachedParent.getChildren();
      logger.log(BasicLevel.DEBUG, "Children names and address.country.code can be accessed: ");
      Iterator it = childrenTmp.iterator();
      while(it.hasNext()){
        Person p = (Person) it.next();
        logger.log(BasicLevel.DEBUG, "Child: " + p.getName() + ", " + p.getAge() + ", " + p.getAddress().getStreet() + ", " + p.getAddress().getCity()
            + ", " + p.getAddress().getCountry().getCode());
      }
      it = childrenTmp.iterator();
      while(it.hasNext()){
        Person p = (Person) it.next();
        Iterator it2 = p.getChildren().iterator();
        while(it2.hasNext()){
          Person person = (Person) it2.next();
          logger.log(BasicLevel.DEBUG, "\tChild of children should not be accessed: " + person.toString());
        }
      }
    } catch(Exception e) {
      assertEquals(e.getClass(), JDODetachedFieldAccessException.class);
      assertTrue(e.getMessage().indexOf("children") != -1);
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.fetchgroup.Person

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.