Package org.objectweb.speedo.pobjects.ref

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


      query.setFilter("((name == aName) || (name == anotherName))");
      Collection col = (Collection)
                    query.execute(POBuilder.names[1], POBuilder.names[2]);
            Iterator iter = col.iterator();
            Assert.assertTrue("The query result is empty", iter.hasNext());
            Employee e1 = (Employee) iter.next();
            Assert.assertNotNull("Null collection element 1", e1);
            Assert.assertTrue("Only one element in the query result", iter.hasNext());
            Employee e2 = (Employee) iter.next();
            Assert.assertNotNull("Null collection element 2", e2);
            Assert.assertTrue("More than one element in the query result", !iter.hasNext());
            Assert.assertEquals("Bad query result size", 2, col.size());
            query.close(col);

            if (POBuilder.names[1].equals(e1.getName())) {
                Assert.assertEquals("Bad employee name", POBuilder.names[2], e2.getName());
            } else if (POBuilder.names[1].equals(e2.getName())) {
                Assert.assertEquals("Bad employee name", POBuilder.names[2], e1.getName());
            } else {
                fail("Bad employee name");
            }
        } catch (JDOException e) {
View Full Code Here


            Collection foundNames = new ArrayList(3);
            expectedNames.add(POBuilder.names[1]);
            expectedNames.add(POBuilder.names[2]);
            expectedNames.add(POBuilder.names[3]);
            Assert.assertTrue("The query result is empty", iter.hasNext());
            Employee e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element 1", e);
            foundNames.add(e.getName());
            Assert.assertTrue("Only one element in the query result", iter.hasNext());
            e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element 2", e);
            foundNames.add(e.getName());
            e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element 3", e);
            foundNames.add(e.getName());
            Assert.assertTrue("More than one element in the query result", !iter.hasNext());
            Assert.assertEquals("Bad query result size", expectedNames.size(), col.size());
            query.close(col);

            Assert.assertTrue("Bad Employee names, expected:"
View Full Code Here

            Iterator iter = col.iterator();
            Collection foundNames = new ArrayList(2);
            Collection expectedNames = map.values();

            Assert.assertTrue("The query result is empty", iter.hasNext());
            Employee e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element 1", e);
            foundNames.add(e.getName());
            Assert.assertTrue("Only one element in the query result", iter.hasNext());
            e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element 2", e);
            foundNames.add(e.getName());
            Assert.assertTrue("More than one element in the query result", !iter.hasNext());
            Assert.assertEquals("Bad query result size", expectedNames.size(), col.size());
            query.close(col);

            Assert.assertTrue("Bad Employee names, expected:"
View Full Code Here

      Collection col = (Collection) query.executeWithArray(expectedNames.toArray());
            Iterator iter = col.iterator();

            Collection foundNames = new ArrayList(2);
            Assert.assertTrue("The query result is empty", iter.hasNext());
            Employee e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element 1", e);
            foundNames.add(e.getName());
            Assert.assertTrue("Only one element in the query result", iter.hasNext());
            e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element 2", e);
            foundNames.add(e.getName());
            Assert.assertTrue("More than one element in the query result", !iter.hasNext());
            Assert.assertEquals("Bad query result size", expectedNames.size(), col.size());
            query.close(col);

            Assert.assertTrue("Bad Employee names, expected:"
View Full Code Here

            query.setFilter(filterFieldRef);

            Collection col = (Collection) query.execute("RD");
            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[0], e.getName());
            Assert.assertTrue("More than one element in the query result", !iter.hasNext());
            Assert.assertEquals("Bad query result size", 1, col.size());

      iter = col.iterator();
            Assert.assertTrue("The query result is empty", iter.hasNext());
            e = (Employee) iter.next();
            Assert.assertNotNull("Null collection element", e);
            Assert.assertEquals("Bad employee name", POBuilder.names[0], e.getName());
            Assert.assertTrue("More than one element in the query result", !iter.hasNext());

            query.close(col);
        } catch (Exception e) {
            Exception ie = ExceptionHelper.getNested(e);
View Full Code Here

        logger.log(BasicLevel.DEBUG, "testFieldRef");
        PersistenceManager pm = pmf.getPersistenceManager();
      final int nbEmp = 5;
      Object[] oid = new Object[nbEmp];
      for(int i=0; i<nbEmp; i++) {
        Employee e = new Employee("testFieldRefNull" + i, null);
        pm.makePersistent(e);
        oid[i] = pm.getObjectId(e);
      }
      pm.close();
        try {
          pm = pmf.getPersistenceManager();
            Query query = pm.newQuery(Employee.class);
            query.declareParameters("Department d");
            query.setFilter("(dept == d)");
            Collection col = (Collection) query.execute(null);
          int size = col.size();
            query.close(col);
          assertEquals("Bad number of employee without department", nbEmp, size);
        } catch (Exception e) {
            Exception ie = ExceptionHelper.getNested(e);
            logger.log(BasicLevel.ERROR, "", ie);
            fail(ie.getMessage());
        } finally {
          pm.currentTransaction().begin();
          for(int i=0; i<nbEmp; i++) {
            Employee e = (Employee) pm.getObjectById(oid[i], false);
            pm.deletePersistent(e);
          }
          pm.currentTransaction().commit();
            pm.close();
        }
View Full Code Here

      query.setFilter(filter);

      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 (Exception e) {
      Exception ie = ExceptionHelper.getNested(e);
View Full Code Here

        q.setOrdering("name ascending");
        q.setRange(2, 4);
        Collection c = (Collection) q.execute(POBuilder.depName);
        ArrayList foundNames = new ArrayList();
        for (Iterator it = c.iterator(); it.hasNext();) {
            Employee e = (Employee) it.next();
            foundNames.add(e.getName());
        }
        q.closeAll();
        pm.currentTransaction().commit();
        pm.close();
        assertEquals("not expected result", expectedNames.subList(2, 4), foundNames);
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.