Package org.objectweb.speedo.pobjects.ref

Examples of org.objectweb.speedo.pobjects.ref.Employee


            pm.makePersistent(new Department(depNames[i]));
        }

        //Creation of Employee
        for(int i=0; i<names.length; i++) {
            pm.makePersistent(new Employee(names[i], d, salaries[i]));
        }

        //Creation of XMNB objects for testing collection operator
        Ref2AMMB[] r1 = new Ref2AMMB[NB_XMMB];
        Ref2Ref2AMMB[] r2 = new Ref2Ref2AMMB[NB_XMMB];
View Full Code Here


  }
  public void test1() {
    String eName = "seb";
    String dName = "ASR";
    PersistenceManager pm = pmf.getPersistenceManager();
    Employee e = new Employee(eName, new Department(dName));
    pm.makePersistent(e);
    Object eId = pm.getObjectId(e);
    Assert.assertNotNull("null object identifier", eId);
    pm.close();

    e = null;
    pm = pmf.getPersistenceManager();
    e = (Employee) pm.getObjectById(eId, true);
    Assert.assertNotNull("null instance returned by getObjectById", e);
    Assert.assertEquals("Bad employee name", eName, e.getName());
    Assert.assertNotNull("null instance returned by e.dept", e.getDept());
    Assert.assertEquals("Bad department name", dName, e.getDept().getName());
    pm.currentTransaction().begin();
    pm.deletePersistent(e.getDept());
    pm.deletePersistent(e);
    pm.currentTransaction().commit();
    pm.close();
  }
View Full Code Here

  }

    public void testNullRef() {
        String eName = "nullRefEmp";
        PersistenceManager pm = pmf.getPersistenceManager();
        Employee e = new Employee(eName, null);
        pm.makePersistent(e);
        Object eId = pm.getObjectId(e);
        Assert.assertNotNull("null object identifier", eId);
        pm.close();

        e = null;
        pm = pmf.getPersistenceManager();
        e = (Employee) pm.getObjectById(eId, true);
        Assert.assertNotNull("null instance returned by getObjectById", e);
        Assert.assertEquals("Bad employee name", eName, e.getName());
        Assert.assertNull("not null instance returned by e.dept", e.getDept());
        pm.currentTransaction().begin();
        pm.deletePersistent(e);
        pm.currentTransaction().commit();
        pm.close();
    }
View Full Code Here

    }
    public void testDeleteReferencedObject(boolean withEvict) {
        PersistenceManager pm = pmf.getPersistenceManager();

        pm.currentTransaction().begin();
        Employee e = new Employee("employee testDeleteReferencedObject",
                new Department("department testDeleteReferencedObject"));
        pm.makePersistent(e);
        long eid = e.getOid();
        Long did = e.getDept().getOid();
        e= null;
        pm.currentTransaction().commit();

        pm.currentTransaction().begin();
        Department d = (Department) pm.getObjectById(
                pm.newObjectIdInstance(Department.class, "" + did), true);
        pm.deletePersistent(d);
        d = null;
        pm.currentTransaction().commit();
       
        if (withEvict) {
            pm.evictAll();
        }
        pm.currentTransaction().begin();
        e = (Employee) pm.getObjectById(
                pm.newObjectIdInstance(Employee.class, "" + eid), true);
        boolean isNull = (null == e.getDept());
        pm.currentTransaction().commit();
       
        pm.currentTransaction().begin();
        pm.deletePersistent(e);
        pm.currentTransaction().commit();
View Full Code Here

            Class empClass = Employee.class;
            Query query = pm.newQuery(empClass);
            Collection col = (Collection) query.execute();
            Iterator it = col.iterator();
            while(it.hasNext()) {
                Employee e = (Employee) it.next();
                Assert.assertNotNull("null element in the query result", e);
                Assert.assertNotNull("null name  of a element in the query result", e.getName());
            }
            query.close(col);
        } catch (JDOException e) {
            Exception ie = ExceptionHelper.getNested(e);
            logger.log(BasicLevel.ERROR, "", ie);
View Full Code Here

            Collection col = (Collection) query.execute();
            Iterator it = col.iterator();
      int i=0;
      while(it.hasNext()) {
              assertTrue("More result than expected ", i<POBuilder.nameOrder.length);
                Employee e = (Employee) it.next();
                Assert.assertNotNull("null element in the query result", e);
        try {
          Assert.assertEquals("Bad order (" + i + ")",
            POBuilder.names[POBuilder.nameOrder[i]],e.getName());
        } catch (Throwable e1) {
          e1.printStackTrace();
        }
        i++;
      }
View Full Code Here

            Iterator it = col.iterator();
      int i=0;
      while(it.hasNext()) {
              assertTrue("More result than expected ", i<POBuilder.salariesOrder.length);
                Assert.assertTrue("No enough values in the result", it.hasNext());
                Employee e = (Employee) it.next();
                Assert.assertNotNull("null element in the query result", e);
        try {
          Assert.assertEquals("Bad order (" + i + ")",
            POBuilder.names[POBuilder.salariesOrder[i]],e.getName());
        } catch (Throwable e1) {
          e1.printStackTrace();
        }
        i++;
      }
View Full Code Here

            query.declareParameters("String aName");
            query.setFilter("(name == aName)");
            Collection col = (Collection) query.execute(POBuilder.names[1]);
            Iterator iter = col.iterator();
            Assert.assertTrue("The query result is empty", iter.hasNext());
            Employee e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element", e);
            Assert.assertEquals("Bad employee name", POBuilder.names[1], e.getName());
            Assert.assertTrue("More than one element in the query result", !iter.hasNext());
            Assert.assertEquals("Bad query result size", 1, col.size());
            query.close(col);
        } catch (JDOException e) {
            Exception ie = ExceptionHelper.getNested(e);
View Full Code Here

            query.setFilter("(salary > sal)");
            Collection col = (Collection) query.execute(new Float(POBuilder.salaries[2]));
            Iterator iter = col.iterator();
      HashSet s = new HashSet();
      while(iter.hasNext()) {
              Employee e = (Employee) iter.next();
        s.add(e.getName());
      }
      query.close(col);
      assertSameCollection("Bad query result",
        Arrays.asList(new String[]{POBuilder.names[0],POBuilder.names[1],POBuilder.names[3]}),
        s);
View Full Code Here

            Collection col = (Collection)
                    query.execute(POBuilder.names[1], new Float(3000.0));
            Iterator iter = col.iterator();
            Assert.assertTrue("The query result is empty", iter.hasNext());
            Employee e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element", e);
            Assert.assertEquals("Bad employee name", POBuilder.names[1], e.getName());
            Assert.assertEquals("Bad employee salary", new Float(3000.0), new Float(e.getSalary()));
            Assert.assertTrue("More than one element in the query result", !iter.hasNext());
            Assert.assertEquals("Bad query result size", 1, col.size());
            query.close(col);
        } catch (JDOException e) {
            Exception ie = ExceptionHelper.getNested(e);
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.pobjects.ref.Employee

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.